glimpse-sdk 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -30
- package/dist/src/app.d.ts +16 -12
- package/dist/src/app.js +83 -7
- package/dist/src/events.d.ts +1 -1
- package/dist/src/events.js +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +4 -4
- package/dist/src/protocol.d.ts +10 -15
- package/dist/src/protocol.js +15 -18
- package/dist/src/widgets.d.ts +415 -256
- package/dist/src/widgets.js +396 -457
- package/package.json +1 -1
- package/src/app.ts +94 -17
- package/src/events.ts +2 -2
- package/src/index.ts +39 -36
- package/src/protocol.ts +18 -23
- package/src/widgets.ts +365 -794
package/dist/src/widgets.js
CHANGED
|
@@ -1,680 +1,619 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
payload.tooltip = props.tooltip;
|
|
16
|
-
if (props.variant !== undefined)
|
|
17
|
-
payload.variant = props.variant;
|
|
18
|
-
return payload;
|
|
19
|
-
}
|
|
20
|
-
class WidgetBase {
|
|
1
|
+
export class InlineHandlerRegistry {
|
|
2
|
+
handlers = new Map();
|
|
3
|
+
generatedId(event, path) {
|
|
4
|
+
const suffix = path.length === 0 ? "root" : path.join(".");
|
|
5
|
+
return `__glimpse:${event}:${suffix}`;
|
|
6
|
+
}
|
|
7
|
+
targetId(event, id, path) {
|
|
8
|
+
return id ?? this.generatedId(event, path);
|
|
9
|
+
}
|
|
10
|
+
add(event, id, handler) {
|
|
11
|
+
this.handlers.set(`${event}:${id}`, handler);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class WidgetBase {
|
|
21
15
|
common;
|
|
22
16
|
constructor(common = {}) {
|
|
23
17
|
this.common = common;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
bindHandlers(_registry, _path) { }
|
|
20
|
+
toProtocol() {
|
|
21
|
+
return { type: this.type, data: this.data() };
|
|
22
|
+
}
|
|
23
|
+
commonData() {
|
|
24
|
+
const out = {};
|
|
25
|
+
if (this.common.visible !== undefined)
|
|
26
|
+
out.visible = this.common.visible;
|
|
27
|
+
if (this.common.tooltip !== undefined)
|
|
28
|
+
out.tooltip = this.common.tooltip;
|
|
29
|
+
if (this.common.css_classes?.length)
|
|
30
|
+
out.css_classes = this.common.css_classes;
|
|
31
|
+
if (this.common.styles && Object.keys(this.common.styles).length > 0)
|
|
32
|
+
out.styles = this.common.styles;
|
|
33
|
+
return out;
|
|
27
34
|
}
|
|
28
35
|
}
|
|
36
|
+
const child = (node) => node?.toProtocol();
|
|
37
|
+
const children = (nodes) => nodes.map((node) => node.toProtocol());
|
|
29
38
|
export class Label extends WidgetBase {
|
|
30
|
-
|
|
39
|
+
type = "label";
|
|
31
40
|
options;
|
|
32
|
-
constructor(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.options =
|
|
41
|
+
constructor(options) {
|
|
42
|
+
const normalized = typeof options === "string" ? { label: options } : options;
|
|
43
|
+
super(normalized);
|
|
44
|
+
this.options = normalized;
|
|
36
45
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (this.options.wrap !== undefined)
|
|
40
|
-
payload.wrap = this.options.wrap;
|
|
46
|
+
data() {
|
|
47
|
+
const out = { ...this.commonData(), label: this.options.label };
|
|
41
48
|
if (this.options.xalign !== undefined)
|
|
42
|
-
|
|
43
|
-
if (this.options.
|
|
44
|
-
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export class Image extends WidgetBase {
|
|
49
|
-
icon;
|
|
50
|
-
options;
|
|
51
|
-
constructor(icon, options = {}) {
|
|
52
|
-
super(options);
|
|
53
|
-
this.icon = icon;
|
|
54
|
-
this.options = options;
|
|
55
|
-
}
|
|
56
|
-
toProtocol() {
|
|
57
|
-
const payload = this.withCommon({ icon: this.icon.toProtocol() });
|
|
58
|
-
if (this.options.pixel_size !== undefined)
|
|
59
|
-
payload.pixel_size = this.options.pixel_size;
|
|
60
|
-
return { type: "image", data: payload };
|
|
49
|
+
out.xalign = this.options.xalign;
|
|
50
|
+
if (this.options.wrap !== undefined)
|
|
51
|
+
out.wrap = this.options.wrap;
|
|
52
|
+
return out;
|
|
61
53
|
}
|
|
62
54
|
}
|
|
63
|
-
export class
|
|
55
|
+
export class Header extends WidgetBase {
|
|
64
56
|
options;
|
|
57
|
+
type = "header";
|
|
65
58
|
constructor(options) {
|
|
66
59
|
super(options);
|
|
67
60
|
this.options = options;
|
|
68
61
|
}
|
|
69
|
-
|
|
70
|
-
const payload = this.withCommon({
|
|
71
|
-
value: this.options.value,
|
|
72
|
-
max: this.options.max ?? 1,
|
|
73
|
-
});
|
|
74
|
-
if (this.options.show_text !== undefined)
|
|
75
|
-
payload.show_text = this.options.show_text;
|
|
76
|
-
if (this.options.text !== undefined)
|
|
77
|
-
payload.text = this.options.text;
|
|
78
|
-
return { type: "progress", data: payload };
|
|
79
|
-
}
|
|
62
|
+
data() { return { ...this.commonData(), label: this.options.label }; }
|
|
80
63
|
}
|
|
81
|
-
export class
|
|
64
|
+
export class Hero extends WidgetBase {
|
|
82
65
|
options;
|
|
66
|
+
type = "hero";
|
|
83
67
|
constructor(options) {
|
|
84
68
|
super(options);
|
|
85
69
|
this.options = options;
|
|
86
70
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
71
|
+
data() {
|
|
72
|
+
const out = { ...this.commonData(), title: this.options.title, subtitle: this.options.subtitle ?? "" };
|
|
73
|
+
for (const key of ["id", "icon", "icon_size", "toggle", "toggle_sensitive", "separator"]) {
|
|
74
|
+
if (this.options[key] !== undefined)
|
|
75
|
+
out[key] = this.options[key];
|
|
76
|
+
}
|
|
77
|
+
const trailing = child(this.options.trailing);
|
|
78
|
+
if (trailing)
|
|
79
|
+
out.trailing = trailing;
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
bindHandlers(registry, path) {
|
|
83
|
+
if (this.options.on_toggle) {
|
|
84
|
+
this.options.id = registry.targetId("toggle", this.options.id, path);
|
|
85
|
+
registry.add("toggle", this.options.id, this.options.on_toggle);
|
|
86
|
+
}
|
|
87
|
+
this.options.trailing?.bindHandlers(registry, [...path, 0]);
|
|
97
88
|
}
|
|
98
89
|
}
|
|
99
|
-
export class
|
|
90
|
+
export class Badge extends WidgetBase {
|
|
100
91
|
options;
|
|
92
|
+
type = "badge";
|
|
101
93
|
constructor(options) {
|
|
102
94
|
super(options);
|
|
103
95
|
this.options = options;
|
|
104
96
|
}
|
|
105
|
-
|
|
106
|
-
const payload = this.withCommon({ path: this.options.path });
|
|
107
|
-
if (this.options.content_fit !== undefined)
|
|
108
|
-
payload.content_fit = this.options.content_fit;
|
|
109
|
-
return { type: "picture", data: payload };
|
|
110
|
-
}
|
|
97
|
+
data() { return { ...this.commonData(), label: this.options.label, kind: this.options.kind ?? "default" }; }
|
|
111
98
|
}
|
|
112
|
-
export class
|
|
99
|
+
export class StatusDot extends WidgetBase {
|
|
113
100
|
options;
|
|
101
|
+
type = "status_dot";
|
|
114
102
|
constructor(options = {}) {
|
|
115
|
-
const { variant: _variant, ...common } = options;
|
|
116
|
-
super(common);
|
|
117
|
-
this.options = options;
|
|
118
|
-
}
|
|
119
|
-
toProtocol() {
|
|
120
|
-
const { variant, ...common } = this.options;
|
|
121
|
-
const payload = applyCommonProps({}, common);
|
|
122
|
-
if (this.options.label !== undefined)
|
|
123
|
-
payload.label = this.options.label;
|
|
124
|
-
if (this.options.icon !== undefined)
|
|
125
|
-
payload.icon = this.options.icon;
|
|
126
|
-
if (this.options.enabled !== undefined)
|
|
127
|
-
payload.enabled = this.options.enabled;
|
|
128
|
-
if (variant !== undefined)
|
|
129
|
-
payload.variant = variant;
|
|
130
|
-
return { type: "button", data: payload };
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export class LinkButton extends WidgetBase {
|
|
134
|
-
options;
|
|
135
|
-
constructor(options) {
|
|
136
103
|
super(options);
|
|
137
104
|
this.options = options;
|
|
138
105
|
}
|
|
139
|
-
|
|
140
|
-
const payload = this.withCommon({ uri: this.options.uri });
|
|
141
|
-
if (this.options.label !== undefined)
|
|
142
|
-
payload.label = this.options.label;
|
|
143
|
-
return { type: "link_button", data: payload };
|
|
144
|
-
}
|
|
106
|
+
data() { return { ...this.commonData(), status: this.options.status ?? "neutral" }; }
|
|
145
107
|
}
|
|
146
|
-
export class
|
|
108
|
+
export class PanelIndicator extends WidgetBase {
|
|
147
109
|
options;
|
|
110
|
+
type = "panel_indicator";
|
|
148
111
|
constructor(options) {
|
|
149
112
|
super(options);
|
|
150
113
|
this.options = options;
|
|
151
114
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
115
|
+
data() {
|
|
116
|
+
const out = { ...this.commonData(), active: this.options.active ?? false, checked: this.options.checked ?? false, needs_attention: this.options.needs_attention ?? false };
|
|
117
|
+
for (const key of ["id", "icon", "label"])
|
|
118
|
+
if (this.options[key] !== undefined)
|
|
119
|
+
out[key] = this.options[key];
|
|
120
|
+
const extra = child(this.options.extra);
|
|
121
|
+
if (extra)
|
|
122
|
+
out.extra = extra;
|
|
123
|
+
return out;
|
|
161
124
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
super(options);
|
|
167
|
-
this.options = options;
|
|
168
|
-
}
|
|
169
|
-
toProtocol() {
|
|
170
|
-
return {
|
|
171
|
-
type: "tree_expander",
|
|
172
|
-
data: this.withCommon({
|
|
173
|
-
child: this.options.child.toProtocol(),
|
|
174
|
-
hide_expander: this.options.hide_expander ?? false,
|
|
175
|
-
indent_for_depth: this.options.indent_for_depth ?? false,
|
|
176
|
-
indent_for_icon: this.options.indent_for_icon ?? false,
|
|
177
|
-
}),
|
|
178
|
-
};
|
|
125
|
+
bindHandlers(registry, path) {
|
|
126
|
+
if (this.options.id && this.options.on_click)
|
|
127
|
+
registry.add("click", this.options.id, this.options.on_click);
|
|
128
|
+
this.options.extra?.bindHandlers(registry, [...path, 0]);
|
|
179
129
|
}
|
|
180
130
|
}
|
|
181
|
-
export class
|
|
131
|
+
export class EmptyState extends WidgetBase {
|
|
182
132
|
options;
|
|
133
|
+
type = "empty_state";
|
|
183
134
|
constructor(options) {
|
|
184
135
|
super(options);
|
|
185
136
|
this.options = options;
|
|
186
137
|
}
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
if (this.options.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
payload.icon = this.options.icon;
|
|
193
|
-
return { type: "menu_button", data: payload };
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
export class Switch extends WidgetBase {
|
|
197
|
-
options;
|
|
198
|
-
constructor(options = {}) {
|
|
199
|
-
super(options);
|
|
200
|
-
this.options = options;
|
|
201
|
-
}
|
|
202
|
-
toProtocol() {
|
|
203
|
-
const payload = this.withCommon({ active: this.options.active ?? false });
|
|
204
|
-
if (this.options.label !== undefined)
|
|
205
|
-
payload.label = this.options.label;
|
|
206
|
-
return { type: "switch", data: payload };
|
|
138
|
+
data() {
|
|
139
|
+
const out = { ...this.commonData(), title: this.options.title };
|
|
140
|
+
if (this.options.subtitle !== undefined)
|
|
141
|
+
out.subtitle = this.options.subtitle;
|
|
142
|
+
return out;
|
|
207
143
|
}
|
|
208
144
|
}
|
|
209
|
-
export class
|
|
145
|
+
export class Spinner extends WidgetBase {
|
|
210
146
|
options;
|
|
147
|
+
type = "spinner";
|
|
211
148
|
constructor(options = {}) {
|
|
212
149
|
super(options);
|
|
213
150
|
this.options = options;
|
|
214
151
|
}
|
|
215
|
-
|
|
216
|
-
const payload = this.withCommon({ active: this.options.active ?? false });
|
|
217
|
-
if (this.options.label !== undefined)
|
|
218
|
-
payload.label = this.options.label;
|
|
219
|
-
return { type: "toggle_button", data: payload };
|
|
220
|
-
}
|
|
152
|
+
data() { return { ...this.commonData(), spinning: this.options.spinning ?? true }; }
|
|
221
153
|
}
|
|
222
|
-
export class
|
|
154
|
+
export class Meter extends WidgetBase {
|
|
223
155
|
options;
|
|
156
|
+
type = "meter";
|
|
224
157
|
constructor(options = {}) {
|
|
225
158
|
super(options);
|
|
226
159
|
this.options = options;
|
|
227
160
|
}
|
|
228
|
-
|
|
229
|
-
const
|
|
161
|
+
data() {
|
|
162
|
+
const out = {
|
|
163
|
+
...this.commonData(),
|
|
164
|
+
label: this.options.label ?? "",
|
|
165
|
+
value: this.options.value ?? 0,
|
|
230
166
|
min: this.options.min ?? 0,
|
|
231
167
|
max: this.options.max ?? 1,
|
|
232
|
-
step: this.options.step ?? 0.
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
168
|
+
step: this.options.step ?? 0.01,
|
|
169
|
+
interactive: this.options.interactive ?? this.options.on_change !== undefined,
|
|
170
|
+
};
|
|
171
|
+
for (const key of ["id", "icon", "text"])
|
|
172
|
+
if (this.options[key] !== undefined)
|
|
173
|
+
out[key] = this.options[key];
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
bindHandlers(registry, _path) {
|
|
177
|
+
if (this.options.id && this.options.on_change)
|
|
178
|
+
registry.add("change", this.options.id, this.options.on_change);
|
|
240
179
|
}
|
|
241
180
|
}
|
|
242
|
-
export class
|
|
181
|
+
export class Separator extends WidgetBase {
|
|
182
|
+
type = "separator";
|
|
183
|
+
constructor(common = {}) { super(common); }
|
|
184
|
+
data() { return this.commonData(); }
|
|
185
|
+
}
|
|
186
|
+
export class Scroll extends WidgetBase {
|
|
243
187
|
options;
|
|
244
|
-
|
|
188
|
+
type = "scroll";
|
|
189
|
+
constructor(options) {
|
|
245
190
|
super(options);
|
|
246
191
|
this.options = options;
|
|
247
192
|
}
|
|
248
|
-
toProtocol()
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
payload.label = this.options.label;
|
|
252
|
-
return { type: "checkbox", data: payload };
|
|
193
|
+
data() { return { ...this.commonData(), child: this.options.child.toProtocol() }; }
|
|
194
|
+
bindHandlers(registry, path) {
|
|
195
|
+
this.options.child.bindHandlers(registry, [...path, 0]);
|
|
253
196
|
}
|
|
254
197
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this.
|
|
261
|
-
}
|
|
262
|
-
toProtocol() {
|
|
263
|
-
return { id: this.id, label: this.label };
|
|
198
|
+
class ChildrenWidget extends WidgetBase {
|
|
199
|
+
constructor(common = {}) { super(common); this.kids = common.children ?? []; }
|
|
200
|
+
kids;
|
|
201
|
+
data() { return { ...this.commonData(), children: children(this.kids) }; }
|
|
202
|
+
bindHandlers(registry, path) {
|
|
203
|
+
this.kids.forEach((kid, index) => kid.bindHandlers(registry, [...path, index]));
|
|
264
204
|
}
|
|
265
205
|
}
|
|
266
|
-
export class
|
|
206
|
+
export class Row extends ChildrenWidget {
|
|
207
|
+
type = "row";
|
|
208
|
+
}
|
|
209
|
+
export class Column extends ChildrenWidget {
|
|
210
|
+
type = "column";
|
|
211
|
+
}
|
|
212
|
+
export class BoxedList extends ChildrenWidget {
|
|
213
|
+
type = "boxed_list";
|
|
214
|
+
}
|
|
215
|
+
export class ButtonRow extends ChildrenWidget {
|
|
216
|
+
type = "button_row";
|
|
217
|
+
}
|
|
218
|
+
export class CircleBox extends WidgetBase {
|
|
267
219
|
options;
|
|
268
|
-
|
|
220
|
+
type = "circle_box";
|
|
221
|
+
constructor(options) {
|
|
269
222
|
super(options);
|
|
270
223
|
this.options = options;
|
|
271
224
|
}
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (this.options.selected !== undefined)
|
|
277
|
-
payload.selected = this.options.selected;
|
|
278
|
-
return { type: "select", data: payload };
|
|
225
|
+
data() {
|
|
226
|
+
const out = this.commonData();
|
|
227
|
+
out.color = this.options.color;
|
|
228
|
+
return out;
|
|
279
229
|
}
|
|
280
230
|
}
|
|
281
|
-
export class
|
|
231
|
+
export class Container extends ChildrenWidget {
|
|
232
|
+
type = "container";
|
|
233
|
+
}
|
|
234
|
+
export class PopoverShell extends ChildrenWidget {
|
|
282
235
|
options;
|
|
236
|
+
type = "popover_shell";
|
|
283
237
|
constructor(options = {}) {
|
|
284
238
|
super(options);
|
|
285
239
|
this.options = options;
|
|
286
240
|
}
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
if (this.options.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
export class Scroll extends WidgetBase {
|
|
295
|
-
child;
|
|
296
|
-
constructor(child, options = {}) {
|
|
297
|
-
super(options);
|
|
298
|
-
this.child = child;
|
|
241
|
+
data() {
|
|
242
|
+
const out = { ...super.data(), size: this.options.size ?? "medium" };
|
|
243
|
+
if ((this.options.footer ?? []).length > 0)
|
|
244
|
+
out.footer = children(this.options.footer ?? []);
|
|
245
|
+
if (this.options.footer_visible)
|
|
246
|
+
out.footer_visible = this.options.footer_visible;
|
|
247
|
+
return out;
|
|
299
248
|
}
|
|
300
|
-
|
|
301
|
-
|
|
249
|
+
bindHandlers(registry, path) {
|
|
250
|
+
super.bindHandlers(registry, path);
|
|
251
|
+
(this.options.footer ?? []).forEach((kid, index) => kid.bindHandlers(registry, [...path, this.kids.length + index]));
|
|
302
252
|
}
|
|
303
253
|
}
|
|
304
|
-
export class
|
|
254
|
+
export class Tile extends WidgetBase {
|
|
305
255
|
options;
|
|
256
|
+
type = "tile";
|
|
306
257
|
constructor(options) {
|
|
307
258
|
super(options);
|
|
308
259
|
this.options = options;
|
|
309
260
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
261
|
+
data() {
|
|
262
|
+
const out = { ...this.commonData(), primary: this.options.primary };
|
|
263
|
+
for (const key of ["id", "secondary", "left_icon"])
|
|
264
|
+
if (this.options[key] !== undefined)
|
|
265
|
+
out[key] = this.options[key];
|
|
266
|
+
const left = child(this.options.left);
|
|
267
|
+
const right = child(this.options.right);
|
|
268
|
+
if (left)
|
|
269
|
+
out.left = left;
|
|
270
|
+
if (right)
|
|
271
|
+
out.right = right;
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
bindHandlers(registry, path) {
|
|
275
|
+
if (this.options.on_click) {
|
|
276
|
+
this.options.id = registry.targetId("click", this.options.id, path);
|
|
277
|
+
registry.add("click", this.options.id, this.options.on_click);
|
|
278
|
+
}
|
|
279
|
+
this.options.left?.bindHandlers(registry, [...path, 0]);
|
|
280
|
+
this.options.right?.bindHandlers(registry, [...path, 1]);
|
|
318
281
|
}
|
|
319
282
|
}
|
|
320
|
-
export class
|
|
283
|
+
export class SegmentedTile extends Tile {
|
|
321
284
|
options;
|
|
322
|
-
|
|
285
|
+
type = "segmented_tile";
|
|
286
|
+
constructor(options) {
|
|
323
287
|
super(options);
|
|
324
288
|
this.options = options;
|
|
325
289
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
export class GridChild {
|
|
336
|
-
row;
|
|
337
|
-
column;
|
|
338
|
-
child;
|
|
339
|
-
width;
|
|
340
|
-
height;
|
|
341
|
-
constructor(row, column, child, width = 1, height = 1) {
|
|
342
|
-
this.row = row;
|
|
343
|
-
this.column = column;
|
|
344
|
-
this.child = child;
|
|
345
|
-
this.width = width;
|
|
346
|
-
this.height = height;
|
|
290
|
+
data() {
|
|
291
|
+
const out = super.data();
|
|
292
|
+
const nested = child(this.options.child);
|
|
293
|
+
if (nested)
|
|
294
|
+
out.child = nested;
|
|
295
|
+
out.expanded = this.options.expanded ?? false;
|
|
296
|
+
return out;
|
|
347
297
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
};
|
|
298
|
+
bindHandlers(registry, path) {
|
|
299
|
+
super.bindHandlers(registry, path);
|
|
300
|
+
if (this.options.on_toggle) {
|
|
301
|
+
this.options.id = registry.targetId("toggle", this.options.id, path);
|
|
302
|
+
registry.add("toggle", this.options.id, this.options.on_toggle);
|
|
303
|
+
}
|
|
304
|
+
this.options.child?.bindHandlers(registry, [...path, 2]);
|
|
356
305
|
}
|
|
357
306
|
}
|
|
358
|
-
export class
|
|
307
|
+
export class SwitchTile extends WidgetBase {
|
|
359
308
|
options;
|
|
360
|
-
|
|
309
|
+
type = "switch_tile";
|
|
310
|
+
constructor(options) {
|
|
361
311
|
super(options);
|
|
362
312
|
this.options = options;
|
|
363
313
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
314
|
+
data() {
|
|
315
|
+
const out = { ...this.commonData(), id: this.options.id, primary: this.options.primary, active: this.options.active ?? false };
|
|
316
|
+
for (const key of ["secondary", "left_icon"])
|
|
317
|
+
if (this.options[key] !== undefined)
|
|
318
|
+
out[key] = this.options[key];
|
|
319
|
+
const left = child(this.options.left);
|
|
320
|
+
if (left)
|
|
321
|
+
out.left = left;
|
|
322
|
+
return out;
|
|
323
|
+
}
|
|
324
|
+
bindHandlers(registry, path) {
|
|
325
|
+
if (this.options.on_toggle)
|
|
326
|
+
registry.add("toggle", this.options.id, this.options.on_toggle);
|
|
327
|
+
this.options.left?.bindHandlers(registry, [...path, 0]);
|
|
373
328
|
}
|
|
374
329
|
}
|
|
375
|
-
export class
|
|
330
|
+
export class ExpanderTile extends WidgetBase {
|
|
376
331
|
options;
|
|
332
|
+
type = "expander_tile";
|
|
377
333
|
constructor(options) {
|
|
378
334
|
super(options);
|
|
379
335
|
this.options = options;
|
|
380
336
|
}
|
|
381
|
-
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
337
|
+
data() {
|
|
338
|
+
const out = { ...this.commonData(), primary: this.options.primary, expanded: this.options.expanded ?? false };
|
|
339
|
+
for (const key of ["id", "secondary", "left_icon"])
|
|
340
|
+
if (this.options[key] !== undefined)
|
|
341
|
+
out[key] = this.options[key];
|
|
342
|
+
const left = child(this.options.left);
|
|
343
|
+
const nested = child(this.options.child);
|
|
344
|
+
if (left)
|
|
345
|
+
out.left = left;
|
|
346
|
+
if (nested)
|
|
347
|
+
out.child = nested;
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
bindHandlers(registry, path) {
|
|
351
|
+
if (this.options.on_toggle) {
|
|
352
|
+
this.options.id = registry.targetId("toggle", this.options.id, path);
|
|
353
|
+
registry.add("toggle", this.options.id, this.options.on_toggle);
|
|
354
|
+
}
|
|
355
|
+
this.options.left?.bindHandlers(registry, [...path, 0]);
|
|
356
|
+
this.options.child?.bindHandlers(registry, [...path, 1]);
|
|
389
357
|
}
|
|
390
358
|
}
|
|
391
|
-
export class
|
|
359
|
+
export class SliderTile extends WidgetBase {
|
|
392
360
|
options;
|
|
393
|
-
|
|
361
|
+
type = "slider_tile";
|
|
362
|
+
constructor(options) {
|
|
394
363
|
super(options);
|
|
395
364
|
this.options = options;
|
|
396
365
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
366
|
+
data() {
|
|
367
|
+
const out = { ...this.commonData(), id: this.options.id, value: this.options.value ?? 0, min: this.options.min ?? 0, max: this.options.max ?? 1, step: this.options.step ?? 0.01, page: this.options.page ?? 0.1, digits: this.options.digits ?? 0 };
|
|
368
|
+
for (const key of ["label", "left_icon", "snap_step"])
|
|
369
|
+
if (this.options[key] !== undefined)
|
|
370
|
+
out[key] = this.options[key];
|
|
371
|
+
const left = child(this.options.left);
|
|
372
|
+
if (left)
|
|
373
|
+
out.left = left;
|
|
374
|
+
return out;
|
|
375
|
+
}
|
|
376
|
+
bindHandlers(registry, path) {
|
|
377
|
+
if (this.options.on_change)
|
|
378
|
+
registry.add("change", this.options.id, this.options.on_change);
|
|
379
|
+
this.options.left?.bindHandlers(registry, [...path, 0]);
|
|
404
380
|
}
|
|
405
381
|
}
|
|
406
|
-
export class
|
|
382
|
+
export class ChoiceTile extends WidgetBase {
|
|
407
383
|
options;
|
|
384
|
+
type = "choice_tile";
|
|
408
385
|
constructor(options) {
|
|
409
386
|
super(options);
|
|
410
387
|
this.options = options;
|
|
411
388
|
}
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
389
|
+
data() {
|
|
390
|
+
const out = { ...this.commonData(), primary: this.options.primary, selected: this.options.selected ?? false };
|
|
391
|
+
for (const key of ["id", "secondary", "left_icon"])
|
|
392
|
+
if (this.options[key] !== undefined)
|
|
393
|
+
out[key] = this.options[key];
|
|
394
|
+
const left = child(this.options.left);
|
|
395
|
+
if (left)
|
|
396
|
+
out.left = left;
|
|
397
|
+
return out;
|
|
398
|
+
}
|
|
399
|
+
bindHandlers(registry, path) {
|
|
400
|
+
if (this.options.on_click) {
|
|
401
|
+
this.options.id = registry.targetId("click", this.options.id, path);
|
|
402
|
+
registry.add("click", this.options.id, this.options.on_click);
|
|
419
403
|
}
|
|
420
|
-
|
|
421
|
-
type: "section",
|
|
422
|
-
data: this.withCommon(payload),
|
|
423
|
-
};
|
|
404
|
+
this.options.left?.bindHandlers(registry, [...path, 0]);
|
|
424
405
|
}
|
|
425
406
|
}
|
|
426
|
-
export class
|
|
407
|
+
export class Choice {
|
|
427
408
|
options;
|
|
428
409
|
constructor(options) {
|
|
429
|
-
super(options);
|
|
430
410
|
this.options = options;
|
|
431
411
|
}
|
|
432
412
|
toProtocol() {
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
min: this.options.min ?? 0,
|
|
437
|
-
max: this.options.max ?? 1,
|
|
438
|
-
step: this.options.step ?? 0.01,
|
|
439
|
-
interactive: this.options.interactive ?? false,
|
|
440
|
-
});
|
|
413
|
+
const out = { id: this.options.id, primary: this.options.primary };
|
|
414
|
+
if (this.options.secondary !== undefined)
|
|
415
|
+
out.secondary = this.options.secondary;
|
|
441
416
|
if (this.options.icon !== undefined)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
payload.text = this.options.text;
|
|
445
|
-
return { type: "meter", data: payload };
|
|
417
|
+
out.icon = this.options.icon;
|
|
418
|
+
return out;
|
|
446
419
|
}
|
|
447
420
|
}
|
|
448
|
-
export class
|
|
421
|
+
export class ChoiceList extends WidgetBase {
|
|
449
422
|
options;
|
|
423
|
+
type = "choice_list";
|
|
450
424
|
constructor(options) {
|
|
451
425
|
super(options);
|
|
452
426
|
this.options = options;
|
|
453
427
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
428
|
+
data() {
|
|
429
|
+
const out = { ...this.commonData(), id: this.options.id, choices: (this.options.choices ?? []).map((choice) => choice.toProtocol()) };
|
|
430
|
+
if (this.options.active !== undefined)
|
|
431
|
+
out.active = this.options.active;
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
bindHandlers(registry, _path) {
|
|
435
|
+
if (this.options.on_change)
|
|
436
|
+
registry.add("change", this.options.id, this.options.on_change);
|
|
462
437
|
}
|
|
463
438
|
}
|
|
464
|
-
export class
|
|
439
|
+
export class KeyValueGrid extends WidgetBase {
|
|
465
440
|
options;
|
|
441
|
+
type = "key_value_grid";
|
|
466
442
|
constructor(options = {}) {
|
|
467
443
|
super(options);
|
|
468
444
|
this.options = options;
|
|
469
445
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
446
|
+
data() { return { ...this.commonData(), rows: this.options.rows ?? [] }; }
|
|
447
|
+
}
|
|
448
|
+
export class PagerItem extends WidgetBase {
|
|
449
|
+
options;
|
|
450
|
+
type = "pager_item";
|
|
451
|
+
constructor(options) {
|
|
452
|
+
super(options);
|
|
453
|
+
this.options = options;
|
|
478
454
|
}
|
|
455
|
+
data() { return { ...this.commonData(), id: this.options.id, label: this.options.label ?? "", appearance: this.options.appearance ?? "dots", active: this.options.active ?? false, inactive: this.options.inactive ?? false, occupied: this.options.occupied ?? false, urgent: this.options.urgent ?? false }; }
|
|
456
|
+
bindHandlers(registry, _path) { if (this.options.on_click)
|
|
457
|
+
registry.add("click", String(this.options.id), this.options.on_click); }
|
|
479
458
|
}
|
|
480
|
-
export class
|
|
459
|
+
export class PagerStrip extends WidgetBase {
|
|
481
460
|
options;
|
|
461
|
+
type = "pager_strip";
|
|
482
462
|
constructor(options = {}) {
|
|
483
463
|
super(options);
|
|
484
464
|
this.options = options;
|
|
485
465
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
466
|
+
data() {
|
|
467
|
+
const out = { ...this.commonData(), placeholder: this.options.placeholder ?? false, items: (this.options.items ?? []).map((item) => item.data()) };
|
|
468
|
+
if (this.options.id !== undefined)
|
|
469
|
+
out.id = this.options.id;
|
|
470
|
+
return out;
|
|
471
|
+
}
|
|
472
|
+
bindHandlers(registry, path) {
|
|
473
|
+
if (this.options.id && this.options.on_change)
|
|
474
|
+
registry.add("change", this.options.id, this.options.on_change);
|
|
475
|
+
(this.options.items ?? []).forEach((item, index) => item.bindHandlers(registry, [...path, index]));
|
|
494
476
|
}
|
|
495
477
|
}
|
|
496
|
-
|
|
478
|
+
class ActiveIndicator extends WidgetBase {
|
|
497
479
|
options;
|
|
498
480
|
constructor(options = {}) {
|
|
499
481
|
super(options);
|
|
500
482
|
this.options = options;
|
|
501
483
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
484
|
+
data() { return { ...this.commonData(), active: this.options.active ?? false }; }
|
|
485
|
+
}
|
|
486
|
+
export class CameraIndicator extends ActiveIndicator {
|
|
487
|
+
type = "camera_indicator";
|
|
488
|
+
}
|
|
489
|
+
export class MicIndicator extends ActiveIndicator {
|
|
490
|
+
type = "mic_indicator";
|
|
508
491
|
}
|
|
509
|
-
export class
|
|
492
|
+
export class MutedIndicator extends ActiveIndicator {
|
|
493
|
+
type = "muted_indicator";
|
|
494
|
+
}
|
|
495
|
+
export class LocationIndicator extends ActiveIndicator {
|
|
496
|
+
type = "location_indicator";
|
|
497
|
+
}
|
|
498
|
+
export class ScreenCastIndicator extends ActiveIndicator {
|
|
510
499
|
options;
|
|
500
|
+
type = "screencast_indicator";
|
|
511
501
|
constructor(options = {}) {
|
|
512
502
|
super(options);
|
|
513
503
|
this.options = options;
|
|
514
504
|
}
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
payload.title = this.options.title;
|
|
521
|
-
}
|
|
522
|
-
return {
|
|
523
|
-
type: "property_list",
|
|
524
|
-
data: this.withCommon(payload),
|
|
525
|
-
};
|
|
505
|
+
data() {
|
|
506
|
+
const out = super.data();
|
|
507
|
+
if (this.options.timer_text !== undefined)
|
|
508
|
+
out.timer_text = this.options.timer_text;
|
|
509
|
+
return out;
|
|
526
510
|
}
|
|
527
511
|
}
|
|
528
|
-
export class
|
|
512
|
+
export class Calendar extends WidgetBase {
|
|
529
513
|
options;
|
|
514
|
+
type = "calendar";
|
|
530
515
|
constructor(options) {
|
|
531
516
|
super(options);
|
|
532
517
|
this.options = options;
|
|
533
518
|
}
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
payload.icon = this.options.icon;
|
|
540
|
-
}
|
|
541
|
-
if (this.options.sublabel !== undefined && this.options.sublabel !== "") {
|
|
542
|
-
payload.sublabel = this.options.sublabel;
|
|
543
|
-
}
|
|
544
|
-
if (this.options.right !== undefined) {
|
|
545
|
-
payload.right = this.options.right.toProtocol();
|
|
546
|
-
}
|
|
547
|
-
return {
|
|
548
|
-
type: "item",
|
|
549
|
-
data: this.withCommon(payload),
|
|
550
|
-
};
|
|
519
|
+
data() {
|
|
520
|
+
const out = { ...this.commonData(), selected_date: this.options.selected_date, event_days: this.options.event_days ?? [] };
|
|
521
|
+
if (this.options.id !== undefined)
|
|
522
|
+
out.id = this.options.id;
|
|
523
|
+
return out;
|
|
551
524
|
}
|
|
525
|
+
bindHandlers(registry, _path) { if (this.options.id && this.options.on_change)
|
|
526
|
+
registry.add("change", this.options.id, this.options.on_change); }
|
|
552
527
|
}
|
|
553
|
-
export class
|
|
528
|
+
export class BatteryHero extends WidgetBase {
|
|
554
529
|
options;
|
|
530
|
+
type = "battery_hero";
|
|
555
531
|
constructor(options) {
|
|
556
532
|
super(options);
|
|
557
533
|
this.options = options;
|
|
558
534
|
}
|
|
559
|
-
|
|
560
|
-
const payload = {
|
|
561
|
-
label: this.options.label,
|
|
562
|
-
};
|
|
563
|
-
if (this.options.icon !== undefined && this.options.icon !== "") {
|
|
564
|
-
payload.icon = this.options.icon;
|
|
565
|
-
}
|
|
566
|
-
if (this.options.sublabel !== undefined && this.options.sublabel !== "") {
|
|
567
|
-
payload.sublabel = this.options.sublabel;
|
|
568
|
-
}
|
|
569
|
-
if (this.options.right !== undefined) {
|
|
570
|
-
payload.right = this.options.right.toProtocol();
|
|
571
|
-
}
|
|
572
|
-
if (this.options.enabled !== undefined) {
|
|
573
|
-
payload.enabled = this.options.enabled;
|
|
574
|
-
}
|
|
575
|
-
return {
|
|
576
|
-
type: "action_item",
|
|
577
|
-
data: this.withCommon(payload),
|
|
578
|
-
};
|
|
579
|
-
}
|
|
535
|
+
data() { return { ...this.commonData(), icon: this.options.icon, percentage: this.options.percentage, fraction: this.options.fraction, state: this.options.state }; }
|
|
580
536
|
}
|
|
581
|
-
export class
|
|
537
|
+
export class DateHero extends WidgetBase {
|
|
582
538
|
options;
|
|
539
|
+
type = "date_hero";
|
|
583
540
|
constructor(options) {
|
|
584
541
|
super(options);
|
|
585
542
|
this.options = options;
|
|
586
543
|
}
|
|
587
|
-
|
|
588
|
-
return {
|
|
589
|
-
type: "empty_state",
|
|
590
|
-
data: this.withCommon({
|
|
591
|
-
title: this.options.title,
|
|
592
|
-
subtitle: this.options.subtitle ?? "",
|
|
593
|
-
}),
|
|
594
|
-
};
|
|
595
|
-
}
|
|
544
|
+
data() { return { ...this.commonData(), weekday: this.options.weekday, date: this.options.date }; }
|
|
596
545
|
}
|
|
597
|
-
export class
|
|
546
|
+
export class EventItem {
|
|
598
547
|
options;
|
|
599
548
|
constructor(options) {
|
|
600
|
-
super(options);
|
|
601
549
|
this.options = options;
|
|
602
550
|
}
|
|
603
551
|
toProtocol() {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
}),
|
|
609
|
-
};
|
|
552
|
+
const out = { id: this.options.id, title: this.options.title, start: this.options.start, end: this.options.end ?? "", all_day: this.options.all_day ?? false };
|
|
553
|
+
if (this.options.location !== undefined)
|
|
554
|
+
out.location = this.options.location;
|
|
555
|
+
return out;
|
|
610
556
|
}
|
|
611
557
|
}
|
|
612
|
-
export class
|
|
613
|
-
|
|
558
|
+
export class Events extends WidgetBase {
|
|
559
|
+
options;
|
|
560
|
+
type = "events";
|
|
561
|
+
constructor(options) {
|
|
614
562
|
super(options);
|
|
563
|
+
this.options = options;
|
|
615
564
|
}
|
|
616
|
-
toProtocol()
|
|
617
|
-
|
|
565
|
+
data() { return { ...this.commonData(), date: this.options.date, loading: this.options.loading ?? false, events: (this.options.events ?? []).map((event) => event.toProtocol()) }; }
|
|
566
|
+
}
|
|
567
|
+
export class WeatherForecastItem {
|
|
568
|
+
options;
|
|
569
|
+
constructor(options) {
|
|
570
|
+
this.options = options;
|
|
618
571
|
}
|
|
572
|
+
toProtocol() { return { day_name: this.options.day_name, icon: this.options.icon, condition: this.options.condition, temperatures: this.options.temperatures, is_today: this.options.is_today ?? false }; }
|
|
619
573
|
}
|
|
620
|
-
export class
|
|
574
|
+
export class WeatherForecastList extends WidgetBase {
|
|
621
575
|
options;
|
|
576
|
+
type = "weather_forecast_list";
|
|
622
577
|
constructor(options = {}) {
|
|
623
578
|
super(options);
|
|
624
579
|
this.options = options;
|
|
625
580
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
occupied: this.options.occupied ?? false,
|
|
633
|
-
urgent: this.options.urgent ?? false,
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
toProtocol() {
|
|
637
|
-
return {
|
|
638
|
-
type: "pager_item",
|
|
639
|
-
data: this.toData(),
|
|
640
|
-
};
|
|
581
|
+
data() { return { ...this.commonData(), items: (this.options.items ?? []).map((item) => item.toProtocol()) }; }
|
|
582
|
+
}
|
|
583
|
+
export class WeatherHourlyItem {
|
|
584
|
+
options;
|
|
585
|
+
constructor(options) {
|
|
586
|
+
this.options = options;
|
|
641
587
|
}
|
|
588
|
+
toProtocol() { return { time: this.options.time, icon: this.options.icon, temperature: this.options.temperature }; }
|
|
642
589
|
}
|
|
643
|
-
export class
|
|
590
|
+
export class WeatherHourlyStrip extends WidgetBase {
|
|
644
591
|
options;
|
|
592
|
+
type = "weather_hourly_strip";
|
|
645
593
|
constructor(options = {}) {
|
|
646
594
|
super(options);
|
|
647
595
|
this.options = options;
|
|
648
596
|
}
|
|
597
|
+
data() { return { ...this.commonData(), items: (this.options.items ?? []).map((item) => item.toProtocol()) }; }
|
|
598
|
+
}
|
|
599
|
+
export class WorldClockRow {
|
|
600
|
+
options;
|
|
601
|
+
constructor(options) {
|
|
602
|
+
this.options = options;
|
|
603
|
+
}
|
|
649
604
|
toProtocol() {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}),
|
|
655
|
-
};
|
|
605
|
+
const out = { name: this.options.name, timezone: this.options.timezone, time: this.options.time, offset: this.options.offset };
|
|
606
|
+
if (this.options.day_label !== undefined)
|
|
607
|
+
out.day_label = this.options.day_label;
|
|
608
|
+
return out;
|
|
656
609
|
}
|
|
657
610
|
}
|
|
658
|
-
export class
|
|
611
|
+
export class WorldClock extends WidgetBase {
|
|
659
612
|
options;
|
|
613
|
+
type = "world_clock";
|
|
660
614
|
constructor(options = {}) {
|
|
661
615
|
super(options);
|
|
662
616
|
this.options = options;
|
|
663
617
|
}
|
|
664
|
-
|
|
665
|
-
return new Box({ ...options, orientation: "vertical", spacing, children });
|
|
666
|
-
}
|
|
667
|
-
static horizontal(children, spacing = 0, options = {}) {
|
|
668
|
-
return new Box({ ...options, orientation: "horizontal", spacing, children });
|
|
669
|
-
}
|
|
670
|
-
toProtocol() {
|
|
671
|
-
return {
|
|
672
|
-
type: "box",
|
|
673
|
-
data: this.withCommon({
|
|
674
|
-
orientation: this.options.orientation ?? "vertical",
|
|
675
|
-
spacing: this.options.spacing ?? 0,
|
|
676
|
-
children: (this.options.children ?? []).map((child) => child.toProtocol()),
|
|
677
|
-
}),
|
|
678
|
-
};
|
|
679
|
-
}
|
|
618
|
+
data() { return { ...this.commonData(), rows: (this.options.rows ?? []).map((row) => row.toProtocol()) }; }
|
|
680
619
|
}
|