From b8014412018ccf973d1212025ee209e9d9edae2e Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Mon, 15 Jan 2024 09:40:03 -0500 Subject: [PATCH] Fix property visibility mismatches (1 of 2) (#19376) --- gallery/src/ha-gallery.ts | 12 +++++----- .../addon-view/config/hassio-addon-config.ts | 4 ++-- src/auth/ha-auth-flow.ts | 2 +- src/components/ha-file-upload.ts | 8 +++---- .../config/dashboard/ha-config-updates.ts | 22 ++++++++----------- .../zha/zha-config-dashboard.ts | 4 ++-- .../zwave_js/zwave_js-node-config.ts | 3 +-- src/panels/config/users/ha-config-users.ts | 10 ++++----- .../lovelace/components/hui-action-editor.ts | 2 +- .../components/hui-entities-toggle.ts | 2 +- .../lovelace/components/hui-entity-editor.ts | 8 +++---- .../components/hui-input-list-editor.ts | 6 ++--- .../card-editor/hui-dialog-create-card.ts | 2 +- .../card-editor/hui-dialog-delete-card.ts | 2 +- .../hui-dialog-create-headerfooter.ts | 2 +- .../editor/hui-entities-card-row-editor.ts | 6 ++--- 16 files changed, 45 insertions(+), 50 deletions(-) diff --git a/gallery/src/ha-gallery.ts b/gallery/src/ha-gallery.ts index 31f2337a12..eec45d2b52 100644 --- a/gallery/src/ha-gallery.ts +++ b/gallery/src/ha-gallery.ts @@ -1,14 +1,14 @@ -import { mdiMenu } from "@mdi/js"; import "@material/mwc-drawer"; import "@material/mwc-top-app-bar-fixed"; -import { html, css, LitElement, PropertyValues } from "lit"; -import { customElement, property, query } from "lit/decorators"; +import { mdiMenu } from "@mdi/js"; +import { LitElement, PropertyValues, css, html } from "lit"; +import { customElement, query, state } from "lit/decorators"; +import { dynamicElement } from "../../src/common/dom/dynamic-element-directive"; +import { HaExpansionPanel } from "../../src/components/ha-expansion-panel"; import "../../src/components/ha-icon-button"; import "../../src/managers/notification-manager"; -import { HaExpansionPanel } from "../../src/components/ha-expansion-panel"; import { haStyle } from "../../src/resources/styles"; import { PAGES, SIDEBAR } from "../build/import-pages"; -import { dynamicElement } from "../../src/common/dom/dynamic-element-directive"; import "./components/page-description"; const GITHUB_DEMO_URL = @@ -24,7 +24,7 @@ const FAKE_HASS = { @customElement("ha-gallery") class HaGallery extends LitElement { - @property() private _page = + @state() private _page = document.location.hash.substring(1) || `${SIDEBAR[0].category}/${SIDEBAR[0].pages![0]}`; diff --git a/hassio/src/addon-view/config/hassio-addon-config.ts b/hassio/src/addon-view/config/hassio-addon-config.ts index 75ff632c15..9cd32b64f7 100644 --- a/hassio/src/addon-view/config/hassio-addon-config.ts +++ b/hassio/src/addon-view/config/hassio-addon-config.ts @@ -65,9 +65,9 @@ class HassioAddonConfig extends LitElement { @property({ attribute: false }) public supervisor!: Supervisor; - @property({ type: Boolean }) private _configHasChanged = false; + @state() private _configHasChanged = false; - @property({ type: Boolean }) private _valid = true; + @state() private _valid = true; @state() private _canShowSchema = false; diff --git a/src/auth/ha-auth-flow.ts b/src/auth/ha-auth-flow.ts index fb1d7d7c32..d8d18b4ef2 100644 --- a/src/auth/ha-auth-flow.ts +++ b/src/auth/ha-auth-flow.ts @@ -38,7 +38,7 @@ export class HaAuthFlow extends LitElement { @property({ attribute: false }) public step?: DataEntryFlowStep; - @property({ type: Boolean }) private initStoreToken = false; + @property({ type: Boolean }) public initStoreToken = false; @state() private _storeToken = false; diff --git a/src/components/ha-file-upload.ts b/src/components/ha-file-upload.ts index 29e8b07ed4..952c588ea2 100644 --- a/src/components/ha-file-upload.ts +++ b/src/components/ha-file-upload.ts @@ -33,16 +33,16 @@ export class HaFileUpload extends LitElement { @property() public value?: File | File[] | FileList | string; - @property({ type: Boolean }) private multiple = false; + @property({ type: Boolean }) public multiple = false; @property({ type: Boolean, reflect: true }) public disabled: boolean = false; - @property({ type: Boolean }) private uploading = false; + @property({ type: Boolean }) public uploading = false; - @property({ type: Number }) private progress?: number; + @property({ type: Number }) public progress?: number; @property({ type: Boolean, attribute: "auto-open-file-dialog" }) - private autoOpenFileDialog = false; + public autoOpenFileDialog = false; @state() private _drag = false; diff --git a/src/panels/config/dashboard/ha-config-updates.ts b/src/panels/config/dashboard/ha-config-updates.ts index e12e776096..78b9aaa370 100644 --- a/src/panels/config/dashboard/ha-config-updates.ts +++ b/src/panels/config/dashboard/ha-config-updates.ts @@ -2,7 +2,7 @@ import "@material/mwc-button/mwc-button"; import "@material/mwc-list/mwc-list"; import { UnsubscribeFunc } from "home-assistant-js-websocket"; import { css, CSSResultGroup, html, LitElement, nothing } from "lit"; -import { customElement, property } from "lit/decorators"; +import { customElement, property, state } from "lit/decorators"; import { ifDefined } from "lit/directives/if-defined"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../../common/dom/fire_event"; @@ -30,37 +30,33 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) { @property({ type: Boolean }) public narrow!: boolean; - @property({ attribute: false }) - public updateEntities?: UpdateEntity[]; + @property({ attribute: false }) public updateEntities?: UpdateEntity[]; - @property({ attribute: false, type: Array }) - private devices?: DeviceRegistryEntry[]; + @property({ type: Number }) public total?: number; - @property({ attribute: false, type: Array }) - private entities?: EntityRegistryEntry[]; + @state() private _devices?: DeviceRegistryEntry[]; - @property({ type: Number }) - public total?: number; + @state() private _entities?: EntityRegistryEntry[]; public hassSubscribe(): UnsubscribeFunc[] { return [ subscribeDeviceRegistry(this.hass.connection, (entries) => { - this.devices = entries; + this._devices = entries; }), subscribeEntityRegistry(this.hass.connection!, (entities) => { - this.entities = entities.filter((entity) => entity.device_id !== null); + this._entities = entities.filter((entity) => entity.device_id !== null); }), ]; } private getDeviceEntry = memoizeOne( (deviceId: string): DeviceRegistryEntry | undefined => - this.devices?.find((device) => device.id === deviceId) + this._devices?.find((device) => device.id === deviceId) ); private getEntityEntry = memoizeOne( (entityId: string): EntityRegistryEntry | undefined => - this.entities?.find((entity) => entity.entity_id === entityId) + this._entities?.find((entity) => entity.entity_id === entityId) ); protected render() { diff --git a/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts b/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts index 13b2f85c66..55a08d0731 100644 --- a/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts +++ b/src/panels/config/integrations/integration-panels/zha/zha-config-dashboard.ts @@ -78,9 +78,9 @@ class ZHAConfigDashboard extends LitElement { @property() public configEntryId?: string; - @property() private _configuration?: ZHAConfiguration; + @state() private _configuration?: ZHAConfiguration; - @property() private _networkSettings?: ZHANetworkSettings; + @state() private _networkSettings?: ZHANetworkSettings; @state() private _generatingBackup = false; diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts index df90deec41..b131d8794a 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts @@ -79,8 +79,7 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { @property() public deviceId!: string; - @property({ type: Array }) - private _deviceRegistryEntries?: DeviceRegistryEntry[]; + @state() private _deviceRegistryEntries?: DeviceRegistryEntry[]; @state() private _nodeMetadata?: ZwaveJSNodeMetadata; diff --git a/src/panels/config/users/ha-config-users.ts b/src/panels/config/users/ha-config-users.ts index f7408f5174..e65bcbe0e8 100644 --- a/src/panels/config/users/ha-config-users.ts +++ b/src/panels/config/users/ha-config-users.ts @@ -1,6 +1,6 @@ import { mdiCheck, mdiPlus } from "@mdi/js"; -import { html, LitElement, PropertyValues } from "lit"; -import { customElement, property } from "lit/decorators"; +import { LitElement, PropertyValues, html } from "lit"; +import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { HASSDomEvent } from "../../../common/dom/fire_event"; import { LocalizeFunc } from "../../../common/translations/localize"; @@ -13,11 +13,11 @@ import "../../../components/ha-fab"; import "../../../components/ha-help-tooltip"; import "../../../components/ha-svg-icon"; import { + User, computeUserBadges, deleteUser, fetchUsers, updateUser, - User, } from "../../../data/user"; import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box"; import "../../../layouts/hass-tabs-subpage-data-table"; @@ -30,14 +30,14 @@ import { showUserDetailDialog } from "./show-dialog-user-detail"; export class HaConfigUsers extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property({ attribute: false }) public _users: User[] = []; - @property({ type: Boolean }) public isWide!: boolean; @property({ type: Boolean }) public narrow!: boolean; @property({ attribute: false }) public route!: Route; + @state() private _users: User[] = []; + private _columns = memoizeOne( (narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => { const columns: DataTableColumnContainer = { diff --git a/src/panels/lovelace/components/hui-action-editor.ts b/src/panels/lovelace/components/hui-action-editor.ts index a6999ee4cb..a578e24853 100644 --- a/src/panels/lovelace/components/hui-action-editor.ts +++ b/src/panels/lovelace/components/hui-action-editor.ts @@ -82,7 +82,7 @@ export class HuiActionEditor extends LitElement { @property() public tooltipText?: string; - @property() protected hass?: HomeAssistant; + @property({ attribute: false }) public hass?: HomeAssistant; @query("ha-select") private _select!: HaSelect; diff --git a/src/panels/lovelace/components/hui-entities-toggle.ts b/src/panels/lovelace/components/hui-entities-toggle.ts index 8c28f4b7be..0dfadc7924 100644 --- a/src/panels/lovelace/components/hui-entities-toggle.ts +++ b/src/panels/lovelace/components/hui-entities-toggle.ts @@ -18,7 +18,7 @@ import { turnOnOffEntities } from "../common/entity/turn-on-off-entities"; class HuiEntitiesToggle extends LitElement { @property({ type: Array }) public entities?: string[]; - @property({ attribute: false }) protected hass?: HomeAssistant; + @property({ attribute: false }) public hass?: HomeAssistant; @state() private _toggleEntities?: string[]; diff --git a/src/panels/lovelace/components/hui-entity-editor.ts b/src/panels/lovelace/components/hui-entity-editor.ts index 0af08f1180..c69ad7066e 100644 --- a/src/panels/lovelace/components/hui-entity-editor.ts +++ b/src/panels/lovelace/components/hui-entity-editor.ts @@ -15,13 +15,13 @@ import { EntityConfig } from "../entity-rows/types"; @customElement("hui-entity-editor") export class HuiEntityEditor extends LitElement { - @property({ attribute: false }) protected hass?: HomeAssistant; + @property({ attribute: false }) public hass?: HomeAssistant; - @property({ attribute: false }) protected entities?: EntityConfig[]; + @property({ attribute: false }) public entities?: EntityConfig[]; - @property() protected entityFilter?: HaEntityPickerEntityFilterFunc; + @property() public entityFilter?: HaEntityPickerEntityFilterFunc; - @property() protected label?: string; + @property() public label?: string; private _entityKeys = new WeakMap(); diff --git a/src/panels/lovelace/components/hui-input-list-editor.ts b/src/panels/lovelace/components/hui-input-list-editor.ts index 635eb84800..0a189e5e38 100644 --- a/src/panels/lovelace/components/hui-input-list-editor.ts +++ b/src/panels/lovelace/components/hui-input-list-editor.ts @@ -9,11 +9,11 @@ import { EditorTarget } from "../editor/types"; @customElement("hui-input-list-editor") export class HuiInputListEditor extends LitElement { - @property() protected value?: string[]; + @property({ type: Array }) public value?: string[]; - @property() protected hass?: HomeAssistant; + @property({ attribute: false }) public hass?: HomeAssistant; - @property() protected inputLabel?: string; + @property() public inputLabel?: string; protected render() { if (!this.value) { diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts index e23cafa985..1752a24174 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-create-card.ts @@ -37,7 +37,7 @@ export class HuiCreateDialogCard extends LitElement implements HassDialog { - @property({ attribute: false }) protected hass!: HomeAssistant; + @property({ attribute: false }) public hass!: HomeAssistant; @state() private _params?: CreateCardDialogParams; diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts index ca730833d6..1483268554 100644 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-delete-card.ts @@ -10,7 +10,7 @@ import type { DeleteCardDialogParams } from "./show-delete-card-dialog"; @customElement("hui-dialog-delete-card") export class HuiDialogDeleteCard extends LitElement { - @property() protected hass!: HomeAssistant; + @property({ attribute: false }) public hass!: HomeAssistant; @state() private _params?: DeleteCardDialogParams; diff --git a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts index f3d25a2130..8c13d58b65 100644 --- a/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts +++ b/src/panels/lovelace/editor/header-footer-editor/hui-dialog-create-headerfooter.ts @@ -16,7 +16,7 @@ export class HuiCreateDialogHeaderFooter extends LitElement implements HassDialog { - @property({ attribute: false }) protected hass!: HomeAssistant; + @property({ attribute: false }) public hass!: HomeAssistant; @state() private _params?: CreateHeaderFooterDialogParams; diff --git a/src/panels/lovelace/editor/hui-entities-card-row-editor.ts b/src/panels/lovelace/editor/hui-entities-card-row-editor.ts index 58891055fc..d492ee8918 100644 --- a/src/panels/lovelace/editor/hui-entities-card-row-editor.ts +++ b/src/panels/lovelace/editor/hui-entities-card-row-editor.ts @@ -21,11 +21,11 @@ declare global { @customElement("hui-entities-card-row-editor") export class HuiEntitiesCardRowEditor extends LitElement { - @property({ attribute: false }) protected hass?: HomeAssistant; + @property({ attribute: false }) public hass?: HomeAssistant; - @property({ attribute: false }) protected entities?: LovelaceRowConfig[]; + @property({ attribute: false }) public entities?: LovelaceRowConfig[]; - @property() protected label?: string; + @property() public label?: string; private _entityKeys = new WeakMap();