@agent-factory-platform/ui-kit 0.7.1 → 0.9.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 (90) hide show
  1. package/README.md +22 -0
  2. package/dist/charts/adapter.js +111 -0
  3. package/dist/charts/basic.d.ts +2 -0
  4. package/dist/charts/basic.js +115 -0
  5. package/dist/charts/chart-tooltip.js +21 -0
  6. package/dist/charts/event-markers-primitive.d.ts +10 -1
  7. package/dist/charts/event-markers-primitive.js +116 -0
  8. package/dist/charts/index.d.ts +1 -0
  9. package/dist/charts/ohlc-annotations.d.ts +56 -0
  10. package/dist/charts/ohlc-annotations.js +84 -0
  11. package/dist/charts/ohlc.d.ts +5 -1
  12. package/dist/charts/ohlc.js +240 -0
  13. package/dist/charts/series.js +584 -0
  14. package/dist/charts/theme.js +35 -0
  15. package/dist/charts/time-combo.js +17 -0
  16. package/dist/component-api.js +3 -5
  17. package/dist/component-api.json.js +9 -0
  18. package/dist/component-manifest.json.js +9 -0
  19. package/dist/components/alert.js +35 -0
  20. package/dist/components/avatar.js +101 -0
  21. package/dist/components/badge.js +111 -0
  22. package/dist/components/button-group.js +22 -0
  23. package/dist/components/button.js +64 -0
  24. package/dist/components/calendar-period-navigator.js +34 -0
  25. package/dist/components/card.js +35 -0
  26. package/dist/components/chart-frame.js +53 -0
  27. package/dist/components/color-picker.js +155 -0
  28. package/dist/components/combobox.js +129 -0
  29. package/dist/components/command-dialog.js +89 -0
  30. package/dist/components/confirm-dialog.js +57 -0
  31. package/dist/components/data-table.js +135 -0
  32. package/dist/components/date-time.js +203 -0
  33. package/dist/components/disclosure.js +29 -0
  34. package/dist/components/drawer.js +150 -0
  35. package/dist/components/dropdown-select.js +191 -0
  36. package/dist/components/field.js +21 -0
  37. package/dist/components/floating-window.js +159 -0
  38. package/dist/components/heading.js +21 -0
  39. package/dist/components/hover-tip.js +90 -0
  40. package/dist/components/icon-tip.js +12 -0
  41. package/dist/components/input-group.js +16 -0
  42. package/dist/components/input-otp.js +56 -0
  43. package/dist/components/input.js +44 -0
  44. package/dist/components/item.js +47 -0
  45. package/dist/components/kbd.js +18 -0
  46. package/dist/components/line-chart.js +79 -0
  47. package/dist/components/listbox.js +33 -0
  48. package/dist/components/live-value.js +26 -0
  49. package/dist/components/modal.js +140 -0
  50. package/dist/components/multi-select.js +54 -0
  51. package/dist/components/native-select.js +17 -0
  52. package/dist/components/navigation.js +42 -0
  53. package/dist/components/page.js +24 -0
  54. package/dist/components/popover-menu.js +164 -0
  55. package/dist/components/progress.js +23 -0
  56. package/dist/components/resizable-pane.js +73 -0
  57. package/dist/components/scroll-load-more.js +61 -0
  58. package/dist/components/seg-slider.js +42 -0
  59. package/dist/components/segmented-control.js +46 -0
  60. package/dist/components/selection-controls.js +119 -0
  61. package/dist/components/sidebar.js +23 -0
  62. package/dist/components/skeleton.js +9 -0
  63. package/dist/components/slider.js +162 -0
  64. package/dist/components/sliding-tabs.js +118 -0
  65. package/dist/components/spinner.js +9 -0
  66. package/dist/components/spotlight-tour.js +122 -0
  67. package/dist/components/stat-card.js +23 -0
  68. package/dist/components/state-view.js +75 -0
  69. package/dist/components/stats-table.js +17 -0
  70. package/dist/components/table.js +24 -0
  71. package/dist/components/tag-pill.d.ts +4 -1
  72. package/dist/components/tag-pill.js +69 -0
  73. package/dist/components/theme-editor.js +159 -0
  74. package/dist/components/toast.js +66 -0
  75. package/dist/components/toolbar.js +46 -0
  76. package/dist/components/utility.js +19 -0
  77. package/dist/components/widget-frame.js +41 -0
  78. package/dist/components/widget-picker.js +87 -0
  79. package/dist/components/workspace-grid.js +468 -0
  80. package/dist/focus-modality.js +3 -15
  81. package/dist/index.d.ts +1 -1
  82. package/dist/index.js +228 -5564
  83. package/dist/lib/cn.js +6 -0
  84. package/dist/lib/focus-modality.js +16 -0
  85. package/dist/lib/motion.js +27 -0
  86. package/dist/lib/viewport.js +13 -0
  87. package/dist/manifest.js +5 -7
  88. package/dist/styles.js +1 -1
  89. package/dist/theme.js +158 -0
  90. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,24 @@ Use the exact Agent Factory version across packages in one application.
12
12
 
13
13
  ## Scope
14
14
 
15
+ The public root exports retain module boundaries: importing shell components
16
+ does not force engines from a separately lazy-loaded chart into the initial
17
+ bundle. Continue importing the public package; private `dist` paths are not API.
18
+
19
+ `TagList` defaults to pills. Use `variant="dot"` with `toneForItem` returning
20
+ `up | down | accent | warning | muted` for a compact semantic row; the caller
21
+ supplies `labelForItem`, while `limit` and the overflow count remain shared.
22
+
23
+ `OhlcChart.annotations` accepts neutral `OhlcAnnotation` levels (`price`), bands
24
+ (`from`/`to` prices, optional opacity), and segments (`from`/`to` time-price
25
+ points). Levels/segments accept `lineStyle` and widths 1–4; callers supply colors
26
+ and labels. Times are epoch milliseconds and non-bar times use the engine's
27
+ nearest bar. Annotation prices participate in autoscaling; updating annotations
28
+ preserves the chart instance. `markers[].price` optionally anchors a marker at
29
+ its price instead of the bottom event track, including its keyboard target.
30
+ Both lists are limited to 256 entries; geometry must be finite and marker IDs
31
+ unique. The existing engine owns zoom, resize, theme, drawing and cleanup.
32
+
15
33
  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
34
 
17
35
  The package root exports `OhlcChart`, `SignedAreaChart`, `MultiLineChart`,
@@ -42,3 +60,7 @@ labels. Table pinning supports the leading identity column only.
42
60
  ## Documentation
43
61
 
44
62
  API and package documentation: [https://www.npmjs.com/package/@agent-factory-platform/ui-kit](https://www.npmjs.com/package/@agent-factory-platform/ui-kit)
63
+
64
+ `PieChart` accepts per-slice `color` and `opacity` overrides. Omitted fields keep
65
+ the categorical palette and opacity 1; opacity 0 remains transparent. These are
66
+ presentation fields, so consumers can preserve their own semantic color mapping.
@@ -0,0 +1,111 @@
1
+ const c = {
2
+ canvas: "--color-surface-canvas",
3
+ surface: "--color-surface-raised",
4
+ text: "--color-ink",
5
+ mutedText: "--color-graphite",
6
+ grid: "--color-chart-grid",
7
+ axis: "--color-chart-axis",
8
+ accent: "--color-rust",
9
+ event: "--color-chart-event",
10
+ comparison: "--color-data-blue",
11
+ up: "--color-up",
12
+ down: "--color-down"
13
+ };
14
+ function s(o = document.documentElement) {
15
+ const r = getComputedStyle(o);
16
+ return {
17
+ ...Object.fromEntries(Object.entries(c).map(([e, i]) => [e, r.getPropertyValue(i).trim()])),
18
+ mode: r.colorScheme === "dark" ? "dark" : r.colorScheme === "light" ? "light" : void 0,
19
+ font: r.fontFamily
20
+ };
21
+ }
22
+ function m(o, r = document.documentElement) {
23
+ const e = () => o(s(r));
24
+ e();
25
+ const i = new MutationObserver(e);
26
+ for (let n = r; n; n = n.parentElement)
27
+ i.observe(n, { attributes: !0, attributeFilter: ["class", "style", "data-theme"] });
28
+ return () => i.disconnect();
29
+ }
30
+ function t(o) {
31
+ const r = /^#([0-9a-f]{6})$/i.exec(o);
32
+ if (!r) return !1;
33
+ const e = [0, 2, 4].map((i) => Number.parseInt(r[1].slice(i, i + 2), 16));
34
+ return e[0] * 0.2126 + e[1] * 0.7152 + e[2] * 0.0722 < 128;
35
+ }
36
+ function a(o) {
37
+ return {
38
+ theme: o.mode ?? (t(o.canvas) ? "dark" : "light"),
39
+ overrides: {
40
+ "paneProperties.background": o.canvas,
41
+ "paneProperties.vertGridProperties.color": o.grid,
42
+ "paneProperties.horzGridProperties.color": o.grid,
43
+ "scalesProperties.textColor": o.mutedText,
44
+ "scalesProperties.lineColor": o.axis,
45
+ "mainSeriesProperties.candleStyle.upColor": o.up,
46
+ "mainSeriesProperties.candleStyle.downColor": o.down,
47
+ "mainSeriesProperties.candleStyle.wickUpColor": o.up,
48
+ "mainSeriesProperties.candleStyle.wickDownColor": o.down
49
+ }
50
+ };
51
+ }
52
+ function l(o) {
53
+ return {
54
+ layout: { background: { color: o.canvas }, textColor: o.mutedText },
55
+ grid: { vertLines: { color: o.grid }, horzLines: { color: o.grid } },
56
+ rightPriceScale: { borderColor: o.axis },
57
+ timeScale: { borderColor: o.axis },
58
+ crosshair: { vertLine: { color: o.axis }, horzLine: { color: o.axis } }
59
+ };
60
+ }
61
+ function d(o) {
62
+ return {
63
+ grid: { horizontal: { color: o.grid }, vertical: { color: o.grid } },
64
+ candle: {
65
+ bar: {
66
+ upColor: o.up,
67
+ downColor: o.down,
68
+ noChangeColor: o.mutedText,
69
+ upBorderColor: o.up,
70
+ downBorderColor: o.down,
71
+ upWickColor: o.up,
72
+ downWickColor: o.down
73
+ },
74
+ tooltip: { text: { color: o.text }, rect: { color: o.surface } }
75
+ },
76
+ xAxis: { axisLine: { color: o.axis }, tickText: { color: o.mutedText } },
77
+ yAxis: { axisLine: { color: o.axis }, tickText: { color: o.mutedText } }
78
+ };
79
+ }
80
+ function u(o) {
81
+ return {
82
+ backgroundColor: o.canvas,
83
+ textStyle: { color: o.text, fontFamily: o.font || "system-ui" },
84
+ color: [o.accent, o.comparison, o.up, o.down],
85
+ categoryAxis: {
86
+ axisLine: { lineStyle: { color: o.axis } },
87
+ axisLabel: { color: o.mutedText },
88
+ splitLine: { lineStyle: { color: o.grid } }
89
+ },
90
+ valueAxis: {
91
+ axisLine: { lineStyle: { color: o.axis } },
92
+ axisLabel: { color: o.mutedText },
93
+ splitLine: { lineStyle: { color: o.grid } }
94
+ }
95
+ };
96
+ }
97
+ const x = {
98
+ tradingView: a,
99
+ lightweightCharts: l,
100
+ klineCharts: d,
101
+ echarts: u
102
+ };
103
+ export {
104
+ x as ChartEngineThemeAdapters,
105
+ u as echartsTheme,
106
+ d as klineChartsTheme,
107
+ l as lightweightChartsTheme,
108
+ m as observeChartPalette,
109
+ s as readChartPalette,
110
+ a as tradingViewTheme
111
+ };
@@ -10,6 +10,8 @@ export interface BarPoint {
10
10
  export interface PieSlice {
11
11
  name: string;
12
12
  value: number;
13
+ color?: string;
14
+ opacity?: number;
13
15
  }
14
16
  export interface RadarPoint {
15
17
  label: string;
@@ -0,0 +1,115 @@
1
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
+ import { useId as b } from "react";
3
+ import { ResponsiveContainer as c, AreaChart as v, CartesianGrid as x, XAxis as C, YAxis as k, Tooltip as h, Area as m, BarChart as O, Bar as P, Cell as R, PieChart as S, Legend as B, Pie as N, RadarChart as $, PolarGrid as I, PolarAngleAxis as A, PolarRadiusAxis as G, Radar as y, RadialBarChart as L, RadialBar as T } from "recharts";
4
+ import { ChartTooltip as u } from "./chart-tooltip.js";
5
+ import { CHART as t, gridProps as w, axisProps as p, CATEGORICAL as g } from "./theme.js";
6
+ function H({ data: a, height: i = 240, valueFormat: r = String, showPrevious: n = !0, ariaLabel: s = "Area trend chart" }) {
7
+ const o = b().replace(/:/g, "");
8
+ return /* @__PURE__ */ e(c, { width: "100%", height: i, children: /* @__PURE__ */ l(v, { data: a, margin: { top: 8, right: 8, left: 0, bottom: 0 }, accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": s, children: [
9
+ /* @__PURE__ */ l("defs", { children: [
10
+ /* @__PURE__ */ l("linearGradient", { id: `${o}-current`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
11
+ /* @__PURE__ */ e("stop", { offset: "0%", stopColor: t.blue, stopOpacity: 0.26 }),
12
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: t.blue, stopOpacity: 0 })
13
+ ] }),
14
+ /* @__PURE__ */ l("linearGradient", { id: `${o}-previous`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
15
+ /* @__PURE__ */ e("stop", { offset: "0%", stopColor: t.rust, stopOpacity: 0.18 }),
16
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: t.rust, stopOpacity: 0 })
17
+ ] })
18
+ ] }),
19
+ /* @__PURE__ */ e(x, { ...w }),
20
+ /* @__PURE__ */ e(C, { dataKey: "label", ...p }),
21
+ /* @__PURE__ */ e(k, { ...p, width: 52, tickFormatter: r }),
22
+ /* @__PURE__ */ e(h, { cursor: { stroke: t.dove }, content: /* @__PURE__ */ e(u, { valueFormat: r }) }),
23
+ n && /* @__PURE__ */ e(m, { type: "monotone", dataKey: "previous", name: "Previous", stroke: t.rust, strokeWidth: 1.5, fill: `url(#${o}-previous)`, dot: !1 }),
24
+ /* @__PURE__ */ e(m, { type: "monotone", dataKey: "current", name: "Current", stroke: t.blue, strokeWidth: 2, fill: `url(#${o}-current)`, dot: !1 })
25
+ ] }) });
26
+ }
27
+ function W({ data: a, height: i = 240, valueFormat: r = String, signColor: n = !1, ariaLabel: s = "Bar chart" }) {
28
+ return /* @__PURE__ */ e(c, { width: "100%", height: i, children: /* @__PURE__ */ l(O, { data: a, margin: { top: 8, right: 8, left: 0, bottom: 0 }, accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": s, children: [
29
+ /* @__PURE__ */ e(x, { ...w }),
30
+ /* @__PURE__ */ e(C, { dataKey: "label", ...p }),
31
+ /* @__PURE__ */ e(k, { ...p, width: 52, tickFormatter: r }),
32
+ /* @__PURE__ */ e(h, { cursor: { fill: t.dove, fillOpacity: 0.12 }, content: /* @__PURE__ */ e(u, { valueFormat: r }) }),
33
+ /* @__PURE__ */ e(P, { dataKey: "value", name: "Value", maxBarSize: 36, radius: [4, 4, 0, 0], children: a.map((o) => /* @__PURE__ */ e(R, { fill: n ? o.value >= 0 ? t.up : t.down : t.blue }, o.label)) })
34
+ ] }) });
35
+ }
36
+ function V(a) {
37
+ return /* @__PURE__ */ e(W, { ...a, signColor: !0 });
38
+ }
39
+ function E({ data: a, height: i = 220, donut: r = !1, centerLabel: n, valueFormat: s = String, ariaLabel: o = "Pie chart" }) {
40
+ return /* @__PURE__ */ l("div", { className: "relative", style: { height: i }, children: [
41
+ /* @__PURE__ */ e(c, { width: "100%", height: "100%", children: /* @__PURE__ */ l(S, { accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": o, children: [
42
+ /* @__PURE__ */ e(h, { content: /* @__PURE__ */ e(u, { valueFormat: s }) }),
43
+ /* @__PURE__ */ e(B, { iconType: "circle", wrapperStyle: { color: t.graphite, fontFamily: t.font, fontSize: 12 } }),
44
+ /* @__PURE__ */ e(N, { data: a, dataKey: "value", nameKey: "name", innerRadius: r ? "54%" : 0, outerRadius: "78%", paddingAngle: r ? 2 : 0, cornerRadius: r ? 4 : 0, stroke: t.canvas, strokeWidth: 2, children: a.map((d, f) => /* @__PURE__ */ e(R, { fill: d.color ?? g[f % g.length], fillOpacity: d.opacity ?? 1 }, d.name)) })
45
+ ] }) }),
46
+ r && n && /* @__PURE__ */ e("span", { className: "pointer-events-none absolute inset-0 grid place-items-center font-product text-caption font-[600] text-ink", children: n })
47
+ ] });
48
+ }
49
+ function X({ data: a, height: i = 260, ariaLabel: r = "Radar chart" }) {
50
+ return /* @__PURE__ */ e(c, { width: "100%", height: i, children: /* @__PURE__ */ l($, { data: a, outerRadius: "72%", accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": r, children: [
51
+ /* @__PURE__ */ e(I, { stroke: t.grid }),
52
+ /* @__PURE__ */ e(A, { dataKey: "label", tick: { fill: t.graphite, fontFamily: t.font, fontSize: 11 } }),
53
+ /* @__PURE__ */ e(G, { tick: !1, axisLine: !1 }),
54
+ /* @__PURE__ */ e(h, { content: /* @__PURE__ */ e(u, {}) }),
55
+ /* @__PURE__ */ e(y, { name: "Current", dataKey: "current", stroke: t.blue, fill: t.blue, fillOpacity: 0.2 }),
56
+ /* @__PURE__ */ e(y, { name: "Previous", dataKey: "previous", stroke: t.rust, fill: t.rust, fillOpacity: 0.1 })
57
+ ] }) });
58
+ }
59
+ function Y({ value: a, maximum: i = 100, label: r, height: n = 220 }) {
60
+ const s = Math.min(i, Math.max(0, a));
61
+ return /* @__PURE__ */ l("div", { className: "relative", style: { height: n }, children: [
62
+ /* @__PURE__ */ e(c, { width: "100%", height: "100%", children: /* @__PURE__ */ l(L, { data: [{ name: r, value: s, fill: t.rust }], startAngle: 210, endAngle: -30, innerRadius: "64%", outerRadius: "92%", barSize: 16, accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": r, children: [
63
+ /* @__PURE__ */ e(A, { type: "number", domain: [0, i], tick: !1 }),
64
+ /* @__PURE__ */ e(T, { dataKey: "value", background: { fill: t.grid }, cornerRadius: 8 })
65
+ ] }) }),
66
+ /* @__PURE__ */ l("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center pt-4", children: [
67
+ /* @__PURE__ */ e("strong", { className: "font-data text-heading-sm tabular-nums text-ink", children: s }),
68
+ /* @__PURE__ */ e("span", { className: "text-caption text-graphite", children: r })
69
+ ] })
70
+ ] });
71
+ }
72
+ function q({
73
+ data: a,
74
+ tone: i = "up",
75
+ height: r = 40,
76
+ ariaLabel: n = "Value trend",
77
+ emptyLabel: s
78
+ }) {
79
+ const o = b().replace(/:/g, ""), d = i === "blue" ? t.blue : i === "down" ? t.down : t.up;
80
+ return a.length < 2 ? /* @__PURE__ */ e(
81
+ "div",
82
+ {
83
+ className: "pointer-events-none relative overflow-hidden rounded-md bg-fog/50",
84
+ style: { height: r },
85
+ role: "img",
86
+ "aria-label": s || n,
87
+ children: /* @__PURE__ */ e("svg", { width: "100%", height: "100%", viewBox: "0 0 120 40", preserveAspectRatio: "none", "aria-hidden": !0, className: "absolute inset-0", children: /* @__PURE__ */ e(
88
+ "path",
89
+ {
90
+ d: "M4 22 C 30 18, 55 26, 80 20 S 110 16, 116 22",
91
+ fill: "none",
92
+ stroke: t.dove,
93
+ strokeWidth: 1.25,
94
+ strokeDasharray: "3 3",
95
+ strokeOpacity: 0.75
96
+ }
97
+ ) })
98
+ }
99
+ ) : /* @__PURE__ */ e("div", { className: "pointer-events-none", style: { height: r }, children: /* @__PURE__ */ e(c, { width: "100%", height: "100%", children: /* @__PURE__ */ l(v, { data: a.map((f, K) => ({ index: K, value: f })), margin: { top: 2, right: 0, left: 0, bottom: 0 }, accessibilityLayer: !1, tabIndex: -1, role: "img", "aria-label": n, children: [
100
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l("linearGradient", { id: `${o}-spark`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
101
+ /* @__PURE__ */ e("stop", { offset: "0%", stopColor: d, stopOpacity: 0.25 }),
102
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: d, stopOpacity: 0 })
103
+ ] }) }),
104
+ /* @__PURE__ */ e(m, { type: "monotone", dataKey: "value", stroke: d, strokeWidth: 2, fill: `url(#${o}-spark)`, dot: !1, activeDot: !1, isAnimationActive: !1 })
105
+ ] }) }) });
106
+ }
107
+ export {
108
+ H as AreaTrendChart,
109
+ W as BarChart,
110
+ V as HistogramChart,
111
+ E as PieChart,
112
+ X as RadarChart,
113
+ Y as RadialGaugeChart,
114
+ q as Sparkline
115
+ };
@@ -0,0 +1,21 @@
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import { CHART as c } from "./theme.js";
3
+ function p({
4
+ active: s,
5
+ payload: n,
6
+ label: t,
7
+ valueFormat: i = String,
8
+ labelFormat: l = String
9
+ }) {
10
+ return !s || !(n != null && n.length) ? null : /* @__PURE__ */ a("div", { role: "tooltip", className: "rounded-panel border border-border bg-surface-raised px-3 py-2 shadow-pop", style: { fontFamily: c.font }, children: [
11
+ t != null && /* @__PURE__ */ r("div", { className: "mb-1 text-caption text-graphite", children: l(t) }),
12
+ /* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: n.map((e, o) => /* @__PURE__ */ a("div", { className: "flex items-center gap-2 text-body-sm text-ink", children: [
13
+ /* @__PURE__ */ r("span", { className: "size-2 rounded-indicator", style: { backgroundColor: e.color }, "aria-hidden": !0 }),
14
+ /* @__PURE__ */ r("span", { className: "text-graphite", children: e.name }),
15
+ /* @__PURE__ */ r("span", { className: "ml-auto font-data tabular-nums", children: i(e.value ?? "", e.name) })
16
+ ] }, `${e.name ?? "series"}-${o}`)) })
17
+ ] });
18
+ }
19
+ export {
20
+ p as ChartTooltip
21
+ };
@@ -6,6 +6,7 @@ export interface TradingViewEventMarkerModel {
6
6
  time: UTCTimestamp;
7
7
  color: string;
8
8
  label: string;
9
+ price?: number;
9
10
  }
10
11
  interface EventMarkerGeometry extends TradingViewEventMarkerModel {
11
12
  x: number;
@@ -20,18 +21,26 @@ interface EventMarkerPalette {
20
21
  export declare function buildTradingViewEventMarkers(markers: readonly OhlcChartMarker[], fallbackColor: string): TradingViewEventMarkerModel[];
21
22
  export declare function eventMarkerHitDistance(x: number, y: number, markerX: number, markerY: number): number | null;
22
23
  export declare class TradingViewEventMarkersPrimitive implements ISeriesPrimitive<Time> {
24
+ private onGeometry?;
23
25
  private chart;
26
+ private series;
24
27
  private requestUpdate;
25
28
  private readonly sourceMarkers;
26
29
  private markers;
27
30
  private geometry;
28
31
  private readonly view;
29
32
  palette: EventMarkerPalette;
30
- constructor(markers: readonly OhlcChartMarker[], palette: EventMarkerPalette);
33
+ constructor(markers: readonly OhlcChartMarker[], palette: EventMarkerPalette, onGeometry?: ((geometry: readonly EventMarkerGeometry[]) => void) | undefined);
31
34
  attached(param: SeriesAttachedParameter<Time>): void;
32
35
  detached(): void;
33
36
  paneViews(): readonly IPrimitivePaneView[];
34
37
  updateAllViews(): void;
38
+ autoscaleInfo(): {
39
+ priceRange: {
40
+ minValue: number;
41
+ maxValue: number;
42
+ };
43
+ } | null;
35
44
  setPalette(palette: EventMarkerPalette): void;
36
45
  visibleMarkers(y: number): EventMarkerGeometry[];
37
46
  setGeometry(geometry: EventMarkerGeometry[]): void;
@@ -0,0 +1,116 @@
1
+ var u = Object.defineProperty;
2
+ var p = (n, t, e) => t in n ? u(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var l = (n, t, e) => p(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ohlcTimeCoordinate as d } from "./ohlc-annotations.js";
5
+ const o = 14, m = 3, y = 5, M = 3;
6
+ function f(n) {
7
+ return Math.floor(n / 1e3);
8
+ }
9
+ function c(n, t) {
10
+ return [...n].sort((e, i) => e.time - i.time).map((e) => {
11
+ var i, r;
12
+ return {
13
+ id: e.id,
14
+ time: f(e.time),
15
+ color: ((i = e.color) == null ? void 0 : i.trim()) || t,
16
+ label: ((r = e.label) == null ? void 0 : r.trim().slice(0, M)) || "?",
17
+ ...e.price === void 0 ? {} : { price: e.price }
18
+ };
19
+ });
20
+ }
21
+ function v(n, t, e, i) {
22
+ const r = Math.hypot(n - e, t - i);
23
+ return r <= o ? r : null;
24
+ }
25
+ class T {
26
+ constructor(t) {
27
+ this.primitive = t;
28
+ }
29
+ draw(t) {
30
+ t.useMediaCoordinateSpace(({ context: e, mediaSize: i }) => {
31
+ const r = i.height - o - y, a = this.primitive.visibleMarkers(r).filter((s) => s.x >= 0 && s.x <= i.width && s.y >= 0 && s.y <= i.height);
32
+ this.primitive.setGeometry(a), e.save(), e.textAlign = "center", e.textBaseline = "middle", e.font = `600 9px ${this.primitive.palette.font ?? "system-ui, sans-serif"}`;
33
+ for (const s of a)
34
+ e.beginPath(), e.arc(s.x, s.y, o, 0, Math.PI * 2), e.fillStyle = s.color, e.fill(), e.beginPath(), e.arc(s.x, s.y, o - m, 0, Math.PI * 2), e.fillStyle = this.primitive.palette.interior, e.fill(), e.fillStyle = this.primitive.palette.text, e.fillText(s.label, s.x, s.y + 0.5);
35
+ e.restore();
36
+ });
37
+ }
38
+ }
39
+ class E {
40
+ constructor(t) {
41
+ l(this, "paneRenderer");
42
+ this.paneRenderer = new T(t);
43
+ }
44
+ zOrder() {
45
+ return "top";
46
+ }
47
+ renderer() {
48
+ return this.paneRenderer;
49
+ }
50
+ }
51
+ class _ {
52
+ constructor(t, e, i) {
53
+ l(this, "chart", null);
54
+ l(this, "series", null);
55
+ l(this, "requestUpdate", null);
56
+ l(this, "sourceMarkers");
57
+ l(this, "markers", []);
58
+ l(this, "geometry", []);
59
+ l(this, "view", new E(this));
60
+ l(this, "palette");
61
+ this.onGeometry = i, this.palette = e, this.sourceMarkers = t, this.markers = c(t, e.event);
62
+ }
63
+ attached(t) {
64
+ this.chart = t.chart, this.series = t.series, this.requestUpdate = t.requestUpdate, t.requestUpdate();
65
+ }
66
+ detached() {
67
+ this.chart = null, this.series = null, this.requestUpdate = null, this.geometry = [];
68
+ }
69
+ paneViews() {
70
+ return [this.view];
71
+ }
72
+ updateAllViews() {
73
+ }
74
+ autoscaleInfo() {
75
+ const t = this.markers.flatMap((e) => e.price === void 0 ? [] : [e.price]);
76
+ return t.length ? { priceRange: { minValue: Math.min(...t), maxValue: Math.max(...t) } } : null;
77
+ }
78
+ setPalette(t) {
79
+ var e;
80
+ this.palette = t, this.markers = c(this.sourceMarkers, t.event), (e = this.requestUpdate) == null || e.call(this);
81
+ }
82
+ visibleMarkers(t) {
83
+ var i;
84
+ const e = (i = this.chart) == null ? void 0 : i.timeScale();
85
+ return e ? this.markers.flatMap((r) => {
86
+ var h;
87
+ const a = d(e, Number(r.time) * 1e3), s = r.price === void 0 ? t : ((h = this.series) == null ? void 0 : h.priceToCoordinate(r.price)) ?? null;
88
+ return a === null || s === null ? [] : [{ ...r, x: a, y: s }];
89
+ }) : [];
90
+ }
91
+ setGeometry(t) {
92
+ var e;
93
+ this.geometry = t, (e = this.onGeometry) == null || e.call(this, t);
94
+ }
95
+ hitTest(t, e) {
96
+ for (let i = this.geometry.length - 1; i >= 0; i -= 1) {
97
+ const r = this.geometry[i], a = v(t, e, r.x, r.y);
98
+ if (a !== null)
99
+ return {
100
+ externalId: r.id,
101
+ zOrder: "top",
102
+ itemType: "marker",
103
+ cursorStyle: "pointer",
104
+ hitTestPriority: 2,
105
+ distance: a
106
+ };
107
+ }
108
+ return null;
109
+ }
110
+ }
111
+ export {
112
+ o as CHART_EVENT_MARKER_RADIUS,
113
+ _ as TradingViewEventMarkersPrimitive,
114
+ c as buildTradingViewEventMarkers,
115
+ v as eventMarkerHitDistance
116
+ };
@@ -2,5 +2,6 @@ export { AreaTrendChart, BarChart, HistogramChart, PieChart, RadarChart, RadialG
2
2
  export { CATEGORICAL, CHART, axisProps, gridProps } from "./theme";
3
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
4
  export { OhlcChart, type OhlcChartMarker, type OhlcChartProps, type CandlePoint } from "./ohlc";
5
+ export type { OhlcAnnotation, OhlcAnnotationPoint } from "./ohlc-annotations";
5
6
  export { ChartEngineThemeAdapters, echartsTheme, klineChartsTheme, lightweightChartsTheme, observeChartPalette, readChartPalette, tradingViewTheme, type ChartEngineAdapter, type ChartPalette } from "./adapter";
6
7
  export { TimeComboChart, type TimeComboChartProps, type TimeComboPoint, type TimeComboSeries } from "./time-combo";
@@ -0,0 +1,56 @@
1
+ import { type IPrimitivePaneView, type ISeriesPrimitive, type ITimeScaleApi, type SeriesAttachedParameter, type Time } from "lightweight-charts";
2
+ /** An epoch-millisecond point on the existing OHLC time/price scales. */
3
+ export interface OhlcAnnotationPoint {
4
+ time: number;
5
+ price: number;
6
+ }
7
+ interface AnnotationStyle {
8
+ label?: string;
9
+ color?: string;
10
+ }
11
+ interface AnnotationStroke {
12
+ lineWidth?: 1 | 2 | 3 | 4;
13
+ lineStyle?: "solid" | "dashed" | "dotted";
14
+ }
15
+ /** Host-calculated geometry; domain labels and classifications remain caller-owned. */
16
+ export type OhlcAnnotation = AnnotationStyle & (({
17
+ kind: "level";
18
+ price: number;
19
+ } & AnnotationStroke) | {
20
+ kind: "band";
21
+ from: number;
22
+ to: number;
23
+ opacity?: number;
24
+ } | ({
25
+ kind: "segment";
26
+ from: OhlcAnnotationPoint;
27
+ to: OhlcAnnotationPoint;
28
+ } & AnnotationStroke));
29
+ export declare function validateOhlcAnnotations(annotations: readonly OhlcAnnotation[]): void;
30
+ /** Snap non-bar timestamps using the engine's nearest index, retaining viewport clipping. */
31
+ export declare function ohlcTimeCoordinate(scale: ITimeScaleApi<Time>, time: number): number | null;
32
+ export declare class OhlcAnnotationsPrimitive implements ISeriesPrimitive<Time> {
33
+ private annotations;
34
+ private color;
35
+ private font;
36
+ private host;
37
+ private lines;
38
+ private bounds;
39
+ private readonly views;
40
+ constructor(annotations: readonly OhlcAnnotation[], color: string, font: string);
41
+ attached(host: SeriesAttachedParameter<Time>): void;
42
+ detached(): void;
43
+ paneViews(): IPrimitivePaneView[];
44
+ autoscaleInfo(): {
45
+ priceRange: {
46
+ minValue: number;
47
+ maxValue: number;
48
+ };
49
+ } | null;
50
+ setAnnotations(annotations: readonly OhlcAnnotation[]): void;
51
+ setPalette(color: string): void;
52
+ private clearLines;
53
+ private updateLines;
54
+ private draw;
55
+ }
56
+ export {};
@@ -0,0 +1,84 @@
1
+ var m = Object.defineProperty;
2
+ var b = (s, i, e) => i in s ? m(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var d = (s, i, e) => b(s, typeof i != "symbol" ? i + "" : i, e);
4
+ import { LineStyle as c } from "lightweight-charts";
5
+ const f = { solid: c.Solid, dashed: c.Dashed, dotted: c.Dotted };
6
+ function y(s) {
7
+ if (s.length > 256) throw new RangeError("OHLC supports at most 256 annotations");
8
+ for (const i of s) {
9
+ const e = i.kind === "level" ? [i.price] : i.kind === "band" ? [i.from, i.to] : i.kind === "segment" ? [i.from.time, i.from.price, i.to.time, i.to.price] : [];
10
+ if (!e.length || !e.every(Number.isFinite) || i.kind === "band" && i.opacity !== void 0 && (!Number.isFinite(i.opacity) || i.opacity < 0 || i.opacity > 1) || i.kind !== "band" && (i.lineWidth !== void 0 && ![1, 2, 3, 4].includes(i.lineWidth) || i.lineStyle !== void 0 && !Object.hasOwn(f, i.lineStyle)))
11
+ throw new RangeError("OHLC annotations require finite geometry, valid strokes and opacity from 0 to 1");
12
+ }
13
+ }
14
+ function u(s, i) {
15
+ const e = s.timeToIndex(Math.floor(i / 1e3), !0);
16
+ return e === null ? null : s.logicalToCoordinate(Number(e));
17
+ }
18
+ class w {
19
+ constructor(i, e, n) {
20
+ d(this, "host", null);
21
+ d(this, "lines", []);
22
+ d(this, "bounds", null);
23
+ d(this, "views", [
24
+ { zOrder: () => "bottom", renderer: () => ({ draw: (i) => this.draw(i, "band") }) },
25
+ { zOrder: () => "top", renderer: () => ({ draw: (i) => this.draw(i, "segment") }) }
26
+ ]);
27
+ this.annotations = i, this.color = e, this.font = n, this.setAnnotations(i);
28
+ }
29
+ attached(i) {
30
+ this.host = i, this.updateLines();
31
+ }
32
+ detached() {
33
+ this.clearLines(), this.host = null;
34
+ }
35
+ paneViews() {
36
+ return this.views;
37
+ }
38
+ autoscaleInfo() {
39
+ return this.bounds;
40
+ }
41
+ setAnnotations(i) {
42
+ y(i), this.annotations = i;
43
+ const e = i.flatMap((n) => n.kind === "level" ? [n.price] : n.kind === "band" ? [n.from, n.to] : [n.from.price, n.to.price]);
44
+ this.bounds = e.length ? { priceRange: { minValue: Math.min(...e), maxValue: Math.max(...e) } } : null, this.updateLines();
45
+ }
46
+ setPalette(i) {
47
+ this.color = i, this.updateLines();
48
+ }
49
+ clearLines() {
50
+ var i;
51
+ for (const e of this.lines) (i = this.host) == null || i.series.removePriceLine(e);
52
+ this.lines = [];
53
+ }
54
+ updateLines() {
55
+ if (this.clearLines(), !!this.host) {
56
+ for (const i of this.annotations) i.kind === "level" && this.lines.push(this.host.series.createPriceLine({
57
+ price: i.price,
58
+ color: i.color ?? this.color,
59
+ title: i.label ?? "",
60
+ lineWidth: i.lineWidth ?? 1,
61
+ lineStyle: f[i.lineStyle ?? "solid"],
62
+ axisLabelVisible: !0
63
+ }));
64
+ this.host.requestUpdate();
65
+ }
66
+ }
67
+ draw(i, e) {
68
+ const n = this.host;
69
+ n && i.useMediaCoordinateSpace(({ context: o, mediaSize: p }) => {
70
+ for (const t of this.annotations) {
71
+ if (t.kind !== e) continue;
72
+ const r = n.series.priceToCoordinate(t.kind === "band" ? t.from : t.from.price), l = n.series.priceToCoordinate(t.kind === "band" ? t.to : t.to.price);
73
+ if (r === null || l === null) continue;
74
+ const a = t.kind === "band" ? 0 : u(n.chart.timeScale(), t.from.time), h = t.kind === "band" ? p.width : u(n.chart.timeScale(), t.to.time);
75
+ a === null || h === null || (o.save(), o.fillStyle = o.strokeStyle = t.color ?? this.color, t.kind === "band" ? (o.globalAlpha = t.opacity ?? 0.12, o.fillRect(a, Math.min(r, l), h - a, Math.abs(l - r)), o.globalAlpha = 1) : (o.lineWidth = t.lineWidth ?? 1, o.setLineDash(t.lineStyle === "dashed" ? [6, 4] : t.lineStyle === "dotted" ? [2, 3] : []), o.beginPath(), o.moveTo(a, r), o.lineTo(h, l), o.stroke()), t.label && (o.font = `11px ${this.font}`, o.fillText(t.label, Math.max(4, a + 4), Math.max(12, Math.min(r, l) - 4))), o.restore());
76
+ }
77
+ });
78
+ }
79
+ }
80
+ export {
81
+ w as OhlcAnnotationsPrimitive,
82
+ u as ohlcTimeCoordinate,
83
+ y as validateOhlcAnnotations
84
+ };
@@ -1,4 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
+ import { type OhlcAnnotation } from "./ohlc-annotations";
2
3
  export interface CandlePoint {
3
4
  time: number;
4
5
  label: string;
@@ -11,6 +12,8 @@ export interface CandlePoint {
11
12
  export interface OhlcChartMarker {
12
13
  id: string;
13
14
  time: number;
15
+ /** Optional price anchor; omitted markers retain the bottom event track. */
16
+ price?: number;
14
17
  color?: string;
15
18
  label?: string;
16
19
  ariaLabel: string;
@@ -20,6 +23,7 @@ export interface OhlcChartMarker {
20
23
  }
21
24
  export interface OhlcChartProps {
22
25
  data: CandlePoint[];
26
+ annotations?: readonly OhlcAnnotation[];
23
27
  markers?: readonly OhlcChartMarker[];
24
28
  onMarkerClick?: (marker: OhlcChartMarker) => void;
25
29
  height?: number | string;
@@ -33,4 +37,4 @@ export interface OhlcChartProps {
33
37
  }
34
38
  /** The engine requires strictly increasing second timestamps and finite OHLC values. */
35
39
  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;
40
+ export declare function OhlcChart({ data, annotations, markers, onMarkerClick, height, valueFormat, locale, pricePrecision, showVolume, transparent, ariaLabel, className, }: OhlcChartProps): import("react").JSX.Element;