Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240903.1 #21865

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
env:
IS_TEST: "true"
- name: Upload bundle stats
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: frontend-bundle-stats
path: build/stats/*.json
Expand All @@ -113,7 +113,7 @@ jobs:
env:
IS_TEST: "true"
- name: Upload bundle stats
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: supervisor-bundle-stats
path: build/stats/*.json
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ jobs:
run: tar -czvf translations.tar.gz translations

- name: Upload build artifacts
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: wheels
path: dist/home_assistant_frontend*.whl
if-no-files-found: error

- name: Upload translations
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: translations
path: translations.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions gallery/src/pages/misc/ha-markdown.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: Markdown
---
93 changes: 93 additions & 0 deletions gallery/src/pages/misc/ha-markdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { css, html, LitElement } from "lit";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-markdown";

import { customElement } from "lit/decorators";

interface MarkdownContent {
content: string;
breaks: boolean;
allowSvg: boolean;
lazyImages: boolean;
}

const mdContentwithDefaults = (md: Partial<MarkdownContent>) =>
({
breaks: false,
allowSvg: false,
lazyImages: false,
...md,
}) as MarkdownContent;

const generateContent = (md) => `
\`\`\`json
${JSON.stringify({ ...md, content: undefined })}
\`\`\`

---

${md.content}
`;

const markdownContents: MarkdownContent[] = [
mdContentwithDefaults({
content: "_Hello_ **there** 👋, ~~nice~~ of you ||to|| show up.",
}),
...[true, false].map((breaks) =>
mdContentwithDefaults({
breaks,
content: `
![image](https://img.shields.io/badge/markdown-rendering-brightgreen)
![image](https://img.shields.io/badge/markdown-rendering-blue)

> [!TIP]
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dictum quis ante eu eleifend. Integer sed [consectetur est, nec elementum magna](#). Fusce lobortis lectus ac rutrum tincidunt. Quisque suscipit gravida ante, in convallis risus vulputate non.

key | description
-- | --
lorem | ipsum

- list item 1
- list item 2


`,
})
),
];

@customElement("demo-misc-ha-markdown")
export class DemoMiscMarkdown extends LitElement {
protected render() {
return html`
<div class="container">
${markdownContents.map(
(md) =>
html`<ha-card>
<ha-markdown
.content=${generateContent(md)}
.breaks=${md.breaks}
.allowSvg=${md.allowSvg}
.lazyImages=${md.lazyImages}
></ha-markdown>
</ha-card>`
)}
</div>
`;
}

static get styles() {
return css`
ha-card {
margin: 12px;
padding: 12px;
}
`;
}
}

declare global {
interface HTMLElementTagNameMap {
"demo-misc-ha-markdown": DemoMiscMarkdown;
}
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@babel/runtime": "7.25.4",
"@babel/runtime": "7.25.6",
"@braintree/sanitize-url": "7.1.0",
"@codemirror/autocomplete": "6.18.0",
"@codemirror/commands": "6.6.0",
Expand Down Expand Up @@ -88,8 +88,8 @@
"@polymer/paper-tabs": "3.1.0",
"@polymer/polymer": "3.5.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.4.6",
"@vaadin/vaadin-themable-mixin": "24.4.6",
"@vaadin/combo-box": "24.4.7",
"@vaadin/vaadin-themable-mixin": "24.4.7",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
Expand Down Expand Up @@ -118,7 +118,7 @@
"leaflet-draw": "1.0.4",
"lit": "2.8.0",
"luxon": "3.5.0",
"marked": "14.0.0",
"marked": "14.1.0",
"memoize-one": "6.0.0",
"node-vibrant": "3.2.1-alpha.1",
"proxy-polyfill": "0.3.2",
Expand Down Expand Up @@ -155,7 +155,7 @@
"@babel/plugin-transform-runtime": "7.25.4",
"@babel/preset-env": "7.25.4",
"@babel/preset-typescript": "7.24.7",
"@bundle-stats/plugin-webpack-filter": "4.14.2",
"@bundle-stats/plugin-webpack-filter": "4.15.0",
"@koa/cors": "5.0.0",
"@lokalise/node-api": "12.7.0",
"@octokit/auth-oauth-device": "7.1.1",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20240829.0"
version = "20240903.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
20 changes: 19 additions & 1 deletion src/components/ha-markdown-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,25 @@ class HaMarkdownElement extends ReactiveElement {

haAlertNode.append(
...Array.from(node.childNodes)
.map((child) => Array.from(child.childNodes))
.map((child) => {
const arr = Array.from(child.childNodes);
if (!this.breaks && arr.length) {
// When we are not breaking, the first line of the blockquote is not considered,
// so we need to adjust the first child text content
const firstChild = arr[0];
if (
firstChild.nodeType === Node.TEXT_NODE &&
firstChild.textContent === gitHubAlertMatch.input &&
firstChild.textContent?.includes("\n")
) {
firstChild.textContent = firstChild.textContent
.split("\n")
.slice(1)
.join("\n");
}
}
return arr;
})
.reduce((acc, val) => acc.concat(val), [])
.filter(
(childNode) =>
Expand Down
1 change: 1 addition & 0 deletions src/components/ha-selector/ha-selector-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class HaTextSelector extends LitElement {
.disabled=${this.disabled}
.type=${this._unmaskedPassword ? "text" : this.selector.text?.type}
@input=${this._handleChange}
@change=${this._handleChange}
.label=${this.label || ""}
.prefix=${this.selector.text?.prefix}
.suffix=${this.selector.text?.type === "password"
Expand Down
1 change: 1 addition & 0 deletions src/data/lovelace/config/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface LovelaceBaseSectionConfig {
title?: string;
visibility?: Condition[];
column_span?: number;
row_span?: number;
}

export interface LovelaceSectionConfig extends LovelaceBaseSectionConfig {
Expand Down
6 changes: 6 additions & 0 deletions src/data/script_i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ const tryDescribeAction = <T extends ActionType>(
targets.push(
computeEntityRegistryName(hass, entityReg) || targetThing
);
} else if (targetThing === "all") {
targets.push(
hass.localize(
`${actionTranslationBaseKey}.service.description.target_every_entity`
)
);
} else {
targets.push(
hass.localize(
Expand Down
2 changes: 1 addition & 1 deletion src/panels/lovelace/badges/hui-entity-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class HuiEntityBadge extends LitElement implements LovelaceBadge {
.badge.no-info {
padding: 0;
}
.badge:not(.no-icon) img {
.badge:not(.no-icon):not(.no-info) img {
margin-left: -6px;
margin-inline-start: -6px;
margin-inline-end: initial;
Expand Down
43 changes: 5 additions & 38 deletions src/panels/lovelace/sections/hui-grid-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
private _cardConfigKeys = new WeakMap<LovelaceCardConfig, string>();

private _getKey(cardConfig: LovelaceCardConfig) {
if (!this._cardConfigKeys.has(cardConfig)) {
if (
!this._cardConfigKeys.has(cardConfig) &&
typeof cardConfig === "object"
) {
this._cardConfigKeys.set(cardConfig, Math.random().toString());
}
return this._cardConfigKeys.get(cardConfig)!;
Expand All @@ -62,20 +65,6 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
const editMode = Boolean(this.lovelace?.editMode && !this.isStrategy);

return html`
${this._config.title || this.lovelace?.editMode
? html`
<h2
class="title ${classMap({
placeholder: !this._config.title,
})}"
>
${this._config.title ||
this.hass.localize(
"ui.panel.lovelace.editor.section.unnamed_section"
)}
</h2>
`
: nothing}
<ha-sortable
.disabled=${!editMode}
@item-moved=${this._cardMoved}
Expand Down Expand Up @@ -203,33 +192,11 @@ export class GridSection extends LitElement implements LovelaceSectionElement {
.container.edit-mode {
padding: 8px;
border-radius: var(--ha-card-border-radius, 12px);
border-start-end-radius: 0px;
border: 2px dashed var(--divider-color);
min-height: var(--row-height);
}

.title {
color: var(--primary-text-color);
font-size: 20px;
font-weight: normal;
margin: 0px;
letter-spacing: 0.1px;
line-height: 32px;
text-align: var(--ha-view-sections-title-text-align, start);
min-height: 32px;
display: block;
height: var(--row-height);
box-sizing: border-box;
padding: 0 10px 10px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}

.title.placeholder {
color: var(--secondary-text-color);
font-style: italic;
}

.card {
border-radius: var(--ha-card-border-radius, 12px);
position: relative;
Expand Down
Loading
Loading