@agent-factory-platform/ui-kit 0.8.0 → 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.
- package/README.md +18 -0
- package/dist/charts/adapter.js +111 -0
- package/dist/charts/basic.js +115 -0
- package/dist/charts/chart-tooltip.js +21 -0
- package/dist/charts/event-markers-primitive.d.ts +10 -1
- package/dist/charts/event-markers-primitive.js +116 -0
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/ohlc-annotations.d.ts +56 -0
- package/dist/charts/ohlc-annotations.js +84 -0
- package/dist/charts/ohlc.d.ts +5 -1
- package/dist/charts/ohlc.js +240 -0
- package/dist/charts/series.js +584 -0
- package/dist/charts/theme.js +35 -0
- package/dist/charts/time-combo.js +17 -0
- package/dist/component-api.js +3 -5
- package/dist/component-api.json.js +9 -0
- package/dist/component-manifest.json.js +9 -0
- package/dist/components/alert.js +35 -0
- package/dist/components/avatar.js +101 -0
- package/dist/components/badge.js +111 -0
- package/dist/components/button-group.js +22 -0
- package/dist/components/button.js +64 -0
- package/dist/components/calendar-period-navigator.js +34 -0
- package/dist/components/card.js +35 -0
- package/dist/components/chart-frame.js +53 -0
- package/dist/components/color-picker.js +155 -0
- package/dist/components/combobox.js +129 -0
- package/dist/components/command-dialog.js +89 -0
- package/dist/components/confirm-dialog.js +57 -0
- package/dist/components/data-table.js +135 -0
- package/dist/components/date-time.js +203 -0
- package/dist/components/disclosure.js +29 -0
- package/dist/components/drawer.js +150 -0
- package/dist/components/dropdown-select.js +191 -0
- package/dist/components/field.js +21 -0
- package/dist/components/floating-window.js +159 -0
- package/dist/components/heading.js +21 -0
- package/dist/components/hover-tip.js +90 -0
- package/dist/components/icon-tip.js +12 -0
- package/dist/components/input-group.js +16 -0
- package/dist/components/input-otp.js +56 -0
- package/dist/components/input.js +44 -0
- package/dist/components/item.js +47 -0
- package/dist/components/kbd.js +18 -0
- package/dist/components/line-chart.js +79 -0
- package/dist/components/listbox.js +33 -0
- package/dist/components/live-value.js +26 -0
- package/dist/components/modal.js +140 -0
- package/dist/components/multi-select.js +54 -0
- package/dist/components/native-select.js +17 -0
- package/dist/components/navigation.js +42 -0
- package/dist/components/page.js +24 -0
- package/dist/components/popover-menu.js +164 -0
- package/dist/components/progress.js +23 -0
- package/dist/components/resizable-pane.js +73 -0
- package/dist/components/scroll-load-more.js +61 -0
- package/dist/components/seg-slider.js +42 -0
- package/dist/components/segmented-control.js +46 -0
- package/dist/components/selection-controls.js +119 -0
- package/dist/components/sidebar.js +23 -0
- package/dist/components/skeleton.js +9 -0
- package/dist/components/slider.js +162 -0
- package/dist/components/sliding-tabs.js +118 -0
- package/dist/components/spinner.js +9 -0
- package/dist/components/spotlight-tour.js +122 -0
- package/dist/components/stat-card.js +23 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/stats-table.js +17 -0
- package/dist/components/table.js +24 -0
- package/dist/components/tag-pill.d.ts +4 -1
- package/dist/components/tag-pill.js +69 -0
- package/dist/components/theme-editor.js +159 -0
- package/dist/components/toast.js +66 -0
- package/dist/components/toolbar.js +46 -0
- package/dist/components/utility.js +19 -0
- package/dist/components/widget-frame.js +41 -0
- package/dist/components/widget-picker.js +87 -0
- package/dist/components/workspace-grid.js +468 -0
- package/dist/focus-modality.js +3 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +228 -5564
- package/dist/lib/cn.js +6 -0
- package/dist/lib/focus-modality.js +16 -0
- package/dist/lib/motion.js +27 -0
- package/dist/lib/viewport.js +13 -0
- package/dist/manifest.js +5 -7
- package/dist/styles.js +1 -1
- package/dist/theme.js +158 -0
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { jsx as c, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as w, useState as T, useEffect as F } from "react";
|
|
3
|
+
import { createChart as k, LineStyle as x, CrosshairMode as ee, ColorType as K, CandlestickSeries as te, HistogramSeries as oe } from "lightweight-charts";
|
|
4
|
+
import { readChartPalette as ie, observeChartPalette as ne } from "./adapter.js";
|
|
5
|
+
import { TradingViewEventMarkersPrimitive as re } from "./event-markers-primitive.js";
|
|
6
|
+
import { validateOhlcAnnotations as se, OhlcAnnotationsPrimitive as le } from "./ohlc-annotations.js";
|
|
7
|
+
import { cn as ce } from "../lib/cn.js";
|
|
8
|
+
import { Popover as ae } from "../components/popover-menu.js";
|
|
9
|
+
const de = [], ue = [], fe = (i) => i.toLocaleString();
|
|
10
|
+
function I(i) {
|
|
11
|
+
return Math.floor(i / 1e3);
|
|
12
|
+
}
|
|
13
|
+
function he(i) {
|
|
14
|
+
return 10 ** -i;
|
|
15
|
+
}
|
|
16
|
+
function be(i, d) {
|
|
17
|
+
if (!Number.isInteger(d) || d < 0 || d > 12) throw new RangeError("OHLC precision must be an integer from 0 to 12");
|
|
18
|
+
let l = -1 / 0;
|
|
19
|
+
for (const o of i) {
|
|
20
|
+
const b = Math.floor(o.time / 1e3);
|
|
21
|
+
if (![o.time, o.open, o.high, o.low, o.close, o.volume].every(Number.isFinite) || b <= l || o.volume < 0 || o.low > Math.min(o.open, o.close) || o.high < Math.max(o.open, o.close) || o.low > o.high) throw new RangeError("OHLC points must be finite, ordered by unique seconds, and bounded by low/high");
|
|
22
|
+
l = b;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function Se({
|
|
26
|
+
data: i,
|
|
27
|
+
annotations: d = ue,
|
|
28
|
+
markers: l = de,
|
|
29
|
+
onMarkerClick: o,
|
|
30
|
+
height: b = 300,
|
|
31
|
+
valueFormat: a = fe,
|
|
32
|
+
locale: O = "en-US",
|
|
33
|
+
pricePrecision: C = 2,
|
|
34
|
+
showVolume: N = !0,
|
|
35
|
+
transparent: D = !1,
|
|
36
|
+
ariaLabel: P = "Candlestick price chart",
|
|
37
|
+
className: W
|
|
38
|
+
}) {
|
|
39
|
+
if (be(i, C), se(d), l.length > 256 || new Set(l.map((t) => t.id)).size !== l.length || l.some((t) => {
|
|
40
|
+
var s;
|
|
41
|
+
return !((s = t.id) != null && s.trim()) || !Number.isFinite(t.time) || t.price !== void 0 && !Number.isFinite(t.price);
|
|
42
|
+
})) throw new RangeError("OHLC markers require unique IDs, finite coordinates and at most 256 entries");
|
|
43
|
+
const V = w(null), R = w(d), M = w(null);
|
|
44
|
+
R.current = d;
|
|
45
|
+
const j = w(a), S = w(o);
|
|
46
|
+
S.current = o;
|
|
47
|
+
const [f, _] = T(i.at(-1) ?? null), [G, A] = T(null), [J, E] = T({});
|
|
48
|
+
return j.current = a, F(() => {
|
|
49
|
+
const t = V.current;
|
|
50
|
+
if (!t || i.length === 0) return;
|
|
51
|
+
const s = getComputedStyle(t).fontFamily, r = ie(t), z = t.clientHeight || (typeof b == "number" ? b : 300), u = k(t, {
|
|
52
|
+
autoSize: !0,
|
|
53
|
+
height: z,
|
|
54
|
+
layout: {
|
|
55
|
+
background: { type: K.Solid, color: D ? "rgba(0, 0, 0, 0)" : r.canvas },
|
|
56
|
+
textColor: r.mutedText,
|
|
57
|
+
fontFamily: s,
|
|
58
|
+
fontSize: 11,
|
|
59
|
+
attributionLogo: !0,
|
|
60
|
+
panes: { separatorColor: "rgba(127, 127, 127, 0.12)", separatorHoverColor: "rgba(127, 127, 127, 0.2)", enableResize: !1 }
|
|
61
|
+
},
|
|
62
|
+
grid: {
|
|
63
|
+
vertLines: { color: "rgba(127, 127, 127, 0.07)", style: x.Dotted },
|
|
64
|
+
horzLines: { color: "rgba(127, 127, 127, 0.07)", style: x.Dotted }
|
|
65
|
+
},
|
|
66
|
+
crosshair: {
|
|
67
|
+
mode: ee.Normal,
|
|
68
|
+
vertLine: { color: "rgba(127, 127, 127, 0.52)", style: x.Dashed, labelBackgroundColor: "#3f3f3f" },
|
|
69
|
+
horzLine: { color: "rgba(127, 127, 127, 0.52)", style: x.Dashed, labelBackgroundColor: "#3f3f3f" }
|
|
70
|
+
},
|
|
71
|
+
rightPriceScale: {
|
|
72
|
+
borderVisible: !1,
|
|
73
|
+
scaleMargins: { top: 0.1, bottom: N ? 0.17 : 0.08 },
|
|
74
|
+
entireTextOnly: !0
|
|
75
|
+
},
|
|
76
|
+
timeScale: {
|
|
77
|
+
borderVisible: !1,
|
|
78
|
+
timeVisible: !0,
|
|
79
|
+
secondsVisible: !1,
|
|
80
|
+
rightOffset: 3,
|
|
81
|
+
barSpacing: 12,
|
|
82
|
+
minBarSpacing: 4,
|
|
83
|
+
fixLeftEdge: !0,
|
|
84
|
+
lockVisibleTimeRangeOnResize: !0
|
|
85
|
+
},
|
|
86
|
+
localization: {
|
|
87
|
+
locale: O,
|
|
88
|
+
priceFormatter: (e) => j.current(e)
|
|
89
|
+
},
|
|
90
|
+
handleScroll: { mouseWheel: !0, pressedMouseMove: !0, horzTouchDrag: !0, vertTouchDrag: !1 },
|
|
91
|
+
handleScale: { axisPressedMouseMove: !0, mouseWheel: !0, pinch: !0 }
|
|
92
|
+
}), v = u.addSeries(te, {
|
|
93
|
+
upColor: r.up,
|
|
94
|
+
downColor: r.down,
|
|
95
|
+
borderVisible: !1,
|
|
96
|
+
wickUpColor: r.up,
|
|
97
|
+
wickDownColor: r.down,
|
|
98
|
+
lastValueVisible: !0,
|
|
99
|
+
priceLineVisible: !0,
|
|
100
|
+
priceLineStyle: x.Dotted,
|
|
101
|
+
priceFormat: { type: "price", precision: C, minMove: he(C) }
|
|
102
|
+
}), Q = i.map((e) => ({
|
|
103
|
+
time: I(e.time),
|
|
104
|
+
open: e.open,
|
|
105
|
+
high: e.high,
|
|
106
|
+
low: e.low,
|
|
107
|
+
close: e.close
|
|
108
|
+
}));
|
|
109
|
+
v.setData(Q);
|
|
110
|
+
const L = new le(R.current, r.event, s);
|
|
111
|
+
M.current = L, v.attachPrimitive(L);
|
|
112
|
+
const y = N ? u.addSeries(oe, {
|
|
113
|
+
priceFormat: { type: "volume" },
|
|
114
|
+
priceScaleId: "volume",
|
|
115
|
+
lastValueVisible: !1,
|
|
116
|
+
priceLineVisible: !1
|
|
117
|
+
}) : null, H = (e, h) => i.map((n) => ({
|
|
118
|
+
time: I(n.time),
|
|
119
|
+
value: n.volume,
|
|
120
|
+
color: n.close >= n.open ? e : h
|
|
121
|
+
}));
|
|
122
|
+
y && (y.setData(H(r.up, r.down)), u.priceScale("volume").applyOptions({ scaleMargins: { top: 0.86, bottom: 0 } }));
|
|
123
|
+
const p = l.length > 0 ? new re(l, { interior: r.canvas, text: r.text, event: r.event, font: s }, (e) => {
|
|
124
|
+
const h = Object.fromEntries(e.map((n) => [n.id, { x: n.x, y: n.y }]));
|
|
125
|
+
E((n) => Object.keys(n).length === e.length && e.every((m) => {
|
|
126
|
+
var $, q;
|
|
127
|
+
return (($ = n[m.id]) == null ? void 0 : $.x) === m.x && ((q = n[m.id]) == null ? void 0 : q.y) === m.y;
|
|
128
|
+
}) ? n : h);
|
|
129
|
+
}) : null;
|
|
130
|
+
p || E((e) => Object.keys(e).length ? {} : e), p && v.attachPrimitive(p);
|
|
131
|
+
const X = new Map(l.map((e) => [e.id, e])), Y = new Map(i.map((e) => [I(e.time), e])), B = (e) => {
|
|
132
|
+
const h = typeof e.time == "number" ? Y.get(e.time) : void 0;
|
|
133
|
+
_(h ?? i.at(-1) ?? null);
|
|
134
|
+
};
|
|
135
|
+
u.subscribeCrosshairMove(B), u.timeScale().fitContent();
|
|
136
|
+
const U = (e) => {
|
|
137
|
+
var n, m;
|
|
138
|
+
if (((n = e.hoveredInfo) == null ? void 0 : n.objectKind) !== "primitive" || typeof e.hoveredInfo.objectId != "string") return;
|
|
139
|
+
const h = X.get(e.hoveredInfo.objectId);
|
|
140
|
+
h && (A(h.id), (m = S.current) == null || m.call(S, h));
|
|
141
|
+
};
|
|
142
|
+
u.subscribeClick(U);
|
|
143
|
+
const Z = ne((e) => {
|
|
144
|
+
u.applyOptions({
|
|
145
|
+
layout: {
|
|
146
|
+
background: { type: K.Solid, color: D ? "rgba(0, 0, 0, 0)" : e.canvas },
|
|
147
|
+
textColor: e.mutedText,
|
|
148
|
+
fontFamily: s,
|
|
149
|
+
attributionLogo: !0
|
|
150
|
+
},
|
|
151
|
+
grid: { vertLines: { color: e.grid }, horzLines: { color: e.grid } },
|
|
152
|
+
crosshair: {
|
|
153
|
+
vertLine: { color: e.axis, labelBackgroundColor: e.surface },
|
|
154
|
+
horzLine: { color: e.axis, labelBackgroundColor: e.surface }
|
|
155
|
+
}
|
|
156
|
+
}), v.applyOptions({
|
|
157
|
+
upColor: e.up,
|
|
158
|
+
downColor: e.down,
|
|
159
|
+
wickUpColor: e.up,
|
|
160
|
+
wickDownColor: e.down
|
|
161
|
+
}), y == null || y.setData(H(e.up, e.down)), p == null || p.setPalette({ interior: e.canvas, text: e.text, event: e.event, font: s }), L.setPalette(e.event);
|
|
162
|
+
}, t);
|
|
163
|
+
return () => {
|
|
164
|
+
Z(), u.unsubscribeCrosshairMove(B), u.unsubscribeClick(U), v.detachPrimitive(L), M.current = null, p && v.detachPrimitive(p), u.remove();
|
|
165
|
+
};
|
|
166
|
+
}, [i, b, O, l, C, N, D]), F(() => {
|
|
167
|
+
var t;
|
|
168
|
+
(t = M.current) == null || t.setAnnotations(d);
|
|
169
|
+
}, [d]), i.length === 0 ? /* @__PURE__ */ c("div", { role: "img", "aria-label": P, style: { height: b }, className: "grid place-items-center text-graphite", children: "-" }) : /* @__PURE__ */ g(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
"data-chart-engine": "tradingview-lightweight-charts",
|
|
173
|
+
className: ce("relative min-w-0 overflow-hidden bg-surface-canvas", W),
|
|
174
|
+
style: { height: b },
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ c("div", { ref: V, role: "img", "aria-label": P, className: "absolute inset-0" }),
|
|
177
|
+
/* @__PURE__ */ c("ul", { className: "sr-only", "aria-label": "Chart annotations", children: d.map((t, s) => /* @__PURE__ */ g("li", { children: [
|
|
178
|
+
t.label ?? t.kind,
|
|
179
|
+
": ",
|
|
180
|
+
t.kind === "level" ? a(t.price) : t.kind === "band" ? `${a(t.from)} – ${a(t.to)}` : `${a(t.from.price)} – ${a(t.to.price)}`
|
|
181
|
+
] }, s)) }),
|
|
182
|
+
f ? /* @__PURE__ */ g("div", { className: "pointer-events-none absolute left-2 top-1 z-10 flex max-w-[calc(100%-4rem)] flex-wrap gap-x-2 font-data text-micro tabular-nums text-graphite", "data-overflow-guard": !0, children: [
|
|
183
|
+
/* @__PURE__ */ c("span", { className: "font-product text-ash", children: f.label }),
|
|
184
|
+
/* @__PURE__ */ g("span", { children: [
|
|
185
|
+
"O ",
|
|
186
|
+
/* @__PURE__ */ c("b", { className: "font-[500] text-ink", children: a(f.open) })
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ g("span", { children: [
|
|
189
|
+
"H ",
|
|
190
|
+
/* @__PURE__ */ c("b", { className: "font-[500] text-ink", children: a(f.high) })
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ g("span", { children: [
|
|
193
|
+
"L ",
|
|
194
|
+
/* @__PURE__ */ c("b", { className: "font-[500] text-ink", children: a(f.low) })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ g("span", { children: [
|
|
197
|
+
"C ",
|
|
198
|
+
/* @__PURE__ */ c("b", { className: f.close >= f.open ? "font-[500] text-up" : "font-[500] text-down", children: a(f.close) })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ g("span", { children: [
|
|
201
|
+
"Vol ",
|
|
202
|
+
/* @__PURE__ */ c("b", { className: "font-[500] text-ink", children: f.volume.toLocaleString(O) })
|
|
203
|
+
] })
|
|
204
|
+
] }) : null,
|
|
205
|
+
l.map((t) => {
|
|
206
|
+
const s = J[t.id];
|
|
207
|
+
if (s === void 0) return null;
|
|
208
|
+
const r = /* @__PURE__ */ c(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
"aria-label": t.ariaLabel,
|
|
213
|
+
"data-chart-marker": t.id,
|
|
214
|
+
"data-chart-marker-time": t.time,
|
|
215
|
+
className: "absolute z-20 size-7 -translate-x-1/2 -translate-y-1/2 rounded-full opacity-0 outline-none focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-chart-event focus-visible:ring-offset-2 focus-visible:ring-offset-surface-canvas",
|
|
216
|
+
style: { left: s.x, top: s.y },
|
|
217
|
+
onClick: () => o == null ? void 0 : o(t)
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
return t.popover ? /* @__PURE__ */ c(
|
|
221
|
+
ae,
|
|
222
|
+
{
|
|
223
|
+
title: t.popoverTitle ?? t.ariaLabel,
|
|
224
|
+
closeLabel: t.popoverCloseLabel,
|
|
225
|
+
trigger: r,
|
|
226
|
+
open: G === t.id,
|
|
227
|
+
onOpenChange: (z) => A(z ? t.id : null),
|
|
228
|
+
children: t.popover
|
|
229
|
+
},
|
|
230
|
+
t.id
|
|
231
|
+
) : /* @__PURE__ */ c("span", { children: r }, t.id);
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
export {
|
|
238
|
+
Se as OhlcChart,
|
|
239
|
+
be as validateOhlcData
|
|
240
|
+
};
|