diff --git a/build-scripts/webpack.js b/build-scripts/webpack.js index 185ef3aa65..c5d741a5af 100644 --- a/build-scripts/webpack.js +++ b/build-scripts/webpack.js @@ -3,10 +3,10 @@ const webpack = require("webpack"); const path = require("path"); const TerserPlugin = require("terser-webpack-plugin"); const { WebpackManifestPlugin } = require("webpack-manifest-plugin"); -const paths = require("./paths.js"); -const bundle = require("./bundle.js"); const log = require("fancy-log"); const WebpackBar = require("webpackbar"); +const paths = require("./paths.js"); +const bundle = require("./bundle.js"); class LogStartCompilePlugin { ignoredFirst = false; @@ -138,6 +138,8 @@ const createWebpackConfig = ({ "lit/directives/cache$": "lit/directives/cache.js", "lit/directives/repeat$": "lit/directives/repeat.js", "lit/polyfill-support$": "lit/polyfill-support.js", + "@lit-labs/virtualizer/layouts/grid": + "@lit-labs/virtualizer/layouts/grid.js", }, }, output: { diff --git a/gallery/src/pages/automation/describe-action.ts b/gallery/src/pages/automation/describe-action.ts index dd3d6c6e93..49fa3dc7f9 100644 --- a/gallery/src/pages/automation/describe-action.ts +++ b/gallery/src/pages/automation/describe-action.ts @@ -62,6 +62,45 @@ const ACTIONS = [ entity_id: "input_boolean.toggle_4", }, }, + { + parallel: [ + { scene: "scene.kitchen_morning" }, + { + service: "media_player.play_media", + target: { entity_id: "media_player.living_room" }, + data: { media_content_id: "", media_content_type: "" }, + metadata: { title: "Happy Song" }, + }, + ], + }, + { + stop: "No one is home!", + }, + { repeat: { count: 3, sequence: [{ delay: "00:00:01" }] } }, + { + repeat: { + for_each: ["bread", "butter", "cheese"], + sequence: [{ delay: "00:00:01" }], + }, + }, + { + if: [{ condition: "state" }], + then: [{ delay: "00:00:01" }], + else: [{ delay: "00:00:05" }], + }, + { + choose: [ + { + conditions: [{ condition: "state" }], + sequence: [{ delay: "00:00:01" }], + }, + { + conditions: [{ condition: "sun" }], + sequence: [{ delay: "00:00:05" }], + }, + ], + default: [{ delay: "00:00:03" }], + }, ]; @customElement("demo-automation-describe-action") diff --git a/gallery/src/pages/automation/editor-action.ts b/gallery/src/pages/automation/editor-action.ts index 1f7a0d8206..4551593c44 100644 --- a/gallery/src/pages/automation/editor-action.ts +++ b/gallery/src/pages/automation/editor-action.ts @@ -20,6 +20,10 @@ import { HaWaitForTriggerAction } from "../../../../src/panels/config/automation import { HaWaitAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-wait_template"; import { Action } from "../../../../src/data/script"; import { HaConditionAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-condition"; +import { HaParallelAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-parallel"; +import { HaIfAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-if"; +import { HaStopAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-stop"; +import { HaPlayMediaAction } from "../../../../src/panels/config/automation/action/types/ha-automation-action-play_media"; const SCHEMAS: { name: string; actions: Action[] }[] = [ { name: "Event", actions: [HaEventAction.defaultConfig] }, @@ -28,11 +32,15 @@ const SCHEMAS: { name: string; actions: Action[] }[] = [ { name: "Condition", actions: [HaConditionAction.defaultConfig] }, { name: "Delay", actions: [HaDelayAction.defaultConfig] }, { name: "Scene", actions: [HaSceneAction.defaultConfig] }, + { name: "Play media", actions: [HaPlayMediaAction.defaultConfig] }, { name: "Wait", actions: [HaWaitAction.defaultConfig] }, { name: "WaitForTrigger", actions: [HaWaitForTriggerAction.defaultConfig] }, { name: "Repeat", actions: [HaRepeatAction.defaultConfig] }, + { name: "If-Then", actions: [HaIfAction.defaultConfig] }, { name: "Choose", actions: [HaChooseAction.defaultConfig] }, { name: "Variables", actions: [{ variables: { hello: "1" } }] }, + { name: "Parallel", actions: [HaParallelAction.defaultConfig] }, + { name: "Stop", actions: [HaStopAction.defaultConfig] }, ]; @customElement("demo-automation-editor-action") @@ -86,6 +94,6 @@ class DemoHaAutomationEditorAction extends LitElement { declare global { interface HTMLElementTagNameMap { - "demo-ha-automation-editor-action": DemoHaAutomationEditorAction; + "demo-automation-editor-action": DemoHaAutomationEditorAction; } } diff --git a/gallery/src/pages/automation/editor-condition.ts b/gallery/src/pages/automation/editor-condition.ts index 77e42e6171..8f8ee17604 100644 --- a/gallery/src/pages/automation/editor-condition.ts +++ b/gallery/src/pages/automation/editor-condition.ts @@ -8,7 +8,7 @@ import { mockEntityRegistry } from "../../../../demo/src/stubs/entity_registry"; import { mockDeviceRegistry } from "../../../../demo/src/stubs/device_registry"; import { mockAreaRegistry } from "../../../../demo/src/stubs/area_registry"; import { mockHassioSupervisor } from "../../../../demo/src/stubs/hassio_supervisor"; -import type { Condition } from "../../../../src/data/automation"; +import type { ConditionWithShorthand } from "../../../../src/data/automation"; import "../../../../src/panels/config/automation/condition/ha-automation-condition"; import { HaDeviceCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-device"; import { HaLogicalCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-logical"; @@ -20,7 +20,7 @@ import { HaTimeCondition } from "../../../../src/panels/config/automation/condit import { HaTriggerCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-trigger"; import { HaZoneCondition } from "../../../../src/panels/config/automation/condition/types/ha-automation-condition-zone"; -const SCHEMAS: { name: string; conditions: Condition[] }[] = [ +const SCHEMAS: { name: string; conditions: ConditionWithShorthand[] }[] = [ { name: "State", conditions: [{ condition: "state", ...HaStateCondition.defaultConfig }], @@ -69,6 +69,14 @@ const SCHEMAS: { name: string; conditions: Condition[] }[] = [ name: "Trigger", conditions: [{ condition: "trigger", ...HaTriggerCondition.defaultConfig }], }, + { + name: "Shorthand", + conditions: [ + { and: HaLogicalCondition.defaultConfig.conditions }, + { or: HaLogicalCondition.defaultConfig.conditions }, + { not: HaLogicalCondition.defaultConfig.conditions }, + ], + }, ]; @customElement("demo-automation-editor-condition") diff --git a/gallery/src/pages/components/ha-alert.ts b/gallery/src/pages/components/ha-alert.ts index c4f44e80a9..ced4c5a44b 100644 --- a/gallery/src/pages/components/ha-alert.ts +++ b/gallery/src/pages/components/ha-alert.ts @@ -159,13 +159,19 @@ export class DemoHaAlert extends LitElement { firstUpdated(changedProps) { super.firstUpdated(changedProps); - applyThemesOnElement(this.shadowRoot!.querySelector(".dark"), { - default_theme: "default", - default_dark_theme: "default", - themes: {}, - darkMode: true, - theme: "default", - }); + applyThemesOnElement( + this.shadowRoot!.querySelector(".dark"), + { + default_theme: "default", + default_dark_theme: "default", + themes: {}, + darkMode: true, + theme: "default", + }, + undefined, + undefined, + true + ); } static get styles() { diff --git a/gallery/src/pages/components/ha-selector.ts b/gallery/src/pages/components/ha-selector.ts index 972c7d7f26..6ce04e0995 100644 --- a/gallery/src/pages/components/ha-selector.ts +++ b/gallery/src/pages/components/ha-selector.ts @@ -170,6 +170,7 @@ const SCHEMAS: { select: { options: ["Option 1", "Option 2"], mode: "list" }, }, }, + template: { name: "Template", selector: { template: {} } }, select: { name: "Select", selector: { diff --git a/gallery/src/pages/components/ha-tip.markdown b/gallery/src/pages/components/ha-tip.markdown new file mode 100644 index 0000000000..a3bc162733 --- /dev/null +++ b/gallery/src/pages/components/ha-tip.markdown @@ -0,0 +1,3 @@ +--- +title: Tips +--- diff --git a/gallery/src/pages/components/ha-tip.ts b/gallery/src/pages/components/ha-tip.ts new file mode 100644 index 0000000000..49fa1f2c71 --- /dev/null +++ b/gallery/src/pages/components/ha-tip.ts @@ -0,0 +1,73 @@ +import { html, css, LitElement, TemplateResult } from "lit"; +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"; + +const tips: (string | TemplateResult)[] = [ + "Test tip", + "Bigger test tip, with some random text just to fill up as much space as possible without it looking like I'm really trying to to that", + html`Tip with HTML`, +]; + +@customElement("demo-components-ha-tip") +export class DemoHaTip extends LitElement { + protected render(): TemplateResult { + return html` ${["light", "dark"].map( + (mode) => html` +
+ ${this.supervisor.localize( + "addon.configuration.network.introduction" + )} +
${this._error ? html`- ${this.supervisor.localize( - "addon.configuration.network.container" - )} - | -- ${this.supervisor.localize( - "addon.configuration.network.host" - )} - | -${this.supervisor.localize("common.description")} | -
---|---|---|
${item.container} | -
- |
- ${this._computeDescription(item)} | -