Remove ondemand methods for CodeMirror and SortableJS (#18336)
This commit is contained in:
parent
b24e99c56c
commit
77e05decdf
|
@ -12,7 +12,6 @@ import { customElement, property, state } from "lit/decorators";
|
|||
import memoizeOne from "memoize-one";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { stopPropagation } from "../common/dom/stop_propagation";
|
||||
import { CodeMirror, loadCodeMirror } from "../resources/codemirror.ondemand";
|
||||
import { HomeAssistant } from "../types";
|
||||
import "./ha-icon";
|
||||
|
||||
|
@ -58,7 +57,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||
|
||||
@state() private _value = "";
|
||||
|
||||
private _loadedCodeMirror?: CodeMirror;
|
||||
private _loadedCodeMirror?: typeof import("../resources/codemirror");
|
||||
|
||||
private _iconList?: Completion[];
|
||||
|
||||
|
@ -110,7 +109,7 @@ export class HaCodeEditor extends ReactiveElement {
|
|||
|
||||
// Ensure CodeMirror module is loaded before any update
|
||||
protected override async scheduleUpdate() {
|
||||
this._loadedCodeMirror ??= await loadCodeMirror();
|
||||
this._loadedCodeMirror ??= await import("../resources/codemirror");
|
||||
super.scheduleUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ import { subscribeRepairsIssueRegistry } from "../data/repairs";
|
|||
import { UpdateEntity, updateCanInstall } from "../data/update";
|
||||
import { SubscribeMixin } from "../mixins/subscribe-mixin";
|
||||
import { actionHandler } from "../panels/lovelace/common/directives/action-handler-directive";
|
||||
import { SortableInstance, loadSortable } from "../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../resources/sortable";
|
||||
import { haStyleScrollbar } from "../resources/styles";
|
||||
import type { HomeAssistant, PanelInfo, Route } from "../types";
|
||||
import "./ha-icon";
|
||||
|
@ -689,7 +689,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.getElementById("sortable")!,
|
||||
{
|
||||
|
|
|
@ -24,10 +24,7 @@ import {
|
|||
computeDefaultFavoriteColors,
|
||||
} from "../../../../data/light";
|
||||
import { actionHandler } from "../../../../panels/lovelace/common/directives/action-handler-directive";
|
||||
import {
|
||||
SortableInstance,
|
||||
loadSortable,
|
||||
} from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { showConfirmationDialog } from "../../../generic/show-dialog-box";
|
||||
import "./ha-favorite-color-button";
|
||||
|
@ -73,7 +70,7 @@ export class HaMoreInfoLightFavoriteColors extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".container")!,
|
||||
{
|
||||
|
|
|
@ -32,10 +32,7 @@ import { ACTION_TYPES } from "../../../../data/action";
|
|||
import { AutomationClipboard } from "../../../../data/automation";
|
||||
import { Action } from "../../../../data/script";
|
||||
import { sortableStyles } from "../../../../resources/ha-sortable-style";
|
||||
import {
|
||||
SortableInstance,
|
||||
loadSortable,
|
||||
} from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
import { Entries, HomeAssistant } from "../../../../types";
|
||||
import type HaAutomationActionRow from "./ha-automation-action-row";
|
||||
import { getType } from "./ha-automation-action-row";
|
||||
|
@ -227,7 +224,7 @@ export default class HaAutomationAction extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(this.shadowRoot!.querySelector(".actions")!, {
|
||||
animation: 150,
|
||||
fallbackClass: "sortable-fallback",
|
||||
|
|
|
@ -16,10 +16,7 @@ import { CSSResultGroup, LitElement, PropertyValues, css, html } from "lit";
|
|||
import { customElement, property, state } from "lit/decorators";
|
||||
import { repeat } from "lit/directives/repeat";
|
||||
import type { ActionDetail } from "@material/mwc-list";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../../resources/sortable";
|
||||
import { ensureArray } from "../../../../../common/array/ensure-array";
|
||||
import { fireEvent } from "../../../../../common/dom/fire_event";
|
||||
import { capitalizeFirstLetter } from "../../../../../common/string/capitalize-first-letter";
|
||||
|
@ -481,7 +478,8 @@ export class HaChooseAction extends LitElement implements ActionElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../../resources/sortable"))
|
||||
.default;
|
||||
this._sortable = new Sortable(this.shadowRoot!.querySelector(".options")!, {
|
||||
animation: 150,
|
||||
fallbackClass: "sortable-fallback",
|
||||
|
|
|
@ -40,10 +40,7 @@ import type { LocalizeFunc } from "../../../../common/translations/localize";
|
|||
import type { HaSelect } from "../../../../components/ha-select";
|
||||
import { CONDITION_TYPES } from "../../../../data/condition";
|
||||
import { sortableStyles } from "../../../../resources/ha-sortable-style";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
import "./types/ha-automation-condition-and";
|
||||
import "./types/ha-automation-condition-device";
|
||||
import "./types/ha-automation-condition-numeric_state";
|
||||
|
@ -248,7 +245,7 @@ export default class HaAutomationCondition extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".conditions")!,
|
||||
{
|
||||
|
|
|
@ -31,8 +31,7 @@ import "../../../../components/ha-svg-icon";
|
|||
import { AutomationClipboard, Trigger } from "../../../../data/automation";
|
||||
import { TRIGGER_TYPES } from "../../../../data/trigger";
|
||||
import { sortableStyles } from "../../../../resources/ha-sortable-style";
|
||||
import { SortableInstance } from "../../../../resources/sortable";
|
||||
import { loadSortable } from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
import { Entries, HomeAssistant } from "../../../../types";
|
||||
import "./ha-automation-trigger-row";
|
||||
import type HaAutomationTriggerRow from "./ha-automation-trigger-row";
|
||||
|
@ -225,7 +224,7 @@ export default class HaAutomationTrigger extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".triggers")!,
|
||||
{
|
||||
|
|
|
@ -16,10 +16,7 @@ import type { InputSelect } from "../../../../data/input_select";
|
|||
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
|
||||
import { haStyle } from "../../../../resources/styles";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
|
||||
@customElement("ha-input_select-form")
|
||||
class HaInputSelectForm extends LitElement {
|
||||
|
@ -50,7 +47,7 @@ class HaInputSelectForm extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(this.shadowRoot!.querySelector(".options")!, {
|
||||
animation: 150,
|
||||
fallbackClass: "sortable-fallback",
|
||||
|
|
|
@ -28,10 +28,7 @@ import {
|
|||
updateItem,
|
||||
} from "../../../data/shopping-list";
|
||||
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../resources/sortable";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { LovelaceCard, LovelaceCardEditor } from "../types";
|
||||
import { SensorCardConfig, ShoppingListCardConfig } from "./types";
|
||||
|
@ -318,7 +315,7 @@ class HuiShoppingListCard
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../resources/sortable")).default;
|
||||
const sortableEl = this._sortableEl;
|
||||
this._sortable = new Sortable(sortableEl!, {
|
||||
animation: 150,
|
||||
|
|
|
@ -11,10 +11,7 @@ import type {
|
|||
} from "../../../components/entity/ha-entity-picker";
|
||||
import "../../../components/ha-icon-button";
|
||||
import { sortableStyles } from "../../../resources/ha-sortable-style";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../resources/sortable";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { EntityConfig } from "../entity-rows/types";
|
||||
|
||||
|
@ -93,7 +90,7 @@ export class HuiEntityEditor extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".entities")!,
|
||||
{
|
||||
|
|
|
@ -19,10 +19,7 @@ import {
|
|||
stripCustomPrefix,
|
||||
} from "../../../../data/lovelace_custom_cards";
|
||||
import { sortableStyles } from "../../../../resources/ha-sortable-style";
|
||||
import {
|
||||
SortableInstance,
|
||||
loadSortable,
|
||||
} from "../../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../../resources/sortable";
|
||||
import { HomeAssistant } from "../../../../types";
|
||||
import { getTileFeatureElementClass } from "../../create-element/create-tile-feature-element";
|
||||
import { supportsAlarmModesTileFeature } from "../../tile-features/hui-alarm-modes-tile-feature";
|
||||
|
@ -321,7 +318,7 @@ export class HuiTileCardFeaturesEditor extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".features")!,
|
||||
{
|
||||
|
|
|
@ -9,10 +9,7 @@ import type { HaEntityPicker } from "../../../components/entity/ha-entity-picker
|
|||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { sortableStyles } from "../../../resources/ha-sortable-style";
|
||||
import {
|
||||
loadSortable,
|
||||
SortableInstance,
|
||||
} from "../../../resources/sortable.ondemand";
|
||||
import type { SortableInstance } from "../../../resources/sortable";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { EntityConfig, LovelaceRowConfig } from "../entity-rows/types";
|
||||
|
||||
|
@ -134,7 +131,7 @@ export class HuiEntitiesCardRowEditor extends LitElement {
|
|||
}
|
||||
|
||||
private async _createSortable() {
|
||||
const Sortable = await loadSortable();
|
||||
const Sortable = (await import("../../../resources/sortable")).default;
|
||||
this._sortable = new Sortable(
|
||||
this.shadowRoot!.querySelector(".entities")!,
|
||||
{
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
export type CodeMirror = typeof import("./codemirror");
|
||||
|
||||
let loaded: CodeMirror;
|
||||
|
||||
export const loadCodeMirror = async () => {
|
||||
loaded ??= await import("./codemirror");
|
||||
return loaded;
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
let loaded: typeof import("./sortable").default;
|
||||
|
||||
export type { SortableInstance } from "./sortable";
|
||||
export const loadSortable = async (): Promise<
|
||||
typeof import("./sortable").default
|
||||
> => {
|
||||
if (!loaded) {
|
||||
loaded = (await import("./sortable")).default;
|
||||
}
|
||||
return loaded;
|
||||
};
|
Loading…
Reference in New Issue