@devicechain/widgets 0.19.0 → 0.20.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 CHANGED
@@ -34,14 +34,24 @@ acknowledge, command send — render without their controls. That is the whole
34
34
  opt-in: a viewer that never passes `actions` cannot write, regardless of what the
35
35
  board contains.
36
36
 
37
- Or drive a single widget yourself with `ConnectedWidget`, and look components up
38
- by type through `WIDGET_REGISTRY` and its per-channel siblings.
37
+ A templated board takes its slot bindings on the renderer, not the hub:
38
+ `<DashboardRenderer bindings={bindings} … />`. Keep one hub for the board
39
+ (`useDashboardHub(resolver, authorities)` builds and disposes it); a new
40
+ `bindings` map re-subscribes only the widgets whose slot moved.
41
+
42
+ Or drive a single widget yourself with `ConnectedWidget`; it resolves the widget's
43
+ component, channel and binding policy through a registry (the built-ins by default,
44
+ or the one you pass as `registry`; see `createBuiltinWidgetRegistry` and
45
+ `builtinWidgetDefinitions`, and `@devicechain/widget-sdk` to add your own). A widget
46
+ bound to a slot needs its datasource resolved first (`resolveWidgets` or
47
+ `resolveWidgetDatasource`).
39
48
 
40
49
  ## The widgets
41
50
 
42
51
  | channel | widgets |
43
52
  | --- | --- |
44
- | measurement | `timeseries-chart`, `gauge`, `latest-card`, `table`, `label`, `image` |
53
+ | measurement | `timeseries-chart`, `gauge`, `latest-card`, `table` |
54
+ | none (static) | `label`, `image` |
45
55
  | alarm | `alarm-table`, `alarm-count` |
46
56
  | control | `command-button` |
47
57
  | selection | `entity-selector` |
@@ -0,0 +1,4 @@
1
+ import type { AlarmSubscription, CommandSubscription, WidgetDescriptor, WidgetInstance } from '@devicechain/dashboards';
2
+ export declare function measurementWindow(descriptor: WidgetDescriptor, widget: WidgetInstance): number | undefined;
3
+ export declare function alarmSubscription(descriptor: WidgetDescriptor, widget: WidgetInstance): AlarmSubscription;
4
+ export declare function commandSubscription(descriptor: WidgetDescriptor, widget: WidgetInstance): CommandSubscription;
@@ -0,0 +1,390 @@
1
+ import { type WidgetDescriptor } from '@devicechain/dashboards';
2
+ export declare const builtinWidgetDescriptors: {
3
+ readonly 'timeseries-chart': WidgetDescriptor<"measurement", {
4
+ readonly title: {
5
+ readonly kind: 'string';
6
+ readonly labelId: 'widgetLabelTitle';
7
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
8
+ };
9
+ readonly window: {
10
+ readonly kind: 'number';
11
+ readonly integer: true;
12
+ readonly min: 1;
13
+ readonly labelId: 'widgetLabelWindow';
14
+ readonly helpId: 'widgetHintWindow';
15
+ readonly doc: 'Samples retained across ALL of the widget\'s measurements before the oldest are dropped. Bounds memory; only the chart draws them. Default 300.';
16
+ };
17
+ }>;
18
+ readonly 'latest-card': WidgetDescriptor<"measurement", {
19
+ readonly title: {
20
+ readonly kind: 'string';
21
+ readonly labelId: 'widgetLabelTitle';
22
+ readonly doc: 'Heading shown in the widget frame. Defaults to the displayed measurement name.';
23
+ };
24
+ readonly measurement: {
25
+ readonly kind: "string";
26
+ readonly labelId: "widgetLabelMeasurement";
27
+ readonly helpId: "widgetHintMeasurement";
28
+ readonly doc: "Which measurement to display. Defaults to the first the datasource selects.";
29
+ };
30
+ readonly unit: {
31
+ readonly kind: 'string';
32
+ readonly labelId: 'widgetLabelUnit';
33
+ readonly doc: 'Unit suffix shown beside the value.';
34
+ };
35
+ readonly precision: {
36
+ readonly kind: 'number';
37
+ readonly integer: true;
38
+ readonly min: 0;
39
+ readonly max: 100;
40
+ readonly labelId: 'widgetLabelPrecision';
41
+ readonly helpId: 'widgetHintPrecision';
42
+ readonly doc: 'Decimal places to round displayed values to. Unset shows the raw value.';
43
+ };
44
+ readonly flashOnChange: {
45
+ readonly kind: 'boolean';
46
+ readonly labelId: 'widgetFlashOnChange';
47
+ readonly helpId: 'widgetFlashOnChangeHint';
48
+ readonly doc: 'Briefly tint a value green on a rise and red on a fall when it changes.';
49
+ };
50
+ readonly window: {
51
+ readonly kind: 'number';
52
+ readonly integer: true;
53
+ readonly min: 1;
54
+ readonly labelId: 'widgetLabelWindow';
55
+ readonly helpId: 'widgetHintWindow';
56
+ readonly doc: 'Samples retained across ALL of the widget\'s measurements before the oldest are dropped. Bounds memory; only the chart draws them. Default 300.';
57
+ };
58
+ }>;
59
+ readonly gauge: WidgetDescriptor<"measurement", {
60
+ readonly title: {
61
+ readonly kind: 'string';
62
+ readonly labelId: 'widgetLabelTitle';
63
+ readonly doc: 'Heading shown in the widget frame. Defaults to the displayed measurement name.';
64
+ };
65
+ readonly measurement: {
66
+ readonly kind: "string";
67
+ readonly labelId: "widgetLabelMeasurement";
68
+ readonly helpId: "widgetHintMeasurement";
69
+ readonly doc: "Which measurement to display. Defaults to the first the datasource selects.";
70
+ };
71
+ readonly min: {
72
+ readonly kind: "number";
73
+ readonly labelId: "widgetLabelMin";
74
+ readonly doc: "Low end of the gauge scale. Default 0.";
75
+ };
76
+ readonly max: {
77
+ readonly kind: "number";
78
+ readonly labelId: "widgetLabelMax";
79
+ readonly doc: "High end of the gauge scale. Default 100.";
80
+ };
81
+ readonly unit: {
82
+ readonly kind: 'string';
83
+ readonly labelId: 'widgetLabelUnit';
84
+ readonly doc: 'Unit suffix shown beside the value.';
85
+ };
86
+ readonly flashOnChange: {
87
+ readonly kind: 'boolean';
88
+ readonly labelId: 'widgetFlashOnChange';
89
+ readonly helpId: 'widgetFlashOnChangeHint';
90
+ readonly doc: 'Briefly tint a value green on a rise and red on a fall when it changes.';
91
+ };
92
+ readonly window: {
93
+ readonly kind: 'number';
94
+ readonly integer: true;
95
+ readonly min: 1;
96
+ readonly labelId: 'widgetLabelWindow';
97
+ readonly helpId: 'widgetHintWindow';
98
+ readonly doc: 'Samples retained across ALL of the widget\'s measurements before the oldest are dropped. Bounds memory; only the chart draws them. Default 300.';
99
+ };
100
+ }>;
101
+ readonly table: WidgetDescriptor<"measurement", {
102
+ readonly title: {
103
+ readonly kind: 'string';
104
+ readonly labelId: 'widgetLabelTitle';
105
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
106
+ };
107
+ readonly precision: {
108
+ readonly kind: 'number';
109
+ readonly integer: true;
110
+ readonly min: 0;
111
+ readonly max: 100;
112
+ readonly labelId: 'widgetLabelPrecision';
113
+ readonly helpId: 'widgetHintPrecision';
114
+ readonly doc: 'Decimal places to round displayed values to. Unset shows the raw value.';
115
+ };
116
+ readonly flashOnChange: {
117
+ readonly kind: 'boolean';
118
+ readonly labelId: 'widgetFlashOnChange';
119
+ readonly helpId: 'widgetFlashOnChangeHint';
120
+ readonly doc: 'Briefly tint a value green on a rise and red on a fall when it changes.';
121
+ };
122
+ readonly window: {
123
+ readonly kind: 'number';
124
+ readonly integer: true;
125
+ readonly min: 1;
126
+ readonly labelId: 'widgetLabelWindow';
127
+ readonly helpId: 'widgetHintWindow';
128
+ readonly doc: 'Samples retained across ALL of the widget\'s measurements before the oldest are dropped. Bounds memory; only the chart draws them. Default 300.';
129
+ };
130
+ }>;
131
+ readonly label: WidgetDescriptor<"none", {
132
+ readonly title: {
133
+ readonly kind: 'string';
134
+ readonly labelId: 'widgetLabelTitle';
135
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
136
+ };
137
+ readonly text: {
138
+ readonly kind: "string";
139
+ readonly required: true;
140
+ readonly labelId: "widgetLabelText";
141
+ readonly doc: "The text to show. Rendered as plain text — markup is never interpreted.";
142
+ };
143
+ readonly align: {
144
+ readonly kind: "enum";
145
+ readonly values: readonly ["left", "center", "right"];
146
+ readonly labelId: "widgetLabelAlign";
147
+ readonly valueLabelIds: {
148
+ readonly left: "widgetAlignLeft";
149
+ readonly center: "widgetAlignCenter";
150
+ readonly right: "widgetAlignRight";
151
+ };
152
+ readonly placeholderId: "widgetPlaceholderDefault";
153
+ readonly doc: "Horizontal alignment of the text. Default center.";
154
+ };
155
+ readonly fontSize: {
156
+ readonly kind: "number";
157
+ readonly min: 1;
158
+ readonly labelId: "widgetLabelFontSize";
159
+ readonly helpId: "widgetHintFontSize";
160
+ readonly doc: "Text size in pixels. Default 16.";
161
+ };
162
+ }>;
163
+ readonly image: WidgetDescriptor<"none", {
164
+ readonly title: {
165
+ readonly kind: 'string';
166
+ readonly labelId: 'widgetLabelTitle';
167
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
168
+ };
169
+ readonly url: {
170
+ readonly kind: "string";
171
+ readonly required: true;
172
+ readonly labelId: "widgetLabelImageUrl";
173
+ readonly doc: "Source URL of the image.";
174
+ };
175
+ readonly alt: {
176
+ readonly kind: "string";
177
+ readonly labelId: "widgetLabelAltText";
178
+ readonly doc: "Alternative text describing the image for assistive technology.";
179
+ };
180
+ readonly fit: {
181
+ readonly kind: "enum";
182
+ readonly values: readonly ["contain", "cover", "fill"];
183
+ readonly labelId: "widgetLabelFit";
184
+ readonly valueLabelIds: {
185
+ readonly contain: "widgetFitContain";
186
+ readonly cover: "widgetFitCover";
187
+ readonly fill: "widgetFitFill";
188
+ };
189
+ readonly placeholderId: "widgetPlaceholderDefault";
190
+ readonly doc: "How the image fills its box. Default contain.";
191
+ };
192
+ }>;
193
+ readonly 'alarm-table': WidgetDescriptor<"alarm", {
194
+ readonly title: {
195
+ readonly kind: 'string';
196
+ readonly labelId: 'widgetLabelTitle';
197
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
198
+ };
199
+ readonly state: {
200
+ readonly kind: 'enum';
201
+ readonly values: readonly ["ACTIVE", "CLEARED"];
202
+ readonly labelId: 'widgetLabelState';
203
+ readonly helpId: 'widgetStateHint';
204
+ readonly valueLabelIds: {
205
+ readonly ACTIVE: 'widgetAlarmStateActive';
206
+ readonly CLEARED: 'widgetAlarmStateCleared';
207
+ };
208
+ readonly placeholderId: 'widgetPlaceholderAny';
209
+ readonly doc: 'Show only alarms in this state. Unset shows every state.';
210
+ };
211
+ readonly severity: {
212
+ readonly kind: 'enum';
213
+ readonly values: readonly ["CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"];
214
+ readonly labelId: 'widgetLabelSeverity';
215
+ readonly helpId: 'widgetSeverityHint';
216
+ readonly valueLabelIds: {
217
+ readonly CRITICAL: 'widgetAlarmSeverityCritical';
218
+ readonly MAJOR: 'widgetAlarmSeverityMajor';
219
+ readonly MINOR: 'widgetAlarmSeverityMinor';
220
+ readonly WARNING: 'widgetAlarmSeverityWarning';
221
+ readonly INDETERMINATE: 'widgetAlarmSeverityIndeterminate';
222
+ };
223
+ readonly placeholderId: 'widgetPlaceholderAny';
224
+ readonly doc: 'Show only alarms at this severity. Unset shows every severity.';
225
+ };
226
+ readonly acknowledged: {
227
+ readonly kind: 'enum';
228
+ readonly values: readonly ["true", "false"];
229
+ readonly labelId: 'widgetLabelAcknowledged';
230
+ readonly helpId: 'widgetAcknowledgedHint';
231
+ readonly valueLabelIds: {
232
+ readonly true: 'widgetAlarmAckAcknowledged';
233
+ readonly false: 'widgetAlarmAckUnacknowledged';
234
+ };
235
+ readonly placeholderId: 'widgetPlaceholderAny';
236
+ readonly doc: "Show only acknowledged ('true') or unacknowledged ('false') alarms. Unset shows both.";
237
+ };
238
+ readonly maxRows: {
239
+ readonly kind: "number";
240
+ readonly integer: true;
241
+ readonly min: 1;
242
+ readonly labelId: "widgetLabelMaxRows";
243
+ readonly helpId: "widgetMaxRowsAlarmHint";
244
+ readonly doc: "Alarms loaded into the table. Default 50.";
245
+ };
246
+ readonly precision: {
247
+ readonly kind: 'number';
248
+ readonly integer: true;
249
+ readonly min: 0;
250
+ readonly max: 100;
251
+ readonly labelId: 'widgetLabelPrecision';
252
+ readonly helpId: 'widgetHintPrecision';
253
+ readonly doc: 'Decimal places to round displayed values to. Unset shows the raw value.';
254
+ };
255
+ readonly flashOnChange: {
256
+ readonly kind: 'boolean';
257
+ readonly labelId: 'widgetFlashOnChange';
258
+ readonly helpId: 'widgetFlashOnChangeHint';
259
+ readonly doc: 'Briefly tint a value green on a rise and red on a fall when it changes.';
260
+ };
261
+ readonly selectionTarget: {
262
+ readonly kind: 'string';
263
+ readonly labelId: 'widgetLabelTargetSlot';
264
+ readonly helpId: 'widgetTargetSlotHint';
265
+ readonly control: 'slot-target';
266
+ readonly doc: 'Name of the slot this widget re-points when the viewer picks an entity.';
267
+ };
268
+ }>;
269
+ readonly 'alarm-count': WidgetDescriptor<"alarm", {
270
+ readonly title: {
271
+ readonly kind: 'string';
272
+ readonly labelId: 'widgetLabelTitle';
273
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
274
+ };
275
+ readonly state: {
276
+ readonly kind: 'enum';
277
+ readonly values: readonly ["ACTIVE", "CLEARED"];
278
+ readonly labelId: 'widgetLabelState';
279
+ readonly helpId: 'widgetStateHint';
280
+ readonly valueLabelIds: {
281
+ readonly ACTIVE: 'widgetAlarmStateActive';
282
+ readonly CLEARED: 'widgetAlarmStateCleared';
283
+ };
284
+ readonly placeholderId: 'widgetPlaceholderAny';
285
+ readonly doc: 'Show only alarms in this state. Unset shows every state.';
286
+ };
287
+ readonly severity: {
288
+ readonly kind: 'enum';
289
+ readonly values: readonly ["CRITICAL", "MAJOR", "MINOR", "WARNING", "INDETERMINATE"];
290
+ readonly labelId: 'widgetLabelSeverity';
291
+ readonly helpId: 'widgetSeverityHint';
292
+ readonly valueLabelIds: {
293
+ readonly CRITICAL: 'widgetAlarmSeverityCritical';
294
+ readonly MAJOR: 'widgetAlarmSeverityMajor';
295
+ readonly MINOR: 'widgetAlarmSeverityMinor';
296
+ readonly WARNING: 'widgetAlarmSeverityWarning';
297
+ readonly INDETERMINATE: 'widgetAlarmSeverityIndeterminate';
298
+ };
299
+ readonly placeholderId: 'widgetPlaceholderAny';
300
+ readonly doc: 'Show only alarms at this severity. Unset shows every severity.';
301
+ };
302
+ readonly acknowledged: {
303
+ readonly kind: 'enum';
304
+ readonly values: readonly ["true", "false"];
305
+ readonly labelId: 'widgetLabelAcknowledged';
306
+ readonly helpId: 'widgetAcknowledgedHint';
307
+ readonly valueLabelIds: {
308
+ readonly true: 'widgetAlarmAckAcknowledged';
309
+ readonly false: 'widgetAlarmAckUnacknowledged';
310
+ };
311
+ readonly placeholderId: 'widgetPlaceholderAny';
312
+ readonly doc: "Show only acknowledged ('true') or unacknowledged ('false') alarms. Unset shows both.";
313
+ };
314
+ }>;
315
+ readonly 'command-button': WidgetDescriptor<"control", {
316
+ readonly title: {
317
+ readonly kind: 'string';
318
+ readonly labelId: 'widgetLabelTitle';
319
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
320
+ };
321
+ readonly commandName: {
322
+ readonly kind: "string";
323
+ readonly required: true;
324
+ readonly labelId: "widgetCommandHeading";
325
+ readonly helpId: "widgetCommandFieldHint";
326
+ readonly control: "command-vocabulary";
327
+ readonly doc: "Command key issued to the target device. Without it the widget cannot send.";
328
+ };
329
+ readonly commandLabel: {
330
+ readonly kind: "string";
331
+ readonly labelId: "widgetCommandHeading";
332
+ readonly helpId: "widgetCommandFieldHint";
333
+ readonly control: "command-vocabulary";
334
+ readonly doc: "Text on the send button. Defaults to the command key.";
335
+ };
336
+ readonly parameterSchema: {
337
+ readonly kind: "string";
338
+ readonly format: "json";
339
+ readonly labelId: "widgetCommandHeading";
340
+ readonly helpId: "widgetCommandFieldHint";
341
+ readonly control: "command-vocabulary";
342
+ readonly doc: "The command's parameter descriptors, baked in as JSON at author time. Drives the typed form.";
343
+ };
344
+ readonly maxRows: {
345
+ readonly kind: "number";
346
+ readonly integer: true;
347
+ readonly min: 1;
348
+ readonly labelId: "widgetLabelMaxRows";
349
+ readonly helpId: "widgetMaxRowsCommandHint";
350
+ readonly doc: "Recent commands shown in the history. Default 20.";
351
+ };
352
+ }>;
353
+ readonly 'entity-selector': WidgetDescriptor<"selection", {
354
+ readonly title: {
355
+ readonly kind: 'string';
356
+ readonly labelId: 'widgetLabelTitle';
357
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
358
+ };
359
+ readonly selectionTarget: {
360
+ readonly kind: 'string';
361
+ readonly labelId: 'widgetLabelTargetSlot';
362
+ readonly helpId: 'widgetTargetSlotHint';
363
+ readonly control: 'slot-target';
364
+ readonly doc: 'Name of the slot this widget re-points when the viewer picks an entity.';
365
+ readonly required: true;
366
+ };
367
+ }>;
368
+ readonly map: WidgetDescriptor<"location", {
369
+ readonly title: {
370
+ readonly kind: 'string';
371
+ readonly labelId: 'widgetLabelTitle';
372
+ readonly doc: 'Heading shown in the widget frame. Blank hides the frame heading.';
373
+ };
374
+ readonly tileUrl: {
375
+ readonly kind: "string";
376
+ readonly labelId: "widgetLabelTileUrl";
377
+ readonly helpId: "widgetTileUrlHint";
378
+ readonly control: "basemap";
379
+ readonly doc: "Raster tile URL template, e.g. https://tiles.example.com/{z}/{x}/{y}.png. Leave empty to inherit the tenant's basemap; setting one overrides it for this board only.";
380
+ };
381
+ readonly attribution: {
382
+ readonly kind: "string";
383
+ readonly labelId: "widgetLabelAttribution";
384
+ readonly helpId: "widgetAttributionHint";
385
+ readonly control: "basemap";
386
+ readonly doc: "Credit line the tile source requires, shown on the map. Set whatever the provider you chose asks for.";
387
+ };
388
+ }>;
389
+ };
390
+ export declare const builtinWidgetCatalog: import("@devicechain/dashboards").WidgetCatalog;