@camstack/ui-library 1.2.328 → 1.2.330

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.
@@ -9,6 +9,7 @@
9
9
  * and every bucket is also a real button for keyboard and screen readers.
10
10
  */
11
11
  import { type JSX, type ReactNode } from "react";
12
+ import type { DisplayPreference } from "@camstack/types";
12
13
  import { type ChartWindowToggleProps } from "./chart-window";
13
14
  import { type BarBucket, type BarLayerDef } from "./bar-series-model";
14
15
  import type { ChartRange } from "./TimeSeriesChart";
@@ -22,6 +23,8 @@ export interface BarSeriesProps<TId extends string = string> {
22
23
  readonly range: ChartRange;
23
24
  readonly unit?: string | null;
24
25
  readonly formatValue?: (v: number, unit: string | null) => string;
26
+ /** Display preference for base-unit samples in the point tooltip. Default metric. */
27
+ readonly displayPreference?: DisplayPreference;
25
28
  /** Plot height in px. Default 100 (24 when `compact`). */
26
29
  readonly height?: number;
27
30
  /** Stack the layers (default true for more than one layer). */
@@ -46,4 +49,4 @@ export interface BarSeriesProps<TId extends string = string> {
46
49
  readonly bucketTestId?: string;
47
50
  readonly className?: string;
48
51
  }
49
- export declare function BarSeries<TId extends string = string>({ title, layers, buckets, bucketMs, range, unit, formatValue, height, stacked, showTotal, syncKey, pending, emptyMessage, actions, footer, windowToggle, compact, minBarFraction, selectedIndex, onSelect, bucketLabel, bucketTestId, className }: BarSeriesProps<TId>): JSX.Element;
52
+ export declare function BarSeries<TId extends string = string>({ title, layers, buckets, bucketMs, range, unit, formatValue, displayPreference, height, stacked, showTotal, syncKey, pending, emptyMessage, actions, footer, windowToggle, compact, minBarFraction, selectedIndex, onSelect, bucketLabel, bucketTestId, className }: BarSeriesProps<TId>): JSX.Element;
@@ -4,6 +4,7 @@
4
4
  * by (an epoch, a time); the value next to it names what the line is.
5
5
  */
6
6
  import { type JSX } from "react";
7
+ import type { DisplayPreference, ReadingQuantity } from "@camstack/types";
7
8
  import { type ChartChromeToken, type ChartSeriesToken } from "./chart-palette";
8
9
  export interface SparklinePoint {
9
10
  readonly x: number;
@@ -21,6 +22,10 @@ export interface SparklineProps {
21
22
  readonly widthClassName?: string;
22
23
  /** Start the value axis at zero (default true). */
23
24
  readonly zeroBased?: boolean;
25
+ readonly unit?: string | null;
26
+ readonly quantity?: ReadingQuantity;
27
+ /** Display preference for a base-unit sample in the point tooltip. Default metric. */
28
+ readonly displayPreference?: DisplayPreference;
24
29
  readonly className?: string;
25
30
  }
26
- export declare function Sparkline({ points, ariaLabel, token, height, widthClassName, zeroBased, className }: SparklineProps): JSX.Element;
31
+ export declare function Sparkline({ points, ariaLabel, token, height, widthClassName, zeroBased, unit, quantity, displayPreference, className }: SparklineProps): JSX.Element;
@@ -11,6 +11,7 @@
11
11
  * for the cross-device History page, where the reader chose the series.
12
12
  */
13
13
  import { type JSX, type ReactNode } from "react";
14
+ import type { DisplayPreference } from "@camstack/types";
14
15
  import { type ValueAxisSpec } from "./chart-uplot";
15
16
  import { type ChartWindowToggleProps } from "./chart-window";
16
17
  import { type TimeSeriesDef } from "./time-series-model";
@@ -34,6 +35,8 @@ export interface TimeSeriesChartProps<TId extends string = string> {
34
35
  readonly syncKey?: string;
35
36
  /** Value formatter per unit; default: bytes binary, `%` glued, unit after a space. */
36
37
  readonly formatValue?: (v: number, unit: string | null) => string;
38
+ /** Display preference for base-unit samples in the point tooltip. Default metric. */
39
+ readonly displayPreference?: DisplayPreference;
37
40
  /** Axis layout per unit; default by unit (°C floats, `%` floors at 10, bytes binary). */
38
41
  readonly axisFor?: (unit: string | null) => ValueAxisSpec;
39
42
  /** Shown when no series has a known value. */
@@ -45,4 +48,4 @@ export interface TimeSeriesChartProps<TId extends string = string> {
45
48
  readonly windowToggle?: ChartWindowToggleProps<TId>;
46
49
  readonly className?: string;
47
50
  }
48
- export declare function TimeSeriesChart<TId extends string = string>({ title, series, range, height, stacked, area, syncKey, formatValue, axisFor, emptyMessage, pending, actions, footer, windowToggle, className }: TimeSeriesChartProps<TId>): JSX.Element;
51
+ export declare function TimeSeriesChart<TId extends string = string>({ title, series, range, height, stacked, area, syncKey, formatValue, displayPreference, axisFor, emptyMessage, pending, actions, footer, windowToggle, className }: TimeSeriesChartProps<TId>): JSX.Element;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * One tooltip for every chart. The plot stays in `UPlotHost`; this shell
3
+ * tracks the pointer, a touch scrub and the arrow keys, and draws the
4
+ * readout inside the chart.
5
+ */
6
+ import { type JSX, type ReactNode, type RefObject } from "react";
7
+ import type uPlot from "uplot";
8
+ import { type ChartTooltipBody } from "./chart-tooltip-model";
9
+ export type ChartKind = "lines" | "states" | "bars" | "spark";
10
+ export interface ChartTooltipSpec {
11
+ readonly xMin: number;
12
+ readonly xMax: number;
13
+ readonly stops: readonly number[];
14
+ /** `null` means this x has nothing to show (the tooltip hides). */
15
+ readonly resolve: (dataX: number) => ChartTooltipBody | null;
16
+ /** The chart's own cursor (legend, state label) follows the selection. */
17
+ readonly onDataX?: (dataX: number | null) => void;
18
+ }
19
+ export interface ChartTooltipShellProps {
20
+ readonly spec: ChartTooltipSpec | null;
21
+ readonly plotRef: RefObject<uPlot | null>;
22
+ readonly kind?: ChartKind;
23
+ readonly label?: string;
24
+ readonly inline?: boolean;
25
+ readonly children: ReactNode;
26
+ }
27
+ export declare function ChartTooltipShell({ spec, plotRef, kind, label, inline, children }: ChartTooltipShellProps): JSX.Element;
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Selection, placement and readout for the chart point tooltip.
3
+ * Pure: no DOM. Every chart asks this, then the shared host draws one tooltip.
4
+ *
5
+ * A numeric sample is a base-unit reading (D944 §4): the quantity formatter
6
+ * applies the display preference. A unit string is used only when it names
7
+ * one quantity, so the tooltip never shows a bare number that has a unit.
8
+ */
9
+ import { type DisplayPreference, type ReadingQuantity } from "@camstack/types";
10
+ import { type StateSegment } from "./chart-data";
11
+ /** Movement below this is still a tap, not a scrub. */
12
+ export declare const CHART_TOUCH_SLOP_PX: number;
13
+ /** Gap between the selected point and the tooltip, in px. */
14
+ export declare const CHART_TOOLTIP_GAP_PX: number;
15
+ /** Inset that keeps the tooltip inside the chart. */
16
+ export declare const CHART_TOOLTIP_PAD_PX: number;
17
+ export type ChartPointerKind = "mouse" | "touch";
18
+ export interface ChartSelection {
19
+ readonly visible: boolean;
20
+ readonly dataX: number | null;
21
+ readonly anchorX: number;
22
+ readonly anchorY: number;
23
+ readonly pinned: boolean;
24
+ }
25
+ export interface ChartGesture {
26
+ readonly kind: ChartPointerKind;
27
+ readonly originX: number;
28
+ readonly originY: number;
29
+ readonly axis: "pending" | "x" | "y";
30
+ }
31
+ export interface ChartInteraction {
32
+ readonly selection: ChartSelection;
33
+ readonly gesture: ChartGesture | null;
34
+ readonly lockHorizontalScroll: boolean;
35
+ }
36
+ export declare const HIDDEN_SELECTION: ChartSelection;
37
+ export declare const HIDDEN_INTERACTION: ChartInteraction;
38
+ export interface ChartPointerEvent {
39
+ readonly type: "down" | "move" | "up";
40
+ readonly kind: ChartPointerKind;
41
+ readonly x: number;
42
+ readonly y: number;
43
+ readonly dataX: number | null;
44
+ }
45
+ export type ChartInteractionEvent = {
46
+ readonly type: "hover";
47
+ readonly dataX: number;
48
+ readonly anchorX: number;
49
+ readonly anchorY: number;
50
+ } | {
51
+ readonly type: "leave";
52
+ } | {
53
+ readonly type: "outside";
54
+ } | {
55
+ readonly type: "hide";
56
+ } | {
57
+ readonly type: "key";
58
+ readonly dataX: number;
59
+ readonly anchorX: number;
60
+ readonly anchorY: number;
61
+ } | ChartPointerEvent;
62
+ export interface DataXFromPointerInput {
63
+ readonly localX: number;
64
+ readonly plotLeft: number;
65
+ readonly plotWidth: number;
66
+ readonly xMin: number;
67
+ readonly xMax: number;
68
+ readonly clamp: boolean;
69
+ }
70
+ export interface PlaceTooltipInput {
71
+ readonly anchorX: number;
72
+ readonly anchorY: number;
73
+ readonly tooltipWidth: number;
74
+ readonly tooltipHeight: number;
75
+ readonly boundsWidth: number;
76
+ readonly boundsHeight: number;
77
+ readonly gap?: number;
78
+ }
79
+ export interface TooltipPlacement {
80
+ readonly left: number;
81
+ readonly top: number;
82
+ readonly placed: "left" | "right";
83
+ readonly vertical: "above" | "below";
84
+ }
85
+ export interface TooltipValueInput {
86
+ readonly value: number | null;
87
+ readonly quantity?: ReadingQuantity;
88
+ readonly preference?: DisplayPreference;
89
+ readonly precision?: number;
90
+ readonly unit?: string | null;
91
+ readonly unknownLabel?: string;
92
+ }
93
+ export interface ChartTooltipLine {
94
+ readonly id: string;
95
+ readonly label: string;
96
+ readonly value: string;
97
+ }
98
+ export interface ChartTooltipBody {
99
+ readonly heading: string;
100
+ readonly lines: readonly ChartTooltipLine[];
101
+ readonly liveText: string;
102
+ }
103
+ export interface LineTooltipSample {
104
+ readonly id: string;
105
+ readonly label: string;
106
+ readonly value: number | null;
107
+ readonly quantity?: ReadingQuantity;
108
+ readonly unit?: string | null;
109
+ readonly precision?: number;
110
+ readonly visible?: boolean;
111
+ }
112
+ export interface StateTooltipRow {
113
+ readonly id: string;
114
+ readonly label: string;
115
+ readonly stateLabel: string | null;
116
+ readonly spanMs: number | null;
117
+ }
118
+ export interface StateSpanHit {
119
+ readonly state: string | null;
120
+ readonly spanMs: number;
121
+ }
122
+ export interface BarTooltipLayer {
123
+ readonly id: string;
124
+ readonly label: string;
125
+ readonly value: number | null;
126
+ readonly quantity?: ReadingQuantity;
127
+ readonly unit?: string | null;
128
+ readonly precision?: number;
129
+ }
130
+ export interface BucketStart {
131
+ readonly t: number;
132
+ }
133
+ /** Index of the sample closest to `x`. A tie keeps the earlier sample. */
134
+ export declare function nearestPointIndex(xs: readonly number[], x: number): number | null;
135
+ /** Data x for a pointer inside the plot. `null` when it is outside and clamping is off. */
136
+ export declare function dataXFromPointer(input: DataXFromPointerInput): number | null;
137
+ /** Bucket that contains `dataX`, or the nearest one when `dataX` falls in a gap. */
138
+ export declare function bucketSelectionIndex(buckets: readonly BucketStart[], bucketMs: number, dataX: number): number | null;
139
+ /** Next keyboard stop. A null current starts at the first or last stop. */
140
+ export declare function stepStop(stops: readonly number[], current: number | null, direction: -1 | 1): number | null;
141
+ /** Pointer, keyboard and dismiss rules for one chart. */
142
+ export declare function reduceChartInteraction(state: ChartInteraction, event: ChartInteractionEvent): ChartInteraction;
143
+ /** One sample, with its unit. Missing samples are an em dash, never zero. */
144
+ export declare function formatTooltipValue(input: TooltipValueInput): string;
145
+ export interface LineTooltipBodyInput {
146
+ readonly timeLabel: string;
147
+ readonly series: readonly LineTooltipSample[];
148
+ readonly preference?: DisplayPreference;
149
+ }
150
+ /** Time plus one line per visible series. */
151
+ export declare function lineTooltipBody(input: LineTooltipBodyInput): ChartTooltipBody;
152
+ /** The state in force at `t`, and how long that span lasts. */
153
+ export declare function stateSpanAt(segments: readonly StateSegment[], t: number): StateSpanHit | null;
154
+ export declare function stateTooltipValue(stateLabel: string | null, spanMs: number | null): string;
155
+ export interface StateTooltipBodyInput {
156
+ readonly timeLabel: string;
157
+ readonly rows: readonly StateTooltipRow[];
158
+ }
159
+ /** One row per state series: the label and the span under the pointer. */
160
+ export declare function stateTooltipBody(input: StateTooltipBodyInput): ChartTooltipBody;
161
+ /** `start – end` for one bar bucket, at the window's time precision. */
162
+ export declare function barRangeLabel(start: number, bucketMs: number, spanMs: number): string;
163
+ export interface BarTooltipBodyInput {
164
+ readonly rangeLabel: string;
165
+ readonly layers: readonly BarTooltipLayer[];
166
+ readonly preference?: DisplayPreference;
167
+ }
168
+ /** The bucket's range, and each layer's value with its unit. */
169
+ export declare function barTooltipBody(input: BarTooltipBodyInput): ChartTooltipBody;
170
+ /**
171
+ * Place the tooltip beside the point, inside the chart. The first side that
172
+ * fits and does not cover the point wins; the edges flip before the corners.
173
+ */
174
+ export declare function placeChartTooltip(input: PlaceTooltipInput): TooltipPlacement;
@@ -2,6 +2,7 @@
2
2
  * The pure half of `TimeSeriesChart`: which series go on which value axis,
3
3
  * the aligned data uPlot draws, and what the readout says at an index.
4
4
  */
5
+ import type { ReadingQuantity } from "@camstack/types";
5
6
  import { type AlignedValue, type GapSpan, type TimePoint } from "./chart-data";
6
7
  export type SeriesInterpolation = "linear" | "step";
7
8
  export interface TimeSeriesDef {
@@ -10,6 +11,8 @@ export interface TimeSeriesDef {
10
11
  readonly label: string;
11
12
  /** `null` is an unknown unit; series sharing a unit share an axis. */
12
13
  readonly unit?: string | null;
14
+ /** Stored base-unit quantity (D944 §4). The tooltip formats through it. */
15
+ readonly quantity?: ReadingQuantity;
13
16
  readonly points: readonly TimePoint[];
14
17
  /** Categorical slot (`chartSeriesStyle`); the caller keeps it stable across filters. */
15
18
  readonly colorIndex: number;
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { type JSX } from "react";
15
15
  import type uPlot from "uplot";
16
+ import { type ChartKind, type ChartTooltipSpec } from "./chart-tooltip-host";
16
17
  export type UPlotCtor = typeof uPlot;
17
18
  /** Options without the size: the host owns width (the container) and height (the prop). */
18
19
  export type ChartPlotOptions = Omit<uPlot.Options, "width" | "height">;
@@ -30,5 +31,12 @@ export interface UPlotHostProps {
30
31
  readonly className?: string;
31
32
  /** Render a `<span class="block">` host, for a plot inside phrasing content. */
32
33
  readonly inline?: boolean;
34
+ /** Point tooltip. Absent on a plot that has nothing to select. */
35
+ readonly tooltip?: ChartTooltipSpec | null;
36
+ /** Which chart this plot is, so a shot can aim the pointer at one of them. */
37
+ readonly kind?: ChartKind;
38
+ /** Accessible name for the focusable plot. */
39
+ readonly label?: string;
33
40
  }
34
- export declare function UPlotHost({ optionsKey, buildOptions, data, height, onInstance, className, inline }: UPlotHostProps): JSX.Element;
41
+ export type { ChartKind, ChartTooltipSpec };
42
+ export declare function UPlotHost({ optionsKey, buildOptions, data, height, onInstance, className, inline, tooltip, kind, label }: UPlotHostProps): JSX.Element;
@@ -63,6 +63,8 @@ export declare const useAddonsListCapabilityProviders: typeof trpc.addons.listCa
63
63
  export declare const useAddonsSetCapabilityProviderEnabled: typeof trpc.addons.setCapabilityProviderEnabled.useMutation;
64
64
  /** Generated alias around `trpc.addons.getVersions.useQuery`. */
65
65
  export declare const useAddonsGetVersions: typeof trpc.addons.getVersions.useQuery;
66
+ /** Generated alias around `trpc.addons.getPackageDocs.useQuery`. */
67
+ export declare const useAddonsGetPackageDocs: typeof trpc.addons.getPackageDocs.useQuery;
66
68
  /** Generated alias around `trpc.addons.restartAddon.useMutation`. */
67
69
  export declare const useAddonsRestartAddon: typeof trpc.addons.restartAddon.useMutation;
68
70
  /** Generated alias around `trpc.addons.retryLoad.useMutation`. */
@@ -841,6 +843,8 @@ export declare const useFeatureProbeGetStatus: typeof trpc.featureProbe.getStatu
841
843
  export declare const useFloodGetStatus: typeof trpc.flood.getStatus.useQuery;
842
844
  /** Generated alias around `trpc.gas.getStatus.useQuery`. */
843
845
  export declare const useGasGetStatus: typeof trpc.gas.getStatus.useQuery;
846
+ /** Generated alias around `trpc.groupCommands.getStatus.useQuery`. */
847
+ export declare const useGroupCommandsGetStatus: typeof trpc.groupCommands.getStatus.useQuery;
844
848
  /** Generated alias around `trpc.groupStatus.getStatus.useQuery`. */
845
849
  export declare const useGroupStatusGetStatus: typeof trpc.groupStatus.getStatus.useQuery;
846
850
  /** Generated alias around `trpc.heatingValve.getStatus.useQuery`. */