Remove polymer types, cleanups (#16385)

* Remove polymer types, cleanups

* Delete updated.ts
This commit is contained in:
Bram Kragten 2023-05-04 17:24:24 +02:00 committed by GitHub
parent ab237f19c0
commit 4e5a18d272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 97 additions and 149 deletions

View File

@ -1,5 +1,3 @@
import "@polymer/polymer/lib/elements/dom-if";
import "@polymer/polymer/lib/elements/dom-repeat";
import "../../src/resources/ha-style"; import "../../src/resources/ha-style";
import "../../src/resources/roboto"; import "../../src/resources/roboto";
import "./ha-gallery"; import "./ha-gallery";

View File

@ -5,8 +5,8 @@ import {
CSSResultGroup, CSSResultGroup,
html, html,
LitElement, LitElement,
TemplateResult,
nothing, nothing,
TemplateResult,
} from "lit"; } from "lit";
import { customElement, property, query } from "lit/decorators"; import { customElement, property, query } from "lit/decorators";
import { atLeastVersion } from "../../../src/common/config/version"; import { atLeastVersion } from "../../../src/common/config/version";
@ -23,8 +23,11 @@ import {
HassioPartialBackupCreateParams, HassioPartialBackupCreateParams,
} from "../../../src/data/hassio/backup"; } from "../../../src/data/hassio/backup";
import { Supervisor } from "../../../src/data/supervisor/supervisor"; import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { PolymerChangedEvent } from "../../../src/polymer-types"; import {
import { HomeAssistant, TranslationDict } from "../../../src/types"; HomeAssistant,
TranslationDict,
ValueChangedEvent,
} from "../../../src/types";
import "./supervisor-formfield-label"; import "./supervisor-formfield-label";
type BackupOrRestoreKey = keyof TranslationDict["supervisor"]["backup"] & type BackupOrRestoreKey = keyof TranslationDict["supervisor"]["backup"] &
@ -416,7 +419,7 @@ export class SupervisorBackupContent extends LitElement {
this[input.name] = input.value; this[input.name] = input.value;
} }
private _handleTextValueChanged(ev: PolymerChangedEvent<string>) { private _handleTextValueChanged(ev: ValueChangedEvent<string>) {
const input = ev.currentTarget as PaperInputElement; const input = ev.currentTarget as PaperInputElement;
this[input.name!] = ev.detail.value; this[input.name!] = ev.detail.value;
} }

View File

@ -21,8 +21,7 @@ import {
subscribeEntityRegistry, subscribeEntityRegistry,
} from "../../data/entity_registry"; } from "../../data/entity_registry";
import { SubscribeMixin } from "../../mixins/subscribe-mixin"; import { SubscribeMixin } from "../../mixins/subscribe-mixin";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "../ha-icon-button"; import "../ha-icon-button";
import "../ha-svg-icon"; import "../ha-svg-icon";
import "./ha-devices-picker"; import "./ha-devices-picker";
@ -291,7 +290,7 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
this._areaPicker = !this._areaPicker; this._areaPicker = !this._areaPicker;
} }
private async _areaPicked(ev: PolymerChangedEvent<string>) { private async _areaPicked(ev: ValueChangedEvent<string>) {
const value = ev.detail.value; const value = ev.detail.value;
let selectedDevices = []; let selectedDevices = [];
const target = ev.target as any; const target = ev.target as any;

View File

@ -22,8 +22,7 @@ import {
subscribeEntityRegistry, subscribeEntityRegistry,
} from "../../data/entity_registry"; } from "../../data/entity_registry";
import { SubscribeMixin } from "../../mixins/subscribe-mixin"; import { SubscribeMixin } from "../../mixins/subscribe-mixin";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
@ -330,7 +329,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
return this.value || ""; return this.value || "";
} }
private _deviceChanged(ev: PolymerChangedEvent<string>) { private _deviceChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
let newValue = ev.detail.value; let newValue = ev.detail.value;
@ -343,7 +342,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
} }
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }

View File

@ -1,8 +1,7 @@
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "./ha-device-picker"; import "./ha-device-picker";
import type { import type {
HaDevicePickerDeviceFilterFunc, HaDevicePickerDeviceFilterFunc,
@ -108,7 +107,7 @@ class HaDevicesPicker extends LitElement {
this.value = devices; this.value = devices;
} }
private _deviceChanged(event: PolymerChangedEvent<string>) { private _deviceChanged(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const curValue = (event.currentTarget as any).curValue; const curValue = (event.currentTarget as any).curValue;
const newValue = event.detail.value; const newValue = event.detail.value;
@ -126,7 +125,7 @@ class HaDevicesPicker extends LitElement {
} }
} }
private async _addDevice(event: PolymerChangedEvent<string>) { private async _addDevice(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const toAdd = event.detail.value; const toAdd = event.detail.value;
(event.currentTarget as any).value = ""; (event.currentTarget as any).value = "";

View File

@ -4,8 +4,7 @@ import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { isValidEntityId } from "../../common/entity/valid_entity_id"; import { isValidEntityId } from "../../common/entity/valid_entity_id";
import type { PolymerChangedEvent } from "../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../types";
import type { HomeAssistant } from "../../types";
import "./ha-entity-picker"; import "./ha-entity-picker";
import type { HaEntityPickerEntityFilterFunc } from "./ha-entity-picker"; import type { HaEntityPickerEntityFilterFunc } from "./ha-entity-picker";
@ -151,7 +150,7 @@ class HaEntitiesPickerLight extends LitElement {
}); });
} }
private _entityChanged(event: PolymerChangedEvent<string>) { private _entityChanged(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const curValue = (event.currentTarget as any).curValue; const curValue = (event.currentTarget as any).curValue;
const newValue = event.detail.value; const newValue = event.detail.value;
@ -171,7 +170,7 @@ class HaEntitiesPickerLight extends LitElement {
); );
} }
private async _addEntity(event: PolymerChangedEvent<string>) { private async _addEntity(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const toAdd = event.detail.value; const toAdd = event.detail.value;
if (!toAdd) { if (!toAdd) {

View File

@ -2,8 +2,7 @@ import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, nothing } from "lit"; import { html, LitElement, PropertyValues, nothing } from "lit";
import { customElement, property, query } from "lit/decorators"; import { customElement, property, query } from "lit/decorators";
import { computeAttributeNameDisplay } from "../../common/entity/compute_attribute_display"; import { computeAttributeNameDisplay } from "../../common/entity/compute_attribute_display";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
@ -99,11 +98,11 @@ class HaEntityAttributePicker extends LitElement {
`; `;
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
this.value = ev.detail.value; this.value = ev.detail.value;
} }
} }

View File

@ -8,8 +8,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import { computeDomain } from "../../common/entity/compute_domain"; import { computeDomain } from "../../common/entity/compute_domain";
import { computeStateName } from "../../common/entity/compute_state_name"; import { computeStateName } from "../../common/entity/compute_state_name";
import { caseInsensitiveStringCompare } from "../../common/string/compare"; import { caseInsensitiveStringCompare } from "../../common/string/compare";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
import "../ha-icon-button"; import "../ha-icon-button";
@ -325,11 +324,11 @@ export class HaEntityPicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;
if (newValue !== this._value) { if (newValue !== this._value) {

View File

@ -5,8 +5,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import { computeStateDisplay } from "../../common/entity/compute_state_display"; import { computeStateDisplay } from "../../common/entity/compute_state_display";
import { getStates } from "../../common/entity/get_states"; import { getStates } from "../../common/entity/get_states";
import { computeAttributeValueDisplay } from "../../common/entity/compute_attribute_display"; import { computeAttributeValueDisplay } from "../../common/entity/compute_attribute_display";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
@ -100,11 +99,11 @@ class HaEntityStatePicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;
if (newValue !== this._value) { if (newValue !== this._value) {

View File

@ -11,8 +11,7 @@ import {
getStatisticLabel, getStatisticLabel,
StatisticsMetaData, StatisticsMetaData,
} from "../../data/recorder"; } from "../../data/recorder";
import { PolymerChangedEvent } from "../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../types";
import { HomeAssistant } from "../../types";
import { documentationUrl } from "../../util/documentation-url"; import { documentationUrl } from "../../util/documentation-url";
import "../ha-combo-box"; import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box";
@ -266,7 +265,7 @@ export class HaStatisticPicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _statisticChanged(ev: PolymerChangedEvent<string>) { private _statisticChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
let newValue = ev.detail.value; let newValue = ev.detail.value;
if (newValue === "__missing") { if (newValue === "__missing") {
@ -278,7 +277,7 @@ export class HaStatisticPicker extends LitElement {
} }
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }

View File

@ -1,8 +1,7 @@
import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import type { PolymerChangedEvent } from "../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../types";
import type { HomeAssistant } from "../../types";
import "./ha-statistic-picker"; import "./ha-statistic-picker";
@customElement("ha-statistics-picker") @customElement("ha-statistics-picker")
@ -130,7 +129,7 @@ class HaStatisticsPicker extends LitElement {
}); });
} }
private _statisticChanged(event: PolymerChangedEvent<string>) { private _statisticChanged(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const oldValue = (event.currentTarget as any).curValue; const oldValue = (event.currentTarget as any).curValue;
const newValue = event.detail.value; const newValue = event.detail.value;
@ -149,7 +148,7 @@ class HaStatisticsPicker extends LitElement {
); );
} }
private async _addStatistic(event: PolymerChangedEvent<string>) { private async _addStatistic(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const toAdd = event.detail.value; const toAdd = event.detail.value;
if (!toAdd) { if (!toAdd) {

View File

@ -6,8 +6,7 @@ import { fireEvent } from "../common/dom/fire_event";
import { stringCompare } from "../common/string/compare"; import { stringCompare } from "../common/string/compare";
import { fetchHassioAddonsInfo, HassioAddonInfo } from "../data/hassio/addon"; import { fetchHassioAddonsInfo, HassioAddonInfo } from "../data/hassio/addon";
import { showAlertDialog } from "../dialogs/generic/show-dialog-box"; import { showAlertDialog } from "../dialogs/generic/show-dialog-box";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../types";
import { HomeAssistant } from "../types";
import { HaComboBox } from "./ha-combo-box"; import { HaComboBox } from "./ha-combo-box";
const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = ( const rowRenderer: ComboBoxLitRenderer<HassioAddonInfo> = (
@ -113,7 +112,7 @@ class HaAddonPicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _addonChanged(ev: PolymerChangedEvent<string>) { private _addonChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;

View File

@ -21,8 +21,7 @@ import {
showAlertDialog, showAlertDialog,
showPromptDialog, showPromptDialog,
} from "../dialogs/generic/show-dialog-box"; } from "../dialogs/generic/show-dialog-box";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../types";
import { HomeAssistant } from "../types";
import type { HaDevicePickerDeviceFilterFunc } from "./device/ha-device-picker"; import type { HaDevicePickerDeviceFilterFunc } from "./device/ha-device-picker";
import "./ha-combo-box"; import "./ha-combo-box";
import type { HaComboBox } from "./ha-combo-box"; import type { HaComboBox } from "./ha-combo-box";
@ -370,11 +369,11 @@ export class HaAreaPicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _openedChanged(ev: PolymerChangedEvent<boolean>) { private _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }
private _areaChanged(ev: PolymerChangedEvent<string>) { private _areaChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
let newValue = ev.detail.value; let newValue = ev.detail.value;

View File

@ -6,8 +6,7 @@ import { fireEvent } from "../common/dom/fire_event";
import { caseInsensitiveStringCompare } from "../common/string/compare"; import { caseInsensitiveStringCompare } from "../common/string/compare";
import { ConfigEntry, getConfigEntries } from "../data/config_entries"; import { ConfigEntry, getConfigEntries } from "../data/config_entries";
import { domainToName } from "../data/integration"; import { domainToName } from "../data/integration";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../types";
import { HomeAssistant } from "../types";
import { brandsUrl } from "../util/brands-url"; import { brandsUrl } from "../util/brands-url";
import "./ha-combo-box"; import "./ha-combo-box";
import type { HaComboBox } from "./ha-combo-box"; import type { HaComboBox } from "./ha-combo-box";
@ -133,7 +132,7 @@ class HaConfigEntryPicker extends LitElement {
return this.value || ""; return this.value || "";
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value; const newValue = ev.detail.value;

View File

@ -8,8 +8,7 @@ import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import { customIcons } from "../data/custom_icons"; import { customIcons } from "../data/custom_icons";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../types";
import { HomeAssistant } from "../types";
import "./ha-combo-box"; import "./ha-combo-box";
import "./ha-icon"; import "./ha-icon";
@ -173,7 +172,7 @@ export class HaIconPicker extends LitElement {
callback(filteredItems.slice(iStart, iEnd), filteredItems.length); callback(filteredItems.slice(iStart, iEnd), filteredItems.length);
}; };
private async _openedChanged(ev: PolymerChangedEvent<boolean>) { private async _openedChanged(ev: ValueChangedEvent<boolean>) {
const opened = ev.detail.value; const opened = ev.detail.value;
if (opened && !ICONS_LOADED) { if (opened && !ICONS_LOADED) {
await loadIcons(); await loadIcons();
@ -181,7 +180,7 @@ export class HaIconPicker extends LitElement {
} }
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
this._setValue(ev.detail.value); this._setValue(ev.detail.value);
} }

View File

@ -8,8 +8,7 @@ import {
LovelaceConfig, LovelaceConfig,
LovelaceViewConfig, LovelaceViewConfig,
} from "../data/lovelace"; } from "../data/lovelace";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant, PanelInfo } from "../types";
import { HomeAssistant, PanelInfo } from "../types";
import "./ha-combo-box"; import "./ha-combo-box";
import type { HaComboBox } from "./ha-combo-box"; import type { HaComboBox } from "./ha-combo-box";
import "./ha-icon"; import "./ha-icon";
@ -96,7 +95,7 @@ export class HaNavigationPicker extends LitElement {
`; `;
} }
private async _openedChanged(ev: PolymerChangedEvent<boolean>) { private async _openedChanged(ev: ValueChangedEvent<boolean>) {
this._opened = ev.detail.value; this._opened = ev.detail.value;
if (this._opened && !this.navigationItemsLoaded) { if (this._opened && !this.navigationItemsLoaded) {
this._loadNavigationItems(); this._loadNavigationItems();
@ -152,7 +151,7 @@ export class HaNavigationPicker extends LitElement {
return !this._opened || changedProps.has("_opened"); return !this._opened || changedProps.has("_opened");
} }
private _valueChanged(ev: PolymerChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
this._setValue(ev.detail.value); this._setValue(ev.detail.value);
} }

View File

@ -15,8 +15,7 @@ import {
IntegrationManifest, IntegrationManifest,
} from "../data/integration"; } from "../data/integration";
import { Selector } from "../data/selector"; import { Selector } from "../data/selector";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../types";
import { HomeAssistant } from "../types";
import { documentationUrl } from "../util/documentation-url"; import { documentationUrl } from "../util/documentation-url";
import "./ha-checkbox"; import "./ha-checkbox";
import "./ha-icon-button"; import "./ha-icon-button";
@ -397,7 +396,7 @@ export class HaServiceControl extends LitElement {
this.requestUpdate("_checkedKeys"); this.requestUpdate("_checkedKeys");
} }
private _serviceChanged(ev: PolymerChangedEvent<string>) { private _serviceChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
if (ev.detail.value === this._value?.service) { if (ev.detail.value === this._value?.service) {
return; return;

View File

@ -5,8 +5,7 @@ import { guard } from "lit/directives/guard";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { fetchUsers, User } from "../../data/user"; import { fetchUsers, User } from "../../data/user";
import type { PolymerChangedEvent } from "../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../types";
import type { HomeAssistant } from "../../types";
import "../ha-icon-button"; import "../ha-icon-button";
import "./ha-user-picker"; import "./ha-user-picker";
@ -117,7 +116,7 @@ class HaUsersPickerLight extends LitElement {
}); });
} }
private _userChanged(event: PolymerChangedEvent<string>) { private _userChanged(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const index = (event.currentTarget as any).index; const index = (event.currentTarget as any).index;
const newValue = event.detail.value; const newValue = event.detail.value;
@ -130,7 +129,7 @@ class HaUsersPickerLight extends LitElement {
this._updateUsers(newUsers); this._updateUsers(newUsers);
} }
private async _addUser(event: PolymerChangedEvent<string>) { private async _addUser(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
const toAdd = event.detail.value; const toAdd = event.detail.value;
(event.currentTarget as any).value = ""; (event.currentTarget as any).value = "";

View File

@ -33,8 +33,7 @@ import {
} from "../data/core"; } from "../data/core";
import { SYMBOL_TO_ISO } from "../data/currency"; import { SYMBOL_TO_ISO } from "../data/currency";
import { onboardCoreConfigStep } from "../data/onboarding"; import { onboardCoreConfigStep } from "../data/onboarding";
import type { PolymerChangedEvent } from "../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../types";
import type { HomeAssistant } from "../types";
import { getLocalLanguage } from "../util/common-translation"; import { getLocalLanguage } from "../util/common-translation";
const amsterdam: [number, number] = [52.3731339, 4.8903147]; const amsterdam: [number, number] = [52.3731339, 4.8903147];
@ -368,7 +367,7 @@ class OnboardingCoreConfig extends LitElement {
] ]
); );
private _handleChange(ev: PolymerChangedEvent<string>) { private _handleChange(ev: ValueChangedEvent<string>) {
const target = ev.currentTarget as HaTextField; const target = ev.currentTarget as HaTextField;
let value = target.value; let value = target.value;

View File

@ -15,7 +15,7 @@ import "../components/ha-form/ha-form";
import type { HaForm } from "../components/ha-form/ha-form"; import type { HaForm } from "../components/ha-form/ha-form";
import { HaFormDataContainer, HaFormSchema } from "../components/ha-form/types"; import { HaFormDataContainer, HaFormSchema } from "../components/ha-form/types";
import { onboardUserStep } from "../data/onboarding"; import { onboardUserStep } from "../data/onboarding";
import { PolymerChangedEvent } from "../polymer-types"; import { ValueChangedEvent } from "../types";
const CREATE_USER_SCHEMA: HaFormSchema[] = [ const CREATE_USER_SCHEMA: HaFormSchema[] = [
{ {
@ -112,7 +112,7 @@ class OnboardingCreateUser extends LitElement {
} }
private _handleValueChanged( private _handleValueChanged(
ev: PolymerChangedEvent<HaFormDataContainer> ev: ValueChangedEvent<HaFormDataContainer>
): void { ): void {
const nameChanged = ev.detail.value.name !== this._newUser.name; const nameChanged = ev.detail.value.name !== this._newUser.name;
this._newUser = ev.detail.value; this._newUser = ev.detail.value;

View File

@ -13,9 +13,8 @@ import "../../../components/ha-textfield";
import { AreaRegistryEntryMutableParams } from "../../../data/area_registry"; import { AreaRegistryEntryMutableParams } from "../../../data/area_registry";
import { showAliasesDialog } from "../../../dialogs/aliases/show-dialog-aliases"; import { showAliasesDialog } from "../../../dialogs/aliases/show-dialog-aliases";
import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog"; import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog";
import { PolymerChangedEvent } from "../../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../../types";
import { haStyleDialog } from "../../../resources/styles"; import { haStyleDialog } from "../../../resources/styles";
import { HomeAssistant } from "../../../types";
import { AreaRegistryDetailDialogParams } from "./show-dialog-area-registry-detail"; import { AreaRegistryDetailDialogParams } from "./show-dialog-area-registry-detail";
const cropOptions: CropOptions = { const cropOptions: CropOptions = {
@ -187,7 +186,7 @@ class DialogAreaDetail extends LitElement {
this._name = ev.target.value; this._name = ev.target.value;
} }
private _pictureChanged(ev: PolymerChangedEvent<string | null>) { private _pictureChanged(ev: ValueChangedEvent<string | null>) {
this._error = undefined; this._error = undefined;
this._picture = (ev.target as HaPictureUpload).value; this._picture = (ev.target as HaPictureUpload).value;
} }

View File

@ -3,8 +3,7 @@ import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../../../../common/dom/fire_event"; import { fireEvent } from "../../../../../common/dom/fire_event";
import "../../../../../components/entity/ha-entity-picker"; import "../../../../../components/entity/ha-entity-picker";
import { SceneAction } from "../../../../../data/script"; import { SceneAction } from "../../../../../data/script";
import { PolymerChangedEvent } from "../../../../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../../../../types";
import { HomeAssistant } from "../../../../../types";
import { ActionElement } from "../ha-automation-action-row"; import { ActionElement } from "../ha-automation-action-row";
const includeDomains = ["scene"]; const includeDomains = ["scene"];
@ -51,7 +50,7 @@ export class HaSceneAction extends LitElement implements ActionElement {
`; `;
} }
private _entityPicked(ev: PolymerChangedEvent<string>) { private _entityPicked(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { value: {

View File

@ -5,8 +5,7 @@ import { computeStateDomain } from "../../../../../common/entity/compute_state_d
import { hasLocation } from "../../../../../common/entity/has_location"; import { hasLocation } from "../../../../../common/entity/has_location";
import "../../../../../components/entity/ha-entity-picker"; import "../../../../../components/entity/ha-entity-picker";
import { ZoneCondition } from "../../../../../data/automation"; import { ZoneCondition } from "../../../../../data/automation";
import { PolymerChangedEvent } from "../../../../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../../../../types";
import { HomeAssistant } from "../../../../../types";
function zoneAndLocationFilter(stateObj) { function zoneAndLocationFilter(stateObj) {
return hasLocation(stateObj) && computeStateDomain(stateObj) !== "zone"; return hasLocation(stateObj) && computeStateDomain(stateObj) !== "zone";
@ -62,14 +61,14 @@ export class HaZoneCondition extends LitElement {
`; `;
} }
private _entityPicked(ev: PolymerChangedEvent<string>) { private _entityPicked(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { ...this.condition, entity_id: ev.detail.value }, value: { ...this.condition, entity_id: ev.detail.value },
}); });
} }
private _zonePicked(ev: PolymerChangedEvent<string>) { private _zonePicked(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { ...this.condition, zone: ev.detail.value }, value: { ...this.condition, zone: ev.detail.value },

View File

@ -6,8 +6,7 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
import { computeStateDomain } from "../../../../../common/entity/compute_state_domain"; import { computeStateDomain } from "../../../../../common/entity/compute_state_domain";
import { hasLocation } from "../../../../../common/entity/has_location"; import { hasLocation } from "../../../../../common/entity/has_location";
import type { ZoneTrigger } from "../../../../../data/automation"; import type { ZoneTrigger } from "../../../../../data/automation";
import type { PolymerChangedEvent } from "../../../../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../../../../types";
import type { HomeAssistant } from "../../../../../types";
import type { HaRadio } from "../../../../../components/ha-radio"; import type { HaRadio } from "../../../../../components/ha-radio";
function zoneAndLocationFilter(stateObj) { function zoneAndLocationFilter(stateObj) {
@ -94,14 +93,14 @@ export class HaZoneTrigger extends LitElement {
`; `;
} }
private _entityPicked(ev: PolymerChangedEvent<string>) { private _entityPicked(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { ...this.trigger, entity_id: ev.detail.value }, value: { ...this.trigger, entity_id: ev.detail.value },
}); });
} }
private _zonePicked(ev: PolymerChangedEvent<string>) { private _zonePicked(ev: ValueChangedEvent<string>) {
ev.stopPropagation(); ev.stopPropagation();
fireEvent(this, "value-changed", { fireEvent(this, "value-changed", {
value: { ...this.trigger, zone: ev.detail.value }, value: { ...this.trigger, zone: ev.detail.value },

View File

@ -6,8 +6,7 @@ import {
HassRouterPage, HassRouterPage,
RouterOptions, RouterOptions,
} from "../../../layouts/hass-router-page"; } from "../../../layouts/hass-router-page";
import { PolymerChangedEvent } from "../../../polymer-types"; import { ValueChangedEvent, HomeAssistant, Route } from "../../../types";
import { HomeAssistant, Route } from "../../../types";
import "./account/cloud-account"; import "./account/cloud-account";
import "./login/cloud-login"; import "./login/cloud-login";
@ -95,10 +94,10 @@ class HaConfigCloud extends HassRouterPage {
protected createElement(tag: string) { protected createElement(tag: string) {
const el = super.createElement(tag); const el = super.createElement(tag);
el.addEventListener("email-changed", (ev) => { el.addEventListener("email-changed", (ev) => {
this._loginEmail = (ev as PolymerChangedEvent<string>).detail.value; this._loginEmail = (ev as ValueChangedEvent<string>).detail.value;
}); });
el.addEventListener("flash-message-changed", (ev) => { el.addEventListener("flash-message-changed", (ev) => {
this._flashMessage = (ev as PolymerChangedEvent<string>).detail.value; this._flashMessage = (ev as ValueChangedEvent<string>).detail.value;
}); });
return el; return el;
} }

View File

@ -14,8 +14,7 @@ import {
ZHAGroup, ZHAGroup,
} from "../../../../../data/zha"; } from "../../../../../data/zha";
import "../../../../../layouts/hass-subpage"; import "../../../../../layouts/hass-subpage";
import type { PolymerChangedEvent } from "../../../../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../../../../types";
import type { HomeAssistant } from "../../../../../types";
import "../../../ha-config-section"; import "../../../ha-config-section";
import "./zha-device-endpoint-data-table"; import "./zha-device-endpoint-data-table";
import type { ZHADeviceEndpointDataTable } from "./zha-device-endpoint-data-table"; import type { ZHADeviceEndpointDataTable } from "./zha-device-endpoint-data-table";
@ -140,7 +139,7 @@ export class ZHAAddGroupPage extends LitElement {
navigate(`/config/zha/group/${group.group_id}`, { replace: true }); navigate(`/config/zha/group/${group.group_id}`, { replace: true });
} }
private _handleNameChange(ev: PolymerChangedEvent<string>) { private _handleNameChange(ev: ValueChangedEvent<string>) {
const target = ev.currentTarget as PaperInputElement; const target = ev.currentTarget as PaperInputElement;
this._groupName = target.value || ""; this._groupName = target.value || "";
} }

View File

@ -21,7 +21,7 @@ import {
ZHADevice, ZHADevice,
} from "../../../../../data/zha"; } from "../../../../../data/zha";
import "../../../../../layouts/hass-tabs-subpage"; import "../../../../../layouts/hass-tabs-subpage";
import { PolymerChangedEvent } from "../../../../../polymer-types"; import { ValueChangedEvent } from "../../../../../types";
import type { HomeAssistant, Route } from "../../../../../types"; import type { HomeAssistant, Route } from "../../../../../types";
import { formatAsPaddedHex } from "./functions"; import { formatAsPaddedHex } from "./functions";
import { zhaTabs } from "./zha-config-dashboard"; import { zhaTabs } from "./zha-config-dashboard";
@ -339,7 +339,7 @@ export class ZHANetworkVisualizationPage extends LitElement {
} }
} }
private _onZoomToDevice(event: PolymerChangedEvent<string>) { private _onZoomToDevice(event: ValueChangedEvent<string>) {
event.stopPropagation(); event.stopPropagation();
this.zoomedDeviceId = event.detail.value; this.zoomedDeviceId = event.detail.value;
if (!this._network) { if (!this._network) {

View File

@ -18,8 +18,7 @@ import "../../../components/ha-textfield";
import type { HaTextField } from "../../../components/ha-textfield"; import type { HaTextField } from "../../../components/ha-textfield";
import { CloudStatus, fetchCloudStatus } from "../../../data/cloud"; import { CloudStatus, fetchCloudStatus } from "../../../data/cloud";
import { saveCoreConfig } from "../../../data/core"; import { saveCoreConfig } from "../../../data/core";
import type { PolymerChangedEvent } from "../../../polymer-types"; import type { ValueChangedEvent, HomeAssistant } from "../../../types";
import type { HomeAssistant } from "../../../types";
@customElement("ha-config-url-form") @customElement("ha-config-url-form")
class ConfigUrlForm extends LitElement { class ConfigUrlForm extends LitElement {
@ -291,7 +290,7 @@ class ConfigUrlForm extends LitElement {
this._showCustomInternalUrl = !ev.currentTarget.checked; this._showCustomInternalUrl = !ev.currentTarget.checked;
} }
private _handleChange(ev: PolymerChangedEvent<string>) { private _handleChange(ev: ValueChangedEvent<string>) {
const target = ev.currentTarget as HaTextField; const target = ev.currentTarget as HaTextField;
this[`_${target.name}`] = target.value || null; this[`_${target.name}`] = target.value || null;
} }

View File

@ -21,9 +21,8 @@ import {
showConfirmationDialog, showConfirmationDialog,
} from "../../../dialogs/generic/show-dialog-box"; } from "../../../dialogs/generic/show-dialog-box";
import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog"; import { CropOptions } from "../../../dialogs/image-cropper-dialog/show-image-cropper-dialog";
import { PolymerChangedEvent } from "../../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../../types";
import { haStyleDialog } from "../../../resources/styles"; import { haStyleDialog } from "../../../resources/styles";
import { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url"; import { documentationUrl } from "../../../util/documentation-url";
import { showAddUserDialog } from "../users/show-dialog-add-user"; import { showAddUserDialog } from "../users/show-dialog-add-user";
import { showAdminChangePasswordDialog } from "../users/show-dialog-admin-change-password"; import { showAdminChangePasswordDialog } from "../users/show-dialog-admin-change-password";
@ -325,12 +324,12 @@ class DialogPersonDetail extends LitElement {
} }
} }
private _deviceTrackersChanged(ev: PolymerChangedEvent<string[]>) { private _deviceTrackersChanged(ev: ValueChangedEvent<string[]>) {
this._error = undefined; this._error = undefined;
this._deviceTrackers = ev.detail.value; this._deviceTrackers = ev.detail.value;
} }
private _pictureChanged(ev: PolymerChangedEvent<string | null>) { private _pictureChanged(ev: ValueChangedEvent<string | null>) {
this._error = undefined; this._error = undefined;
this._picture = (ev.target as HaPictureUpload).value; this._picture = (ev.target as HaPictureUpload).value;
} }

View File

@ -22,9 +22,8 @@ import {
SYSTEM_GROUP_ID_USER, SYSTEM_GROUP_ID_USER,
User, User,
} from "../../../data/user"; } from "../../../data/user";
import { PolymerChangedEvent } from "../../../polymer-types"; import { ValueChangedEvent, HomeAssistant } from "../../../types";
import { haStyleDialog } from "../../../resources/styles"; import { haStyleDialog } from "../../../resources/styles";
import { HomeAssistant } from "../../../types";
import { AddUserDialogParams } from "./show-dialog-add-user"; import { AddUserDialogParams } from "./show-dialog-add-user";
@customElement("dialog-add-user") @customElement("dialog-add-user")
@ -231,7 +230,7 @@ export class DialogAddUser extends LitElement {
} }
} }
private _handleValueChanged(ev: PolymerChangedEvent<string>): void { private _handleValueChanged(ev: ValueChangedEvent<string>): void {
this._error = undefined; this._error = undefined;
const name = (ev.target as any).name; const name = (ev.target as any).name;
this[`_${name}`] = ev.detail.value; this[`_${name}`] = ev.detail.value;

View File

@ -11,12 +11,13 @@ import {
string, string,
} from "superstruct"; } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event"; import { fireEvent } from "../../../../common/dom/fire_event";
import { hasLocation } from "../../../../common/entity/has_location";
import "../../../../components/ha-form/ha-form"; import "../../../../components/ha-form/ha-form";
import { SchemaUnion } from "../../../../components/ha-form/types"; import { SchemaUnion } from "../../../../components/ha-form/types";
import "../../../../components/ha-formfield"; import "../../../../components/ha-formfield";
import "../../../../components/ha-switch"; import "../../../../components/ha-switch";
import { PolymerChangedEvent } from "../../../../polymer-types"; import { HomeAssistant, ValueChangedEvent } from "../../../../types";
import { HomeAssistant } from "../../../../types"; import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
import { MapCardConfig } from "../../cards/types"; import { MapCardConfig } from "../../cards/types";
import "../../components/hui-entity-editor"; import "../../components/hui-entity-editor";
import "../../components/hui-input-list-editor"; import "../../components/hui-input-list-editor";
@ -27,8 +28,6 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
import { entitiesConfigStruct } from "../structs/entities-struct"; import { entitiesConfigStruct } from "../structs/entities-struct";
import { EntitiesEditorEvent } from "../types"; import { EntitiesEditorEvent } from "../types";
import { configElementStyle } from "./config-elements-style"; import { configElementStyle } from "./config-elements-style";
import { hasLocation } from "../../../../common/entity/has_location";
import { DEFAULT_HOURS_TO_SHOW, DEFAULT_ZOOM } from "../../cards/hui-map-card";
const cardConfigStruct = assign( const cardConfigStruct = assign(
baseLovelaceCardConfig, baseLovelaceCardConfig,
@ -134,7 +133,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
} }
} }
private _geoSourcesChanged(ev: PolymerChangedEvent<any>): void { private _geoSourcesChanged(ev: ValueChangedEvent<any>): void {
if (!this._config || !this.hass) { if (!this._config || !this.hass) {
return; return;
} }

View File

@ -15,7 +15,6 @@ import {
showPromptDialog, showPromptDialog,
} from "../../dialogs/generic/show-dialog-box"; } from "../../dialogs/generic/show-dialog-box";
import { haStyle } from "../../resources/styles"; import { haStyle } from "../../resources/styles";
import "../../styles/polymer-ha-style";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import { showLongLivedAccessTokenDialog } from "./show-long-lived-access-token-dialog"; import { showLongLivedAccessTokenDialog } from "./show-long-lived-access-token-dialog";

View File

@ -1,38 +0,0 @@
export const applyPolymerEvent = <T>(
ev: PolymerChangedEvent<T>,
curValue: T
): T => {
const { path, value } = ev.detail;
if (!path) {
return value;
}
const propName = path.split(".")[1];
return { ...curValue, [propName]: value };
};
export interface PolymerChangedEvent<T> extends Event {
detail: {
value: T;
path?: string;
queueProperty: boolean;
};
}
export interface PolymerIronSelectEvent<T> extends Event {
detail: {
item: T;
};
}
declare global {
// for fire event
interface HASSDomEvents {
"hass-logout": undefined;
"iron-resize": undefined;
"config-refresh": undefined;
"hass-api-called": {
success: boolean;
response: unknown;
};
}
}

View File

@ -1,4 +1,3 @@
import "@polymer/iron-flex-layout/iron-flex-layout-classes";
import type { HassEntity } from "home-assistant-js-websocket"; import type { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";

View File

@ -40,12 +40,20 @@ declare global {
getComputedStyleValue(element, propertyName); getComputedStyleValue(element, propertyName);
}; };
} }
// for fire event // for fire event
interface HASSDomEvents { interface HASSDomEvents {
"value-changed": { "value-changed": {
value: unknown; value: unknown;
}; };
change: undefined; change: undefined;
"hass-logout": undefined;
"iron-resize": undefined;
"config-refresh": undefined;
"hass-api-called": {
success: boolean;
response: unknown;
};
} }
// For loading workers in webpack // For loading workers in webpack
@ -54,6 +62,12 @@ declare global {
} }
} }
export interface ValueChangedEvent<T> extends CustomEvent {
detail: {
value: T;
};
}
export type Constructor<T = any> = new (...args: any[]) => T; export type Constructor<T = any> = new (...args: any[]) => T;
export interface ClassElement { export interface ClassElement {