diff --git a/.yarn/patches/@polymer/polymer/pr-5569.patch b/.yarn/patches/@polymer/polymer/pr-5569.patch deleted file mode 100644 index ec2018f0d7..0000000000 --- a/.yarn/patches/@polymer/polymer/pr-5569.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/lib/legacy/class.js b/lib/legacy/class.js -index aee2511be1cd9bf900ee552bc98190c1631c57c0..f2f499d68bf52034cac9c28307c99e8ce6b8417d 100644 ---- a/lib/legacy/class.js -+++ b/lib/legacy/class.js -@@ -304,17 +304,23 @@ function GenerateClassFromInfo(info, Base, behaviors) { - // only proceed if the generated class' prototype has not been registered. - const generatedProto = PolymerGenerated.prototype; - if (!generatedProto.hasOwnProperty(JSCompiler_renameProperty('__hasRegisterFinished', generatedProto))) { -- generatedProto.__hasRegisterFinished = true; -+ // make sure legacy lifecycle is called on the *element*'s prototype -+ // and not the generated class prototype; if the element has been -+ // extended, these are *not* the same. -+ const proto = Object.getPrototypeOf(this); -+ // Only set flag when generated prototype itself is registered, -+ // as this element may be extended from, and needs to run `registered` -+ // on all behaviors on the subclass as well. -+ if (proto === generatedProto) { -+ generatedProto.__hasRegisterFinished = true; -+ } - // ensure superclass is registered first. - super._registered(); - // copy properties onto the generated class lazily if we're optimizing, -- if (legacyOptimizations) { -+ if (legacyOptimizations && !Object.hasOwnProperty(generatedProto, '__hasCopiedProperties')) { -+ generatedProto.__hasCopiedProperties = true; - copyPropertiesToProto(generatedProto); - } -- // make sure legacy lifecycle is called on the *element*'s prototype -- // and not the generated class prototype; if the element has been -- // extended, these are *not* the same. -- const proto = Object.getPrototypeOf(this); - let list = lifecycle.beforeRegister; - if (list) { - for (let i=0; i < list.length; i++) { diff --git a/build-scripts/babel-plugins/custom-polyfill-plugin.js b/build-scripts/babel-plugins/custom-polyfill-plugin.js index 709f3b87e0..2a86470b52 100644 --- a/build-scripts/babel-plugins/custom-polyfill-plugin.js +++ b/build-scripts/babel-plugins/custom-polyfill-plugin.js @@ -2,7 +2,7 @@ import defineProvider from "@babel/helper-define-polyfill-provider"; import { join } from "node:path"; import paths from "../paths.cjs"; -const POLYFILL_DIR = join(paths.polymer_dir, "src/resources/polyfills"); +const POLYFILL_DIR = join(paths.root_dir, "src/resources/polyfills"); // List of polyfill keys with supported browser targets for the functionality const polyfillSupport = { diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index 37c8183cc9..61ec4dbee8 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -20,22 +20,16 @@ module.exports.ignorePackages = () => []; // Files from NPM packages that we should replace with empty file module.exports.emptyPackages = ({ isHassioBuild }) => [ - // Contains all color definitions for all material color sets. - // We don't use it - require.resolve("@polymer/paper-styles/color.js"), - require.resolve("@polymer/paper-styles/default-theme.js"), - // Loads stuff from a CDN - require.resolve("@polymer/font-roboto/roboto.js"), require.resolve("@vaadin/vaadin-material-styles/typography.js"), require.resolve("@vaadin/vaadin-material-styles/font-icons.js"), // Icons in supervisor conflict with icons in HA so we don't load. isHassioBuild && require.resolve( - path.resolve(paths.polymer_dir, "src/components/ha-icon.ts") + path.resolve(paths.root_dir, "src/components/ha-icon.ts") ), isHassioBuild && require.resolve( - path.resolve(paths.polymer_dir, "src/components/ha-icon-picker.ts") + path.resolve(paths.root_dir, "src/components/ha-icon-picker.ts") ), ].filter(Boolean); @@ -50,7 +44,8 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({ __HASS_URL__: `\`${ "HASS_URL" in process.env ? process.env.HASS_URL - : "${location.protocol}//${location.host}" + : // eslint-disable-next-line no-template-curly-in-string + "${location.protocol}//${location.host}" }\``, "process.env.NODE_ENV": JSON.stringify( isProdBuild ? "production" : "development" @@ -164,7 +159,7 @@ module.exports.babelOptions = ({ ], ], exclude: [ - path.join(paths.polymer_dir, "src/resources/polyfills"), + path.join(paths.root_dir, "src/resources/polyfills"), ...[ "@formatjs/(?:ecma402-abstract|intl-\\w+)", "@lit-labs/virtualizer/polyfills", diff --git a/build-scripts/env.cjs b/build-scripts/env.cjs index b4e39607c2..2f2f081ec1 100644 --- a/build-scripts/env.cjs +++ b/build-scripts/env.cjs @@ -21,7 +21,7 @@ module.exports = { }, version() { const version = fs - .readFileSync(path.resolve(paths.polymer_dir, "pyproject.toml"), "utf8") + .readFileSync(path.resolve(paths.root_dir, "pyproject.toml"), "utf8") .match(/version\W+=\W"(\d{8}\.\d(?:\.dev)?)"/); if (!version) { throw Error("Version not found"); diff --git a/build-scripts/gulp/entry-html.js b/build-scripts/gulp/entry-html.js index b5994b4d68..d41dd8f457 100644 --- a/build-scripts/gulp/entry-html.js +++ b/build-scripts/gulp/entry-html.js @@ -169,14 +169,14 @@ const APP_PAGE_ENTRIES = { gulp.task( "gen-pages-app-dev", - genPagesDevTask(APP_PAGE_ENTRIES, paths.polymer_dir, paths.app_output_root) + genPagesDevTask(APP_PAGE_ENTRIES, paths.root_dir, paths.app_output_root) ); gulp.task( "gen-pages-app-prod", genPagesProdTask( APP_PAGE_ENTRIES, - paths.polymer_dir, + paths.root_dir, paths.app_output_root, paths.app_output_latest, paths.app_output_es5 diff --git a/build-scripts/gulp/gather-static.js b/build-scripts/gulp/gather-static.js index fc34e9f8eb..0c8637c21c 100644 --- a/build-scripts/gulp/gather-static.js +++ b/build-scripts/gulp/gather-static.js @@ -6,8 +6,8 @@ import path from "path"; import paths from "../paths.cjs"; const npmPath = (...parts) => - path.resolve(paths.polymer_dir, "node_modules", ...parts); -const polyPath = (...parts) => path.resolve(paths.polymer_dir, ...parts); + path.resolve(paths.root_dir, "node_modules", ...parts); +const polyPath = (...parts) => path.resolve(paths.root_dir, ...parts); const copyFileDir = (fromFile, toDir) => fs.copySync(fromFile, path.join(toDir, path.basename(fromFile))); diff --git a/build-scripts/gulp/locale-data.js b/build-scripts/gulp/locale-data.js index 4cf91711d4..ec75185d6d 100755 --- a/build-scripts/gulp/locale-data.js +++ b/build-scripts/gulp/locale-data.js @@ -4,7 +4,7 @@ import gulp from "gulp"; import { join, resolve } from "node:path"; import paths from "../paths.cjs"; -const formatjsDir = join(paths.polymer_dir, "node_modules", "@formatjs"); +const formatjsDir = join(paths.root_dir, "node_modules", "@formatjs"); const outDir = join(paths.build_dir, "locale-data"); const INTL_POLYFILLS = { diff --git a/build-scripts/paths.cjs b/build-scripts/paths.cjs index fc8357d947..b181ee7c00 100644 --- a/build-scripts/paths.cjs +++ b/build-scripts/paths.cjs @@ -1,7 +1,7 @@ const path = require("path"); module.exports = { - polymer_dir: path.resolve(__dirname, ".."), + root_dir: path.resolve(__dirname, ".."), build_dir: path.resolve(__dirname, "../build"), app_output_root: path.resolve(__dirname, "../hass_frontend"), diff --git a/build-scripts/rspack.cjs b/build-scripts/rspack.cjs index 02bff46372..0925ecfa0f 100644 --- a/build-scripts/rspack.cjs +++ b/build-scripts/rspack.cjs @@ -161,7 +161,7 @@ const createRspackConfig = ({ }), new rspack.NormalModuleReplacementPlugin( new RegExp(bundle.emptyPackages({ isHassioBuild }).join("|")), - path.resolve(paths.polymer_dir, "src/util/empty.js") + path.resolve(paths.root_dir, "src/util/empty.js") ), !isProdBuild && new LogStartCompilePlugin(), isProdBuild && diff --git a/eslint.config.mjs b/eslint.config.mjs index 6907fdecbe..f4d7223f1c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -42,7 +42,6 @@ export default tseslint.config( __VERSION__: false, __STATIC_PATH__: false, __SUPERVISOR__: false, - Polymer: true, }, parser: tseslint.parser, diff --git a/hassio/src/entrypoint.ts b/hassio/src/entrypoint.ts index 4f4c1c9b0a..9ba0a12b4d 100644 --- a/hassio/src/entrypoint.ts +++ b/hassio/src/entrypoint.ts @@ -1,9 +1,6 @@ import "./hassio-main"; import("../../src/resources/ha-style"); -import("@polymer/polymer/lib/utils/settings").then( - ({ setCancelSyntheticClickEvents }) => setCancelSyntheticClickEvents(false) -); const styleEl = document.createElement("style"); styleEl.textContent = ` diff --git a/package.json b/package.json index 9226c29999..83cf6a956d 100644 --- a/package.json +++ b/package.json @@ -84,9 +84,6 @@ "@material/web": "2.3.0", "@mdi/js": "7.4.47", "@mdi/svg": "7.4.47", - "@polymer/paper-item": "3.0.1", - "@polymer/paper-listbox": "3.0.1", - "@polymer/polymer": "3.5.2", "@replit/codemirror-indentation-markers": "6.5.3", "@shoelace-style/shoelace": "2.20.1", "@thomasloven/round-slider": "0.6.0", @@ -231,9 +228,7 @@ "webpackbar": "7.0.0", "workbox-build": "patch:workbox-build@npm%3A7.1.1#~/.yarn/patches/workbox-build-npm-7.1.1-a854f3faae.patch" }, - "_comment": "Polymer 3.2 contained a bug, fixed in https://github.com/Polymer/polymer/pull/5569, add as patch", "resolutions": { - "@polymer/polymer": "patch:@polymer/polymer@3.5.2#./.yarn/patches/@polymer/polymer/pr-5569.patch", "@material/mwc-button@^0.25.3": "^0.27.0", "lit": "2.8.0", "lit-html": "2.8.0", diff --git a/src/common/dom/apply_themes_on_element.ts b/src/common/dom/apply_themes_on_element.ts index 0fc7061833..841917af68 100644 --- a/src/common/dom/apply_themes_on_element.ts +++ b/src/common/dom/apply_themes_on_element.ts @@ -134,10 +134,7 @@ export const applyThemesOnElement = ( element.__themes = { cacheKey, keys: newTheme?.keys }; // Set and/or reset styles - if (element.updateStyles) { - // Use updateStyles() method of Polymer elements - element.updateStyles(styles); - } else if (window.ShadyCSS) { + if (window.ShadyCSS) { // Use ShadyCSS if available window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ element, styles); } else { diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 680bd37d7f..4c4a75c7d0 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -17,15 +17,16 @@ import { mdiTooltipAccount, mdiViewDashboard, } from "@mdi/js"; -import "@polymer/paper-item/paper-icon-item"; -import type { PaperIconItemElement } from "@polymer/paper-item/paper-icon-item"; -import "@polymer/paper-item/paper-item"; -import "@polymer/paper-listbox/paper-listbox"; import type { UnsubscribeFunc } from "home-assistant-js-websocket"; import type { CSSResult, CSSResultGroup, PropertyValues } from "lit"; import { LitElement, css, html, nothing } from "lit"; -import { customElement, eventOptions, property, state } from "lit/decorators"; -import { classMap } from "lit/directives/class-map"; +import { + customElement, + eventOptions, + property, + state, + query, +} from "lit/decorators"; import memoizeOne from "memoize-one"; import { storage } from "../common/decorators/storage"; import { fireEvent } from "../common/dom/fire_event"; @@ -48,7 +49,9 @@ import "./ha-menu-button"; import "./ha-sortable"; import "./ha-svg-icon"; import "./user/ha-user-badge"; -import { preventDefault } from "../common/dom/prevent_default"; +import "./ha-md-list"; +import "./ha-md-list-item"; +import type { HaMdListItem } from "./ha-md-list-item"; const SHOW_AFTER_SPACER = ["config", "developer-tools"]; @@ -221,6 +224,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { }) private _hiddenPanels: string[] = []; + @query(".tooltip") private _tooltip!: HTMLDivElement; + public hassSubscribe(): UnsubscribeFunc[] { return this.hass.user?.is_admin ? [ @@ -238,13 +243,18 @@ class HaSidebar extends SubscribeMixin(LitElement) { return nothing; } + // Show the supervisor as being part of configuration + const selectedPanel = this.route.path?.startsWith("/hassio/") + ? "config" + : this.hass.panelUrl; + // prettier-ignore return html` ${this._renderHeader()} - ${this._renderAllPanels()} + ${this._renderAllPanels(selectedPanel)} ${this._renderDivider()} ${this._renderNotifications()} - ${this._renderUserItem()} + ${this._renderUserItem(selectedPanel)}
`; @@ -314,9 +324,11 @@ class HaSidebar extends SubscribeMixin(LitElement) { return; } + const oldHass = changedProps.get("hass") as HomeAssistant | undefined; + if ( this.hass && - changedProps.get("hass")?.connected === false && + oldHass?.connected === false && this.hass.connected === true ) { this._subscribePersistentNotifications(); @@ -327,9 +339,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { if (!SUPPORT_SCROLL_IF_NEEDED) { return; } - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; - if (!oldHass || oldHass.panelUrl !== this.hass.panelUrl) { - const selectedEl = this.shadowRoot!.querySelector(".iron-selected"); + if (oldHass?.panelUrl !== this.hass.panelUrl) { + const selectedEl = this.shadowRoot!.querySelector(".selected"); if (selectedEl) { // @ts-ignore selectedEl.scrollIntoViewIfNeeded(); @@ -381,7 +392,7 @@ class HaSidebar extends SubscribeMixin(LitElement) { `; } - private _renderAllPanels() { + private _renderAllPanels(selectedPanel: string) { const [beforeSpacer, afterSpacer] = computePanels( this.hass.panels, this.hass.defaultPanel, @@ -390,34 +401,26 @@ class HaSidebar extends SubscribeMixin(LitElement) { this.hass.locale ); - // Show the supervisor as being part of configuration - const selectedPanel = this.route.path?.startsWith("/hassio/") - ? "config" - : this.hass.panelUrl; - // prettier-ignore return html` -