glimpse-sdk 0.1.1 → 0.3.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 +27 -21
- package/dist/src/app.d.ts +2 -13
- package/dist/src/app.js +12 -19
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +3 -3
- package/dist/src/protocol.d.ts +0 -15
- package/dist/src/protocol.js +0 -19
- package/dist/src/widgets.d.ts +134 -116
- package/dist/src/widgets.js +250 -196
- package/package.json +1 -1
- package/src/app.ts +14 -25
- package/src/index.ts +23 -16
- package/src/protocol.ts +0 -25
- package/src/widgets.ts +353 -253
package/src/widgets.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { Icon
|
|
1
|
+
import { Icon } from "./protocol.js";
|
|
2
2
|
|
|
3
3
|
export type Align = "fill" | "start" | "end" | "center" | "baseline";
|
|
4
4
|
export type Orientation = "horizontal" | "vertical";
|
|
5
5
|
export type Variant = "normal" | "muted" | "accent" | "success" | "warning" | "danger";
|
|
6
|
+
export type ButtonVariant = "primary" | "secondary" | "compact" | "flat" | "danger";
|
|
7
|
+
export type PagerAppearance = "dots" | "numbers";
|
|
8
|
+
export type ContentFit = "fill" | "contain" | "cover" | "scale_down";
|
|
9
|
+
export type LevelBarMode = "continuous" | "discrete";
|
|
6
10
|
|
|
7
11
|
export interface WidgetNode {
|
|
8
12
|
toProtocol(): Record<string, unknown>;
|
|
@@ -80,21 +84,6 @@ export class Image extends WidgetBase {
|
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
export class IconWidget extends WidgetBase {
|
|
84
|
-
constructor(
|
|
85
|
-
public readonly icon: Icon,
|
|
86
|
-
private readonly options: CommonProps & { pixel_size?: number } = {},
|
|
87
|
-
) {
|
|
88
|
-
super(options);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
toProtocol(): Record<string, unknown> {
|
|
92
|
-
const payload = this.withCommon({ icon: this.icon.toProtocol() });
|
|
93
|
-
if (this.options.pixel_size !== undefined) payload.pixel_size = this.options.pixel_size;
|
|
94
|
-
return { type: "icon", data: payload };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
87
|
export class Progress extends WidgetBase {
|
|
99
88
|
constructor(
|
|
100
89
|
private readonly options: CommonProps & {
|
|
@@ -118,23 +107,156 @@ export class Progress extends WidgetBase {
|
|
|
118
107
|
}
|
|
119
108
|
}
|
|
120
109
|
|
|
110
|
+
export class LevelBar extends WidgetBase {
|
|
111
|
+
constructor(
|
|
112
|
+
private readonly options: CommonProps & {
|
|
113
|
+
value: number;
|
|
114
|
+
min?: number;
|
|
115
|
+
max?: number;
|
|
116
|
+
mode?: LevelBarMode;
|
|
117
|
+
},
|
|
118
|
+
) {
|
|
119
|
+
super(options);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
toProtocol(): Record<string, unknown> {
|
|
123
|
+
return {
|
|
124
|
+
type: "level_bar",
|
|
125
|
+
data: this.withCommon({
|
|
126
|
+
value: this.options.value,
|
|
127
|
+
min: this.options.min ?? 0,
|
|
128
|
+
max: this.options.max ?? 1,
|
|
129
|
+
mode: this.options.mode ?? "continuous",
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export class Picture extends WidgetBase {
|
|
136
|
+
constructor(
|
|
137
|
+
public readonly options: CommonProps & { path: string; content_fit?: ContentFit },
|
|
138
|
+
) {
|
|
139
|
+
super(options);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
toProtocol(): Record<string, unknown> {
|
|
143
|
+
const payload = this.withCommon({ path: this.options.path });
|
|
144
|
+
if (this.options.content_fit !== undefined) payload.content_fit = this.options.content_fit;
|
|
145
|
+
return { type: "picture", data: payload };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
121
149
|
export class Button extends WidgetBase {
|
|
150
|
+
private readonly options: Omit<CommonProps, "variant"> & {
|
|
151
|
+
label?: string;
|
|
152
|
+
icon?: string;
|
|
153
|
+
enabled?: boolean;
|
|
154
|
+
variant?: ButtonVariant;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
constructor(options: Omit<CommonProps, "variant"> & {
|
|
158
|
+
label?: string;
|
|
159
|
+
icon?: string;
|
|
160
|
+
enabled?: boolean;
|
|
161
|
+
variant?: ButtonVariant;
|
|
162
|
+
} = {}) {
|
|
163
|
+
const { variant: _variant, ...common } = options;
|
|
164
|
+
super(common);
|
|
165
|
+
this.options = options;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
toProtocol(): Record<string, unknown> {
|
|
169
|
+
const { variant, ...common } = this.options;
|
|
170
|
+
const payload = applyCommonProps({}, common);
|
|
171
|
+
if (this.options.label !== undefined) payload.label = this.options.label;
|
|
172
|
+
if (this.options.icon !== undefined) payload.icon = this.options.icon;
|
|
173
|
+
if (this.options.enabled !== undefined) payload.enabled = this.options.enabled;
|
|
174
|
+
if (variant !== undefined) payload.variant = variant;
|
|
175
|
+
return { type: "button", data: payload };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export class LinkButton extends WidgetBase {
|
|
122
180
|
constructor(
|
|
123
181
|
private readonly options: CommonProps & {
|
|
182
|
+
uri: string;
|
|
124
183
|
label?: string;
|
|
125
|
-
|
|
126
|
-
child?: TreeNode;
|
|
127
|
-
} = {},
|
|
184
|
+
},
|
|
128
185
|
) {
|
|
129
186
|
super(options);
|
|
130
187
|
}
|
|
131
188
|
|
|
132
189
|
toProtocol(): Record<string, unknown> {
|
|
133
|
-
const payload = this.withCommon({});
|
|
190
|
+
const payload = this.withCommon({ uri: this.options.uri });
|
|
134
191
|
if (this.options.label !== undefined) payload.label = this.options.label;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
192
|
+
return { type: "link_button", data: payload };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export class Expander extends WidgetBase {
|
|
197
|
+
constructor(
|
|
198
|
+
private readonly options: CommonProps & {
|
|
199
|
+
label: string;
|
|
200
|
+
child: TreeNode;
|
|
201
|
+
expanded?: boolean;
|
|
202
|
+
},
|
|
203
|
+
) {
|
|
204
|
+
super(options);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
toProtocol(): Record<string, unknown> {
|
|
208
|
+
return {
|
|
209
|
+
type: "expander",
|
|
210
|
+
data: this.withCommon({
|
|
211
|
+
label: this.options.label,
|
|
212
|
+
expanded: this.options.expanded ?? false,
|
|
213
|
+
child: this.options.child.toProtocol(),
|
|
214
|
+
}),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export class TreeExpander extends WidgetBase {
|
|
220
|
+
constructor(
|
|
221
|
+
private readonly options: CommonProps & {
|
|
222
|
+
child: TreeNode;
|
|
223
|
+
hide_expander?: boolean;
|
|
224
|
+
indent_for_depth?: boolean;
|
|
225
|
+
indent_for_icon?: boolean;
|
|
226
|
+
},
|
|
227
|
+
) {
|
|
228
|
+
super(options);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
toProtocol(): Record<string, unknown> {
|
|
232
|
+
return {
|
|
233
|
+
type: "tree_expander",
|
|
234
|
+
data: this.withCommon({
|
|
235
|
+
child: this.options.child.toProtocol(),
|
|
236
|
+
hide_expander: this.options.hide_expander ?? false,
|
|
237
|
+
indent_for_depth: this.options.indent_for_depth ?? false,
|
|
238
|
+
indent_for_icon: this.options.indent_for_icon ?? false,
|
|
239
|
+
}),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export class MenuButton extends WidgetBase {
|
|
245
|
+
constructor(
|
|
246
|
+
private readonly options: CommonProps & {
|
|
247
|
+
label?: string;
|
|
248
|
+
icon?: string;
|
|
249
|
+
popover: TreeNode;
|
|
250
|
+
},
|
|
251
|
+
) {
|
|
252
|
+
super(options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
toProtocol(): Record<string, unknown> {
|
|
256
|
+
const payload = this.withCommon({ popover: this.options.popover.toProtocol() });
|
|
257
|
+
if (this.options.label !== undefined) payload.label = this.options.label;
|
|
258
|
+
if (this.options.icon !== undefined) payload.icon = this.options.icon;
|
|
259
|
+
return { type: "menu_button", data: payload };
|
|
138
260
|
}
|
|
139
261
|
}
|
|
140
262
|
|
|
@@ -155,7 +277,24 @@ export class Switch extends WidgetBase {
|
|
|
155
277
|
}
|
|
156
278
|
}
|
|
157
279
|
|
|
158
|
-
export class
|
|
280
|
+
export class ToggleButton extends WidgetBase {
|
|
281
|
+
constructor(
|
|
282
|
+
private readonly options: CommonProps & {
|
|
283
|
+
label?: string;
|
|
284
|
+
active?: boolean;
|
|
285
|
+
} = {},
|
|
286
|
+
) {
|
|
287
|
+
super(options);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
toProtocol(): Record<string, unknown> {
|
|
291
|
+
const payload = this.withCommon({ active: this.options.active ?? false });
|
|
292
|
+
if (this.options.label !== undefined) payload.label = this.options.label;
|
|
293
|
+
return { type: "toggle_button", data: payload };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export class Slider extends WidgetBase {
|
|
159
298
|
constructor(
|
|
160
299
|
private readonly options: CommonProps & {
|
|
161
300
|
min?: number;
|
|
@@ -178,7 +317,7 @@ export class Scale extends WidgetBase {
|
|
|
178
317
|
});
|
|
179
318
|
if (this.options.orientation !== undefined) payload.orientation = this.options.orientation;
|
|
180
319
|
if (this.options.draw_value !== undefined) payload.draw_value = this.options.draw_value;
|
|
181
|
-
return { type: "
|
|
320
|
+
return { type: "slider", data: payload };
|
|
182
321
|
}
|
|
183
322
|
}
|
|
184
323
|
|
|
@@ -199,7 +338,7 @@ export class Checkbox extends WidgetBase {
|
|
|
199
338
|
}
|
|
200
339
|
}
|
|
201
340
|
|
|
202
|
-
export class
|
|
341
|
+
export class SelectOption {
|
|
203
342
|
constructor(
|
|
204
343
|
public readonly id: string,
|
|
205
344
|
public readonly label: string,
|
|
@@ -210,10 +349,10 @@ export class DropdownItem {
|
|
|
210
349
|
}
|
|
211
350
|
}
|
|
212
351
|
|
|
213
|
-
export class
|
|
352
|
+
export class Select extends WidgetBase {
|
|
214
353
|
constructor(
|
|
215
354
|
private readonly options: CommonProps & {
|
|
216
|
-
items?:
|
|
355
|
+
items?: SelectOption[];
|
|
217
356
|
selected?: number;
|
|
218
357
|
} = {},
|
|
219
358
|
) {
|
|
@@ -225,7 +364,7 @@ export class Dropdown extends WidgetBase {
|
|
|
225
364
|
items: (this.options.items ?? []).map((item) => item.toProtocol()),
|
|
226
365
|
});
|
|
227
366
|
if (this.options.selected !== undefined) payload.selected = this.options.selected;
|
|
228
|
-
return { type: "
|
|
367
|
+
return { type: "select", data: payload };
|
|
229
368
|
}
|
|
230
369
|
}
|
|
231
370
|
|
|
@@ -254,6 +393,46 @@ export class Scroll extends WidgetBase {
|
|
|
254
393
|
}
|
|
255
394
|
}
|
|
256
395
|
|
|
396
|
+
export class Overlay extends WidgetBase {
|
|
397
|
+
constructor(
|
|
398
|
+
private readonly options: CommonProps & {
|
|
399
|
+
child: TreeNode;
|
|
400
|
+
overlays?: TreeNode[];
|
|
401
|
+
},
|
|
402
|
+
) {
|
|
403
|
+
super(options);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
toProtocol(): Record<string, unknown> {
|
|
407
|
+
return {
|
|
408
|
+
type: "overlay",
|
|
409
|
+
data: this.withCommon({
|
|
410
|
+
child: this.options.child.toProtocol(),
|
|
411
|
+
overlays: (this.options.overlays ?? []).map((overlay) => overlay.toProtocol()),
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export class ListBox extends WidgetBase {
|
|
418
|
+
constructor(
|
|
419
|
+
private readonly options: CommonProps & {
|
|
420
|
+
children?: TreeNode[];
|
|
421
|
+
} = {},
|
|
422
|
+
) {
|
|
423
|
+
super(options);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
toProtocol(): Record<string, unknown> {
|
|
427
|
+
return {
|
|
428
|
+
type: "list_box",
|
|
429
|
+
data: this.withCommon({
|
|
430
|
+
children: (this.options.children ?? []).map((child) => child.toProtocol()),
|
|
431
|
+
}),
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
257
436
|
export class GridChild {
|
|
258
437
|
constructor(
|
|
259
438
|
public readonly row: number,
|
|
@@ -337,26 +516,11 @@ export class Card extends WidgetBase {
|
|
|
337
516
|
}
|
|
338
517
|
}
|
|
339
518
|
|
|
340
|
-
export class Header {
|
|
341
|
-
constructor(
|
|
342
|
-
public readonly title: string,
|
|
343
|
-
public readonly subtitle = "",
|
|
344
|
-
) {}
|
|
345
|
-
|
|
346
|
-
toProtocol(): Record<string, unknown> {
|
|
347
|
-
const payload: Record<string, unknown> = { title: this.title };
|
|
348
|
-
if (this.subtitle !== "") payload.subtitle = this.subtitle;
|
|
349
|
-
return payload;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
519
|
export class Section extends WidgetBase {
|
|
354
520
|
constructor(
|
|
355
521
|
private readonly options: CommonProps & {
|
|
356
522
|
title?: string;
|
|
357
523
|
subtitle?: string;
|
|
358
|
-
header?: Header;
|
|
359
|
-
body?: TreeNode[];
|
|
360
524
|
children?: TreeNode[];
|
|
361
525
|
},
|
|
362
526
|
) {
|
|
@@ -364,105 +528,20 @@ export class Section extends WidgetBase {
|
|
|
364
528
|
}
|
|
365
529
|
|
|
366
530
|
toProtocol(): Record<string, unknown> {
|
|
367
|
-
const
|
|
368
|
-
this.options.
|
|
369
|
-
(this.options.
|
|
370
|
-
? undefined
|
|
371
|
-
: new Header(this.options.title, this.options.subtitle ?? ""));
|
|
372
|
-
const body = this.options.body ?? this.options.children ?? [];
|
|
373
|
-
return {
|
|
374
|
-
type: "section",
|
|
375
|
-
data: this.withCommon({
|
|
376
|
-
...(header === undefined ? {} : { header: header.toProtocol() }),
|
|
377
|
-
body: body.map((child) => child.toProtocol()),
|
|
378
|
-
}),
|
|
531
|
+
const payload: Record<string, unknown> = {
|
|
532
|
+
title: this.options.title ?? "",
|
|
533
|
+
children: (this.options.children ?? []).map((child) => child.toProtocol()),
|
|
379
534
|
};
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
export class Collapsible extends WidgetBase {
|
|
384
|
-
constructor(
|
|
385
|
-
private readonly options: CommonProps & {
|
|
386
|
-
title?: string;
|
|
387
|
-
subtitle?: string;
|
|
388
|
-
header?: Header;
|
|
389
|
-
expanded?: boolean;
|
|
390
|
-
body?: TreeNode[];
|
|
391
|
-
children?: TreeNode[];
|
|
392
|
-
},
|
|
393
|
-
) {
|
|
394
|
-
super(options);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
toProtocol(): Record<string, unknown> {
|
|
398
|
-
const header =
|
|
399
|
-
this.options.header ??
|
|
400
|
-
(this.options.title === undefined
|
|
401
|
-
? undefined
|
|
402
|
-
: new Header(this.options.title, this.options.subtitle ?? ""));
|
|
403
|
-
const body = this.options.body ?? this.options.children ?? [];
|
|
535
|
+
if (this.options.subtitle !== undefined && this.options.subtitle !== "") {
|
|
536
|
+
payload.subtitle = this.options.subtitle;
|
|
537
|
+
}
|
|
404
538
|
return {
|
|
405
|
-
type: "
|
|
406
|
-
data: this.withCommon(
|
|
407
|
-
...(header === undefined ? {} : { header: header.toProtocol() }),
|
|
408
|
-
expanded: this.options.expanded ?? false,
|
|
409
|
-
body: body.map((child) => child.toProtocol()),
|
|
410
|
-
}),
|
|
539
|
+
type: "section",
|
|
540
|
+
data: this.withCommon(payload),
|
|
411
541
|
};
|
|
412
542
|
}
|
|
413
543
|
}
|
|
414
544
|
|
|
415
|
-
export class Item extends WidgetBase {
|
|
416
|
-
constructor(
|
|
417
|
-
private readonly options: CommonProps & {
|
|
418
|
-
left?: TreeNode;
|
|
419
|
-
label?: string;
|
|
420
|
-
right?: TreeNode;
|
|
421
|
-
clickable?: boolean;
|
|
422
|
-
menu?: MenuItem[];
|
|
423
|
-
} = {},
|
|
424
|
-
) {
|
|
425
|
-
super(options);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
toProtocol(): Record<string, unknown> {
|
|
429
|
-
const payload = this.withCommon({
|
|
430
|
-
label: this.options.label ?? "",
|
|
431
|
-
clickable: this.options.clickable ?? false,
|
|
432
|
-
menu: (this.options.menu ?? []).map((item) => item.toProtocol()),
|
|
433
|
-
});
|
|
434
|
-
if (this.options.left !== undefined) payload.left = this.options.left.toProtocol();
|
|
435
|
-
if (this.options.right !== undefined) payload.right = this.options.right.toProtocol();
|
|
436
|
-
return { type: "item", data: payload };
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
export class CollapsibleItem extends WidgetBase {
|
|
441
|
-
constructor(
|
|
442
|
-
private readonly options: CommonProps & {
|
|
443
|
-
left?: TreeNode;
|
|
444
|
-
label?: string;
|
|
445
|
-
right?: TreeNode;
|
|
446
|
-
expanded?: boolean;
|
|
447
|
-
body?: TreeNode[];
|
|
448
|
-
children?: TreeNode[];
|
|
449
|
-
} = {},
|
|
450
|
-
) {
|
|
451
|
-
super(options);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
toProtocol(): Record<string, unknown> {
|
|
455
|
-
const payload = this.withCommon({
|
|
456
|
-
label: this.options.label ?? "",
|
|
457
|
-
expanded: this.options.expanded ?? false,
|
|
458
|
-
body: (this.options.body ?? this.options.children ?? []).map((child) => child.toProtocol()),
|
|
459
|
-
});
|
|
460
|
-
if (this.options.left !== undefined) payload.left = this.options.left.toProtocol();
|
|
461
|
-
if (this.options.right !== undefined) payload.right = this.options.right.toProtocol();
|
|
462
|
-
return { type: "collapsible_item", data: payload };
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
545
|
export class Meter extends WidgetBase {
|
|
467
546
|
constructor(
|
|
468
547
|
private readonly options: CommonProps & {
|
|
@@ -515,63 +594,6 @@ export class Copyable extends WidgetBase {
|
|
|
515
594
|
}
|
|
516
595
|
}
|
|
517
596
|
|
|
518
|
-
export class ToastAction {
|
|
519
|
-
constructor(
|
|
520
|
-
public readonly id: string,
|
|
521
|
-
public readonly label: string,
|
|
522
|
-
) {}
|
|
523
|
-
|
|
524
|
-
toProtocol(): Record<string, unknown> {
|
|
525
|
-
return { id: this.id, label: this.label };
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
export class Toast extends WidgetBase {
|
|
530
|
-
constructor(
|
|
531
|
-
private readonly options: CommonProps & {
|
|
532
|
-
icon?: Icon;
|
|
533
|
-
title: string;
|
|
534
|
-
message?: string;
|
|
535
|
-
action?: ToastAction;
|
|
536
|
-
},
|
|
537
|
-
) {
|
|
538
|
-
super(options);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
toProtocol(): Record<string, unknown> {
|
|
542
|
-
const payload = this.withCommon({
|
|
543
|
-
title: this.options.title,
|
|
544
|
-
message: this.options.message ?? "",
|
|
545
|
-
});
|
|
546
|
-
if (this.options.icon !== undefined) payload.icon = this.options.icon.toProtocol();
|
|
547
|
-
if (this.options.action !== undefined) payload.action = this.options.action.toProtocol();
|
|
548
|
-
return { type: "toast", data: payload };
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
export class ActionRow extends WidgetBase {
|
|
553
|
-
constructor(
|
|
554
|
-
private readonly options: CommonProps & {
|
|
555
|
-
title: string;
|
|
556
|
-
subtitle?: string;
|
|
557
|
-
meta?: string;
|
|
558
|
-
icon?: Icon;
|
|
559
|
-
},
|
|
560
|
-
) {
|
|
561
|
-
super(options);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
toProtocol(): Record<string, unknown> {
|
|
565
|
-
const payload = this.withCommon({
|
|
566
|
-
title: this.options.title,
|
|
567
|
-
subtitle: this.options.subtitle ?? "",
|
|
568
|
-
meta: this.options.meta ?? "",
|
|
569
|
-
});
|
|
570
|
-
if (this.options.icon !== undefined) payload.icon = this.options.icon.toProtocol();
|
|
571
|
-
return { type: "action_row", data: payload };
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
597
|
export class Row extends WidgetBase {
|
|
576
598
|
constructor(
|
|
577
599
|
private readonly options: CommonProps & {
|
|
@@ -614,93 +636,113 @@ export class Column extends WidgetBase {
|
|
|
614
636
|
}
|
|
615
637
|
}
|
|
616
638
|
|
|
617
|
-
export class
|
|
618
|
-
constructor(
|
|
619
|
-
public readonly options: {
|
|
620
|
-
id: string;
|
|
621
|
-
label: string;
|
|
622
|
-
icon?: Icon;
|
|
623
|
-
visible?: boolean;
|
|
624
|
-
checked?: boolean;
|
|
625
|
-
selectable?: boolean;
|
|
626
|
-
},
|
|
627
|
-
) {}
|
|
628
|
-
|
|
629
|
-
toProtocol(): Record<string, unknown> {
|
|
630
|
-
const payload: Record<string, unknown> = {
|
|
631
|
-
id: this.options.id,
|
|
632
|
-
label: this.options.label,
|
|
633
|
-
};
|
|
634
|
-
if (this.options.icon !== undefined) payload.icon = this.options.icon.toProtocol();
|
|
635
|
-
if (this.options.visible !== undefined) payload.visible = this.options.visible;
|
|
636
|
-
if (this.options.checked !== undefined) payload.checked = this.options.checked;
|
|
637
|
-
if (this.options.selectable !== undefined) payload.selectable = this.options.selectable;
|
|
638
|
-
return payload;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
export class ActionMenu extends WidgetBase {
|
|
639
|
+
export class Spinner extends WidgetBase {
|
|
643
640
|
constructor(
|
|
644
641
|
private readonly options: CommonProps & {
|
|
645
|
-
|
|
646
|
-
items?: ActionMenuItem[];
|
|
642
|
+
spinning?: boolean;
|
|
647
643
|
} = {},
|
|
648
644
|
) {
|
|
649
645
|
super(options);
|
|
650
646
|
}
|
|
651
647
|
|
|
652
648
|
toProtocol(): Record<string, unknown> {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return { type: "action_menu", data: payload };
|
|
649
|
+
return {
|
|
650
|
+
type: "spinner",
|
|
651
|
+
data: this.withCommon({ spinning: this.options.spinning ?? true }),
|
|
652
|
+
};
|
|
658
653
|
}
|
|
659
654
|
}
|
|
660
655
|
|
|
661
|
-
export
|
|
656
|
+
export type Properties = Record<string, string>;
|
|
657
|
+
|
|
658
|
+
export class PropertyList extends WidgetBase {
|
|
662
659
|
constructor(
|
|
663
660
|
private readonly options: CommonProps & {
|
|
664
|
-
|
|
661
|
+
title?: string;
|
|
662
|
+
rows?: Properties;
|
|
665
663
|
} = {},
|
|
666
664
|
) {
|
|
667
665
|
super(options);
|
|
668
666
|
}
|
|
669
667
|
|
|
670
668
|
toProtocol(): Record<string, unknown> {
|
|
669
|
+
const payload: Record<string, unknown> = {
|
|
670
|
+
rows: Object.entries(this.options.rows ?? {}).map(([key, value]) => ({ key, value })),
|
|
671
|
+
};
|
|
672
|
+
if (this.options.title !== undefined && this.options.title !== "") {
|
|
673
|
+
payload.title = this.options.title;
|
|
674
|
+
}
|
|
671
675
|
return {
|
|
672
|
-
type: "
|
|
673
|
-
data: this.withCommon(
|
|
676
|
+
type: "property_list",
|
|
677
|
+
data: this.withCommon(payload),
|
|
674
678
|
};
|
|
675
679
|
}
|
|
676
680
|
}
|
|
677
681
|
|
|
678
|
-
export class
|
|
682
|
+
export class Item extends WidgetBase {
|
|
679
683
|
constructor(
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
684
|
+
private readonly options: CommonProps & {
|
|
685
|
+
label: string;
|
|
686
|
+
sublabel?: string;
|
|
687
|
+
icon?: string;
|
|
688
|
+
right?: TreeNode;
|
|
689
|
+
},
|
|
690
|
+
) {
|
|
691
|
+
super(options);
|
|
692
|
+
}
|
|
683
693
|
|
|
684
694
|
toProtocol(): Record<string, unknown> {
|
|
685
|
-
|
|
695
|
+
const payload: Record<string, unknown> = {
|
|
696
|
+
label: this.options.label,
|
|
697
|
+
};
|
|
698
|
+
if (this.options.icon !== undefined && this.options.icon !== "") {
|
|
699
|
+
payload.icon = this.options.icon;
|
|
700
|
+
}
|
|
701
|
+
if (this.options.sublabel !== undefined && this.options.sublabel !== "") {
|
|
702
|
+
payload.sublabel = this.options.sublabel;
|
|
703
|
+
}
|
|
704
|
+
if (this.options.right !== undefined) {
|
|
705
|
+
payload.right = this.options.right.toProtocol();
|
|
706
|
+
}
|
|
707
|
+
return {
|
|
708
|
+
type: "item",
|
|
709
|
+
data: this.withCommon(payload),
|
|
710
|
+
};
|
|
686
711
|
}
|
|
687
712
|
}
|
|
688
713
|
|
|
689
|
-
export class
|
|
714
|
+
export class ActionItem extends WidgetBase {
|
|
690
715
|
constructor(
|
|
691
716
|
private readonly options: CommonProps & {
|
|
692
|
-
|
|
693
|
-
|
|
717
|
+
label: string;
|
|
718
|
+
sublabel?: string;
|
|
719
|
+
icon?: string;
|
|
720
|
+
right?: TreeNode;
|
|
721
|
+
enabled?: boolean;
|
|
722
|
+
},
|
|
694
723
|
) {
|
|
695
724
|
super(options);
|
|
696
725
|
}
|
|
697
726
|
|
|
698
727
|
toProtocol(): Record<string, unknown> {
|
|
728
|
+
const payload: Record<string, unknown> = {
|
|
729
|
+
label: this.options.label,
|
|
730
|
+
};
|
|
731
|
+
if (this.options.icon !== undefined && this.options.icon !== "") {
|
|
732
|
+
payload.icon = this.options.icon;
|
|
733
|
+
}
|
|
734
|
+
if (this.options.sublabel !== undefined && this.options.sublabel !== "") {
|
|
735
|
+
payload.sublabel = this.options.sublabel;
|
|
736
|
+
}
|
|
737
|
+
if (this.options.right !== undefined) {
|
|
738
|
+
payload.right = this.options.right.toProtocol();
|
|
739
|
+
}
|
|
740
|
+
if (this.options.enabled !== undefined) {
|
|
741
|
+
payload.enabled = this.options.enabled;
|
|
742
|
+
}
|
|
699
743
|
return {
|
|
700
|
-
type: "
|
|
701
|
-
data: this.withCommon(
|
|
702
|
-
rows: (this.options.rows ?? []).map((row) => row.toProtocol()),
|
|
703
|
-
}),
|
|
744
|
+
type: "action_item",
|
|
745
|
+
data: this.withCommon(payload),
|
|
704
746
|
};
|
|
705
747
|
}
|
|
706
748
|
}
|
|
@@ -755,6 +797,58 @@ export class StatusDot extends WidgetBase {
|
|
|
755
797
|
}
|
|
756
798
|
}
|
|
757
799
|
|
|
800
|
+
export class PagerItem extends WidgetBase {
|
|
801
|
+
constructor(
|
|
802
|
+
private readonly options: CommonProps & {
|
|
803
|
+
appearance?: PagerAppearance;
|
|
804
|
+
label?: string;
|
|
805
|
+
active?: boolean;
|
|
806
|
+
inactive?: boolean;
|
|
807
|
+
occupied?: boolean;
|
|
808
|
+
urgent?: boolean;
|
|
809
|
+
} = {},
|
|
810
|
+
) {
|
|
811
|
+
super(options);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
toData(): Record<string, unknown> {
|
|
815
|
+
return this.withCommon({
|
|
816
|
+
appearance: this.options.appearance ?? "dots",
|
|
817
|
+
label: this.options.label ?? "",
|
|
818
|
+
active: this.options.active ?? false,
|
|
819
|
+
inactive: this.options.inactive ?? false,
|
|
820
|
+
occupied: this.options.occupied ?? false,
|
|
821
|
+
urgent: this.options.urgent ?? false,
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
toProtocol(): Record<string, unknown> {
|
|
826
|
+
return {
|
|
827
|
+
type: "pager_item",
|
|
828
|
+
data: this.toData(),
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
export class PagerStrip extends WidgetBase {
|
|
834
|
+
constructor(
|
|
835
|
+
private readonly options: CommonProps & {
|
|
836
|
+
items?: PagerItem[];
|
|
837
|
+
} = {},
|
|
838
|
+
) {
|
|
839
|
+
super(options);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
toProtocol(): Record<string, unknown> {
|
|
843
|
+
return {
|
|
844
|
+
type: "pager_strip",
|
|
845
|
+
data: this.withCommon({
|
|
846
|
+
items: (this.options.items ?? []).map((item) => item.toData()),
|
|
847
|
+
}),
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
758
852
|
export class Box extends WidgetBase {
|
|
759
853
|
constructor(
|
|
760
854
|
private readonly options: CommonProps & {
|
|
@@ -790,31 +884,37 @@ export type TreeNode =
|
|
|
790
884
|
| Hero
|
|
791
885
|
| Card
|
|
792
886
|
| Section
|
|
793
|
-
| Collapsible
|
|
794
|
-
| Item
|
|
795
|
-
| CollapsibleItem
|
|
796
887
|
| Meter
|
|
797
888
|
| Copyable
|
|
798
|
-
|
|
|
799
|
-
|
|
|
800
|
-
|
|
|
801
|
-
| DetailGrid
|
|
889
|
+
| PropertyList
|
|
890
|
+
| Item
|
|
891
|
+
| ActionItem
|
|
802
892
|
| EmptyState
|
|
803
893
|
| Badge
|
|
804
894
|
| StatusDot
|
|
895
|
+
| PagerItem
|
|
896
|
+
| PagerStrip
|
|
805
897
|
| Box
|
|
806
898
|
| Row
|
|
807
899
|
| Column
|
|
808
900
|
| Grid
|
|
809
901
|
| Scroll
|
|
902
|
+
| Overlay
|
|
903
|
+
| ListBox
|
|
904
|
+
| LevelBar
|
|
905
|
+
| TreeExpander
|
|
906
|
+
| MenuButton
|
|
810
907
|
| Progress
|
|
811
908
|
| Separator
|
|
812
909
|
| Spinner
|
|
813
910
|
| Label
|
|
814
|
-
| IconWidget
|
|
815
911
|
| Image
|
|
912
|
+
| Picture
|
|
816
913
|
| Button
|
|
914
|
+
| LinkButton
|
|
915
|
+
| Expander
|
|
817
916
|
| Switch
|
|
818
|
-
|
|
|
819
|
-
|
|
|
917
|
+
| ToggleButton
|
|
918
|
+
| Slider
|
|
919
|
+
| Select
|
|
820
920
|
| Checkbox;
|