Compare commits

..

2 Commits

Author SHA1 Message Date
Joakim Sørensen
d60639f99d Update .devcontainer.json 2023-01-29 10:14:40 +01:00
ludeeus
693b621dd5 Restructure devcontainer 2023-01-29 09:12:41 +00:00
575 changed files with 8724 additions and 13343 deletions

View File

@@ -1,13 +1,20 @@
{
"name": "Home Assistant Frontend",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",
"appPort": "8124:8123",
"postCreateCommand": "script/bootstrap",
"containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}",
"DEVCONTAINER": "true"
},
"remoteUser": "vscode",
"remoteEnv": {
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/node_modules/.bin:/home/vscode/.local/bin"
},
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "16"
}
},
"customizations": {
"vscode": {

View File

@@ -1,13 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/python-3/.devcontainer/base.Dockerfile
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10
ENV \
DEBIAN_FRONTEND=noninteractive \
DEVCONTAINER=true \
PATH=$PATH:./node_modules/.bin
# Install nvm
COPY .nvmrc /tmp/.nvmrc
RUN \
su vscode -c \
"source /usr/local/share/nvm/nvm.sh && nvm install $(cat /tmp/.nvmrc) 2>&1"

View File

@@ -5,7 +5,6 @@
"plugin:@typescript-eslint/recommended",
"plugin:wc/recommended",
"plugin:lit/all",
"plugin:lit-a11y/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
@@ -66,10 +65,7 @@
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"js": "never"
}
{ "ts": "never", "js": "never" }
],
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
"object-curly-newline": "off",
@@ -116,14 +112,7 @@
],
"unused-imports/no-unused-imports": "error",
"lit/attribute-value-entities": "off",
"lit/no-template-map": "off",
"lit/no-native-attributes": "warn",
"lit/no-this-assign-in-render": "warn",
"lit-a11y/click-events-have-key-events": ["off"],
"lit-a11y/no-autofocus": "off",
"lit-a11y/alt-text": "warn",
"lit-a11y/anchor-is-valid": "warn",
"lit-a11y/role-has-required-aria-attrs": "warn"
"lit/no-template-map": "off"
},
"plugins": ["disable", "unused-imports"],
"processor": "disable/disable"

View File

@@ -6,3 +6,13 @@ updates:
interval: weekly
time: "06:00"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
time: "06:00"
open-pull-requests-limit: 5
ignore:
# Ignore rollup and plugins until everything else is updated
- dependency-name: "*rollup*"
- dependency-name: "@rollup/*"

View File

@@ -33,7 +33,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Cast
run: ./node_modules/.bin/gulp build-cast
@@ -69,7 +71,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Cast
run: ./node_modules/.bin/gulp build-cast
@@ -83,4 +87,4 @@ jobs:
args: deploy --dir=cast/dist --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_CAST_SITE_ID }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_CAST_SITE_ID }}

View File

@@ -15,13 +15,8 @@ env:
NODE_OPTIONS: --max_old_space_size=6144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint and check format
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
@@ -32,19 +27,20 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
- name: Check for duplicate dependencies
run: yarn dedupe --check
run: yarn install
env:
CI: true
- name: Build resources
run: ./node_modules/.bin/gulp gen-icons-json build-translations build-locale-data gather-gallery-pages
- name: Run eslint
run: yarn run lint:eslint --quiet
run: yarn run lint:eslint
- name: Run tsc
run: yarn run lint:types
- name: Run prettier
run: yarn run lint:prettier
- name: Check for duplicate dependencies
run: yarn dedupe --check
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out files from GitHub
@@ -55,15 +51,16 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build resources
run: ./node_modules/.bin/gulp build-translations build-locale-data
- name: Run Tests
run: yarn run test
build:
name: Build frontend
needs: [lint, test]
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Check out files from GitHub
uses: actions/checkout@v3.3.0
@@ -73,15 +70,16 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Application
run: ./node_modules/.bin/gulp build-app
env:
IS_TEST: "true"
supervisor:
name: Build supervisor
needs: [lint, test]
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Check out files from GitHub
uses: actions/checkout@v3.3.0
@@ -91,7 +89,9 @@ jobs:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Application
run: ./node_modules/.bin/gulp build-hassio
env:

View File

@@ -34,7 +34,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Demo
run: ./node_modules/.bin/gulp build-demo
@@ -70,7 +72,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Demo
run: ./node_modules/.bin/gulp build-demo
@@ -84,4 +88,4 @@ jobs:
args: deploy --dir=demo/dist --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_SITE_ID }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEMO_SITE_ID }}

View File

@@ -26,7 +26,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Gallery
run: ./node_modules/.bin/gulp build-gallery

View File

@@ -31,7 +31,9 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn install --immutable
run: yarn install
env:
CI: true
- name: Build Gallery
run: ./node_modules/.bin/gulp build-gallery

823
.yarn/releases/yarn-3.3.1.cjs vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,3 @@
defaultSemverRangePrefix: ""
nodeLinker: node-modules
plugins:
@@ -8,4 +6,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-3.4.1.cjs
yarnPath: .yarn/releases/yarn-3.3.1.cjs

View File

@@ -53,25 +53,13 @@ module.exports.definedVars = ({ isProdBuild, latestBuild, defineOverlay }) => ({
...defineOverlay,
});
const htmlMinifierOptions = {
caseSensitive: true,
collapseWhitespace: true,
conservativeCollapse: true,
decodeEntities: true,
removeComments: true,
removeRedundantAttributes: true,
minifyCSS: {
level: 0,
},
};
module.exports.terserOptions = (latestBuild) => ({
safari10: !latestBuild,
ecma: latestBuild ? undefined : 5,
output: { comments: false },
});
module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
module.exports.babelOptions = ({ latestBuild }) => ({
babelrc: false,
compact: false,
presets: [
@@ -79,7 +67,7 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
"@babel/preset-env",
{
useBuiltIns: "entry",
corejs: { version: "3.29", proposals: true },
corejs: "3.15",
bugfixes: true,
},
],
@@ -105,30 +93,12 @@ module.exports.babelOptions = ({ latestBuild, isProdBuild }) => ({
"@babel/plugin-syntax-import-meta",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-top-level-await",
// Support various proposals
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
["@babel/plugin-proposal-private-methods", { loose: true }],
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
["@babel/plugin-proposal-class-properties", { loose: true }],
// Minify template literals for production
isProdBuild && [
"template-html-minifier",
{
modules: {
lit: [
"html",
{ name: "svg", encapsulation: "svg" },
{ name: "css", encapsulation: "style" },
],
"@polymer/polymer/lib/utils/html-tag": ["html"],
},
strictCSS: true,
htmlMinifier: htmlMinifierOptions,
failOnError: true, // we can turn this off in case of false positives
},
],
].filter(Boolean),
exclude: [
// \\ for Windows, / for Mac OS and Linux

View File

@@ -43,14 +43,7 @@ const createRollupConfig = ({
preserveEntrySignatures: false,
plugins: [
ignore({
files: bundle
.emptyPackages({ latestBuild })
// TEMP HACK: Makes Rollup build work again
.concat(
require.resolve(
"@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min"
)
),
files: bundle.emptyPackages({ latestBuild }),
}),
resolve({
extensions,
@@ -61,7 +54,7 @@ const createRollupConfig = ({
commonjs(),
json(),
babel({
...bundle.babelOptions({ latestBuild, isProdBuild }),
...bundle.babelOptions({ latestBuild }),
extensions,
babelHelpers: isWDS ? "inline" : "bundled",
}),

View File

@@ -51,7 +51,7 @@ const createWebpackConfig = ({
use: {
loader: "babel-loader",
options: {
...bundle.babelOptions({ latestBuild, isProdBuild }),
...bundle.babelOptions({ latestBuild }),
cacheDirectory: !isProdBuild,
cacheCompression: false,
},

View File

@@ -181,7 +181,7 @@ class HcCast extends LitElement {
private async _handlePickView(ev: Event) {
const path = (ev.currentTarget as any).getAttribute("data-path");
await ensureConnectedCastSession(this.castManager!, this.auth!);
castSendShowLovelaceView(this.castManager, this.auth.data.hassUrl, path);
castSendShowLovelaceView(this.castManager, path, this.auth.data.hassUrl);
}
private async _handleLogout() {

View File

@@ -1,4 +1,4 @@
import { html, nothing } from "lit";
import { html, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { mockHistory } from "../../../../demo/src/stubs/history";
import { LovelaceConfig } from "../../../../src/data/lovelace";
@@ -18,9 +18,9 @@ class HcDemo extends HassElement {
@state() private _lovelaceConfig?: LovelaceConfig;
protected render() {
protected render(): TemplateResult {
if (!this._lovelaceConfig) {
return nothing;
return html``;
}
return html`
<hc-lovelace

View File

@@ -252,22 +252,6 @@ export class HcMain extends HassElement {
msg.urlPath = null;
}
this._lovelacePath = msg.viewPath;
if (msg.urlPath === "energy") {
this._lovelaceConfig = {
views: [
{
strategy: {
type: "energy",
options: { show_date_selection: true },
},
},
],
};
this._urlPath = "energy";
this._lovelacePath = 0;
this._sendStatus();
return;
}
if (!this._unsubLovelace || this._urlPath !== msg.urlPath) {
this._urlPath = msg.urlPath;
this._lovelaceConfig = undefined;

View File

@@ -6,9 +6,6 @@ set -e
cd "$(dirname "$0")/.."
export STATS=1
statsfile="compilation-stats-demo.json"
./node_modules/.bin/webpack-cli --profile --node-env=production --json=$statsfile
npx webpack-bundle-analyzer $statsfile dist/frontend_latest
rm -f $statsfile
STATS=1 NODE_ENV=production ../node_modules/.bin/webpack --profile --json > compilation-stats.json
npx webpack-bundle-analyzer compilation-stats.json dist/frontend_latest
rm compilation-stats.json

View File

@@ -1,5 +1,5 @@
import { mdiTelevision } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, state } from "lit/decorators";
import { CastManager } from "../../../src/cast/cast_manager";
import { castSendShowDemo } from "../../../src/cast/receiver_messages";
@@ -20,12 +20,12 @@ class CastDemoRow extends LitElement implements LovelaceRow {
// No config possible.
}
protected render() {
protected render(): TemplateResult {
if (
!this._castManager ||
this._castManager.castState === "NO_DEVICES_AVAILABLE"
) {
return nothing;
return html``;
}
return html`
<ha-svg-icon .path=${mdiTelevision}></ha-svg-icon>

View File

@@ -1,6 +1,6 @@
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { property, state } from "lit/decorators";
import { until } from "lit/directives/until";
import "../../../src/components/ha-card";
import "../../../src/components/ha-circular-progress";
@@ -14,7 +14,6 @@ import {
setDemoConfig,
} from "../configs/demo-configs";
@customElement("ha-demo-card")
export class HADemoCard extends LitElement implements LovelaceCard {
@property({ attribute: false }) public lovelace?: Lovelace;
@@ -30,9 +29,9 @@ export class HADemoCard extends LitElement implements LovelaceCard {
public setConfig(_config: LovelaceCardConfig) {}
protected render() {
protected render(): TemplateResult {
if (this._hidden) {
return nothing;
return html``;
}
return html`
<ha-card>
@@ -155,3 +154,5 @@ declare global {
"ha-demo-card": HADemoCard;
}
}
customElements.define("ha-demo-card", HADemoCard);

View File

@@ -1,6 +1,4 @@
// Compat needs to be first import
import "../../src/resources/compatibility";
import { customElement } from "lit/decorators";
import { isNavigationClick } from "../../src/common/dom/is-navigation-click";
import { navigate } from "../../src/common/navigate";
import {
@@ -8,6 +6,7 @@ import {
provideHass,
} from "../../src/fake_data/provide_hass";
import { HomeAssistantAppEl } from "../../src/layouts/home-assistant";
import "../../src/resources/compatibility";
import { HomeAssistant } from "../../src/types";
import { selectedDemoConfig } from "./configs/demo-configs";
import { mockAuth } from "./stubs/auth";
@@ -27,8 +26,7 @@ import { mockSystemLog } from "./stubs/system_log";
import { mockTemplate } from "./stubs/template";
import { mockTranslations } from "./stubs/translations";
@customElement("ha-demo")
export class HaDemo extends HomeAssistantAppEl {
class HaDemo extends HomeAssistantAppEl {
protected async _initializeHass() {
const initial: Partial<MockHomeAssistant> = {
panelUrl: (this as any)._panelUrl,
@@ -73,7 +71,6 @@ export class HaDemo extends HomeAssistantAppEl {
entity_category: null,
has_entity_name: false,
unique_id: "co2_intensity",
options: null,
},
{
config_entry_id: "co2signal",
@@ -89,7 +86,6 @@ export class HaDemo extends HomeAssistantAppEl {
entity_category: null,
has_entity_name: false,
unique_id: "grid_fossil_fuel_percentage",
options: null,
},
]);
@@ -125,6 +121,8 @@ export class HaDemo extends HomeAssistantAppEl {
}
}
customElements.define("ha-demo", HaDemo);
declare global {
interface HTMLElementTagNameMap {
"ha-demo": HaDemo;

View File

@@ -66,7 +66,7 @@ const incrementalUnits = ["clients", "queries", "ads"];
export const mockHistory = (mockHass: MockHomeAssistant) => {
mockHass.mockAPI(
/history\/period\/.+/,
new RegExp("history/period/.+"),
(hass, _method, path, _parameters) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(",");

View File

@@ -15,7 +15,6 @@ import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
const generateMeanStatistics = (
start: Date,
end: Date,
// eslint-disable-next-line @typescript-eslint/default-param-last
period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number
@@ -52,7 +51,6 @@ const generateMeanStatistics = (
const generateSumStatistics = (
start: Date,
end: Date,
// eslint-disable-next-line @typescript-eslint/default-param-last
period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number
@@ -88,7 +86,6 @@ const generateSumStatistics = (
const generateCurvedStatistics = (
start: Date,
end: Date,
// eslint-disable-next-line @typescript-eslint/default-param-last
_period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number,

View File

@@ -1,4 +1,4 @@
import { css, html, nothing } from "lit";
import { html, css } from "lit";
import { customElement, property } from "lit/decorators";
import { until } from "lit/directives/until";
import { HaMarkdown } from "../../../src/components/ha-markdown";
@@ -10,7 +10,7 @@ class PageDescription extends HaMarkdown {
render() {
if (!PAGES[this.page].description) {
return nothing;
return html``;
}
return html`

View File

@@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { css, html, LitElement, nothing } from "lit";
import { html, css, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@@ -127,16 +127,16 @@ export class DemoAutomationDescribeAction extends LitElement {
@state() _action = initialAction;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`
<ha-card header="Actions">
<div class="action">
<span>
${this._action
? describeAction(this.hass, [], this._action)
? describeAction(this.hass, this._action)
: "<invalid YAML>"}
</span>
<ha-yaml-editor
@@ -149,7 +149,7 @@ export class DemoAutomationDescribeAction extends LitElement {
${ACTIONS.map(
(conf) => html`
<div class="action">
<span>${describeAction(this.hass, [], conf as any)}</span>
<span>${describeAction(this.hass, conf as any)}</span>
<pre>${dump(conf)}</pre>
</div>
`

View File

@@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { css, html, LitElement, nothing } from "lit";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@@ -53,9 +53,9 @@ export class DemoAutomationDescribeCondition extends LitElement {
@state() _condition = initialCondition;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`

View File

@@ -1,5 +1,5 @@
import { dump } from "js-yaml";
import { css, html, LitElement, nothing } from "lit";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-yaml-editor";
@@ -64,9 +64,9 @@ export class DemoAutomationDescribeTrigger extends LitElement {
@state() _trigger = initialTrigger;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`

View File

@@ -1,6 +1,5 @@
/* eslint-disable lit/no-template-arrow */
import { css, html, LitElement, nothing } from "lit";
import { html, css, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/trace/hat-script-graph";
@@ -30,9 +29,9 @@ const traces: DemoTrace[] = [
export class DemoAutomationTraceTimeline extends LitElement {
@property({ attribute: false }) hass?: HomeAssistant;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`
${traces.map(

View File

@@ -1,15 +1,14 @@
/* eslint-disable lit/no-template-arrow */
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { html, css, LitElement, TemplateResult } from "lit";
import "../../../../src/components/ha-card";
import "../../../../src/components/trace/hat-script-graph";
import "../../../../src/components/trace/hat-trace-timeline";
import { customElement, property, state } from "lit/decorators";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../../src/types";
import { DemoTrace } from "../../data/traces/types";
import { basicTrace } from "../../data/traces/basic_trace";
import { motionLightTrace } from "../../data/traces/motion-light-trace";
import { DemoTrace } from "../../data/traces/types";
const traces: DemoTrace[] = [basicTrace, motionLightTrace];
@@ -19,9 +18,9 @@ export class DemoAutomationTrace extends LitElement {
@state() private _selected = {};
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`
${traces.map(

View File

@@ -156,6 +156,18 @@ The `title ` option should not be used without a description.
*Documentation coming soon*
**Right to left**
<ha-alert alert-type="success" rtl>
This is an info alert — check it out!
</ha-alert>
```html
<ha-alert alert-type="success" rtl>
This is an info alert — check it out!
</ha-alert>
```
### API
**Properties/Attributes**

View File

@@ -0,0 +1,3 @@
---
title: Bar Slider
---

View File

@@ -2,7 +2,7 @@ import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { repeat } from "lit/directives/repeat";
import "../../../../src/components/ha-control-slider";
import "../../../../src/components/ha-bar-slider";
import "../../../../src/components/ha-card";
const sliders: {
@@ -46,7 +46,7 @@ const sliders: {
},
];
@customElement("demo-components-ha-control-slider")
@customElement("demo-components-ha-bar-slider")
export class DemoHaBarSlider extends LitElement {
@state() private value = 50;
@@ -86,7 +86,7 @@ export class DemoHaBarSlider extends LitElement {
<div class="card-content">
<label id=${id}>${label}</label>
<pre>Config: ${JSON.stringify(config)}</pre>
<ha-control-slider
<ha-bar-slider
.value=${this.value}
.mode=${config.mode}
class=${ifDefined(config.class)}
@@ -94,7 +94,7 @@ export class DemoHaBarSlider extends LitElement {
@slider-moved=${this.handleSliderMoved}
aria-labelledby=${id}
>
</ha-control-slider>
</ha-bar-slider>
</div>
</ha-card>
`;
@@ -106,7 +106,7 @@ export class DemoHaBarSlider extends LitElement {
${repeat(sliders, (slider) => {
const { id, label, ...config } = slider;
return html`
<ha-control-slider
<ha-bar-slider
.value=${this.value}
.mode=${config.mode}
vertical
@@ -115,7 +115,7 @@ export class DemoHaBarSlider extends LitElement {
@slider-moved=${this.handleSliderMoved}
aria-label=${label}
>
</ha-control-slider>
</ha-bar-slider>
`;
})}
</div>
@@ -141,11 +141,11 @@ export class DemoHaBarSlider extends LitElement {
font-weight: 600;
}
.custom {
--control-slider-color: #ffcf4c;
--control-slider-background: #ffcf4c;
--control-slider-background-opacity: 0.2;
--control-slider-thickness: 100px;
--control-slider-border-radius: 24px;
--slider-bar-color: #ffcf4c;
--slider-bar-background: #ffcf4c;
--slider-bar-background-opacity: 0.2;
--slider-bar-thickness: 100px;
--slider-bar-border-radius: 24px;
}
.vertical-sliders {
height: 300px;
@@ -165,6 +165,6 @@ export class DemoHaBarSlider extends LitElement {
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-slider": DemoHaBarSlider;
"demo-components-ha-bar-slider": DemoHaBarSlider;
}
}

View File

@@ -0,0 +1,3 @@
---
title: Bar Switch
---

View File

@@ -8,7 +8,7 @@ import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { repeat } from "lit/directives/repeat";
import "../../../../src/components/ha-control-switch";
import "../../../../src/components/ha-bar-switch";
import "../../../../src/components/ha-card";
const switches: {
@@ -39,8 +39,8 @@ const switches: {
},
];
@customElement("demo-components-ha-control-switch")
export class DemoHaControlSwitch extends LitElement {
@customElement("demo-components-ha-bar-switch")
export class DemoHaBarSwitch extends LitElement {
@state() private checked = false;
handleValueChanged(e: any) {
@@ -56,7 +56,7 @@ export class DemoHaControlSwitch extends LitElement {
<div class="card-content">
<label id=${id}>${label}</label>
<pre>Config: ${JSON.stringify(config)}</pre>
<ha-control-switch
<ha-bar-switch
.checked=${this.checked}
class=${ifDefined(config.class)}
@change=${this.handleValueChanged}
@@ -66,7 +66,7 @@ export class DemoHaControlSwitch extends LitElement {
disabled=${ifDefined(config.disabled)}
reversed=${ifDefined(config.reversed)}
>
</ha-control-switch>
</ha-bar-switch>
</div>
</ha-card>
`;
@@ -78,7 +78,7 @@ export class DemoHaControlSwitch extends LitElement {
${repeat(switches, (sw) => {
const { id, label, ...config } = sw;
return html`
<ha-control-switch
<ha-bar-switch
.checked=${this.checked}
vertical
class=${ifDefined(config.class)}
@@ -89,7 +89,7 @@ export class DemoHaControlSwitch extends LitElement {
disabled=${ifDefined(config.disabled)}
reversed=${ifDefined(config.reversed)}
>
</ha-control-switch>
</ha-bar-switch>
`;
})}
</div>
@@ -115,11 +115,11 @@ export class DemoHaControlSwitch extends LitElement {
font-weight: 600;
}
.custom {
--control-switch-on-color: var(--green-color);
--control-switch-off-color: var(--red-color);
--control-switch-thickness: 100px;
--control-switch-border-radius: 24px;
--control-switch-padding: 6px;
--switch-bar-on-color: var(--green-color);
--switch-bar-off-color: var(--red-color);
--switch-bar-thickness: 100px;
--switch-bar-border-radius: 24px;
--switch-bar-padding: 6px;
--mdc-icon-size: 24px;
}
.vertical-switches {
@@ -140,6 +140,6 @@ export class DemoHaControlSwitch extends LitElement {
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-switch": DemoHaControlSwitch;
"demo-components-ha-bar-switch": DemoHaBarSwitch;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Control Button
---

View File

@@ -1,192 +0,0 @@
import {
mdiFanSpeed1,
mdiFanSpeed2,
mdiFanSpeed3,
mdiLightbulb,
} from "@mdi/js";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import { repeat } from "lit/directives/repeat";
import "../../../../src/components/ha-control-button";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-svg-icon";
import "../../../../src/components/ha-control-button-group";
type Button = {
label: string;
icon?: string;
class?: string;
disabled?: boolean;
};
const buttons: Button[] = [
{
label: "Button",
},
{
label: "Button and custom style",
class: "custom",
},
{
label: "Disabled Button",
disabled: true,
},
];
type ButtonGroup = {
vertical?: boolean;
class?: string;
};
const buttonGroups: ButtonGroup[] = [
{},
{
class: "custom-group",
},
];
@customElement("demo-components-ha-control-button")
export class DemoHaBarButton extends LitElement {
protected render(): TemplateResult {
return html`
<ha-card>
${repeat(
buttons,
(btn) => html`
<div class="card-content">
<pre>Config: ${JSON.stringify(btn)}</pre>
<ha-control-button
class=${ifDefined(btn.class)}
label=${ifDefined(btn.label)}
disabled=${ifDefined(btn.disabled)}
>
<ha-svg-icon .path=${btn.icon || mdiLightbulb}></ha-svg-icon>
</ha-control-button>
</div>
`
)}
</ha-card>
<ha-card>
${repeat(
buttonGroups,
(group) => html`
<div class="card-content">
<pre>Config: ${JSON.stringify(group)}</pre>
<ha-control-button-group class=${ifDefined(group.class)}>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed1}
label="Speed 1"
></ha-svg-icon>
</ha-control-button>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed2}
label="Speed 2"
></ha-svg-icon>
</ha-control-button>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed3}
label="Speed 3"
></ha-svg-icon>
</ha-control-button>
</ha-control-button-group>
</div>
`
)}
</ha-card>
<ha-card>
<div class="card-content">
<p class="title"><b>Vertical</b></p>
<div class="vertical-buttons">
${repeat(
buttonGroups,
(group) => html`
<ha-control-button-group
vertical
class=${ifDefined(group.class)}
>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed1}
label="Speed 1"
></ha-svg-icon>
</ha-control-button>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed2}
label="Speed 2"
></ha-svg-icon>
</ha-control-button>
<ha-control-button>
<ha-svg-icon
.path=${mdiFanSpeed3}
label="Speed 3"
></ha-svg-icon>
</ha-control-button>
</ha-control-button-group>
`
)}
</div>
</div>
</ha-card>
`;
}
static get styles() {
return css`
ha-card {
max-width: 600px;
margin: 24px auto;
}
pre {
margin-top: 0;
margin-bottom: 8px;
}
p {
margin: 0;
}
label {
font-weight: 600;
}
.custom {
--control-button-icon-color: var(--primary-color);
--control-button-background-color: var(--primary-color);
--control-button-background-opacity: 0.2;
--control-button-border-radius: 18px;
height: 100px;
width: 100px;
}
.custom-group {
--control-button-group-thickness: 100px;
--control-button-group-border-radius: 18px;
--control-button-group-spacing: 20px;
}
.custom-group ha-control-button {
--control-button-border-radius: 18px;
--mdc-icon-size: 32px;
}
.vertical-buttons {
height: 300px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
p.title {
margin-bottom: 12px;
}
.vertical-switches > *:not(:last-child) {
margin-right: 4px;
}
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-components-ha-control-button": DemoHaBarButton;
}
}

View File

@@ -1,3 +0,0 @@
---
title: Control Slider
---

View File

@@ -1,3 +0,0 @@
---
title: Control Switch
---

View File

@@ -3,7 +3,6 @@ import { customElement } from "lit/decorators";
import "../../../../src/components/ha-tip";
import "../../../../src/components/ha-card";
import { applyThemesOnElement } from "../../../../src/common/dom/apply_themes_on_element";
import { provideHass } from "../../../../src/fake_data/provide_hass";
const tips: (string | TemplateResult)[] = [
"Test tip",
@@ -19,11 +18,7 @@ export class DemoHaTip extends LitElement {
<div class=${mode}>
<ha-card header="ha-tip ${mode} demo">
<div class="card-content">
${tips.map(
(tip) => html`<ha-tip .hass=${provideHass(this)}
>${tip}</ha-tip
>`
)}
${tips.map((tip) => html`<ha-tip>${tip}</ha-tip>`)}
</div>
</ha-card>
</div>

View File

@@ -1,3 +0,0 @@
---
title: Tile Card
---

View File

@@ -1,173 +0,0 @@
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, query } from "lit/decorators";
import { CoverEntityFeature } from "../../../../src/data/cover";
import { LightColorMode } from "../../../../src/data/light";
import { VacuumEntityFeature } from "../../../../src/data/vacuum";
import { getEntity } from "../../../../src/fake_data/entity";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import "../../components/demo-cards";
const ENTITIES = [
getEntity("switch", "tv_outlet", "on", {
friendly_name: "TV outlet",
device_class: "outlet",
}),
getEntity("light", "bed_light", "on", {
friendly_name: "Bed Light",
supported_color_modes: [LightColorMode.HS],
}),
getEntity("light", "unavailable", "unavailable", {
friendly_name: "Unavailable entity",
}),
getEntity("climate", "thermostat", "heat", {
current_temperature: 73,
min_temp: 45,
max_temp: 95,
temperature: 80,
hvac_modes: ["heat", "cool", "auto", "off"],
friendly_name: "Thermostat",
hvac_action: "heating",
}),
getEntity("person", "paulus", "home", {
friendly_name: "Paulus",
}),
getEntity("vacuum", "first_floor_vacuum", "docked", {
friendly_name: "First floor vacuum",
supported_features:
VacuumEntityFeature.START +
VacuumEntityFeature.STOP +
VacuumEntityFeature.RETURN_HOME,
}),
getEntity("cover", "kitchen_shutter", "open", {
friendly_name: "Kitchen shutter",
device_class: "shutter",
supported_features:
CoverEntityFeature.CLOSE +
CoverEntityFeature.OPEN +
CoverEntityFeature.STOP,
}),
getEntity("cover", "pergola_roof", "open", {
friendly_name: "Pergola Roof",
supported_features:
CoverEntityFeature.CLOSE_TILT +
CoverEntityFeature.OPEN_TILT +
CoverEntityFeature.STOP_TILT,
}),
];
const CONFIGS = [
{
heading: "Basic example",
config: `
- type: tile
entity: switch.tv_outlet
`,
},
{
heading: "Vertical example",
config: `
- type: tile
entity: switch.tv_outlet
vertical: true
`,
},
{
heading: "Custom color",
config: `
- type: tile
entity: switch.tv_outlet
color: pink
`,
},
{
heading: "Unknown entity",
config: `
- type: tile
entity: light.unknown
`,
},
{
heading: "Unavailable entity",
config: `
- type: tile
entity: light.unavailable
`,
},
{
heading: "Climate",
config: `
- type: tile
entity: climate.thermostat
`,
},
{
heading: "Person",
config: `
- type: tile
entity: person.paulus
`,
},
{
heading: "Light brightness feature",
config: `
- type: tile
entity: light.bed_light
features:
- type: "light-brightness"
`,
},
{
heading: "Vacuum commands feature",
config: `
- type: tile
entity: vacuum.first_floor_vacuum
features:
- type: "vacuum-commands"
commands:
- start_pause
- stop
- return_home
`,
},
{
heading: "Cover open close feature",
config: `
- type: tile
entity: cover.kitchen_shutter
features:
- type: "cover-open-close"
`,
},
{
heading: "Cover tilt feature",
config: `
- type: tile
entity: cover.pergola_roof
features:
- type: "cover-tilt"
`,
},
];
@customElement("demo-lovelace-tile-card")
class DemoTile extends LitElement {
@query("#demos") private _demoRoot!: HTMLElement;
protected render(): TemplateResult {
return html`<demo-cards id="demos" .configs=${CONFIGS}></demo-cards>`;
}
protected firstUpdated(changedProperties: PropertyValues) {
super.firstUpdated(changedProperties);
const hass = provideHass(this._demoRoot);
hass.updateTranslations(null, "en");
hass.updateTranslations("lovelace", "en");
hass.addEntities(ENTITIES);
}
}
declare global {
interface HTMLElementTagNameMap {
"demo-lovelace-tile-card": DemoTile;
}
}

View File

@@ -2,7 +2,7 @@ import {
HassEntity,
HassEntityAttributeBase,
} from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { computeDomain } from "../../../../src/common/entity/compute_domain";
@@ -387,9 +387,9 @@ export class DemoEntityState extends LitElement {
hass.updateTranslations("config", "en");
}
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`

View File

@@ -1,22 +1,22 @@
import { css, html, LitElement, nothing } from "lit";
import { html, css, LitElement, TemplateResult } from "lit";
import "../../../../src/components/ha-formfield";
import "../../../../src/components/ha-switch";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { customElement, property, state } from "lit/decorators";
import { IntegrationManifest } from "../../../../src/data/integration";
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
import { provideHass } from "../../../../src/fake_data/provide_hass";
import { HomeAssistant } from "../../../../src/types";
import "../../../../src/panels/config/integrations/ha-integration-card";
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
import "../../../../src/panels/config/integrations/ha-config-flow-card";
import type {
ConfigEntryExtended,
DataEntryFlowProgressExtended,
} from "../../../../src/panels/config/integrations/ha-config-integrations";
import "../../../../src/panels/config/integrations/ha-ignored-config-entry-card";
import "../../../../src/panels/config/integrations/ha-integration-card";
import { HomeAssistant } from "../../../../src/types";
import { DeviceRegistryEntry } from "../../../../src/data/device_registry";
import { EntityRegistryEntry } from "../../../../src/data/entity_registry";
const createConfigEntry = (
title: string,
@@ -197,7 +197,6 @@ const createEntityRegistryEntries = (
platform: "updater",
has_entity_name: false,
unique_id: "updater",
options: null,
},
];
@@ -231,9 +230,9 @@ export class DemoIntegrationCard extends LitElement {
@state() isCloud = false;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`
<div class="container">

View File

@@ -1,6 +1,6 @@
import { mdiArrowUpBoldCircle, mdiPuzzle } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { atLeastVersion } from "../../../src/common/config/version";
import { navigate } from "../../../src/common/navigate";
@@ -14,8 +14,7 @@ import "../components/hassio-card-content";
import { filterAndSort } from "../components/hassio-filter-addons";
import { hassioStyle } from "../resources/hassio-style";
@customElement("hassio-addon-repository")
export class HassioAddonRepositoryEl extends LitElement {
class HassioAddonRepositoryEl extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public supervisor!: Supervisor;
@@ -141,3 +140,5 @@ export class HassioAddonRepositoryEl extends LitElement {
];
}
}
customElements.define("hassio-addon-repository", HassioAddonRepositoryEl);

View File

@@ -6,11 +6,10 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { atLeastVersion } from "../../../src/common/config/version";
import { fireEvent } from "../../../src/common/dom/fire_event";
@@ -50,8 +49,7 @@ const sortRepos = (a: HassioAddonRepository, b: HassioAddonRepository) => {
return a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1;
};
@customElement("hassio-addon-store")
export class HassioAddonStore extends LitElement {
class HassioAddonStore extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public supervisor!: Supervisor;
@@ -74,8 +72,8 @@ export class HassioAddonStore extends LitElement {
}
}
protected render() {
let repos: (TemplateResult | typeof nothing)[] = [];
protected render(): TemplateResult {
let repos: TemplateResult[] = [];
if (this.supervisor.store.repositories) {
repos = this.addonRepositories(
@@ -174,7 +172,7 @@ export class HassioAddonStore extends LitElement {
.supervisor=${this.supervisor}
></hassio-addon-repository>
`
: nothing;
: html``;
})
);
@@ -252,3 +250,5 @@ export class HassioAddonStore extends LitElement {
`;
}
}
customElements.define("hassio-addon-store", HassioAddonStore);

View File

@@ -4,7 +4,7 @@ import {
html,
LitElement,
PropertyValues,
nothing,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@@ -47,9 +47,9 @@ class HassioAddonNetwork extends LitElement {
this._setNetworkConfig();
}
protected render() {
protected render(): TemplateResult {
if (!this._config) {
return nothing;
return html``;
}
const hasHiddenOptions = Object.keys(this._config).find(

View File

@@ -8,7 +8,7 @@ import {
html,
LitElement,
PropertyValues,
nothing,
TemplateResult,
} from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
@@ -160,9 +160,9 @@ export class HassioBackups extends LitElement {
}))
);
protected render() {
protected render(): TemplateResult {
if (!this.supervisor) {
return nothing;
return html``;
}
return html`
<hass-tabs-subpage-data-table

View File

@@ -1,13 +1,6 @@
import { mdiFolder, mdiHomeAssistant, mdiPuzzle } from "@mdi/js";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
import {
css,
CSSResultGroup,
html,
LitElement,
TemplateResult,
nothing,
} from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import { atLeastVersion } from "../../../src/common/config/version";
import { formatDate } from "../../../src/common/datetime/format_date";
@@ -18,9 +11,9 @@ import "../../../src/components/ha-formfield";
import "../../../src/components/ha-radio";
import type { HaRadio } from "../../../src/components/ha-radio";
import {
HassioBackupDetail,
HassioFullBackupCreateParams,
HassioPartialBackupCreateParams,
HassioBackupDetail,
} from "../../../src/data/hassio/backup";
import { Supervisor } from "../../../src/data/supervisor/supervisor";
import { PolymerChangedEvent } from "../../../src/polymer-types";
@@ -122,9 +115,9 @@ export class SupervisorBackupContent extends LitElement {
this.supervisor?.localize(`backup.${key}`) ||
this.localize!(`ui.panel.page-onboarding.restore.${key}`);
protected render() {
protected render(): TemplateResult {
if (!this.onboarding && !this.supervisor) {
return nothing;
return html``;
}
const foldersSection =
this.backupType === "partial" ? this._getSection("folders") : undefined;

View File

@@ -1,6 +1,6 @@
import "@material/mwc-button";
import { mdiHomeAssistant } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import "../../../src/components/buttons/ha-progress-button";
@@ -33,14 +33,14 @@ export class HassioUpdate extends LitElement {
).length
);
protected render() {
protected render(): TemplateResult {
if (!this.supervisor) {
return nothing;
return html``;
}
const updatesAvailable = this._pendingUpdates(this.supervisor);
if (!updatesAvailable) {
return nothing;
return html``;
}
return html`
@@ -80,9 +80,9 @@ export class HassioUpdate extends LitElement {
name: string,
key: string,
object: HassioHomeAssistantInfo | HassioSupervisorInfo | HassioHassOSInfo
) {
): TemplateResult {
if (!object.update_available) {
return nothing;
return html``;
}
return html`
<ha-card outlined>

View File

@@ -1,5 +1,5 @@
import { mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/ha-header-bar";
@@ -36,9 +36,9 @@ export class DialogHassioBackupUpload
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this._dialogParams) {
return nothing;
return html``;
}
return html`

View File

@@ -1,11 +1,9 @@
import { ActionDetail } from "@material/mwc-list";
import "@material/mwc-list/mwc-list-item";
import { mdiClose, mdiDotsVertical } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { atLeastVersion } from "../../../../src/common/config/version";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
import { slugify } from "../../../../src/common/string/slugify";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
@@ -13,11 +11,11 @@ import "../../../../src/components/ha-button-menu";
import "../../../../src/components/ha-header-bar";
import "../../../../src/components/ha-icon-button";
import { getSignedPath } from "../../../../src/data/auth";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
fetchHassioBackupInfo,
HassioBackupDetail,
} from "../../../../src/data/hassio/backup";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
showAlertDialog,
showConfirmationDialog,
@@ -29,6 +27,8 @@ import { fileDownload } from "../../../../src/util/file_download";
import "../../components/supervisor-backup-content";
import type { SupervisorBackupContent } from "../../components/supervisor-backup-content";
import { HassioBackupDialogParams } from "./show-dialog-hassio-backup";
import { atLeastVersion } from "../../../../src/common/config/version";
import { stopPropagation } from "../../../../src/common/dom/stop_propagation";
@customElement("dialog-hassio-backup")
class HassioBackupDialog
@@ -62,9 +62,9 @@ class HassioBackupDialog
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this._dialogParams || !this._backup) {
return nothing;
return html``;
}
return html`
<ha-dialog

View File

@@ -1,15 +1,15 @@
import "@material/mwc-button";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/buttons/ha-progress-button";
import "../../../../src/components/ha-alert";
import "../../../../src/components/buttons/ha-progress-button";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
createHassioFullBackup,
createHassioPartialBackup,
} from "../../../../src/data/hassio/backup";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import { showAlertDialog } from "../../../../src/dialogs/generic/show-dialog-box";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import { HomeAssistant } from "../../../../src/types";
@@ -42,9 +42,9 @@ class HassioCreateBackupDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this._dialogParams) {
return nothing;
return html``;
}
return html`
<ha-dialog

View File

@@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@@ -55,9 +55,9 @@ class HassioDatadiskDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this.dialogParams) {
return nothing;
return html``;
}
return html`
<ha-dialog

8
hassio/src/dialogs/hardware/dialog-hassio-hardware.ts Normal file → Executable file
View File

@@ -1,13 +1,13 @@
import { mdiClose } from "@mdi/js";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
import "../../../../src/components/search-input";
import { stringCompare } from "../../../../src/common/string/compare";
import "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-expansion-panel";
import "../../../../src/components/ha-icon-button";
import "../../../../src/components/search-input";
import { HassioHardwareInfo } from "../../../../src/data/hassio/hardware";
import { dump } from "../../../../src/resources/js-yaml-dump";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
@@ -53,9 +53,9 @@ class HassioHardwareDialog extends LitElement {
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this._dialogParams) {
return nothing;
return html``;
}
const devices = _filterDevices(

View File

@@ -1,4 +1,4 @@
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { createCloseHeading } from "../../../../src/components/ha-dialog";
import "../../../../src/components/ha-markdown";
@@ -27,9 +27,9 @@ class HassioMarkdownDialog extends LitElement {
this._opened = false;
}
protected render() {
protected render(): TemplateResult {
if (!this._opened) {
return nothing;
return html``;
}
return html`
<ha-dialog

View File

@@ -5,7 +5,7 @@ import "@material/mwc-tab";
import "@material/mwc-tab-bar";
import { mdiClose } from "@mdi/js";
import { PaperInputElement } from "@polymer/paper-input/paper-input";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { cache } from "lit/directives/cache";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@@ -17,6 +17,7 @@ import "../../../../src/components/ha-formfield";
import "../../../../src/components/ha-header-bar";
import "../../../../src/components/ha-icon-button";
import "../../../../src/components/ha-radio";
import "../../../../src/components/ha-related-items";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import {
AccessPoints,
@@ -83,9 +84,9 @@ export class DialogHassioNetwork
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
protected render() {
protected render(): TemplateResult {
if (!this._params || !this._interface) {
return nothing;
return html``;
}
return html`
@@ -137,10 +138,7 @@ export class DialogHassioNetwork
)}
${this._interface?.type === "wireless"
? html`
<ha-expansion-panel
.header=${this.supervisor.localize("dialog.network.wifi")}
outlined
>
<ha-expansion-panel header="Wi-Fi" outlined>
${this._interface?.wifi?.ssid
? html`<p>
${this.supervisor.localize(
@@ -179,11 +177,7 @@ export class DialogHassioNetwork
>
<span>${ap.ssid}</span>
<span slot="secondary">
${ap.mac} -
${this.supervisor.localize(
"dialog.network.signal_strength"
)}:
${ap.signal}
${ap.mac} - Strength: ${ap.signal}
</span>
</mwc-list-item>
`
@@ -247,9 +241,7 @@ export class DialogHassioNetwork
class="flex-auto"
type="password"
id="psk"
.label=${this.supervisor.localize(
"dialog.network.wifi_password"
)}
label="Password"
version="wifi"
@value-changed=${this
._handleInputValueChangedWifi}

View File

@@ -1,11 +1,11 @@
import "@polymer/paper-tooltip/paper-tooltip";
import "@material/mwc-button/mwc-button";
import { mdiDelete, mdiDeleteOff } from "@mdi/js";
import "@polymer/paper-input/paper-input";
import type { PaperInputElement } from "@polymer/paper-input/paper-input";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-item/paper-item-body";
import "@polymer/paper-tooltip/paper-tooltip";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, query, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../../src/common/dom/fire_event";
@@ -19,14 +19,14 @@ import {
HassioAddonRepository,
} from "../../../../src/data/hassio/addon";
import { extractApiErrorMessage } from "../../../../src/data/hassio/common";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import type { HomeAssistant } from "../../../../src/types";
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
import {
addStoreRepository,
fetchStoreRepositories,
removeStoreRepository,
} from "../../../../src/data/supervisor/store";
import { haStyle, haStyleDialog } from "../../../../src/resources/styles";
import type { HomeAssistant } from "../../../../src/types";
import { HassioRepositoryDialogParams } from "./show-dialog-repositories";
@customElement("dialog-hassio-repositories")
class HassioRepositoriesDialog extends LitElement {
@@ -82,9 +82,9 @@ class HassioRepositoriesDialog extends LitElement {
.map((repo) => repo.slug)
);
protected render() {
protected render(): TemplateResult {
if (!this._dialogParams?.supervisor || this._repositories === undefined) {
return nothing;
return html``;
}
const repositories = this._filteredRepositories(this._repositories);
const usedRepositories = this._filteredUsedRepositories(

View File

@@ -1,5 +1,5 @@
import { sanitizeUrl } from "@braintree/sanitize-url";
import { html, LitElement, TemplateResult, nothing } from "lit";
import { html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { navigate } from "../../src/common/navigate";
import {
@@ -101,13 +101,13 @@ class HassioMyRedirect extends LitElement {
navigate(url, { replace: true });
}
protected render() {
protected render(): TemplateResult {
if (this._error) {
return html`<hass-error-screen
.error=${this._error}
></hass-error-screen>`;
}
return nothing;
return html``;
}
private _createRedirectUrl(redirect: Redirect): string {

View File

@@ -5,7 +5,7 @@ import {
html,
LitElement,
PropertyValues,
nothing,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@@ -116,12 +116,12 @@ class UpdateAvailableCard extends LitElement {
storeAddons.find((addon) => addon.slug === slug)
);
protected render() {
protected render(): TemplateResult {
if (
!this._updateType ||
(this._updateType === "addon" && !this._addonInfo)
) {
return nothing;
return html``;
}
const changelog = changelogUrl(this._updateType, this._version_latest);

View File

@@ -5,5 +5,5 @@ module.exports = {
'printf "%s\n" "Translation files should not be added or modified here. Instead, make the necessary modifications in src/translations/en.json. Other languages are managed externally. Please see https://developers.home-assistant.io/docs/translations/ for details." ' +
files.join(" ") +
" >&2 && exit 1",
"yarn.lock": () => "yarn dedupe",
"/yarn.lock": () => "yarn dedupe",
};

View File

@@ -24,238 +24,234 @@
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
"license": "Apache-2.0",
"dependencies": {
"@braintree/sanitize-url": "6.0.2",
"@codemirror/autocomplete": "6.4.2",
"@codemirror/commands": "6.2.1",
"@codemirror/language": "6.6.0",
"@codemirror/legacy-modes": "6.3.1",
"@codemirror/search": "6.2.3",
"@codemirror/state": "6.2.0",
"@codemirror/view": "6.9.1",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.5.1",
"@formatjs/intl-getcanonicallocales": "2.1.0",
"@formatjs/intl-locale": "3.1.1",
"@formatjs/intl-numberformat": "8.3.5",
"@formatjs/intl-pluralrules": "5.1.10",
"@formatjs/intl-relativetimeformat": "11.1.10",
"@fullcalendar/core": "6.1.4",
"@fullcalendar/daygrid": "6.1.4",
"@fullcalendar/interaction": "6.1.4",
"@fullcalendar/list": "6.1.4",
"@fullcalendar/timegrid": "6.1.4",
"@lezer/highlight": "1.1.3",
"@lit-labs/motion": "1.0.3",
"@lit-labs/virtualizer": "1.0.1",
"@braintree/sanitize-url": "^6.0.0",
"@codemirror/autocomplete": "^6.4.0",
"@codemirror/commands": "^6.1.3",
"@codemirror/language": "^6.4.0",
"@codemirror/legacy-modes": "^6.3.1",
"@codemirror/search": "^6.2.3",
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.7.1",
"@formatjs/intl-datetimeformat": "^4.2.5",
"@formatjs/intl-getcanonicallocales": "^2.0.5",
"@formatjs/intl-locale": "^3.0.11",
"@formatjs/intl-numberformat": "^7.2.5",
"@formatjs/intl-pluralrules": "^4.1.5",
"@formatjs/intl-relativetimeformat": "^9.3.2",
"@fullcalendar/common": "5.9.0",
"@fullcalendar/core": "5.9.0",
"@fullcalendar/daygrid": "5.9.0",
"@fullcalendar/interaction": "5.9.0",
"@fullcalendar/list": "5.9.0",
"@fullcalendar/timegrid": "5.9.0",
"@lezer/highlight": "^1.1.3",
"@lit-labs/motion": "^1.0.3",
"@lit-labs/virtualizer": "^1.0.1",
"@material/chips": "=14.0.0-canary.53b3cad2f.0",
"@material/data-table": "=14.0.0-canary.53b3cad2f.0",
"@material/mwc-button": "0.27.0",
"@material/mwc-checkbox": "0.27.0",
"@material/mwc-circular-progress": "0.27.0",
"@material/mwc-dialog": "0.27.0",
"@material/mwc-drawer": "0.27.0",
"@material/mwc-fab": "0.27.0",
"@material/mwc-formfield": "0.27.0",
"@material/mwc-icon-button": "0.27.0",
"@material/mwc-linear-progress": "0.27.0",
"@material/mwc-list": "0.27.0",
"@material/mwc-menu": "0.27.0",
"@material/mwc-radio": "0.27.0",
"@material/mwc-ripple": "0.27.0",
"@material/mwc-select": "0.27.0",
"@material/mwc-slider": "0.27.0",
"@material/mwc-switch": "0.27.0",
"@material/mwc-tab": "0.27.0",
"@material/mwc-tab-bar": "0.27.0",
"@material/mwc-textarea": "0.27.0",
"@material/mwc-textfield": "0.27.0",
"@material/mwc-top-app-bar-fixed": "0.27.0",
"@material/mwc-button": "^0.27.0",
"@material/mwc-checkbox": "^0.27.0",
"@material/mwc-circular-progress": "^0.27.0",
"@material/mwc-dialog": "^0.27.0",
"@material/mwc-drawer": "^0.27.0",
"@material/mwc-fab": "^0.27.0",
"@material/mwc-formfield": "^0.27.0",
"@material/mwc-icon-button": "^0.27.0",
"@material/mwc-linear-progress": "^0.27.0",
"@material/mwc-list": "^0.27.0",
"@material/mwc-menu": "^0.27.0",
"@material/mwc-radio": "^0.27.0",
"@material/mwc-ripple": "^0.27.0",
"@material/mwc-select": "^0.27.0",
"@material/mwc-slider": "^0.27.0",
"@material/mwc-switch": "^0.27.0",
"@material/mwc-tab": "^0.27.0",
"@material/mwc-tab-bar": "^0.27.0",
"@material/mwc-textarea": "^0.27.0",
"@material/mwc-textfield": "^0.27.0",
"@material/mwc-top-app-bar-fixed": "^0.27.0",
"@material/top-app-bar": "=14.0.0-canary.53b3cad2f.0",
"@material/web": "=1.0.0-pre.3",
"@mdi/js": "7.1.96",
"@mdi/svg": "7.1.96",
"@polymer/app-layout": "3.1.0",
"@polymer/iron-flex-layout": "3.0.1",
"@polymer/iron-icon": "3.0.1",
"@polymer/iron-input": "3.0.1",
"@polymer/iron-resizable-behavior": "3.0.1",
"@polymer/paper-input": "3.2.1",
"@polymer/paper-item": "3.0.1",
"@polymer/paper-listbox": "3.0.1",
"@polymer/paper-slider": "3.0.1",
"@polymer/paper-styles": "3.0.1",
"@polymer/paper-tabs": "3.1.0",
"@polymer/paper-toast": "3.0.1",
"@polymer/paper-tooltip": "3.0.1",
"@polymer/app-layout": "^3.1.0",
"@polymer/iron-flex-layout": "^3.0.1",
"@polymer/iron-icon": "^3.0.1",
"@polymer/iron-input": "^3.0.1",
"@polymer/iron-resizable-behavior": "^3.0.1",
"@polymer/paper-input": "^3.2.1",
"@polymer/paper-item": "^3.0.1",
"@polymer/paper-listbox": "^3.0.1",
"@polymer/paper-slider": "^3.0.1",
"@polymer/paper-styles": "^3.0.1",
"@polymer/paper-tabs": "^3.1.0",
"@polymer/paper-toast": "^3.0.1",
"@polymer/paper-tooltip": "^3.0.1",
"@polymer/polymer": "3.4.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "23.3.8",
"@vaadin/vaadin-themable-mixin": "23.3.8",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
"@vue/web-component-wrapper": "1.3.0",
"@webcomponents/scoped-custom-element-registry": "0.0.8",
"@webcomponents/webcomponentsjs": "2.7.0",
"app-datepicker": "5.1.1",
"chart.js": "3.3.2",
"comlink": "4.4.1",
"core-js": "3.29.0",
"cropperjs": "1.5.13",
"date-fns": "2.29.3",
"date-fns-tz": "2.0.0",
"deep-clone-simple": "1.1.1",
"deep-freeze": "0.0.1",
"fuse.js": "6.6.2",
"google-timezones-json": "1.0.2",
"hls.js": "1.3.4",
"home-assistant-js-websocket": "8.0.1",
"idb-keyval": "6.2.0",
"intl-messageformat": "10.3.1",
"js-yaml": "4.1.0",
"leaflet": "1.9.3",
"leaflet-draw": "1.0.4",
"lit": "2.6.1",
"marked": "4.2.12",
"memoize-one": "6.0.0",
"@vaadin/combo-box": "^23.3.5",
"@vaadin/vaadin-themable-mixin": "^23.3.5",
"@vibrant/color": "^3.2.1-alpha.1",
"@vibrant/core": "^3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "^3.2.1-alpha.1",
"@vue/web-component-wrapper": "^1.3.0",
"@webcomponents/scoped-custom-element-registry": "^0.0.5",
"@webcomponents/webcomponentsjs": "^2.2.10",
"app-datepicker": "^5.1.0",
"chart.js": "^3.3.2",
"comlink": "^4.3.1",
"core-js": "^3.15.2",
"cropperjs": "^1.5.13",
"date-fns": "^2.29.3",
"date-fns-tz": "^1.3.7",
"deep-clone-simple": "^1.1.1",
"deep-freeze": "^0.0.1",
"fuse.js": "^6.6.2",
"google-timezones-json": "^1.0.2",
"hammerjs": "^2.0.8",
"hls.js": "^1.3.1",
"home-assistant-js-websocket": "^8.0.1",
"idb-keyval": "^5.1.3",
"intl-messageformat": "^10.2.5",
"js-yaml": "^4.1.0",
"leaflet": "^1.7.1",
"leaflet-draw": "^1.0.4",
"lit": "^2.6.1",
"marked": "^4.0.12",
"memoize-one": "^6.0.0",
"node-vibrant": "3.2.1-alpha.1",
"proxy-polyfill": "0.3.2",
"punycode": "2.3.0",
"qr-scanner": "1.4.2",
"qrcode": "1.5.1",
"regenerator-runtime": "0.13.11",
"resize-observer-polyfill": "1.5.1",
"roboto-fontface": "0.10.0",
"rrule": "2.7.2",
"sortablejs": "1.15.0",
"superstruct": "1.0.3",
"tinykeys": "1.4.0",
"tsparticles-engine": "2.9.3",
"tsparticles-preset-links": "2.9.3",
"unfetch": "5.0.0",
"vis-data": "7.1.4",
"vis-network": "9.1.4",
"vue": "2.7.14",
"vue2-daterange-picker": "0.6.8",
"weekstart": "2.0.0",
"workbox-cacheable-response": "6.5.4",
"workbox-core": "6.5.4",
"workbox-expiration": "6.5.4",
"workbox-precaching": "6.5.4",
"workbox-routing": "6.5.4",
"workbox-strategies": "6.5.4",
"xss": "1.0.14"
"proxy-polyfill": "^0.3.2",
"punycode": "^2.3.0",
"qr-scanner": "^1.3.0",
"qrcode": "^1.5.1",
"regenerator-runtime": "^0.13.11",
"resize-observer-polyfill": "^1.5.1",
"roboto-fontface": "^0.10.0",
"rrule": "^2.7.1",
"sortablejs": "^1.14.0",
"superstruct": "^1.0.3",
"tinykeys": "^1.1.3",
"tsparticles": "^1.34.0",
"unfetch": "^4.1.0",
"vis-data": "^7.1.2",
"vis-network": "^8.5.4",
"vue": "^2.6.12",
"vue2-daterange-picker": "^0.5.1",
"weekstart": "^1.1.0",
"workbox-cacheable-response": "^6.5.4",
"workbox-core": "^6.5.4",
"workbox-expiration": "^6.5.4",
"workbox-precaching": "^6.5.4",
"workbox-routing": "^6.5.4",
"workbox-strategies": "^6.5.4",
"xss": "^1.0.14"
},
"devDependencies": {
"@babel/core": "7.21.0",
"@babel/plugin-external-helpers": "7.18.6",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-decorators": "7.21.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-import-meta": "7.10.4",
"@babel/plugin-syntax-top-level-await": "7.14.5",
"@babel/preset-env": "7.20.2",
"@babel/preset-typescript": "7.21.0",
"@koa/cors": "4.0.0",
"@octokit/auth-oauth-device": "4.0.4",
"@octokit/rest": "19.0.7",
"@open-wc/dev-server-hmr": "0.1.3",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-commonjs": "11.1.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "7.1.3",
"@rollup/plugin-replace": "2.4.2",
"@babel/core": "^7.20.2",
"@babel/plugin-external-helpers": "^7.18.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.20.7",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.2",
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@koa/cors": "^3.1.0",
"@octokit/auth-oauth-device": "^4.0.2",
"@octokit/rest": "^19.0.7",
"@open-wc/dev-server-hmr": "^0.0.2",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.2",
"@types/chromecast-caf-receiver": "5.0.12",
"@types/chromecast-caf-sender": "1.0.5",
"@types/esprima": "4.0.3",
"@types/glob": "8.1.0",
"@types/js-yaml": "4.0.5",
"@types/leaflet": "1.9.1",
"@types/leaflet-draw": "1.0.6",
"@types/marked": "4.0.8",
"@types/mocha": "10.0.1",
"@types/qrcode": "1.5.0",
"@types/serve-handler": "6.1.1",
"@types/sortablejs": "1.15.0",
"@types/tar": "6.1.4",
"@types/webspeechapi": "0.0.29",
"@typescript-eslint/eslint-plugin": "5.54.0",
"@typescript-eslint/parser": "5.54.0",
"@web/dev-server": "0.1.35",
"@web/dev-server-rollup": "0.3.21",
"babel-loader": "9.1.2",
"babel-plugin-template-html-minifier": "4.1.0",
"chai": "4.3.7",
"del": "7.0.0",
"eslint": "8.35.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.6.0",
"eslint-import-resolver-webpack": "0.13.2",
"eslint-plugin-disable": "2.0.3",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-lit": "1.8.2",
"eslint-plugin-lit-a11y": "2.3.0",
"eslint-plugin-unused-imports": "2.0.0",
"eslint-plugin-wc": "1.4.0",
"esprima": "4.0.1",
"fancy-log": "2.0.0",
"fs-extra": "11.1.0",
"glob": "8.1.0",
"gulp": "4.0.2",
"gulp-flatmap": "1.0.2",
"gulp-json-transform": "0.4.8",
"gulp-merge-json": "2.1.2",
"gulp-rename": "2.0.0",
"gulp-zopfli-green": "6.0.1",
"html-minifier": "4.0.0",
"husky": "8.0.3",
"instant-mocha": "1.5.0",
"jszip": "3.10.1",
"lint-staged": "13.1.2",
"lit-analyzer": "1.2.1",
"lodash.template": "4.5.0",
"magic-string": "0.30.0",
"map-stream": "0.0.7",
"merge-stream": "2.0.0",
"mocha": "10.2.0",
"object-hash": "3.0.0",
"open": "8.4.2",
"pinst": "3.0.0",
"prettier": "2.8.4",
"require-dir": "1.2.0",
"rollup": "2.79.1",
"rollup-plugin-string": "3.0.0",
"rollup-plugin-terser": "5.3.1",
"rollup-plugin-visualizer": "5.9.0",
"serve-handler": "6.1.5",
"sinon": "15.0.1",
"source-map-url": "0.4.1",
"systemjs": "6.14.0",
"tar": "6.1.13",
"terser-webpack-plugin": "5.3.6",
"ts-lit-plugin": "1.2.1",
"typescript": "4.9.5",
"vinyl-buffer": "1.0.1",
"vinyl-source-stream": "2.0.0",
"webpack": "=5.72.1",
"webpack-cli": "5.0.1",
"webpack-dev-server": "4.11.1",
"webpack-manifest-plugin": "5.0.0",
"webpackbar": "5.0.2",
"workbox-build": "6.5.4"
"@types/chromecast-caf-sender": "^1.0.3",
"@types/glob": "^8",
"@types/hammerjs": "^2.0.41",
"@types/js-yaml": "^4",
"@types/leaflet": "^1",
"@types/leaflet-draw": "^1",
"@types/marked": "^4",
"@types/mocha": "^8",
"@types/qrcode": "^1.5.0",
"@types/sortablejs": "^1",
"@types/tar": "^6",
"@types/webspeechapi": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.49.0",
"@web/dev-server": "^0.0.24",
"@web/dev-server-rollup": "^0.2.11",
"babel-loader": "^9.1.0",
"chai": "^4.3.4",
"del": "^7.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^14.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-disable": "^2.0.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-lit": "^1.6.1",
"eslint-plugin-unused-imports": "^1.1.5",
"eslint-plugin-wc": "^1.4.0",
"fancy-log": "^2.0.0",
"fs-extra": "^11.1.0",
"glob": "^8.1.0",
"gulp": "^4.0.2",
"gulp-flatmap": "^1.0.2",
"gulp-json-transform": "^0.4.6",
"gulp-merge-json": "^2.1.2",
"gulp-rename": "^2.0.0",
"gulp-zopfli-green": "^3.0.1",
"html-minifier": "^4.0.0",
"husky": "^8.0.3",
"instant-mocha": "^1.3.1",
"jszip": "^3.10.1",
"lint-staged": "^13.1.0",
"lit-analyzer": "^1.2.1",
"lodash.template": "^4.5.0",
"magic-string": "^0.25.7",
"map-stream": "^0.0.7",
"merge-stream": "^1.0.1",
"mocha": "^8.4.0",
"object-hash": "^3.0.0",
"open": "^8.4.0",
"pinst": "^3.0.0",
"prettier": "^2.8.3",
"require-dir": "^1.2.0",
"rollup": "^2.8.2",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-visualizer": "^5.9.0",
"serve": "^11.3.2",
"sinon": "^15.0.1",
"source-map-url": "^0.4.0",
"systemjs": "^6.3.2",
"tar": "^6.1.11",
"terser-webpack-plugin": "^5.2.4",
"ts-lit-plugin": "^1.2.1",
"typescript": "^4.9.4",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"webpack": "^5.55.1",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1",
"webpack-manifest-plugin": "^4.0.2",
"webpackbar": "^5.0.2",
"workbox-build": "^6.5.4"
},
"_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.4.1#./.yarn/patches/@polymer/polymer/pr-5569.patch"
"@polymer/polymer": "patch:@polymer/polymer@3.4.1#./.yarn/patches/@polymer/polymer/pr-5569.patch",
"@webcomponents/webcomponentsjs": "^2.2.10"
},
"main": "src/home-assistant.js",
"prettier": {
"trailingComma": "es5",
"arrowParens": "always"
},
"packageManager": "yarn@3.4.1"
"packageManager": "yarn@3.3.1"
}

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "home-assistant-frontend"
version = "20230306.0"
version = "20230128.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"

View File

@@ -1,32 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
":ignoreModulesAndTests",
":label(dependencies)",
":pinVersions",
":prConcurrentLimit10",
":semanticCommitsDisabled",
"group:monorepos",
"group:recommended",
"npm:unpublishSafe"
],
"enabledManagers": ["npm"],
"postUpdateOptions": ["yarnDedupeHighest"],
"lockFileMaintenance": {
"description": ["Run after patch releases but before next beta"],
"enabled": true,
"schedule": ["on the 19th day of the month"]
},
"packageRules": [
{
"description": ["MDC packages are pinned to the same version as MWC"],
"extends": ["monorepo:material-components-web"],
"enabled": false
},
{
"description": ["Vue is only used by date range which is only v2"],
"matchPackageNames": ["vue"],
"allowedVersions": "< 3"
}
]
}

View File

@@ -6,9 +6,6 @@ set -e
cd "$(dirname "$0")/.."
export STATS=1
statsfile="compilation-stats.json"
./node_modules/.bin/webpack-cli --profile --node-env=production --json=$statsfile
npx webpack-bundle-analyzer $statsfile hass_frontend/frontend_latest
rm -f $statsfile
STATS=1 NODE_ENV=production ./node_modules/.bin/webpack --profile --json > compilation-stats.json
npx webpack-bundle-analyzer compilation-stats.json hass_frontend/frontend_latest
rm compilation-stats.json

View File

@@ -5,10 +5,10 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { property, state } from "lit/decorators";
import "../components/ha-alert";
import "../components/ha-checkbox";
import { computeInitialHaFormData } from "../components/ha-form/compute-initial-ha-form-data";
@@ -25,8 +25,7 @@ import "./ha-password-manager-polyfill";
type State = "loading" | "error" | "step";
@customElement("ha-auth-flow")
export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
@property({ attribute: false }) public authProvider?: AuthProvider;
@property() public clientId?: string;
@@ -134,11 +133,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
}, 500);
}
private _renderForm() {
private _renderForm(): TemplateResult {
switch (this._state) {
case "step":
if (this._step == null) {
return nothing;
return html``;
}
return html`
${this._renderStep(this._step)}
@@ -176,11 +175,11 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
</ha-alert>
`;
default:
return nothing;
return html``;
}
}
private _renderStep(step: DataEntryFlowStep) {
private _renderStep(step: DataEntryFlowStep): TemplateResult {
switch (step.type) {
case "abort":
return html`
@@ -202,7 +201,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
.content=${this._computeStepDescription(step)}
></ha-markdown>
`
: nothing}
: html``}
<ha-form
.data=${this._stepData}
.schema=${autocompleteLoginFields(step.data_schema)}
@@ -228,7 +227,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
: ""}
`;
default:
return nothing;
return html``;
}
}
@@ -408,6 +407,7 @@ export class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
`;
}
}
customElements.define("ha-auth-flow", HaAuthFlow);
declare global {
interface HTMLElementTagNameMap {

View File

@@ -1,5 +1,5 @@
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators";
import { property, state } from "lit/decorators";
import punycode from "punycode";
import { applyThemesOnElement } from "../common/dom/apply_themes_on_element";
import { extractSearchParamsObject } from "../common/url/search-params";
@@ -14,8 +14,7 @@ import "./ha-auth-flow";
import("./ha-pick-auth-provider");
@customElement("ha-authorize")
export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
@property() public clientId?: string;
@property() public redirectUri?: string;
@@ -184,3 +183,4 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
`;
}
}
customElements.define("ha-authorize", HaAuthorize);

View File

@@ -1,6 +1,6 @@
import { css, html, LitElement, nothing } from "lit";
/* eslint-disable lit/prefer-static-styles */
import { html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
import { fireEvent } from "../common/dom/fire_event";
import type { HaFormSchema } from "../components/ha-form/types";
import { autocompleteLoginFields } from "../data/auth";
@@ -29,43 +29,35 @@ export class HaPasswordManagerPolyfill extends LitElement {
@property({ attribute: false }) public boundingRect?: DOMRect;
private _styleElement?: HTMLStyleElement;
public connectedCallback() {
super.connectedCallback();
this._styleElement = document.createElement("style");
this._styleElement.textContent = css`
.password-manager-polyfill {
position: absolute;
opacity: 0;
z-index: -1;
}
.password-manager-polyfill input {
width: 100%;
height: 62px;
padding: 0;
border: 0;
}
.password-manager-polyfill input[type="submit"] {
width: 0;
height: 0;
}
`.toString();
document.head.append(this._styleElement);
}
public disconnectedCallback() {
super.disconnectedCallback();
this._styleElement?.remove();
delete this._styleElement;
}
protected createRenderRoot() {
// Add under document body so the element isn't placed inside any shadow roots
return document.body;
}
protected render() {
private get styles() {
return `
.password-manager-polyfill {
position: absolute;
top: ${this.boundingRect?.y || 148}px;
left: calc(50% - ${(this.boundingRect?.width || 360) / 2}px);
width: ${this.boundingRect?.width || 360}px;
opacity: 0;
z-index: -1;
}
.password-manager-polyfill input {
width: 100%;
height: 62px;
padding: 0;
border: 0;
}
.password-manager-polyfill input[type="submit"] {
width: 0;
height: 0;
}
`;
}
protected render(): TemplateResult {
if (
this.step &&
this.step.type === "form" &&
@@ -75,11 +67,6 @@ export class HaPasswordManagerPolyfill extends LitElement {
return html`
<form
class="password-manager-polyfill"
style=${styleMap({
top: `${this.boundingRect?.y || 148}px`,
left: `calc(50% - ${(this.boundingRect?.width || 360) / 2}px)`,
width: `${this.boundingRect?.width || 360}px`,
})}
aria-hidden="true"
@submit=${this._handleSubmit}
>
@@ -87,13 +74,16 @@ export class HaPasswordManagerPolyfill extends LitElement {
this.render_input(input)
)}
<input type="submit" />
<style>
${this.styles}
</style>
</form>
`;
}
return nothing;
return html``;
}
private render_input(schema: HaFormSchema) {
private render_input(schema: HaFormSchema): TemplateResult | string {
const inputType = schema.name.includes("password") ? "password" : "text";
if (schema.type !== "string") {
return "";

View File

@@ -1,7 +1,7 @@
import "@polymer/paper-item/paper-item";
import "@polymer/paper-item/paper-item-body";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators";
import { property } from "lit/decorators";
import { fireEvent } from "../common/dom/fire_event";
import "../components/ha-icon-next";
import { AuthProvider } from "../data/auth";
@@ -13,8 +13,7 @@ declare global {
}
}
@customElement("ha-pick-auth-provider")
export class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
@property() public authProviders: AuthProvider[] = [];
protected render() {
@@ -48,3 +47,4 @@ export class HaPickAuthProvider extends litLocalizeLiteMixin(LitElement) {
}
`;
}
customElements.define("ha-pick-auth-provider", HaPickAuthProvider);

View File

@@ -2,7 +2,6 @@ type NonUndefined<T> = T extends undefined ? never : T;
export function ensureArray(value: undefined): undefined;
export function ensureArray<T>(value: T | T[]): NonUndefined<T>[];
export function ensureArray<T>(value: T | readonly T[]): NonUndefined<T>[];
export function ensureArray(value) {
if (value === undefined || Array.isArray(value)) {
return value;

View File

@@ -22,11 +22,3 @@ export const atLeastVersion = (
Number(haPatch) >= patch)
);
};
export const isDevVersion = (version: string): boolean => {
if (__DEMO__) {
return false;
}
return version.includes("dev");
};

View File

@@ -1,6 +1,7 @@
/** Constants to be used in the frontend. */
import {
mdiAccount,
mdiAirFilter,
mdiAlert,
mdiAngleAcute,
@@ -23,6 +24,7 @@ import {
mdiDatabase,
mdiEarHearing,
mdiEye,
mdiFan,
mdiFlash,
mdiFlower,
mdiFormatListBulleted,
@@ -47,6 +49,7 @@ import {
mdiProgressClock,
mdiRayVertex,
mdiRemote,
mdiRobot,
mdiRobotVacuum,
mdiScriptText,
mdiSineWave,
@@ -57,12 +60,15 @@ import {
mdiThermostat,
mdiTimerOutline,
mdiTransmissionTower,
mdiVideo,
mdiWater,
mdiWaterPercent,
mdiWeatherCloudy,
mdiWeatherPouring,
mdiWeatherRainy,
mdiWeatherWindy,
mdiWeight,
mdiWhiteBalanceSunny,
mdiWifi,
} from "@mdi/js";
@@ -77,12 +83,15 @@ export const DEFAULT_DOMAIN_ICON = mdiBookmark;
export const FIXED_DOMAIN_ICONS = {
alert: mdiAlert,
air_quality: mdiAirFilter,
automation: mdiRobot,
calendar: mdiCalendar,
camera: mdiVideo,
climate: mdiThermostat,
configurator: mdiCog,
conversation: mdiMicrophoneMessage,
counter: mdiCounter,
demo: mdiHomeAssistant,
fan: mdiFan,
google_assistant: mdiGoogleAssistant,
group: mdiGoogleCirclesCommunities,
homeassistant: mdiHomeAssistant,
@@ -98,6 +107,7 @@ export const FIXED_DOMAIN_ICONS = {
notify: mdiCommentAlert,
number: mdiRayVertex,
persistent_notification: mdiBell,
person: mdiAccount,
plant: mdiFlower,
proximity: mdiAppleSafari,
remote: mdiRemote,
@@ -108,10 +118,13 @@ export const FIXED_DOMAIN_ICONS = {
sensor: mdiEye,
siren: mdiBullhorn,
simple_alarm: mdiBell,
sun: mdiWhiteBalanceSunny,
text: mdiFormTextbox,
timer: mdiTimerOutline,
updater: mdiCloudUpload,
vacuum: mdiRobotVacuum,
water_heater: mdiThermometer,
weather: mdiWeatherCloudy,
zone: mdiMapMarkerRadius,
};

View File

@@ -10,19 +10,11 @@ export const createDurationData = (
if (typeof duration !== "object") {
if (typeof duration === "string" || isNaN(duration)) {
const parts = duration?.toString().split(":") || [];
if (parts.length === 1) {
return { seconds: Number(parts[0]) };
}
if (parts.length > 3) {
return undefined;
}
const seconds = Number(parts[2]) || 0;
const seconds_whole = Math.floor(seconds);
return {
hours: Number(parts[0]) || 0,
minutes: Number(parts[1]) || 0,
seconds: seconds_whole,
milliseconds: Math.floor((seconds - seconds_whole) * 1000),
seconds: Number(parts[2]) || 0,
milliseconds: Number(parts[3]) || 0,
};
}
return { seconds: duration };

View File

@@ -1,12 +1,6 @@
import { getWeekStartByLocale } from "weekstart";
import { FrontendLocaleData, FirstWeekday } from "../../data/translation";
import { polyfillsLoaded } from "../translations/localize";
if (__BUILD__ === "latest" && polyfillsLoaded) {
await polyfillsLoaded;
}
export const weekdays = [
"sunday",
"monday",

View File

@@ -11,7 +11,8 @@ export const setupLeafletMap = async (
throw new Error("Cannot setup Leaflet map on disconnected element");
}
// eslint-disable-next-line
const Leaflet = (await import("leaflet")).default as LeafletModuleType;
const Leaflet = ((await import("leaflet")) as any)
.default as LeafletModuleType;
Leaflet.Icon.Default.imagePath = "/static/images/leaflet/images/";
const map = Leaflet.map(mapElement);

View File

@@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
import { EntityRegistryEntry } from "../../data/entity_registry";
import { HomeAssistant } from "../../types";
import { LocalizeFunc } from "../translations/localize";
import { computeDomain } from "./compute_domain";
@@ -15,7 +15,7 @@ export const computeAttributeValueDisplay = (
const attributeValue =
value !== undefined ? value : stateObj.attributes[attribute];
const domain = computeDomain(entityId);
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
const entity = entities[entityId] as EntityRegistryEntry | undefined;
const translationKey = entity?.translation_key;
return (
@@ -38,7 +38,7 @@ export const computeAttributeNameDisplay = (
): string => {
const entityId = stateObj.entity_id;
const domain = computeDomain(entityId);
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
const entity = entities[entityId] as EntityRegistryEntry | undefined;
const translationKey = entity?.translation_key;
return (

View File

@@ -1,6 +1,6 @@
import { HassEntity } from "home-assistant-js-websocket";
import { UNAVAILABLE, UNKNOWN } from "../../data/entity";
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
import { EntityRegistryEntry } from "../../data/entity_registry";
import { FrontendLocaleData } from "../../data/translation";
import {
updateIsInstallingFromAttributes,
@@ -49,8 +49,6 @@ export const computeStateDisplayFromEntityAttributes = (
return localize(`state.default.${state}`);
}
const entity = entities[entityId] as EntityRegistryDisplayEntry | undefined;
// Entities with a `unit_of_measurement` or `state_class` are numeric values and should use `formatNumber`
if (isNumericFromAttributes(attributes)) {
// state is duration
@@ -71,11 +69,6 @@ export const computeStateDisplayFromEntityAttributes = (
style: "currency",
currency: attributes.unit_of_measurement,
minimumFractionDigits: 2,
// Override monetary options with number format
...getNumberFormatOptions(
{ state, attributes } as HassEntity,
entity
),
});
} catch (_err) {
// fallback to default
@@ -89,7 +82,7 @@ export const computeStateDisplayFromEntityAttributes = (
return `${formatNumber(
state,
locale,
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
getNumberFormatOptions({ state, attributes } as HassEntity)
)}${unit}`;
}
@@ -167,7 +160,7 @@ export const computeStateDisplayFromEntityAttributes = (
return formatNumber(
state,
locale,
getNumberFormatOptions({ state, attributes } as HassEntity, entity)
getNumberFormatOptions({ state, attributes } as HassEntity)
);
}
@@ -206,6 +199,8 @@ export const computeStateDisplayFromEntityAttributes = (
: localize("ui.card.update.up_to_date");
}
const entity = entities[entityId] as EntityRegistryEntry | undefined;
return (
(entity?.translation_key &&
localize(

View File

@@ -15,8 +15,6 @@ import {
mdiCheckCircleOutline,
mdiClock,
mdiCloseCircleOutline,
mdiFan,
mdiFanOff,
mdiGestureTapButton,
mdiLanConnect,
mdiLanDisconnect,
@@ -30,8 +28,6 @@ import {
mdiPowerPlug,
mdiPowerPlugOff,
mdiRestart,
mdiRobot,
mdiRobotOff,
mdiSpeaker,
mdiSpeakerOff,
mdiSpeakerPause,
@@ -43,12 +39,7 @@ import {
mdiTelevisionPlay,
mdiToggleSwitchVariant,
mdiToggleSwitchVariantOff,
mdiVideo,
mdiVideoOff,
mdiWaterBoiler,
mdiWaterBoilerOff,
mdiWeatherNight,
mdiWhiteBalanceSunny,
} from "@mdi/js";
import { HassEntity } from "home-assistant-js-websocket";
import { UpdateEntity, updateIsInstalling } from "../../data/update";
@@ -90,9 +81,6 @@ export const domainIconWithoutDefault = (
case "alarm_control_panel":
return alarmPanelIcon(compareState);
case "automation":
return compareState === "off" ? mdiRobotOff : mdiRobot;
case "binary_sensor":
return binarySensorIcon(compareState, stateObj);
@@ -106,9 +94,6 @@ export const domainIconWithoutDefault = (
return mdiGestureTapButton;
}
case "camera":
return compareState === "off" ? mdiVideoOff : mdiVideo;
case "cover":
return coverIcon(compareState, stateObj);
@@ -123,9 +108,6 @@ export const domainIconWithoutDefault = (
}
return compareState === "not_home" ? mdiAccountArrowRight : mdiAccount;
case "fan":
return compareState === "off" ? mdiFanOff : mdiFan;
case "humidifier":
return compareState === "off" ? mdiAirHumidifierOff : mdiAirHumidifier;
@@ -234,7 +216,7 @@ export const domainIconWithoutDefault = (
case "sun":
return stateObj?.state === "above_horizon"
? mdiWhiteBalanceSunny
? FIXED_DOMAIN_ICONS[domain]
: mdiWeatherNight;
case "switch_as_x":
@@ -250,9 +232,6 @@ export const domainIconWithoutDefault = (
: mdiPackageUp
: mdiPackage;
case "water_heater":
return compareState === "off" ? mdiWaterBoilerOff : mdiWaterBoiler;
case "weather":
return weatherIcon(stateObj?.state);
}

View File

@@ -4,15 +4,12 @@ import { domainToName } from "../../data/integration";
import { getIntegrationDescriptions } from "../../data/integrations";
import { showConfigFlowDialog } from "../../dialogs/config-flow/show-dialog-config-flow";
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
import { showMatterAddDeviceDialog } from "../../panels/config/integrations/integration-panels/matter/show-dialog-add-matter-device";
import { showZWaveJSAddNodeDialog } from "../../panels/config/integrations/integration-panels/zwave_js/show-dialog-zwave_js-add-node";
import type { HomeAssistant } from "../../types";
import { documentationUrl } from "../../util/documentation-url";
import { isComponentLoaded } from "../config/is_component_loaded";
import { navigate } from "../navigate";
export const PROTOCOL_INTEGRATIONS = ["zha", "zwave_js", "matter"] as const;
export const protocolIntegrationPicked = async (
element: HTMLElement,
hass: HomeAssistant,
@@ -116,43 +113,5 @@ export const protocolIntegrationPicked = async (
}
navigate("/config/zha/add");
} else if (domain === "matter") {
const entries = await getConfigEntries(hass, {
domain,
});
if (!isComponentLoaded(hass, domain) || !entries.length) {
// If the component isn't loaded, ask them to load the integration first
showConfirmationDialog(element, {
title: hass.localize(
"ui.panel.config.integrations.config_flow.missing_zwave_zigbee_title",
{ integration: "Matter" }
),
text: hass.localize(
"ui.panel.config.integrations.config_flow.missing_matter",
{
integration: "Matter",
brand: options?.brand || options?.domain || "Matter",
supported_hardware_link: html`<a
href=${documentationUrl(hass, "/integrations/matter")}
target="_blank"
rel="noreferrer"
>${hass.localize(
"ui.panel.config.integrations.config_flow.supported_hardware"
)}</a
>`,
}
),
confirmText: hass.localize(
"ui.panel.config.integrations.config_flow.proceed"
),
confirm: () => {
showConfigFlowDialog(element, {
startFlowHandler: "matter",
});
},
});
return;
}
showMatterAddDeviceDialog(element);
}
};

View File

@@ -2,7 +2,6 @@ import {
HassEntity,
HassEntityAttributeBase,
} from "home-assistant-js-websocket";
import { EntityRegistryDisplayEntry } from "../../data/entity_registry";
import { FrontendLocaleData, NumberFormat } from "../../data/translation";
import { round } from "./round";
@@ -77,23 +76,6 @@ export const formatNumber = (
).format(Number(num));
}
}
if (
!Number.isNaN(Number(num)) &&
num !== "" &&
localeOptions?.number_format === NumberFormat.none &&
Intl
) {
// If NumberFormat is none, use en-US format without grouping.
return new Intl.NumberFormat(
"en-US",
getDefaultFormatOptions(num, {
...options,
useGrouping: false,
})
).format(Number(num));
}
if (typeof num === "string") {
return num;
}
@@ -108,16 +90,8 @@ export const formatNumber = (
* @returns An `Intl.NumberFormatOptions` object with `maximumFractionDigits` set to 0, or `undefined`
*/
export const getNumberFormatOptions = (
entityState: HassEntity,
entity?: EntityRegistryDisplayEntry
entityState: HassEntity
): Intl.NumberFormatOptions | undefined => {
const precision = entity?.display_precision;
if (precision != null) {
return {
maximumFractionDigits: precision,
minimumFractionDigits: precision,
};
}
if (
Number.isInteger(Number(entityState.attributes?.step)) &&
Number.isInteger(Number(entityState.state))

View File

@@ -1,4 +1,4 @@
const isTemplateRegex = /{%|{{/;
const isTemplateRegex = new RegExp("{%|{{");
export const isTemplate = (value: string): boolean =>
isTemplateRegex.test(value);

View File

@@ -1,5 +1,6 @@
import { refine, string } from "superstruct";
import { isCustomType } from "../../data/lovelace_custom_cards";
export const isCustomType = (value: string) => value.startsWith("custom:");
export const customType = () =>
refine(string(), "custom element type", isCustomType);

View File

@@ -65,21 +65,19 @@ export interface FormatsType {
const loadedPolyfillLocale = new Set();
const locale = getLocalLanguage();
const polyfills: Promise<any>[] = [];
if (__BUILD__ === "latest") {
if (shouldPolyfillLocale()) {
await import("@formatjs/intl-locale/polyfill");
polyfills.push(import("@formatjs/intl-locale/polyfill"));
}
if (shouldPolyfillPluralRules(locale)) {
if (shouldPolyfillPluralRules()) {
polyfills.push(import("@formatjs/intl-pluralrules/polyfill"));
polyfills.push(import("@formatjs/intl-pluralrules/locale-data/en"));
}
if (shouldPolyfillRelativeTime(locale)) {
if (shouldPolyfillRelativeTime()) {
polyfills.push(import("@formatjs/intl-relativetimeformat/polyfill"));
}
if (shouldPolyfillDateTime(locale)) {
if (shouldPolyfillDateTime()) {
polyfills.push(import("@formatjs/intl-datetimeformat/polyfill"));
polyfills.push(import("@formatjs/intl-datetimeformat/add-all-tz"));
}
@@ -90,7 +88,7 @@ export const polyfillsLoaded =
? undefined
: Promise.all(polyfills).then(() =>
// Load the default language
loadPolyfillLocales(locale)
loadPolyfillLocales(getLocalLanguage())
);
/**
@@ -216,7 +214,7 @@ export const loadPolyfillLocales = async (language: string) => {
// @ts-ignore
Intl.DateTimeFormat.__addLocaleData(await result.json());
}
} catch (e) {
} catch (_e) {
// Ignore
}
};

View File

@@ -19,7 +19,6 @@ const SECS_PER_HOUR = SECS_PER_MIN * 60;
// Adapted from https://github.com/formatjs/formatjs/blob/186cef62f980ec66252ee232f438a42d0b51b9f9/packages/intl-utils/src/diff.ts
export function selectUnit(
from: Date | number,
// eslint-disable-next-line @typescript-eslint/default-param-last
to: Date | number = Date.now(),
locale: FrontendLocaleData,
thresholds: Partial<Thresholds> = {}

View File

@@ -1,10 +1,9 @@
import { css, CSSResultGroup, html, LitElement } from "lit";
import { customElement, property, query } from "lit/decorators";
import { property, query } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { HomeAssistant } from "../../types";
import "./ha-progress-button";
@customElement("ha-call-api-button")
class HaCallApiButton extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -70,6 +69,8 @@ class HaCallApiButton extends LitElement {
}
}
customElements.define("ha-call-api-button", HaCallApiButton);
declare global {
interface HTMLElementTagNameMap {
"ha-call-api-button": HaCallApiButton;

View File

@@ -233,11 +233,7 @@ export default class HaChartBase extends LitElement {
{
id: "afterRenderHook",
afterRender: (chart) => {
const change = chart.height - (this._chartHeight ?? 0);
if (!this._chartHeight || change > 0 || change < -12) {
// hysteresis to prevent infinite render loops
this._chartHeight = chart.height;
}
this._chartHeight = chart.height;
},
legend: {
...this.options?.plugins?.legend,

View File

@@ -22,7 +22,7 @@ class StateHistoryChartLine extends LitElement {
@property({ attribute: false }) public data: LineChartEntity[] = [];
@property() public names?: Record<string, string>;
@property() public names: boolean | Record<string, string> = false;
@property() public unit?: string;

View File

@@ -19,7 +19,7 @@ export class StateHistoryChartTimeline extends LitElement {
@property() public narrow!: boolean;
@property() public names?: Record<string, string>;
@property() public names: boolean | Record<string, string> = false;
@property() public unit?: string;
@@ -64,8 +64,6 @@ export class StateHistoryChartTimeline extends LitElement {
}
if (
changedProps.has("startTime") ||
changedProps.has("endTime") ||
changedProps.has("data") ||
this._chartTime <
new Date(this.endTime.getTime() - MIN_TIME_BETWEEN_UPDATES)
@@ -143,10 +141,7 @@ export class StateHistoryChartTimeline extends LitElement {
}
},
afterUpdate: (y) => {
if (
this._yWidth !== Math.floor(y.width) &&
y.ticks.length === this.data.length
) {
if (this._yWidth !== Math.floor(y.width)) {
this._yWidth = Math.floor(y.width);
fireEvent(this, "y-width-changed", {
value: this._yWidth,

View File

@@ -4,12 +4,11 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
import { customElement, eventOptions, property, state } from "lit/decorators";
import { customElement, property, state, eventOptions } from "lit/decorators";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { restoreScroll } from "../../common/decorators/restore-scroll";
import {
HistoryResult,
LineChartUnit,
@@ -18,6 +17,7 @@ import {
import type { HomeAssistant } from "../../types";
import "./state-history-chart-line";
import "./state-history-chart-timeline";
import { restoreScroll } from "../../common/decorators/restore-scroll";
const CANVAS_TIMELINE_ROWS_CHUNK = 10; // Split up the canvases to avoid hitting the render limit
@@ -38,14 +38,14 @@ declare global {
}
@customElement("state-history-charts")
export class StateHistoryCharts extends LitElement {
class StateHistoryCharts extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public historyData!: HistoryResult;
@property() public narrow!: boolean;
@property() public names?: Record<string, string>;
@property({ type: Boolean }) public names = false;
@property({ type: Boolean, attribute: "virtualize", reflect: true })
public virtualize = false;
@@ -71,7 +71,8 @@ export class StateHistoryCharts extends LitElement {
// @ts-ignore
@restoreScroll(".container") private _savedScrollPos?: number;
protected render() {
@eventOptions({ passive: true })
protected render(): TemplateResult {
if (!isComponentLoaded(this.hass, "history")) {
return html`<div class="info">
${this.hass.localize("ui.components.history_charts.history_disabled")}
@@ -130,9 +131,9 @@ export class StateHistoryCharts extends LitElement {
private _renderHistoryItem = (
item: TimelineEntity[] | LineChartUnit,
index: number
) => {
): TemplateResult => {
if (!item || index === undefined) {
return nothing;
return html``;
}
if (!Array.isArray(item)) {
return html`<div class="entry-container">

View File

@@ -59,14 +59,14 @@ export const statTypeMap: Record<ExtendedStatisticType, StatisticType> = {
class StatisticsChart extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public statisticsData?: Statistics;
@property({ attribute: false }) public statisticsData!: Statistics;
@property({ attribute: false }) public metadata?: Record<
string,
StatisticsMetaData
>;
@property() public names?: Record<string, string>;
@property() public names: boolean | Record<string, string> = false;
@property() public unit?: string;
@@ -99,11 +99,7 @@ class StatisticsChart extends LitElement {
if (!this.hasUpdated || changedProps.has("unit")) {
this._createOptions();
}
if (
changedProps.has("statisticsData") ||
changedProps.has("statTypes") ||
changedProps.has("hideLegend")
) {
if (changedProps.has("statisticsData") || changedProps.has("statTypes")) {
this._generateData();
}
}
@@ -332,10 +328,7 @@ class StatisticsChart extends LitElement {
prevEndTime = end;
};
const color = getGraphColorByIndex(
colorIndex,
this._computedStyle || getComputedStyle(this)
);
const color = getGraphColorByIndex(colorIndex, this._computedStyle!);
colorIndex++;
const statTypes: this["statTypes"] = [];

View File

@@ -1,4 +1,3 @@
import "@lit-labs/virtualizer";
import { mdiArrowDown, mdiArrowUp } from "@mdi/js";
import deepClone from "deep-clone-simple";
import {
@@ -6,7 +5,6 @@ import {
CSSResultGroup,
html,
LitElement,
nothing,
PropertyValues,
TemplateResult,
} from "lit";
@@ -23,15 +21,16 @@ import { styleMap } from "lit/directives/style-map";
import memoizeOne from "memoize-one";
import { restoreScroll } from "../../common/decorators/restore-scroll";
import { fireEvent } from "../../common/dom/fire_event";
import "../search-input";
import { debounce } from "../../common/util/debounce";
import { nextRender } from "../../common/util/render-status";
import { haStyleScrollbar } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import "../ha-checkbox";
import type { HaCheckbox } from "../ha-checkbox";
import "../ha-svg-icon";
import "../search-input";
import { filterData, sortData } from "./sort-filter";
import { HomeAssistant } from "../../types";
import "@lit-labs/virtualizer";
declare global {
// for fire event
@@ -74,7 +73,7 @@ export interface DataTableColumnData<T = any> extends DataTableSortColumnData {
title: TemplateResult | string;
label?: TemplateResult | string;
type?: "numeric" | "icon" | "icon-button" | "overflow-menu";
template?: (data: any, row: T) => TemplateResult | string | typeof nothing;
template?: (data: any, row: T) => TemplateResult | string;
width?: string;
maxWidth?: string;
grows?: boolean;
@@ -353,10 +352,13 @@ export class HaDataTable extends LitElement {
`;
}
private _renderRow = (row: DataTableRowData, index: number) => {
private _renderRow = (
row: DataTableRowData,
index: number
): TemplateResult => {
// not sure how this happens...
if (!row) {
return nothing;
return html``;
}
if (row.append) {
return html` <div class="mdc-data-table__row">${row.content}</div> `;
@@ -459,9 +461,7 @@ export class HaDataTable extends LitElement {
const elapsed = curTime - startTime;
if (elapsed < 100) {
await new Promise((resolve) => {
setTimeout(resolve, 100 - elapsed);
});
await new Promise((resolve) => setTimeout(resolve, 100 - elapsed));
}
if (this.curRequest !== curRequest) {
return;

View File

@@ -67,11 +67,11 @@ const sortData = (
}
}
// Ensure "undefined" and "null" are always sorted to the bottom
if (valA == null && valB != null) {
// Ensure "undefined" is always sorted to the bottom
if (valA === undefined && valB !== undefined) {
return 1;
}
if (valB == null && valA != null) {
if (valB === undefined && valA !== undefined) {
return -1;
}

View File

@@ -1,7 +1,7 @@
import "@material/mwc-button/mwc-button";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
@@ -230,9 +230,9 @@ export class HaAreaDevicesPicker extends SubscribeMixin(LitElement) {
}
}
protected render() {
protected render(): TemplateResult {
if (!this._devices || !this._areas || !this._entities) {
return nothing;
return html``;
}
const areas = this._getAreasWithDevices(
this._devices,

View File

@@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import {
@@ -85,9 +85,9 @@ export abstract class HaDeviceAutomationPicker<
return `${this._automations[idx].device_id}_${idx}`;
}
protected render() {
protected render(): TemplateResult {
if (this._renderEmpty) {
return nothing;
return html``;
}
const value = this._value;
return html`

View File

@@ -1,5 +1,5 @@
import "@material/mwc-list/mwc-list-item";
import { HassEntity, UnsubscribeFunc } from "home-assistant-js-websocket";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
import { customElement, property, query, state } from "lit/decorators";
@@ -37,8 +37,6 @@ export type HaDevicePickerDeviceFilterFunc = (
device: DeviceRegistryEntry
) => boolean;
export type HaDevicePickerEntityFilterFunc = (entity: HassEntity) => boolean;
const rowRenderer: ComboBoxLitRenderer<Device> = (item) => html`<mwc-list-item
.twoline=${!!item.area}
>
@@ -96,8 +94,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
@property({ type: Boolean }) public disabled?: boolean;
@property({ type: Boolean }) public required?: boolean;
@@ -117,7 +113,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
excludeDomains: this["excludeDomains"],
includeDeviceClasses: this["includeDeviceClasses"],
deviceFilter: this["deviceFilter"],
entityFilter: this["entityFilter"],
excludeDevices: this["excludeDevices"]
): Device[] => {
if (!devices.length) {
@@ -132,12 +127,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
const deviceEntityLookup: DeviceEntityLookup = {};
if (
includeDomains ||
excludeDomains ||
includeDeviceClasses ||
entityFilter
) {
if (includeDomains || excludeDomains || includeDeviceClasses) {
for (const entity of entities) {
if (!entity.device_id) {
continue;
@@ -208,22 +198,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
});
}
if (entityFilter) {
inputDevices = inputDevices.filter((device) => {
const devEntities = deviceEntityLookup[device.id];
if (!devEntities || !devEntities.length) {
return false;
}
return devEntities.some((entity) => {
const stateObj = this.hass.states[entity.entity_id];
if (!stateObj) {
return false;
}
return entityFilter(stateObj);
});
});
}
if (deviceFilter) {
inputDevices = inputDevices.filter(
(device) =>
@@ -300,7 +274,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
this.excludeDomains,
this.includeDeviceClasses,
this.deviceFilter,
this.entityFilter,
this.excludeDevices
);
}

View File

@@ -1,13 +1,10 @@
import { css, html, LitElement, nothing } from "lit";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types";
import "./ha-device-picker";
import type {
HaDevicePickerDeviceFilterFunc,
HaDevicePickerEntityFilterFunc,
} from "./ha-device-picker";
import type { HaDevicePickerDeviceFilterFunc } from "./ha-device-picker";
@customElement("ha-devices-picker")
class HaDevicesPicker extends LitElement {
@@ -47,11 +44,9 @@ class HaDevicesPicker extends LitElement {
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
@property() public entityFilter?: HaDevicePickerEntityFilterFunc;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
const currentDevices = this._currentDevices;
@@ -64,7 +59,6 @@ class HaDevicesPicker extends LitElement {
.curValue=${entityId}
.hass=${this.hass}
.deviceFilter=${this.deviceFilter}
.entityFilter=${this.entityFilter}
.includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains}
.includeDeviceClasses=${this.includeDeviceClasses}
@@ -82,10 +76,8 @@ class HaDevicesPicker extends LitElement {
.hass=${this.hass}
.helper=${this.helper}
.deviceFilter=${this.deviceFilter}
.entityFilter=${this.entityFilter}
.includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains}
.excludeDevices=${currentDevices}
.includeDeviceClasses=${this.includeDeviceClasses}
.label=${this.pickDeviceLabel}
.disabled=${this.disabled}

View File

@@ -1,5 +1,5 @@
import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, nothing } from "lit";
import { css, html, LitElement, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../common/dom/fire_event";
@@ -76,9 +76,9 @@ class HaEntitiesPickerLight extends LitElement {
@property() public entityFilter?: HaEntityPickerEntityFilterFunc;
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
const currentEntities = this._currentEntities;

View File

@@ -1,5 +1,5 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import { formatAttributeName } from "../../data/entity_attributes";
import { PolymerChangedEvent } from "../../polymer-types";
@@ -60,9 +60,9 @@ class HaEntityAttributePicker extends LitElement {
}
}
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`

View File

@@ -1,4 +1,4 @@
import "../ha-list-item";
import "@material/mwc-list/mwc-list-item";
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
@@ -24,13 +24,13 @@ export type HaEntityPickerEntityFilterFunc = (entity: HassEntity) => boolean;
// eslint-disable-next-line lit/prefer-static-styles
const rowRenderer: ComboBoxLitRenderer<HassEntityWithCachedName> = (item) =>
html`<ha-list-item graphic="avatar" .twoline=${!!item.entity_id}>
html`<mwc-list-item graphic="avatar" .twoline=${!!item.entity_id}>
${item.state
? html`<state-badge slot="graphic" .stateObj=${item}></state-badge>`
: ""}
<span>${item.friendly_name}</span>
<span slot="secondary">${item.entity_id}</span>
</ha-list-item>`;
</mwc-list-item>`;
@customElement("ha-entity-picker")
export class HaEntityPicker extends LitElement {

View File

@@ -1,14 +1,14 @@
import { HassEntity } from "home-assistant-js-websocket";
import { html, LitElement, PropertyValues, nothing } from "lit";
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import { computeStateDisplay } from "../../common/entity/compute_state_display";
import { getStates } from "../../common/entity/get_states";
import { formatAttributeValue } from "../../data/entity_attributes";
import { PolymerChangedEvent } from "../../polymer-types";
import { getStates } from "../../common/entity/get_states";
import { HomeAssistant } from "../../types";
import "../ha-combo-box";
import type { HaComboBox } from "../ha-combo-box";
import { formatAttributeValue } from "../../data/entity_attributes";
import { fireEvent } from "../../common/dom/fire_event";
export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean;
@@ -64,9 +64,9 @@ class HaEntityStatePicker extends LitElement {
}
}
protected render() {
protected render(): TemplateResult {
if (!this.hass) {
return nothing;
return html``;
}
return html`

Some files were not shown because too many files have changed in this diff Show More