diff --git a/src/common/dom/prevent_default.ts b/src/common/dom/prevent_default.ts new file mode 100644 index 000000000000..3124b2643341 --- /dev/null +++ b/src/common/dom/prevent_default.ts @@ -0,0 +1 @@ +export const preventDefault = (ev) => ev.preventDefault(); diff --git a/src/components/ha-grid-size-picker.ts b/src/components/ha-grid-size-picker.ts new file mode 100644 index 000000000000..dca2cbd2fbe1 --- /dev/null +++ b/src/components/ha-grid-size-picker.ts @@ -0,0 +1,233 @@ +import { LitElement, css, html, nothing } from "lit"; +import { customElement, property, state } from "lit/decorators"; +import "./ha-icon-button"; +import "../panels/lovelace/editor/card-editor/ha-grid-layout-slider"; + +import { mdiRestore } from "@mdi/js"; +import { styleMap } from "lit/directives/style-map"; +import { fireEvent } from "../common/dom/fire_event"; +import { HomeAssistant } from "../types"; + +type GridSizeValue = { + rows?: number; + columns?: number; +}; + +@customElement("ha-grid-size-picker") +export class HaGridSizeEditor extends LitElement { + @property({ attribute: false }) public hass!: HomeAssistant; + + @property({ attribute: false }) public value?: GridSizeValue; + + @property({ attribute: false }) public rows = 6; + + @property({ attribute: false }) public columns = 4; + + @property({ attribute: false }) public rowMin?: number; + + @property({ attribute: false }) public rowMax?: number; + + @property({ attribute: false }) public columnMin?: number; + + @property({ attribute: false }) public columnMax?: number; + + @property({ attribute: false }) public isDefault?: boolean; + + @state() public _localValue?: GridSizeValue = undefined; + + protected willUpdate(changedProperties) { + if (changedProperties.has("value")) { + this._localValue = this.value; + } + } + + protected render() { + return html` +
+ ${this.hass.localize( + `ui.panel.lovelace.editor.edit_card.layout.explanation` + )} +
+${this.hass.localize( `ui.panel.lovelace.editor.edit_card.visibility.explanation` )} -