@devicechain/widgets 0.21.1 → 0.22.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.
Files changed (78) hide show
  1. package/README.md +28 -7
  2. package/dist/aggregate-feed.d.ts +14 -0
  3. package/dist/aggregate-fold.d.ts +11 -0
  4. package/dist/aggregate-reading.d.ts +19 -0
  5. package/dist/aggregate-strings.d.ts +16 -0
  6. package/dist/binding-policy.d.ts +3 -1
  7. package/dist/builtin-descriptors.d.ts +1210 -8
  8. package/dist/builtin-registry.d.ts +1197 -8
  9. package/dist/category-geometry.d.ts +19 -0
  10. package/dist/category-items.d.ts +10 -0
  11. package/dist/chunks/aggregate-feed-6ZYKOQOB.js +130 -0
  12. package/dist/chunks/aggregate-feed-6ZYKOQOB.js.map +7 -0
  13. package/dist/chunks/aggregate-widgets-WVXAW3UL.js +895 -0
  14. package/dist/chunks/aggregate-widgets-WVXAW3UL.js.map +7 -0
  15. package/dist/chunks/chunk-2D7JNKFE.js +65 -0
  16. package/dist/chunks/chunk-2D7JNKFE.js.map +7 -0
  17. package/dist/chunks/chunk-S2OMBJLI.js +200 -0
  18. package/dist/chunks/chunk-S2OMBJLI.js.map +7 -0
  19. package/dist/chunks/chunk-XQQQNTBX.js +76 -0
  20. package/dist/chunks/chunk-XQQQNTBX.js.map +7 -0
  21. package/dist/chunks/chunk-YPFB6DAL.js +157 -0
  22. package/dist/chunks/chunk-YPFB6DAL.js.map +7 -0
  23. package/dist/chunks/chunk-ZR74ORIT.js +35 -0
  24. package/dist/chunks/chunk-ZR74ORIT.js.map +7 -0
  25. package/dist/chunks/control-widgets-UDS4ET3T.js +775 -0
  26. package/dist/chunks/control-widgets-UDS4ET3T.js.map +7 -0
  27. package/dist/chunks/fleet-feed-FK4ZMKIK.js +252 -0
  28. package/dist/chunks/fleet-feed-FK4ZMKIK.js.map +7 -0
  29. package/dist/chunks/level-widgets-MJB7TOLU.js +833 -0
  30. package/dist/chunks/level-widgets-MJB7TOLU.js.map +7 -0
  31. package/dist/command-control-core.d.ts +68 -0
  32. package/dist/command-control-strings.d.ts +32 -0
  33. package/dist/command-control.d.ts +31 -0
  34. package/dist/dashboard-renderer.d.ts +15 -4
  35. package/dist/fleet-feed.d.ts +21 -0
  36. package/dist/fleet-model.d.ts +43 -0
  37. package/dist/fleet-seed.d.ts +7 -0
  38. package/dist/fleet-strings.d.ts +25 -0
  39. package/dist/heading.d.ts +3 -0
  40. package/dist/index.d.ts +3 -2
  41. package/dist/index.js +1774 -676
  42. package/dist/index.js.map +4 -4
  43. package/dist/level-reading.d.ts +29 -0
  44. package/dist/level-readout.d.ts +25 -0
  45. package/dist/level-strings.d.ts +13 -0
  46. package/dist/options.d.ts +1 -1
  47. package/dist/time-range-bar.d.ts +28 -0
  48. package/dist/use-held.d.ts +1 -0
  49. package/dist/value-scale.d.ts +30 -0
  50. package/dist/widgets/aggregate-lazy.d.ts +305 -0
  51. package/dist/widgets/aggregate-widgets.d.ts +4 -0
  52. package/dist/widgets/alarm-count.d.ts +1 -0
  53. package/dist/widgets/alarm-table.d.ts +4 -1
  54. package/dist/widgets/bar-chart.d.ts +5 -0
  55. package/dist/widgets/battery.d.ts +7 -0
  56. package/dist/widgets/command-slider.d.ts +2 -0
  57. package/dist/widgets/command-toggle.d.ts +4 -0
  58. package/dist/widgets/compass.d.ts +2 -0
  59. package/dist/widgets/control-lazy.d.ts +92 -0
  60. package/dist/widgets/control-widgets.d.ts +2 -0
  61. package/dist/widgets/fleet-table.d.ts +13 -0
  62. package/dist/widgets/gauge.d.ts +52 -0
  63. package/dist/widgets/label.d.ts +1 -1
  64. package/dist/widgets/latest-card.d.ts +44 -1
  65. package/dist/widgets/lazy-chunk.d.ts +8 -0
  66. package/dist/widgets/level-gauge.d.ts +2 -0
  67. package/dist/widgets/level-lazy.d.ts +647 -0
  68. package/dist/widgets/level-widgets.d.ts +7 -0
  69. package/dist/widgets/linear-gauge.d.ts +2 -0
  70. package/dist/widgets/pie-chart.d.ts +2 -0
  71. package/dist/widgets/progress-ring.d.ts +3 -0
  72. package/dist/widgets/severity.d.ts +2 -1
  73. package/dist/widgets/signal-bars.d.ts +3 -0
  74. package/dist/widgets/stat-card.d.ts +3 -0
  75. package/dist/widgets/status-light.d.ts +7 -0
  76. package/dist/widgets/table.d.ts +9 -1
  77. package/dist/widgets/time-series-chart.d.ts +62 -4
  78. package/package.json +8 -8
package/README.md CHANGED
@@ -6,8 +6,8 @@ SPDX-License-Identifier: Apache-2.0
6
6
  # @devicechain/widgets
7
7
 
8
8
  React dashboard widgets for DeviceChain, plus the renderer that lays a board out.
9
- Eleven widgets across five channels — charts, gauges, tables, alarm views, a
10
- command button, an entity selector and a map — all bound to live data through
9
+ Twenty-four widgets — charts, gauges, tables, a fleet table, alarm views,
10
+ command controls, an entity selector and a map — all bound to live data through
11
11
  [`@devicechain/dashboards`](https://www.npmjs.com/package/@devicechain/dashboards).
12
12
 
13
13
  Themed entirely with CSS custom properties. No Tailwind, no global styles, no
@@ -50,16 +50,23 @@ bound to a slot needs its datasource resolved first (`resolveWidgets` or
50
50
 
51
51
  | channel | widgets |
52
52
  | --- | --- |
53
- | measurement | `timeseries-chart`, `gauge`, `latest-card`, `table` |
53
+ | measurement | `timeseries-chart`, `latest-card`, `gauge`, `linear-gauge`, `level-gauge`, `battery`, `status-light`, `signal-bars`, `compass`, `progress-ring`, `table`, `bar-chart`, `pie-chart`, `fleet-table` |
54
+ | aggregate | `stat-card` |
54
55
  | none (static) | `label`, `image` |
55
56
  | alarm | `alarm-table`, `alarm-count` |
56
- | control | `command-button` |
57
+ | control | `command-button`, `command-slider`, `command-toggle` |
57
58
  | selection | `entity-selector` |
58
59
  | location | `map` |
59
60
 
60
- Charts and gauges are [Apache ECharts](https://echarts.apache.org); the map is
61
- [MapLibre GL](https://maplibre.org), loaded lazily so a board with no map on it
62
- downloads none of it.
61
+ `fleet-table`, and `bar-chart` in its one-bar-per-device mode, read a device
62
+ group member by member. The other measurement widgets, and `stat-card`, show one
63
+ device and refuse a group. `stat-card` shows one figure (average, minimum, maximum, sum, count or
64
+ latest) over the board's time range.
65
+
66
+ The time-series chart, the dial gauge and the compass are drawn with
67
+ [Apache ECharts](https://echarts.apache.org); the other widgets are plain DOM
68
+ and SVG. The map is [MapLibre GL](https://maplibre.org), loaded lazily so a board
69
+ with no map on it downloads none of it.
63
70
 
64
71
  `WIDGET_OPTIONS` is the typed schema for every widget's options bag —
65
72
  `validateWidgetOptions` reports exactly where a stored bag disagrees with what the
@@ -158,6 +165,20 @@ widgets by setting variables on any ancestor. The DeviceChain values ship as
158
165
  [`@devicechain/brand`](https://www.npmjs.com/package/@devicechain/brand); nothing
159
166
  here requires them.
160
167
 
168
+ ## Upgrading from 0.21
169
+
170
+ - `severityColor(severity)` is now `severityColor(colors, severity)`; the
171
+ colours come from `useSeverityColors()` in `@devicechain/widget-sdk`.
172
+ - The `timeseries-chart` option `window` (a sample count) is replaced by
173
+ `windowSeconds` (a time span), and the chart's options version moves from 1 to
174
+ 2. A stored board converts when it is parsed: the sample count is dropped and
175
+ the chart follows the board's time range.
176
+ - Thirteen widgets are new, so `WidgetChannel` and the widget id unions gained
177
+ members; an exhaustive `switch` over them needs new cases.
178
+
179
+ See [If you build against the npm packages](https://docs.devicechain.io/deployment/releases-and-upgrades#v0220-packages)
180
+ in the release's upgrade guide.
181
+
161
182
  ## Compatibility
162
183
 
163
184
  React 19, ESM only, built for bundler resolution (Vite, webpack, Rollup, esbuild).
@@ -0,0 +1,14 @@
1
+ import { type WidgetActions, type WidgetDataSource, type WidgetDescriptor, type WidgetInstance } from '@devicechain/dashboards';
2
+ import { type ComponentType } from 'react';
3
+ export interface AggregateFeedProps {
4
+ hub: WidgetDataSource;
5
+ widget: WidgetInstance;
6
+ descriptor: WidgetDescriptor;
7
+ Component: ComponentType<any>;
8
+ actions: WidgetActions | undefined;
9
+ ErrorFrame: ComponentType<{
10
+ widget: WidgetInstance;
11
+ error: unknown;
12
+ }>;
13
+ }
14
+ export default function AggregateFeed({ hub, widget, descriptor, Component, actions, ErrorFrame }: AggregateFeedProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { type HistoryWindow, type MeasurementAggregate, type MeasurementBucket } from '@devicechain/dashboards';
2
+ export declare class AggregateFieldsError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ export declare function aggregateBuckets(buckets: readonly MeasurementBucket[]): Record<string, MeasurementAggregate>;
6
+ export declare function aggregateRefreshMs(spanSeconds: number): number;
7
+ export interface AggregateWindow {
8
+ window: HistoryWindow;
9
+ spanSeconds: number;
10
+ }
11
+ export declare function aggregateWindow(spanSeconds: number, at: number): AggregateWindow;
@@ -0,0 +1,19 @@
1
+ import type { AggregateStreamState, WidgetInstance } from '@devicechain/dashboards';
2
+ import { type AggregateStat } from './aggregate-strings';
3
+ export type EmptyReason = 'loading' | 'unsupported' | 'failed' | 'noReadings' | 'noData' | 'unbound';
4
+ export type StatReading = {
5
+ kind: 'value';
6
+ stat: AggregateStat;
7
+ name: string | undefined;
8
+ value: number;
9
+ spanSeconds: number | undefined;
10
+ time?: string | null;
11
+ } | {
12
+ kind: 'empty';
13
+ reason: EmptyReason;
14
+ name: string | undefined;
15
+ message?: string;
16
+ spanSeconds?: number;
17
+ };
18
+ export declare function parseStat(v: unknown): AggregateStat;
19
+ export declare function statReading(widget: WidgetInstance, data: AggregateStreamState, stat: AggregateStat): StatReading;
@@ -0,0 +1,16 @@
1
+ export declare const AGGREGATE_STATS: readonly ['avg', 'min', 'max', 'sum', 'count', 'last'];
2
+ export type AggregateStat = (typeof AGGREGATE_STATS)[number];
3
+ export interface AggregateStrings {
4
+ stats: Record<AggregateStat, string>;
5
+ loading: string;
6
+ unsupported: string;
7
+ failed: (message: string | undefined) => string;
8
+ noReadings: (span: string) => string;
9
+ noData: string;
10
+ unbound: string;
11
+ noCategories: string;
12
+ pieNegative: string;
13
+ pieNoShare: string;
14
+ }
15
+ export declare const AGGREGATE_STRINGS: Record<'en' | 'es', AggregateStrings>;
16
+ export declare function aggregateStrings(locale?: string | undefined): AggregateStrings;
@@ -1,4 +1,6 @@
1
- import type { AlarmSubscription, CommandSubscription, WidgetDescriptor, WidgetInstance } from '@devicechain/dashboards';
1
+ import { type AlarmSubscription, type CommandSubscription, type WidgetDescriptor, type WidgetInstance } from '@devicechain/dashboards';
2
2
  export declare function measurementWindow(descriptor: WidgetDescriptor, widget: WidgetInstance): number | undefined;
3
+ export declare function measurementSpan(descriptor: WidgetDescriptor, widget: WidgetInstance, boardSpan: number | undefined): number | undefined;
4
+ export declare function membersMode(descriptor: WidgetDescriptor, widget: WidgetInstance): boolean;
3
5
  export declare function alarmSubscription(descriptor: WidgetDescriptor, widget: WidgetInstance): AlarmSubscription;
4
6
  export declare function commandSubscription(descriptor: WidgetDescriptor, widget: WidgetInstance): CommandSubscription;