@overdoser/react-toolkit 0.21.0 → 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.
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +27 -0
- package/components/Accordion/Accordion.js +48 -48
- package/components/ActionButton/ActionButton.js +23 -23
- package/components/ActionButton/CopyButton.js +5 -5
- package/components/Alert/Alert.js +13 -13
- package/components/Avatar/Avatar.js +12 -12
- package/components/Badge/Badge.js +6 -6
- package/components/Breadcrumbs/Breadcrumbs.js +15 -15
- package/components/Button/Button.js +14 -14
- package/components/Card/Card.js +26 -26
- package/components/Chart/AreaChart.js +103 -103
- package/components/Chart/Axis.js +7 -7
- package/components/Chart/BarChart.js +62 -62
- package/components/Chart/ChartContainer.js +11 -11
- package/components/Chart/ChartLegend.js +7 -7
- package/components/Chart/ChartTooltip.js +13 -13
- package/components/Chart/LineChart.js +88 -88
- package/components/Chart/PieChart.js +25 -25
- package/components/Chart/RadarChart.js +42 -42
- package/components/Chart/Sparkline.js +11 -11
- package/components/Chart/TradingChart.js +126 -126
- package/components/Chart/trading/period.js +3 -3
- package/components/Chip/Chip.js +24 -24
- package/components/CodeBlock/CodeBlock.js +31 -31
- package/components/CommandPalette/CommandPalette.js +166 -166
- package/components/ConfirmDialog/ConfirmDialog.js +60 -60
- package/components/Divider/Divider.js +10 -10
- package/components/Draggable/Draggable.js +29 -29
- package/components/Drawer/Drawer.js +53 -53
- package/components/Dropdown/Dropdown.js +66 -66
- package/components/Dropdown/DropdownItem.js +13 -13
- package/components/Dropdown/DropdownLabel.js +5 -5
- package/components/Dropdown/DropdownSeparator.js +5 -5
- package/components/Dropzone/Dropzone.js +15 -15
- package/components/EmptyState/EmptyState.js +11 -11
- package/components/Form/Form.js +17 -17
- package/components/Form/FormField.js +21 -21
- package/components/Form/FormRow.js +3 -3
- package/components/ImageViewer/ImageViewer.js +118 -118
- package/components/Kbd/Kbd.js +11 -11
- package/components/KeyValueList/KeyValueList.js +32 -32
- package/components/Link/Link.js +7 -7
- package/components/List/List.js +7 -7
- package/components/Loader/Loader.js +39 -39
- package/components/Modal/Modal.js +48 -48
- package/components/PageHeader/PageHeader.js +18 -18
- package/components/Pagination/Pagination.js +23 -23
- package/components/Popover/Popover.js +25 -25
- package/components/ProgressBar/ProgressBar.js +17 -17
- package/components/RelativeTime/RelativeTime.js +10 -10
- package/components/SegmentedControl/SegmentedControl.js +38 -38
- package/components/Skeleton/Skeleton.js +10 -10
- package/components/Spinner/Spinner.js +7 -7
- package/components/SplitButton/SplitButton.js +63 -63
- package/components/SplitPane/SplitPane.js +50 -50
- package/components/StatCard/StatCard.js +32 -32
- package/components/StatusDot/StatusDot.js +7 -7
- package/components/Table/Table.js +174 -174
- package/components/Tabs/Tabs.js +47 -47
- package/components/ThemeToggle/ThemeToggle.js +31 -31
- package/components/Timeline/GanttTimeline.js +213 -213
- package/components/Timeline/HistoryTimeline.js +306 -306
- package/components/Timeline/TimelineShared.js +103 -103
- package/components/Timeline/TraceEventDetails.js +103 -103
- package/components/Timeline/TraceTimeline.js +546 -546
- package/components/Timeline/historyLayout.js +2 -2
- package/components/Timer/Timer.js +39 -39
- package/components/Toast/Toast.js +59 -59
- package/components/ToggleIconButton/ToggleIconButton.js +9 -9
- package/components/Tooltip/Tooltip.js +16 -16
- package/components/Typography/Typography.js +5 -5
- package/components/inputs/Checkbox/Checkbox.js +11 -11
- package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
- package/components/inputs/DatePicker/CalendarPanel.js +113 -113
- package/components/inputs/DatePicker/DatePicker.js +39 -39
- package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
- package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
- package/components/inputs/DateTimePicker/TimeField.js +34 -34
- package/components/inputs/Input/Input.js +13 -13
- package/components/inputs/NumberInput/NumberInput.js +16 -16
- package/components/inputs/Radio/Radio.js +17 -17
- package/components/inputs/SearchInput/SearchInput.js +25 -25
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +485 -344
- package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
- package/components/inputs/Slider/Slider.js +21 -21
- package/components/inputs/Switch/Switch.js +4 -4
- package/components/inputs/Textarea/Textarea.js +8 -8
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +6 -3
- package/hooks/useResizable.js +1 -1
- package/hooks/useTheme.js +7 -7
- package/index.css +1 -1
- package/index.js +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +25 -4
- package/manifest.json +33 -4
- package/package.json +1 -1
- /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
- /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
- /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
- /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
- /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
- /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
- /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
- /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
- /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
- /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
- /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
- /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
- /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
- /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
- /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
- /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
- /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
- /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
- /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
- /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
- /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
- /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
- /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
- /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
- /package/components/List/{List.module.js → List.module.scss.js} +0 -0
- /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
- /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
- /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
- /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
- /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
- /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
- /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
- /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
- /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
- /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
- /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
- /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
- /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
- /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
- /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
- /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
- /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
- /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
- /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
- /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
- /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
- /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
- /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
- /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
- /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
- /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
- /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
- /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
- /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
- /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
- /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import n from "
|
|
3
|
-
import {
|
|
4
|
-
import a from "
|
|
1
|
+
import { forwardRef as e, useMemo as t } from "react";
|
|
2
|
+
import n from "clsx";
|
|
3
|
+
import { extent as r, linearScale as i } from "./scales.js";
|
|
4
|
+
import a from "./Chart.module.scss.js";
|
|
5
5
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
6
|
// src/components/Chart/Sparkline.tsx
|
|
7
7
|
function c(e, t) {
|
|
@@ -14,24 +14,24 @@ function c(e, t) {
|
|
|
14
14
|
}
|
|
15
15
|
return n;
|
|
16
16
|
}
|
|
17
|
-
var l =
|
|
18
|
-
let { line: b, area: x, last: S } =
|
|
19
|
-
if (
|
|
17
|
+
var l = e(({ data: e, width: l = 80, height: u = 24, color: d = "var(--crk-chart-1)", strokeWidth: f = 1.5, curve: p = "monotone", fill: m = !1, showLastPoint: h = !1, "aria-label": g, className: _, style: v }, y) => {
|
|
18
|
+
let { line: b, area: x, last: S } = t(() => {
|
|
19
|
+
if (e.length === 0) return {
|
|
20
20
|
line: "",
|
|
21
21
|
area: "",
|
|
22
22
|
last: null
|
|
23
23
|
};
|
|
24
|
-
let
|
|
24
|
+
let t = f, n = Math.max(1, l - t * 2), a = Math.max(1, u - t * 2), [o, s] = r(e), d = i([0, Math.max(1, e.length - 1)], [t, t + n]), h = i([o, s], [t + a, t]), g = e.map((e, t) => ({
|
|
25
25
|
x: d(t),
|
|
26
26
|
y: h(e)
|
|
27
27
|
})), _ = c(g, p);
|
|
28
28
|
return {
|
|
29
29
|
line: _,
|
|
30
|
-
area: m ? `${_} L ${g[g.length - 1].x} ${
|
|
30
|
+
area: m ? `${_} L ${g[g.length - 1].x} ${t + a} L ${g[0].x} ${t + a} Z` : "",
|
|
31
31
|
last: g[g.length - 1]
|
|
32
32
|
};
|
|
33
33
|
}, [
|
|
34
|
-
|
|
34
|
+
e,
|
|
35
35
|
l,
|
|
36
36
|
u,
|
|
37
37
|
f,
|
|
@@ -40,7 +40,7 @@ var l = r(({ data: r, width: l = 80, height: u = 24, color: d = "var(--crk-chart
|
|
|
40
40
|
]);
|
|
41
41
|
return /* @__PURE__ */ s("svg", {
|
|
42
42
|
ref: y,
|
|
43
|
-
className: a
|
|
43
|
+
className: n(a.sparkline, _),
|
|
44
44
|
style: v,
|
|
45
45
|
width: l,
|
|
46
46
|
height: u,
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import g from "
|
|
1
|
+
import { useCallback as e, useEffect as t, useLayoutEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
2
|
+
import o from "clsx";
|
|
3
|
+
import { Button as s } from "../Button/Button.js";
|
|
4
|
+
import { Dropdown as c } from "../Dropdown/Dropdown.js";
|
|
5
|
+
import { Popover as l } from "../Popover/Popover.js";
|
|
6
|
+
import { niceTicks as u } from "./scales.js";
|
|
7
|
+
import { bollinger as d, ema as f, rsi as p, sma as m } from "./trading/indicators.js";
|
|
8
|
+
import { periodToSeconds as h } from "./trading/period.js";
|
|
9
|
+
import g from "./Chart.module.scss.js";
|
|
10
10
|
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
11
11
|
// src/components/Chart/TradingChart.tsx
|
|
12
12
|
var y = 420, b = 64, x = 28, S = 40, ee = 4, C = {
|
|
13
13
|
rsi: .18,
|
|
14
14
|
volume: .14
|
|
15
15
|
}, te = 1, ne = 40, re = 500, ie = [];
|
|
16
|
-
function ae({ datafeed:
|
|
17
|
-
let I =
|
|
16
|
+
function ae({ datafeed: c, symbol: u, resolution: d, period: f, seriesType: m = "candle", indicators: x = ie, precision: S = 2, initialLookback: C = re, height: ae = y, upColor: w = "var(--crk-color-success)", downColor: E = "var(--crk-color-danger)", lineColor: O = "var(--crk-chart-1)", timezone: k, defaultTimezone: A = "local", onTimezoneChange: j, showConfigPanel: M = !0, priceBadgeColorByDirection: N = !1, priceBadgeShowTime: P = !1, priceBadgeTimeFormat: De, onCrosshair: Oe, onVisibleRangeChange: ke, className: Ae, style: je }) {
|
|
17
|
+
let I = i(null), L = i(null), R = i([]), z = i({
|
|
18
18
|
from: 0,
|
|
19
19
|
to: 0
|
|
20
|
-
}), B =
|
|
20
|
+
}), B = i(null), V = i(null), H = i(!1), U = i(0), W = i(null), G = i(null), Me = i(1), K = i({
|
|
21
21
|
width: 0,
|
|
22
22
|
height: 0
|
|
23
|
-
}), Ne =
|
|
23
|
+
}), Ne = i(() => {}), Pe = i(Oe), q = i(ke);
|
|
24
24
|
Pe.current = Oe, q.current = ke;
|
|
25
|
-
let [J, Fe] =
|
|
25
|
+
let [J, Fe] = a(null), [Ie, Le] = a(A), Re = k ?? Ie, ze = e((e) => {
|
|
26
26
|
k === void 0 && Le(e), j?.(e);
|
|
27
|
-
}, [k, j]), Be =
|
|
27
|
+
}, [k, j]), Be = r(() => ({
|
|
28
28
|
up: w,
|
|
29
29
|
down: E,
|
|
30
30
|
line: O
|
|
@@ -33,55 +33,55 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
33
33
|
E,
|
|
34
34
|
O
|
|
35
35
|
]), Y = x, X = Y.some((e) => e.type === "rsi"), Z = Y.some((e) => e.type === "volume");
|
|
36
|
-
Ne.current =
|
|
36
|
+
Ne.current = e(() => {
|
|
37
37
|
let e = L.current;
|
|
38
38
|
if (!e) return;
|
|
39
39
|
let t = e.getContext("2d");
|
|
40
40
|
if (!t) return;
|
|
41
41
|
let { width: n, height: r } = K.current;
|
|
42
42
|
if (n === 0 || r === 0) return;
|
|
43
|
-
let
|
|
44
|
-
t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, e.width, e.height), t.scale(
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
me(t, n, r,
|
|
43
|
+
let i = Me.current;
|
|
44
|
+
t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, e.width, e.height), t.scale(i, i);
|
|
45
|
+
let a = pe(I.current, Be), o = fe(I.current), s = R.current;
|
|
46
|
+
if (s.length === 0) {
|
|
47
|
+
me(t, n, r, a), t.restore();
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
let
|
|
50
|
+
let c = T(n, r, X, Z), { from: l, to: u } = ce(z.current, s.length);
|
|
51
51
|
z.current = {
|
|
52
|
-
from:
|
|
53
|
-
to:
|
|
52
|
+
from: l,
|
|
53
|
+
to: u
|
|
54
54
|
};
|
|
55
|
-
let
|
|
56
|
-
let t =
|
|
57
|
-
return
|
|
58
|
-
}, g =
|
|
55
|
+
let f = s.slice(Math.max(0, Math.floor(l)), Math.min(s.length, Math.ceil(u) + 1)), h = (e) => {
|
|
56
|
+
let t = u - l + 1, n = c.plotWidth / t;
|
|
57
|
+
return c.plotLeft + (e - l + .5) * n;
|
|
58
|
+
}, g = c.plotWidth / (u - l + 1), _ = Y.map((e) => le(e, s)).filter((e) => e !== null).map((e) => ({
|
|
59
59
|
...e,
|
|
60
|
-
color:
|
|
61
|
-
})), v = ue(
|
|
62
|
-
he(t,
|
|
60
|
+
color: o(e.color)
|
|
61
|
+
})), v = ue(c.main, f, _, l, u);
|
|
62
|
+
he(t, c.plotLeft, c.plotRight, v, a), ge(t, c, v, S, a), t.save(), t.beginPath(), t.rect(c.plotLeft, v.paneTop, c.plotWidth, v.paneHeight), t.clip();
|
|
63
63
|
for (let e = 0; e < Y.length; e++) {
|
|
64
64
|
let n = Y[e], r = _[e];
|
|
65
|
-
r && be(t, r, n,
|
|
65
|
+
r && be(t, r, n, s, l, u, h, v);
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
68
|
-
up:
|
|
69
|
-
down:
|
|
70
|
-
}) :
|
|
71
|
-
up:
|
|
72
|
-
down:
|
|
73
|
-
}) : ye(t,
|
|
74
|
-
let e = de(
|
|
75
|
-
he(t,
|
|
76
|
-
up:
|
|
77
|
-
down:
|
|
67
|
+
if (m === "candle" ? _e(t, s, l, u, h, g, v, {
|
|
68
|
+
up: a.up,
|
|
69
|
+
down: a.down
|
|
70
|
+
}) : m === "bar" ? ve(t, s, l, u, h, g, v, {
|
|
71
|
+
up: a.up,
|
|
72
|
+
down: a.down
|
|
73
|
+
}) : ye(t, s, l, u, h, v, a.line, m === "area"), t.restore(), c.volume) {
|
|
74
|
+
let e = de(c.volume, s, l, u);
|
|
75
|
+
he(t, c.plotLeft, c.plotRight, e, a, !0), Ce(t, c, c.volume, "Volume", a), t.save(), t.beginPath(), t.rect(c.plotLeft, e.paneTop, c.plotWidth, e.paneHeight), t.clip(), xe(t, s, l, u, h, g, e, {
|
|
76
|
+
up: a.up,
|
|
77
|
+
down: a.down
|
|
78
78
|
}), t.restore();
|
|
79
79
|
}
|
|
80
|
-
if (
|
|
81
|
-
let e = Y.find((e) => e.type === "rsi"), n = e && e.type === "rsi" ? e.period ?? 14 : 14, r = e && e.type === "rsi" ? e.overbought ?? 70 : 70, i = e && e.type === "rsi" ? e.oversold ?? 30 : 30,
|
|
82
|
-
paneTop:
|
|
83
|
-
paneBottom:
|
|
84
|
-
paneHeight:
|
|
80
|
+
if (c.rsi) {
|
|
81
|
+
let e = Y.find((e) => e.type === "rsi"), n = e && e.type === "rsi" ? e.period ?? 14 : 14, r = e && e.type === "rsi" ? e.overbought ?? 70 : 70, i = e && e.type === "rsi" ? e.oversold ?? 30 : 30, d = o((e && e.type === "rsi" ? e.color : void 0) ?? "var(--crk-chart-5)"), f = p(s, n), m = {
|
|
82
|
+
paneTop: c.rsi.top,
|
|
83
|
+
paneBottom: c.rsi.bottom,
|
|
84
|
+
paneHeight: c.rsi.height,
|
|
85
85
|
priceMin: 0,
|
|
86
86
|
priceMax: 100,
|
|
87
87
|
ticks: [
|
|
@@ -90,28 +90,28 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
90
90
|
r
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
|
-
he(t,
|
|
93
|
+
he(t, c.plotLeft, c.plotRight, m, a, !0), Ce(t, c, c.rsi, `RSI ${n}`, a), t.save(), t.beginPath(), t.rect(c.plotLeft, m.paneTop, c.plotWidth, m.paneHeight), t.clip(), D(t, f, l, u, h, m, d), t.restore(), Se(t, c, m, r, i, a);
|
|
94
94
|
}
|
|
95
|
-
we(t,
|
|
95
|
+
we(t, c, s, l, u, d, a), B.current && Te(t, c, B.current, s, l, u, h, S, v, Re, a, d, N, P, De), t.restore();
|
|
96
96
|
}, [
|
|
97
|
-
|
|
97
|
+
m,
|
|
98
98
|
Y,
|
|
99
99
|
X,
|
|
100
100
|
Z,
|
|
101
101
|
S,
|
|
102
102
|
Be,
|
|
103
|
-
|
|
103
|
+
d,
|
|
104
104
|
Re,
|
|
105
105
|
N,
|
|
106
106
|
P,
|
|
107
107
|
De
|
|
108
108
|
]);
|
|
109
|
-
let Q =
|
|
109
|
+
let Q = e(() => {
|
|
110
110
|
G.current === null && (typeof requestAnimationFrame > "u" ? Ne.current() : G.current = requestAnimationFrame(() => {
|
|
111
111
|
G.current = null, Ne.current();
|
|
112
112
|
}));
|
|
113
113
|
}, []);
|
|
114
|
-
|
|
114
|
+
n(() => {
|
|
115
115
|
let e = I.current;
|
|
116
116
|
if (!e) return;
|
|
117
117
|
let t = () => {
|
|
@@ -126,23 +126,23 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
126
126
|
if (t(), typeof ResizeObserver > "u") return;
|
|
127
127
|
let n = new ResizeObserver(t);
|
|
128
128
|
return n.observe(e), () => n.disconnect();
|
|
129
|
-
}, [Q]),
|
|
130
|
-
let e = !1,
|
|
129
|
+
}, [Q]), t(() => {
|
|
130
|
+
let e = !1, t = Math.floor(Date.now() / 1e3), n = F(d), r = f === "MAX", i = f === void 0 ? n * C : h(f), a = f === void 0 ? C : Math.max(10, Math.ceil(i / n)), o = r ? 0 : t - i;
|
|
131
131
|
R.current = [], z.current = {
|
|
132
132
|
from: 0,
|
|
133
133
|
to: 0
|
|
134
|
-
}, U.current += 1, H.current = !1, Q(),
|
|
135
|
-
symbol:
|
|
136
|
-
resolution:
|
|
137
|
-
from:
|
|
138
|
-
to:
|
|
139
|
-
countBack:
|
|
134
|
+
}, U.current += 1, H.current = !1, Q(), c.getBars({
|
|
135
|
+
symbol: u,
|
|
136
|
+
resolution: d,
|
|
137
|
+
from: o,
|
|
138
|
+
to: t,
|
|
139
|
+
countBack: a
|
|
140
140
|
}).then((t) => {
|
|
141
141
|
if (e) return;
|
|
142
142
|
let n = [...t].sort((e, t) => e.time - t.time);
|
|
143
143
|
R.current = n;
|
|
144
144
|
let r = n.length - 1;
|
|
145
|
-
if (
|
|
145
|
+
if (f !== void 0) z.current = {
|
|
146
146
|
from: 0,
|
|
147
147
|
to: r
|
|
148
148
|
};
|
|
@@ -155,9 +155,9 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
155
155
|
}
|
|
156
156
|
q.current?.(z.current, n), Q();
|
|
157
157
|
}).catch(() => {});
|
|
158
|
-
let
|
|
159
|
-
symbol:
|
|
160
|
-
resolution:
|
|
158
|
+
let s = c.subscribeBars({
|
|
159
|
+
symbol: u,
|
|
160
|
+
resolution: d,
|
|
161
161
|
onTick: (t) => {
|
|
162
162
|
if (e) return;
|
|
163
163
|
let n = R.current, r = n[n.length - 1];
|
|
@@ -173,19 +173,19 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
173
173
|
Q();
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
return W.current =
|
|
177
|
-
e = !0, W.current !== null && (
|
|
176
|
+
return W.current = s, () => {
|
|
177
|
+
e = !0, W.current !== null && (c.unsubscribeBars(W.current), W.current = null);
|
|
178
178
|
};
|
|
179
179
|
}, [
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
c,
|
|
181
|
+
u,
|
|
182
|
+
d,
|
|
183
|
+
f,
|
|
184
184
|
C
|
|
185
185
|
]);
|
|
186
|
-
let $ =
|
|
186
|
+
let $ = e((e) => {
|
|
187
187
|
Fe(e), Pe.current?.(e);
|
|
188
|
-
}, []), Ve =
|
|
188
|
+
}, []), Ve = e((e) => {
|
|
189
189
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
190
190
|
let t = z.current;
|
|
191
191
|
V.current = {
|
|
@@ -193,39 +193,39 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
193
193
|
from: t.from,
|
|
194
194
|
to: t.to
|
|
195
195
|
};
|
|
196
|
-
}, []), He =
|
|
196
|
+
}, []), He = e(() => {
|
|
197
197
|
if (H.current) return;
|
|
198
198
|
let e = R.current;
|
|
199
199
|
if (e.length === 0) return;
|
|
200
200
|
H.current = !0;
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
symbol:
|
|
204
|
-
resolution:
|
|
205
|
-
from:
|
|
206
|
-
to:
|
|
201
|
+
let t = U.current, n = F(d), r = e[0].time, i = r - n * C, a = r - n;
|
|
202
|
+
c.getBars({
|
|
203
|
+
symbol: u,
|
|
204
|
+
resolution: d,
|
|
205
|
+
from: i,
|
|
206
|
+
to: a,
|
|
207
207
|
countBack: C
|
|
208
208
|
}).then((e) => {
|
|
209
|
-
if (
|
|
209
|
+
if (t !== U.current) return;
|
|
210
210
|
if (e.length === 0) {
|
|
211
211
|
H.current = !1;
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
let
|
|
215
|
-
R.current = [...
|
|
216
|
-
from:
|
|
217
|
-
to:
|
|
214
|
+
let n = [...e].sort((e, t) => e.time - t.time).filter((e) => e.time < r), i = z.current;
|
|
215
|
+
R.current = [...n, ...R.current], z.current = {
|
|
216
|
+
from: i.from + n.length,
|
|
217
|
+
to: i.to + n.length
|
|
218
218
|
}, H.current = !1, Q();
|
|
219
219
|
}).catch(() => {
|
|
220
|
-
|
|
220
|
+
t === U.current && (H.current = !1);
|
|
221
221
|
});
|
|
222
222
|
}, [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
c,
|
|
224
|
+
u,
|
|
225
|
+
d,
|
|
226
226
|
C,
|
|
227
227
|
Q
|
|
228
|
-
]), Ue =
|
|
228
|
+
]), Ue = e((e) => {
|
|
229
229
|
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
230
230
|
if (B.current = {
|
|
231
231
|
x: n,
|
|
@@ -253,11 +253,11 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
253
253
|
He,
|
|
254
254
|
Q,
|
|
255
255
|
$
|
|
256
|
-
]), We =
|
|
256
|
+
]), We = e((e) => {
|
|
257
257
|
e.currentTarget.releasePointerCapture(e.pointerId), V.current = null;
|
|
258
|
-
}, []), Ge =
|
|
258
|
+
}, []), Ge = e(() => {
|
|
259
259
|
B.current = null, V.current = null, $(null), Q();
|
|
260
|
-
}, [Q, $]), Ke =
|
|
260
|
+
}, [Q, $]), Ke = e((e) => {
|
|
261
261
|
e.preventDefault();
|
|
262
262
|
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = T(t.width, t.height, X, Z), i = z.current, a = R.current;
|
|
263
263
|
if (a.length === 0) return;
|
|
@@ -270,7 +270,7 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
270
270
|
X,
|
|
271
271
|
Z,
|
|
272
272
|
Q
|
|
273
|
-
]), qe =
|
|
273
|
+
]), qe = e((e) => {
|
|
274
274
|
let t = z.current, n = t.to - t.from + 1, r = R.current;
|
|
275
275
|
if (r.length === 0) return;
|
|
276
276
|
let i = 0;
|
|
@@ -286,7 +286,7 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
286
286
|
}, [Q]);
|
|
287
287
|
return /* @__PURE__ */ v("div", {
|
|
288
288
|
ref: I,
|
|
289
|
-
className: g
|
|
289
|
+
className: o(g.root, Ae),
|
|
290
290
|
style: {
|
|
291
291
|
...je,
|
|
292
292
|
height: ae,
|
|
@@ -294,11 +294,11 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
294
294
|
},
|
|
295
295
|
tabIndex: 0,
|
|
296
296
|
role: "figure",
|
|
297
|
-
"aria-label": `${
|
|
297
|
+
"aria-label": `${u} ${d} chart`,
|
|
298
298
|
onKeyDown: qe,
|
|
299
299
|
children: [/* @__PURE__ */ _("canvas", {
|
|
300
300
|
ref: L,
|
|
301
|
-
className:
|
|
301
|
+
className: g.svg,
|
|
302
302
|
onPointerDown: Ve,
|
|
303
303
|
onPointerMove: Ue,
|
|
304
304
|
onPointerUp: We,
|
|
@@ -309,7 +309,7 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
309
309
|
touchAction: "none"
|
|
310
310
|
}
|
|
311
311
|
}), /* @__PURE__ */ v("div", {
|
|
312
|
-
className:
|
|
312
|
+
className: g.tradingHeader,
|
|
313
313
|
style: {
|
|
314
314
|
position: "absolute",
|
|
315
315
|
top: ee,
|
|
@@ -329,10 +329,10 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
329
329
|
minWidth: 0
|
|
330
330
|
},
|
|
331
331
|
children: [
|
|
332
|
-
/* @__PURE__ */ _("strong", { children:
|
|
332
|
+
/* @__PURE__ */ _("strong", { children: u }),
|
|
333
333
|
/* @__PURE__ */ _("span", {
|
|
334
334
|
style: { color: "var(--crk-color-text-muted)" },
|
|
335
|
-
children:
|
|
335
|
+
children: d
|
|
336
336
|
}),
|
|
337
337
|
J?.bar && /* @__PURE__ */ v("span", {
|
|
338
338
|
style: {
|
|
@@ -354,10 +354,10 @@ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s =
|
|
|
354
354
|
]
|
|
355
355
|
}), M && /* @__PURE__ */ _("div", {
|
|
356
356
|
style: { pointerEvents: "auto" },
|
|
357
|
-
children: /* @__PURE__ */ _(
|
|
357
|
+
children: /* @__PURE__ */ _(l, {
|
|
358
358
|
position: "bottom",
|
|
359
359
|
asChild: !0,
|
|
360
|
-
trigger: /* @__PURE__ */ _(
|
|
360
|
+
trigger: /* @__PURE__ */ _(s, {
|
|
361
361
|
variant: "ghost",
|
|
362
362
|
size: "sm",
|
|
363
363
|
iconOnly: !0,
|
|
@@ -407,7 +407,7 @@ var w = [
|
|
|
407
407
|
label: "Asia / Singapore"
|
|
408
408
|
}
|
|
409
409
|
];
|
|
410
|
-
function oe({ timezone: e, onTimezoneChange:
|
|
410
|
+
function oe({ timezone: e, onTimezoneChange: t }) {
|
|
411
411
|
return /* @__PURE__ */ v("div", {
|
|
412
412
|
style: {
|
|
413
413
|
minWidth: 220,
|
|
@@ -433,13 +433,13 @@ function oe({ timezone: e, onTimezoneChange: n }) {
|
|
|
433
433
|
color: "var(--crk-color-text-muted)"
|
|
434
434
|
},
|
|
435
435
|
children: "Timezone"
|
|
436
|
-
}), /* @__PURE__ */ _(
|
|
436
|
+
}), /* @__PURE__ */ _(c, {
|
|
437
437
|
options: w.map((e) => ({
|
|
438
438
|
value: e.value,
|
|
439
439
|
label: e.label
|
|
440
440
|
})),
|
|
441
441
|
value: e,
|
|
442
|
-
onChange: (e) =>
|
|
442
|
+
onChange: (e) => t(e)
|
|
443
443
|
})]
|
|
444
444
|
})]
|
|
445
445
|
});
|
|
@@ -461,7 +461,7 @@ function se() {
|
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
463
|
function T(e, t, n, r) {
|
|
464
|
-
let i = Math.max(0, e - b), a = S, o = Math.max(a, t - x), s = Math.max(0, i
|
|
464
|
+
let i = Math.max(0, e - b), a = S, o = Math.max(a, t - x), s = Math.max(0, +i), c = Math.max(0, o - a), l = c, u = a, d = {
|
|
465
465
|
top: a,
|
|
466
466
|
bottom: o,
|
|
467
467
|
height: c
|
|
@@ -506,16 +506,16 @@ function ce(e, t) {
|
|
|
506
506
|
function le(e, t) {
|
|
507
507
|
if (e.type === "sma") return {
|
|
508
508
|
kind: "line",
|
|
509
|
-
values:
|
|
509
|
+
values: m(t, e.period),
|
|
510
510
|
color: e.color ?? "var(--crk-chart-2)"
|
|
511
511
|
};
|
|
512
512
|
if (e.type === "ema") return {
|
|
513
513
|
kind: "line",
|
|
514
|
-
values:
|
|
514
|
+
values: f(t, e.period),
|
|
515
515
|
color: e.color ?? "var(--crk-chart-3)"
|
|
516
516
|
};
|
|
517
517
|
if (e.type === "bollinger") {
|
|
518
|
-
let n =
|
|
518
|
+
let n = d(t, e.period, e.stdDev ?? 2);
|
|
519
519
|
return {
|
|
520
520
|
kind: "bollinger",
|
|
521
521
|
middle: n.middle,
|
|
@@ -527,44 +527,44 @@ function le(e, t) {
|
|
|
527
527
|
}
|
|
528
528
|
return null;
|
|
529
529
|
}
|
|
530
|
-
function ue(e, t, n,
|
|
531
|
-
let
|
|
532
|
-
for (let e of t) e.low <
|
|
530
|
+
function ue(e, t, n, r, i) {
|
|
531
|
+
let a = 1e400, o = -1e400;
|
|
532
|
+
for (let e of t) e.low < a && (a = e.low), e.high > o && (o = e.high);
|
|
533
533
|
for (let e of n) {
|
|
534
534
|
let t = e.kind === "line" ? [e.values] : [e.upper, e.lower];
|
|
535
535
|
for (let e of t) {
|
|
536
|
-
let t = Math.max(0, Math.floor(
|
|
536
|
+
let t = Math.max(0, Math.floor(r)), n = Math.min(e.length - 1, Math.ceil(i));
|
|
537
537
|
for (let r = t; r <= n; r++) {
|
|
538
538
|
let t = e[r];
|
|
539
|
-
t != null && (t <
|
|
539
|
+
t != null && (t < a && (a = t), t > o && (o = t));
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
isFinite(
|
|
544
|
-
let
|
|
543
|
+
isFinite(a) && isFinite(o) || (a = 0, o = 1);
|
|
544
|
+
let s = (o - a) * .08 || 1, c = u(a - s, o + s, 5), l = Math.min(c[0], a), d = Math.max(c[c.length - 1], o);
|
|
545
545
|
return {
|
|
546
546
|
paneTop: e.top,
|
|
547
547
|
paneBottom: e.bottom,
|
|
548
548
|
paneHeight: e.height,
|
|
549
|
-
priceMin:
|
|
549
|
+
priceMin: l,
|
|
550
550
|
priceMax: d,
|
|
551
|
-
ticks:
|
|
551
|
+
ticks: c
|
|
552
552
|
};
|
|
553
553
|
}
|
|
554
|
-
function de(e, t, n,
|
|
555
|
-
let
|
|
556
|
-
for (let e =
|
|
554
|
+
function de(e, t, n, r) {
|
|
555
|
+
let i = 0, a = Math.max(0, Math.floor(n)), o = Math.min(t.length - 1, Math.ceil(r));
|
|
556
|
+
for (let e = a; e <= o; e++) {
|
|
557
557
|
let n = t[e].volume ?? 0;
|
|
558
|
-
n >
|
|
558
|
+
n > i && (i = n);
|
|
559
559
|
}
|
|
560
|
-
let
|
|
560
|
+
let s = u(0, i || 1, 3), c = Math.max(s[s.length - 1], i);
|
|
561
561
|
return {
|
|
562
562
|
paneTop: e.top,
|
|
563
563
|
paneBottom: e.bottom,
|
|
564
564
|
paneHeight: e.height,
|
|
565
565
|
priceMin: 0,
|
|
566
|
-
priceMax:
|
|
567
|
-
ticks:
|
|
566
|
+
priceMax: c,
|
|
567
|
+
ticks: s
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
570
|
function E(e, t) {
|
|
@@ -30,11 +30,11 @@ function n(n) {
|
|
|
30
30
|
case "5D": return "15";
|
|
31
31
|
case "1M": return "60";
|
|
32
32
|
case "3M": return "240";
|
|
33
|
-
case "6M":
|
|
33
|
+
case "6M":
|
|
34
34
|
case "1Y": return "D";
|
|
35
|
-
case "5Y":
|
|
35
|
+
case "5Y":
|
|
36
36
|
case "10Y": return "W";
|
|
37
|
-
case "20Y":
|
|
37
|
+
case "20Y":
|
|
38
38
|
case "MAX": return "M";
|
|
39
39
|
}
|
|
40
40
|
let r = t(n);
|