@agent-factory-platform/ui-kit 0.6.0 → 0.7.1

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
@@ -14,6 +14,31 @@ Use the exact Agent Factory version across packages in one application.
14
14
 
15
15
  This package owns reusable, business-free infrastructure and lifecycle contracts. Product prompts, domain tools, policies, credentials, data, and deployment configuration remain in the consuming application.
16
16
 
17
+ The package root exports `OhlcChart`, `SignedAreaChart`, `MultiLineChart`,
18
+ `TimeBarChart`, `TimeComboChart`, `DepthChart`, `DivergingBarChart`,
19
+ `DualAxisLineChart`, `DualAxisBarChart`, `GroupedBarChart`, and `WeightedHeatmap`.
20
+ Hosts supply samples, labels, formatting, links, event content, and domain field
21
+ mapping. The package does not fetch data, calculate strategies, or submit orders.
22
+
23
+ `readChartPalette` and `observeChartPalette` bridge semantic CSS roles to canvas
24
+ engines. Pass the chart's element for scoped themes; dispose the returned observer
25
+ when the chart unmounts. `ChartEngineThemeAdapters` supplies theme configuration
26
+ for Lightweight Charts, TradingView, ECharts, and KLineCharts. OHLC rendering uses
27
+ Lightweight Charts and keeps its attribution visible.
28
+
29
+ `WorkspaceGrid` owns panel movement, resize, keyboard interaction and optional
30
+ layout persistence. `DataTable` owns sorting, paired column resize, optional
31
+ leading-column pinning and row activation. `CalendarPeriodNavigator` composes
32
+ existing date/tabs controls; hosts own date arithmetic and navigation state.
33
+
34
+ OHLC timestamps are milliseconds, strictly increasing at second precision;
35
+ invalid OHLC bounds, nonfinite values, negative volume and precision outside
36
+ 0–12 are rejected before engine dispatch. Independent line series require unique
37
+ IDs other than reserved `timestamp`/`value` and prototype keys. `TimeBarChart`
38
+ is for nonnegative measurements; use `TimeComboChart` for signed bars.
39
+ The Y-axis gutter is capped at 120 pixels: use a compact formatter for longer
40
+ labels. Table pinning supports the leading identity column only.
41
+
17
42
  ## Documentation
18
43
 
19
44
  API and package documentation: [https://www.npmjs.com/package/@agent-factory-platform/ui-kit](https://www.npmjs.com/package/@agent-factory-platform/ui-kit)
@@ -0,0 +1,165 @@
1
+ export interface ChartPalette {
2
+ mode?: "light" | "dark";
3
+ font?: string;
4
+ canvas: string;
5
+ surface: string;
6
+ text: string;
7
+ mutedText: string;
8
+ grid: string;
9
+ axis: string;
10
+ accent: string;
11
+ event: string;
12
+ comparison: string;
13
+ up: string;
14
+ down: string;
15
+ }
16
+ export interface ChartEngineAdapter<Snapshot, Update = Snapshot, Capture = Blob> {
17
+ mount(container: HTMLElement): void | Promise<void>;
18
+ applyTheme(palette: ChartPalette): void | Promise<void>;
19
+ applyLocale(locale: string): void | Promise<void>;
20
+ applyPrecision(precision: {
21
+ price: number;
22
+ size: number;
23
+ }): void | Promise<void>;
24
+ setSnapshot(snapshot: Snapshot): void | Promise<void>;
25
+ update(update: Update): void | Promise<void>;
26
+ resize(width: number, height: number): void | Promise<void>;
27
+ capture(): Capture | Promise<Capture>;
28
+ dispose(): void | Promise<void>;
29
+ }
30
+ export declare function readChartPalette(root?: Element): ChartPalette;
31
+ export declare function observeChartPalette(apply: (palette: ChartPalette) => void, root?: HTMLElement): () => void;
32
+ export declare function tradingViewTheme(palette: ChartPalette): {
33
+ readonly theme: "dark" | "light";
34
+ readonly overrides: {
35
+ readonly "paneProperties.background": string;
36
+ readonly "paneProperties.vertGridProperties.color": string;
37
+ readonly "paneProperties.horzGridProperties.color": string;
38
+ readonly "scalesProperties.textColor": string;
39
+ readonly "scalesProperties.lineColor": string;
40
+ readonly "mainSeriesProperties.candleStyle.upColor": string;
41
+ readonly "mainSeriesProperties.candleStyle.downColor": string;
42
+ readonly "mainSeriesProperties.candleStyle.wickUpColor": string;
43
+ readonly "mainSeriesProperties.candleStyle.wickDownColor": string;
44
+ };
45
+ };
46
+ export declare function lightweightChartsTheme(palette: ChartPalette): {
47
+ readonly layout: {
48
+ readonly background: {
49
+ readonly color: string;
50
+ };
51
+ readonly textColor: string;
52
+ };
53
+ readonly grid: {
54
+ readonly vertLines: {
55
+ readonly color: string;
56
+ };
57
+ readonly horzLines: {
58
+ readonly color: string;
59
+ };
60
+ };
61
+ readonly rightPriceScale: {
62
+ readonly borderColor: string;
63
+ };
64
+ readonly timeScale: {
65
+ readonly borderColor: string;
66
+ };
67
+ readonly crosshair: {
68
+ readonly vertLine: {
69
+ readonly color: string;
70
+ };
71
+ readonly horzLine: {
72
+ readonly color: string;
73
+ };
74
+ };
75
+ };
76
+ export declare function klineChartsTheme(palette: ChartPalette): {
77
+ readonly grid: {
78
+ readonly horizontal: {
79
+ readonly color: string;
80
+ };
81
+ readonly vertical: {
82
+ readonly color: string;
83
+ };
84
+ };
85
+ readonly candle: {
86
+ readonly bar: {
87
+ readonly upColor: string;
88
+ readonly downColor: string;
89
+ readonly noChangeColor: string;
90
+ readonly upBorderColor: string;
91
+ readonly downBorderColor: string;
92
+ readonly upWickColor: string;
93
+ readonly downWickColor: string;
94
+ };
95
+ readonly tooltip: {
96
+ readonly text: {
97
+ readonly color: string;
98
+ };
99
+ readonly rect: {
100
+ readonly color: string;
101
+ };
102
+ };
103
+ };
104
+ readonly xAxis: {
105
+ readonly axisLine: {
106
+ readonly color: string;
107
+ };
108
+ readonly tickText: {
109
+ readonly color: string;
110
+ };
111
+ };
112
+ readonly yAxis: {
113
+ readonly axisLine: {
114
+ readonly color: string;
115
+ };
116
+ readonly tickText: {
117
+ readonly color: string;
118
+ };
119
+ };
120
+ };
121
+ export declare function echartsTheme(palette: ChartPalette): {
122
+ readonly backgroundColor: string;
123
+ readonly textStyle: {
124
+ readonly color: string;
125
+ readonly fontFamily: string;
126
+ };
127
+ readonly color: readonly [string, string, string, string];
128
+ readonly categoryAxis: {
129
+ readonly axisLine: {
130
+ readonly lineStyle: {
131
+ readonly color: string;
132
+ };
133
+ };
134
+ readonly axisLabel: {
135
+ readonly color: string;
136
+ };
137
+ readonly splitLine: {
138
+ readonly lineStyle: {
139
+ readonly color: string;
140
+ };
141
+ };
142
+ };
143
+ readonly valueAxis: {
144
+ readonly axisLine: {
145
+ readonly lineStyle: {
146
+ readonly color: string;
147
+ };
148
+ };
149
+ readonly axisLabel: {
150
+ readonly color: string;
151
+ };
152
+ readonly splitLine: {
153
+ readonly lineStyle: {
154
+ readonly color: string;
155
+ };
156
+ };
157
+ };
158
+ };
159
+ /** Discoverable adapter registry for docs, integration tests, and downstream engines. */
160
+ export declare const ChartEngineThemeAdapters: {
161
+ readonly tradingView: typeof tradingViewTheme;
162
+ readonly lightweightCharts: typeof lightweightChartsTheme;
163
+ readonly klineCharts: typeof klineChartsTheme;
164
+ readonly echarts: typeof echartsTheme;
165
+ };
@@ -7,6 +7,6 @@ export declare function ChartTooltip({ active, payload, label, valueFormat, labe
7
7
  active?: boolean;
8
8
  payload?: ChartTooltipItem[];
9
9
  label?: string | number;
10
- valueFormat?: (value: string | number) => string;
10
+ valueFormat?: (value: string | number, name?: string | number) => string;
11
11
  labelFormat?: (value: string | number) => string;
12
12
  }): import("react").JSX.Element | null;
@@ -0,0 +1,40 @@
1
+ import type { IPrimitivePaneView, ISeriesPrimitive, PrimitiveHoveredItem, SeriesAttachedParameter, Time, UTCTimestamp } from "lightweight-charts";
2
+ import type { OhlcChartMarker } from "./ohlc";
3
+ export declare const CHART_EVENT_MARKER_RADIUS = 14;
4
+ export interface TradingViewEventMarkerModel {
5
+ id: string;
6
+ time: UTCTimestamp;
7
+ color: string;
8
+ label: string;
9
+ }
10
+ interface EventMarkerGeometry extends TradingViewEventMarkerModel {
11
+ x: number;
12
+ y: number;
13
+ }
14
+ interface EventMarkerPalette {
15
+ font?: string;
16
+ interior: string;
17
+ text: string;
18
+ event: string;
19
+ }
20
+ export declare function buildTradingViewEventMarkers(markers: readonly OhlcChartMarker[], fallbackColor: string): TradingViewEventMarkerModel[];
21
+ export declare function eventMarkerHitDistance(x: number, y: number, markerX: number, markerY: number): number | null;
22
+ export declare class TradingViewEventMarkersPrimitive implements ISeriesPrimitive<Time> {
23
+ private chart;
24
+ private requestUpdate;
25
+ private readonly sourceMarkers;
26
+ private markers;
27
+ private geometry;
28
+ private readonly view;
29
+ palette: EventMarkerPalette;
30
+ constructor(markers: readonly OhlcChartMarker[], palette: EventMarkerPalette);
31
+ attached(param: SeriesAttachedParameter<Time>): void;
32
+ detached(): void;
33
+ paneViews(): readonly IPrimitivePaneView[];
34
+ updateAllViews(): void;
35
+ setPalette(palette: EventMarkerPalette): void;
36
+ visibleMarkers(y: number): EventMarkerGeometry[];
37
+ setGeometry(geometry: EventMarkerGeometry[]): void;
38
+ hitTest(x: number, y: number): PrimitiveHoveredItem | null;
39
+ }
40
+ export {};
@@ -1,2 +1,6 @@
1
1
  export { AreaTrendChart, BarChart, HistogramChart, PieChart, RadarChart, RadialGaugeChart, Sparkline, type BarPoint, type PieSlice, type RadarPoint, type SparklineTone, type TrendPoint } from "./basic";
2
2
  export { CATEGORICAL, CHART, axisProps, gridProps } from "./theme";
3
+ export { DepthChart, DivergingBarChart, DualAxisBarChart, DualAxisLineChart, GroupedBarChart, SignedAreaChart, MultiLineChart, TimeBarChart, WeightedHeatmap, buildDepthSeries, chartYAxisWidth, type DepthLevel, type DepthPoint, type DivergingBarChartProps, type DivergingBarPoint, type DualAxisChartProps, type DualAxisPoint, type GroupedBarChartProps, type SignedAreaChartProps, type TimeLineSeries, type TimeSeriesMarker, type MultiLineChartProps, type TimeValuePoint, type TimeBarChartProps, type WeightedHeatmapItem, type WeightedHeatmapProps } from "./series";
4
+ export { OhlcChart, type OhlcChartMarker, type OhlcChartProps, type CandlePoint } from "./ohlc";
5
+ export { ChartEngineThemeAdapters, echartsTheme, klineChartsTheme, lightweightChartsTheme, observeChartPalette, readChartPalette, tradingViewTheme, type ChartEngineAdapter, type ChartPalette } from "./adapter";
6
+ export { TimeComboChart, type TimeComboChartProps, type TimeComboPoint, type TimeComboSeries } from "./time-combo";
@@ -0,0 +1,36 @@
1
+ import { type ReactNode } from "react";
2
+ export interface CandlePoint {
3
+ time: number;
4
+ label: string;
5
+ open: number;
6
+ high: number;
7
+ low: number;
8
+ close: number;
9
+ volume: number;
10
+ }
11
+ export interface OhlcChartMarker {
12
+ id: string;
13
+ time: number;
14
+ color?: string;
15
+ label?: string;
16
+ ariaLabel: string;
17
+ popoverTitle?: string;
18
+ popoverCloseLabel?: string;
19
+ popover?: ReactNode;
20
+ }
21
+ export interface OhlcChartProps {
22
+ data: CandlePoint[];
23
+ markers?: readonly OhlcChartMarker[];
24
+ onMarkerClick?: (marker: OhlcChartMarker) => void;
25
+ height?: number | string;
26
+ valueFormat?: (value: number) => string;
27
+ locale?: string;
28
+ pricePrecision?: number;
29
+ showVolume?: boolean;
30
+ transparent?: boolean;
31
+ ariaLabel?: string;
32
+ className?: string;
33
+ }
34
+ /** The engine requires strictly increasing second timestamps and finite OHLC values. */
35
+ export declare function validateOhlcData(data: readonly CandlePoint[], precision: number): void;
36
+ export declare function OhlcChart({ data, markers, onMarkerClick, height, valueFormat, locale, pricePrecision, showVolume, transparent, ariaLabel, className, }: OhlcChartProps): import("react").JSX.Element;
@@ -0,0 +1,181 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ export interface DepthLevel {
3
+ price: number;
4
+ size: number;
5
+ }
6
+ export interface DepthPoint {
7
+ price: number;
8
+ bid?: number;
9
+ ask?: number;
10
+ }
11
+ export declare function buildDepthSeries(bids: DepthLevel[], asks: DepthLevel[], mid?: number): {
12
+ center: number;
13
+ bestBid: number;
14
+ bestAsk: number;
15
+ data: DepthPoint[];
16
+ domain: [number, number];
17
+ bidTotal: number;
18
+ askTotal: number;
19
+ spread: number;
20
+ bidWalls: (DepthPoint & {
21
+ size: number;
22
+ })[];
23
+ askWalls: (DepthPoint & {
24
+ size: number;
25
+ })[];
26
+ } | null;
27
+ export declare function DepthChart({ bids, asks, mid, height, valueFormat, sizeFormat, bidLabel, askLabel, spreadLabel, ariaLabel }: {
28
+ bids: DepthLevel[];
29
+ asks: DepthLevel[];
30
+ mid?: number;
31
+ height?: number | `${number}%`;
32
+ valueFormat?: (value: number) => string;
33
+ sizeFormat?: (value: number) => string;
34
+ bidLabel?: string;
35
+ askLabel?: string;
36
+ spreadLabel?: string;
37
+ ariaLabel?: string;
38
+ }): import("react").JSX.Element;
39
+ export interface DivergingBarPoint {
40
+ label: string;
41
+ positive: number;
42
+ negative: number;
43
+ }
44
+ export interface DivergingBarChartProps {
45
+ data: DivergingBarPoint[];
46
+ positiveLabel: string;
47
+ negativeLabel: string;
48
+ positiveTone?: "up" | "down" | "blue";
49
+ negativeTone?: "up" | "down" | "blue";
50
+ orientation?: "vertical" | "horizontal";
51
+ numericAxis?: boolean;
52
+ reference?: {
53
+ value: string | number;
54
+ label: string;
55
+ };
56
+ height?: number;
57
+ axisFormat?: (value: string | number) => string;
58
+ valueFormat?: (value: string | number) => string;
59
+ ariaLabel?: string;
60
+ }
61
+ /** Mirrored positive and negative distributions around a fixed zero baseline. */
62
+ export declare function DivergingBarChart({ data, positiveLabel, negativeLabel, positiveTone, negativeTone, orientation, numericAxis, reference, height, axisFormat, valueFormat, ariaLabel, }: DivergingBarChartProps): import("react").JSX.Element;
63
+ export interface DualAxisPoint {
64
+ label: string | number;
65
+ primary: number;
66
+ secondary: number;
67
+ }
68
+ export interface GroupedBarChartProps {
69
+ data: DualAxisPoint[];
70
+ primaryLabel: string;
71
+ secondaryLabel: string;
72
+ valueFormat?: (value: string | number) => string;
73
+ labelFormat?: (value: string | number) => string;
74
+ height?: number;
75
+ ariaLabel?: string;
76
+ }
77
+ export interface DualAxisChartProps {
78
+ data: DualAxisPoint[];
79
+ primaryLabel: string;
80
+ secondaryLabel: string;
81
+ primaryFormat?: (value: string | number) => string;
82
+ secondaryFormat?: (value: string | number) => string;
83
+ labelFormat?: (value: string | number) => string;
84
+ height?: number;
85
+ ariaLabel?: string;
86
+ }
87
+ /** Primary area plus secondary line on independent value axes. */
88
+ export declare function DualAxisLineChart({ data, primaryLabel, secondaryLabel, primaryFormat, secondaryFormat, labelFormat, height, ariaLabel }: DualAxisChartProps): import("react").JSX.Element;
89
+ /** Categorical primary and secondary bars on independent value axes. */
90
+ export declare function DualAxisBarChart({ data, primaryLabel, secondaryLabel, primaryFormat, secondaryFormat, labelFormat, height, ariaLabel }: DualAxisChartProps): import("react").JSX.Element;
91
+ /** Same-unit categorical comparison, such as two measurements by category. */
92
+ export declare function GroupedBarChart({ data, primaryLabel, secondaryLabel, valueFormat, labelFormat, height, ariaLabel }: GroupedBarChartProps): import("react").JSX.Element;
93
+ export interface TimeValuePoint {
94
+ timestamp: number;
95
+ value: number;
96
+ }
97
+ export interface TimeSeriesMarker {
98
+ id: string;
99
+ timestamp: number;
100
+ value: number;
101
+ tone: "up" | "down";
102
+ }
103
+ export interface SignedAreaChartProps {
104
+ data: TimeValuePoint[];
105
+ height?: number;
106
+ name?: string;
107
+ valueFormat?: (value: string | number) => string;
108
+ timestampFormat?: (value: string | number) => string;
109
+ tooltipContent?: ReactElement;
110
+ markers?: TimeSeriesMarker[];
111
+ tone?: "signed" | "blue" | "up" | "warning";
112
+ referenceValue?: number;
113
+ /** Include zero in the value range; otherwise fit the data range. */
114
+ includeZero?: boolean;
115
+ showLastDot?: boolean;
116
+ onActiveValueChange?: (value: number | null) => void;
117
+ testId?: string;
118
+ ariaLabel?: string;
119
+ }
120
+ export interface TimeLineSeries {
121
+ id: string;
122
+ name: string;
123
+ data: TimeValuePoint[];
124
+ color?: string;
125
+ }
126
+ export interface MultiLineChartProps {
127
+ series: TimeLineSeries[];
128
+ height?: number;
129
+ valueFormat?: (value: string | number) => string;
130
+ timestampFormat?: (value: string | number) => string;
131
+ tooltipContent?: ReactElement;
132
+ markers?: TimeSeriesMarker[];
133
+ includeZero?: boolean;
134
+ onActiveValueChange?: (value: number | null) => void;
135
+ testId?: string;
136
+ ariaLabel?: string;
137
+ }
138
+ /** Estimate the gutter for formatted Y ticks. */
139
+ export declare function chartYAxisWidth(domain: [number, number], valueFormat: (value: string | number) => string): number;
140
+ export declare function SignedAreaChart({ data, height, name, valueFormat, timestampFormat, tooltipContent, markers, tone, referenceValue, includeZero, showLastDot, onActiveValueChange, testId, ariaLabel, }: SignedAreaChartProps): import("react").JSX.Element;
141
+ export declare function alignTimeLineSeries(series: TimeLineSeries[], fillBeforeStart?: boolean): Record<string, number>[];
142
+ /** Multiple independent value series on one shared time/value axis. */
143
+ export declare function MultiLineChart({ series, height, valueFormat, timestampFormat, tooltipContent, markers, includeZero, onActiveValueChange, testId, ariaLabel, }: MultiLineChartProps): import("react").JSX.Element;
144
+ export interface TimeBarChartProps {
145
+ data: TimeValuePoint[];
146
+ height?: number;
147
+ name?: string;
148
+ valueFormat?: (value: string | number) => string;
149
+ timestampFormat?: (value: string | number) => string;
150
+ tooltipContent?: ReactElement;
151
+ onActiveValueChange?: (value: number | null) => void;
152
+ testId?: string;
153
+ ariaLabel?: string;
154
+ }
155
+ /** Time-series bar chart with hatch texture (nonnegative measurements). Y ≥ 0. */
156
+ export declare function TimeBarChart({ data, height, name, valueFormat, timestampFormat, tooltipContent, onActiveValueChange, testId, ariaLabel, }: TimeBarChartProps): import("react").JSX.Element;
157
+ export interface WeightedHeatmapItem {
158
+ [key: string]: string | number;
159
+ name: string;
160
+ value: number;
161
+ change: number;
162
+ }
163
+ export interface WeightedHeatmapProps {
164
+ data: WeightedHeatmapItem[];
165
+ height?: number | `${number}%`;
166
+ ariaLabel?: string;
167
+ /** Formats the area-driving value shown inside sufficiently large cells. */
168
+ valueFormat?: (value: number) => string;
169
+ /** Formats the signed color-driving value shown inside cells. */
170
+ changeFormat?: (value: number) => string;
171
+ /** Absolute signed value that reaches maximum color intensity. */
172
+ intensityMax?: number;
173
+ valueLabel?: string;
174
+ changeLabel?: string;
175
+ /** Renders an icon at the size selected for the current cell or tooltip. */
176
+ renderIcon?: (item: WeightedHeatmapItem, size: number) => ReactNode;
177
+ hrefForItem?: (item: WeightedHeatmapItem) => string | undefined;
178
+ itemAriaLabel?: (item: WeightedHeatmapItem) => string;
179
+ }
180
+ /** Area encodes magnitude; color direction and intensity encode a signed secondary metric. */
181
+ export declare function WeightedHeatmap({ data, height, ariaLabel, valueFormat, changeFormat, intensityMax, valueLabel, changeLabel, renderIcon, hrefForItem, itemAriaLabel }: WeightedHeatmapProps): import("react").JSX.Element;
@@ -12,6 +12,7 @@ export declare const CHART: {
12
12
  readonly surface: "var(--color-surface-raised)";
13
13
  readonly up: "var(--color-up)";
14
14
  readonly down: "var(--color-down)";
15
+ readonly warning: "var(--color-warning)";
15
16
  readonly apricot: "var(--color-apricot-wash)";
16
17
  readonly sky: "var(--color-sky-wash)";
17
18
  readonly white: "var(--color-surface-raised)";
@@ -0,0 +1,22 @@
1
+ export interface TimeComboPoint {
2
+ timestamp: number;
3
+ [key: string]: number;
4
+ }
5
+ export interface TimeComboSeries {
6
+ id: string;
7
+ name: string;
8
+ kind: "line" | "bar";
9
+ color?: string;
10
+ opacity?: number;
11
+ dashed?: boolean;
12
+ }
13
+ export interface TimeComboChartProps {
14
+ data: TimeComboPoint[];
15
+ series: TimeComboSeries[];
16
+ height?: number;
17
+ timestampFormat?: (value: string | number) => string;
18
+ valueFormat?: (value: string | number) => string;
19
+ ariaLabel?: string;
20
+ }
21
+ /** Lines and bars share one time/value axis; field meaning belongs to the caller. */
22
+ export declare function TimeComboChart({ data, series, height, timestampFormat, valueFormat, ariaLabel }: TimeComboChartProps): import("react").JSX.Element;