-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
types.ts
88 lines (76 loc) · 2.41 KB
/
types.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
import { ActionConfig, LovelaceCard } from "custom-card-helpers";
import { HapticType } from "custom-card-helpers/src/haptic";
import { BaseActionConfig } from "custom-card-helpers/src/types";
declare global {
interface HTMLElementTagNameMap {
"hui-error-card": LovelaceCard;
}
const __NAME__: string;
const __BRANCH__: string;
const __COMMIT__: string;
const __VERSION__: string;
const __REPO_URL__: string;
const __BUILD_TIME__: string;
}
export interface TemplateConfig {
entity?: string;
attribute?: string;
prefix?: string;
postfix?: string;
case?: "upper" | "lower" | "first";
}
export type Template = string | TemplateConfig;
export type StyleConfig = Partial<
Record<
"button" | "icon" | "name" | "state" | "ripple",
Record<string, string | Template>
>
>;
export interface ButtonConfig {
entity?: string;
name?: string | false | Template;
state?: string | Template;
icon?: string | Template;
image?: string | Template;
layout?: Array<string | Array<string>>;
align_icon?: "top" | "left" | "right" | "bottom"; // deprecated
tooltip?: string | false;
tap_action?: ButtonActionConfig;
hold_action?: ButtonActionConfig;
double_tap_action?: ButtonActionConfig;
styles: StyleConfig;
state_styles?: Record<string, StyleConfig>;
state_icons?: Record<string, string>;
state_text?: Record<string, string>;
}
export interface PaperButtonRowConfig {
type?: string;
buttons: ButtonConfig[][];
align_icons?: "top" | "left" | "right" | "bottom";
base_config?: ButtonConfig;
styles: Record<string, string | Template>;
extra_styles?: string;
position?: "center" | "right";
hide_badge?: boolean;
hide_state?: boolean;
}
export interface ExternalButtonConfig
extends Omit<ButtonConfig, "layout" | "style" | "styles"> {
layout?: string | Array<string | Array<string>>;
style?: StyleConfig;
styles?: StyleConfig;
}
export type ExternalButtonType = string | ExternalButtonConfig;
export interface ExternalPaperButtonRowConfig
extends Omit<PaperButtonRowConfig, "buttons" | "styles"> {
buttons: Array<ExternalButtonType | Array<ExternalButtonType>>;
styles?: Record<string, string | Template>;
}
export interface FireEventActionConfig extends BaseActionConfig {
action: "fire-event";
event_type: string;
event_data?: Record<string, unknown>;
repeat?: number;
haptic?: HapticType;
}
export type ButtonActionConfig = ActionConfig | FireEventActionConfig;