-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Copy pathcreate-row-element.ts
116 lines (113 loc) · 4.17 KB
/
create-row-element.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import "../entity-rows/hui-event-entity-row";
import "../entity-rows/hui-media-player-entity-row";
import "../entity-rows/hui-scene-entity-row";
import "../entity-rows/hui-script-entity-row";
import "../entity-rows/hui-sensor-entity-row";
import "../entity-rows/hui-simple-entity-row";
import "../entity-rows/hui-toggle-entity-row";
import type { LovelaceRowConfig } from "../entity-rows/types";
import "../special-rows/hui-attribute-row";
import "../special-rows/hui-button-row";
import "../special-rows/hui-call-service-row";
import {
createLovelaceElement,
getLovelaceElementClass,
} from "./create-element-base";
const ALWAYS_LOADED_TYPES = new Set([
"media-player-entity",
"scene-entity",
"script-entity",
"sensor-entity",
"simple-entity",
"toggle-entity",
"button",
"call-service",
]);
const LAZY_LOAD_TYPES = {
"button-entity": () => import("../entity-rows/hui-button-entity-row"),
"climate-entity": () => import("../entity-rows/hui-climate-entity-row"),
"cover-entity": () => import("../entity-rows/hui-cover-entity-row"),
"date-entity": () => import("../entity-rows/hui-date-entity-row"),
"datetime-entity": () => import("../entity-rows/hui-datetime-entity-row"),
"event-entity": () => import("../entity-rows/hui-event-entity-row"),
"group-entity": () => import("../entity-rows/hui-group-entity-row"),
"input-button-entity": () =>
import("../entity-rows/hui-input-button-entity-row"),
"humidifier-entity": () => import("../entity-rows/hui-humidifier-entity-row"),
"input-datetime-entity": () =>
import("../entity-rows/hui-input-datetime-entity-row"),
"input-number-entity": () =>
import("../entity-rows/hui-input-number-entity-row"),
"input-select-entity": () =>
import("../entity-rows/hui-input-select-entity-row"),
"input-text-entity": () => import("../entity-rows/hui-input-text-entity-row"),
"lock-entity": () => import("../entity-rows/hui-lock-entity-row"),
"number-entity": () => import("../entity-rows/hui-number-entity-row"),
"select-entity": () => import("../entity-rows/hui-select-entity-row"),
"text-entity": () => import("../entity-rows/hui-text-entity-row"),
"time-entity": () => import("../entity-rows/hui-time-entity-row"),
"timer-entity": () => import("../entity-rows/hui-timer-entity-row"),
"update-entity": () => import("../entity-rows/hui-update-entity-row"),
"valve-entity": () => import("../entity-rows/hui-valve-entity-row"),
conditional: () => import("../special-rows/hui-conditional-row"),
"weather-entity": () => import("../entity-rows/hui-weather-entity-row"),
divider: () => import("../special-rows/hui-divider-row"),
section: () => import("../special-rows/hui-section-row"),
weblink: () => import("../special-rows/hui-weblink-row"),
cast: () => import("../special-rows/hui-cast-row"),
buttons: () => import("../special-rows/hui-buttons-row"),
attribute: () => import("../special-rows/hui-attribute-row"),
text: () => import("../special-rows/hui-text-row"),
};
const DOMAIN_TO_ELEMENT_TYPE = {
_domain_not_found: "simple",
alert: "toggle",
automation: "toggle",
button: "button",
climate: "climate",
cover: "cover",
date: "date",
datetime: "datetime",
event: "event",
fan: "toggle",
group: "group",
humidifier: "humidifier",
input_boolean: "toggle",
input_button: "input-button",
input_datetime: "input-datetime",
input_number: "input-number",
input_select: "input-select",
input_text: "input-text",
light: "toggle",
lock: "lock",
media_player: "media-player",
number: "number",
remote: "toggle",
scene: "scene",
script: "script",
select: "select",
sensor: "sensor",
siren: "toggle",
switch: "toggle",
text: "text",
time: "time",
timer: "timer",
update: "update",
vacuum: "toggle",
valve: "valve",
// Temporary. Once climate is rewritten,
// water heater should get its own row.
water_heater: "climate",
weather: "weather",
};
export const createRowElement = (config: LovelaceRowConfig) =>
createLovelaceElement(
"row",
config,
ALWAYS_LOADED_TYPES,
LAZY_LOAD_TYPES,
DOMAIN_TO_ELEMENT_TYPE,
undefined
);
export const getRowElementClass = (type: string) =>
getLovelaceElementClass(type, "row", ALWAYS_LOADED_TYPES, LAZY_LOAD_TYPES);