@funnest/charts-ui 0.11.18 → 0.11.21
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/dist/context.d.ts +4 -1
- package/dist/i18n.d.ts +32 -8
- package/dist/index.js +117 -124
- package/package.json +2 -2
- package/dist/components/indicator-templates.d.ts +0 -13
package/dist/context.d.ts
CHANGED
|
@@ -200,7 +200,10 @@ export interface WidgetContext {
|
|
|
200
200
|
export interface LayoutSync {
|
|
201
201
|
/** Mirror the crosshair's time in every pane. */
|
|
202
202
|
crosshair: boolean;
|
|
203
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Old 시간 범위 동기화, now ChartSettings.timeLink 'follow' (같이 이동): turning it on sets that on
|
|
205
|
+
* every chart; it reads false.
|
|
206
|
+
*/
|
|
204
207
|
time: boolean;
|
|
205
208
|
/** Changing the symbol changes it in every pane. */
|
|
206
209
|
symbol: boolean;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -112,6 +112,22 @@ export declare const STRINGS: {
|
|
|
112
112
|
hintPriceAnimation: string;
|
|
113
113
|
hintDrawOnLoad: string;
|
|
114
114
|
hintSymbolWatermark: string;
|
|
115
|
+
settingsSplit: string;
|
|
116
|
+
splitSyncCrosshair: string;
|
|
117
|
+
hintSplitSyncCrosshair: string;
|
|
118
|
+
splitSyncSymbol: string;
|
|
119
|
+
hintSplitSyncSymbol: string;
|
|
120
|
+
splitSyncInterval: string;
|
|
121
|
+
hintSplitSyncInterval: string;
|
|
122
|
+
settingsTimeLink: string;
|
|
123
|
+
timeLinkOff: string;
|
|
124
|
+
timeLinkMark: string;
|
|
125
|
+
timeLinkJump: string;
|
|
126
|
+
timeLinkFollow: string;
|
|
127
|
+
hintTimeLinkOff: string;
|
|
128
|
+
hintTimeLinkMark: string;
|
|
129
|
+
hintTimeLinkJump: string;
|
|
130
|
+
hintTimeLinkFollow: string;
|
|
115
131
|
hintReplayWatermark: string;
|
|
116
132
|
undo: string;
|
|
117
133
|
tools: string;
|
|
@@ -164,10 +180,6 @@ export declare const STRINGS: {
|
|
|
164
180
|
saveTemplate: string;
|
|
165
181
|
templateName: string;
|
|
166
182
|
noTemplates: string;
|
|
167
|
-
indicatorTemplates: string;
|
|
168
|
-
saveIndicatorTemplate: string;
|
|
169
|
-
noIndicatorTemplates: string;
|
|
170
|
-
noIndicatorsToSave: string;
|
|
171
183
|
deleteTemplate: string;
|
|
172
184
|
lineWidth: string;
|
|
173
185
|
lineStyle: string;
|
|
@@ -446,6 +458,22 @@ export declare const STRINGS: {
|
|
|
446
458
|
hintPriceAnimation: string;
|
|
447
459
|
hintDrawOnLoad: string;
|
|
448
460
|
hintSymbolWatermark: string;
|
|
461
|
+
settingsSplit: string;
|
|
462
|
+
splitSyncCrosshair: string;
|
|
463
|
+
hintSplitSyncCrosshair: string;
|
|
464
|
+
splitSyncSymbol: string;
|
|
465
|
+
hintSplitSyncSymbol: string;
|
|
466
|
+
splitSyncInterval: string;
|
|
467
|
+
hintSplitSyncInterval: string;
|
|
468
|
+
settingsTimeLink: string;
|
|
469
|
+
timeLinkOff: string;
|
|
470
|
+
timeLinkMark: string;
|
|
471
|
+
timeLinkJump: string;
|
|
472
|
+
timeLinkFollow: string;
|
|
473
|
+
hintTimeLinkOff: string;
|
|
474
|
+
hintTimeLinkMark: string;
|
|
475
|
+
hintTimeLinkJump: string;
|
|
476
|
+
hintTimeLinkFollow: string;
|
|
449
477
|
hintReplayWatermark: string;
|
|
450
478
|
undo: string;
|
|
451
479
|
tools: string;
|
|
@@ -498,10 +526,6 @@ export declare const STRINGS: {
|
|
|
498
526
|
saveTemplate: string;
|
|
499
527
|
templateName: string;
|
|
500
528
|
noTemplates: string;
|
|
501
|
-
indicatorTemplates: string;
|
|
502
|
-
saveIndicatorTemplate: string;
|
|
503
|
-
noIndicatorTemplates: string;
|
|
504
|
-
noIndicatorsToSave: string;
|
|
505
529
|
deleteTemplate: string;
|
|
506
530
|
lineWidth: string;
|
|
507
531
|
lineStyle: string;
|
package/dist/index.js
CHANGED
|
@@ -547,6 +547,22 @@ var STRINGS = {
|
|
|
547
547
|
hintPriceAnimation: "\uC0C8 \uAC00\uACA9\uC774 \uB4E4\uC5B4\uC624\uBA74 \uB9C8\uC9C0\uB9C9 \uCE94\uB4E4\uACFC \uD604\uC7AC\uAC00 \uC120\uC774 \uC0C8 \uAC00\uACA9\uAE4C\uC9C0 \uBBF8\uB044\uB7EC\uC9C0\uB4EF \uC6C0\uC9C1\uC5EC\uC694.",
|
|
548
548
|
hintDrawOnLoad: "\uC885\uBAA9\uC774\uB098 \uC8FC\uAE30\uB97C \uBC14\uAFD4 \uCC28\uD2B8\uB97C \uBD88\uB7EC\uC62C \uB54C \uCE94\uB4E4\uC774 \uC67C\uCABD\uBD80\uD130 \uCC28\uB840\uB85C \uADF8\uB824\uC838\uC694.",
|
|
549
549
|
hintSymbolWatermark: "\uAC00\uACA9 \uC601\uC5ED \uAC00\uC6B4\uB370\uC5D0 \uC885\uBAA9 \uC774\uB984\uACFC \uC8FC\uAE30\uB97C \uD750\uB9AC\uAC8C \uBCF4\uC5EC\uC918\uC694.",
|
|
550
|
+
settingsSplit: "\uBD84\uD560 \uD654\uBA74",
|
|
551
|
+
splitSyncCrosshair: "\uC2ED\uC790\uC120 \uAC19\uC774 \uBCF4\uAE30",
|
|
552
|
+
hintSplitSyncCrosshair: "\uD55C \uCC28\uD2B8\uC5D0 \uB9C8\uC6B0\uC2A4\uB97C \uC62C\uB9AC\uBA74 \uB098\uBA38\uC9C0 \uCC28\uD2B8\uC5D0\uB3C4 \uAC19\uC740 \uC2DC\uAC01\uC5D0 \uC138\uB85C\uC120\uC774 \uBCF4\uC5EC\uC694.",
|
|
553
|
+
splitSyncSymbol: "\uC885\uBAA9 \uAC19\uC774 \uBC14\uAFB8\uAE30",
|
|
554
|
+
hintSplitSyncSymbol: "\uD55C \uCC28\uD2B8\uC758 \uC885\uBAA9\uC744 \uBC14\uAFB8\uBA74 \uB098\uBA38\uC9C0 \uCC28\uD2B8\uB3C4 \uADF8 \uC885\uBAA9\uC73C\uB85C \uBC14\uB00C\uC5B4\uC694.",
|
|
555
|
+
splitSyncInterval: "\uC8FC\uAE30 \uAC19\uC774 \uBC14\uAFB8\uAE30",
|
|
556
|
+
hintSplitSyncInterval: "\uD55C \uCC28\uD2B8\uC758 \uC8FC\uAE30\uB97C \uBC14\uAFB8\uBA74 \uB098\uBA38\uC9C0 \uCC28\uD2B8\uB3C4 \uADF8 \uC8FC\uAE30\uB85C \uBC14\uB00C\uC5B4\uC694.",
|
|
557
|
+
settingsTimeLink: "\uC2DC\uC810 \uB9DE\uCD94\uAE30",
|
|
558
|
+
timeLinkOff: "\uB044\uAE30",
|
|
559
|
+
timeLinkMark: "\uD45C\uC2DC\uB9CC",
|
|
560
|
+
timeLinkJump: "\uD074\uB9AD \uC2DC \uC774\uB3D9",
|
|
561
|
+
timeLinkFollow: "\uAC19\uC774 \uC774\uB3D9",
|
|
562
|
+
hintTimeLinkOff: "\uCC28\uD2B8\uB9C8\uB2E4 \uB530\uB85C \uC6C0\uC9C1\uC5EC\uC694.",
|
|
563
|
+
hintTimeLinkMark: "\uCE94\uB4E4\uC744 \uD074\uB9AD\uD558\uBA74 \uBAA8\uB4E0 \uCC28\uD2B8\uC5D0 \uADF8 \uC2DC\uC810\uC744 \uC138\uB85C \uC810\uC120\uC73C\uB85C \uD45C\uC2DC\uD574\uC694. \uCC28\uD2B8\uB294 \uC6C0\uC9C1\uC774\uC9C0 \uC54A\uC544\uC694.",
|
|
564
|
+
hintTimeLinkJump: "\uCE94\uB4E4\uC744 \uD074\uB9AD\uD558\uBA74 \uADF8 \uC2DC\uC810\uC744 \uD45C\uC2DC\uD558\uACE0, \uB098\uBA38\uC9C0 \uCC28\uD2B8\uB3C4 \uADF8 \uC2DC\uC810\uC73C\uB85C \uAC00\uC694. \uC8FC\uAE30\uC640 \uD655\uB300 \uC815\uB3C4\uB294 \uCC28\uD2B8\uB9C8\uB2E4 \uADF8\uB300\uB85C\uC608\uC694.",
|
|
565
|
+
hintTimeLinkFollow: "\uD55C \uCC28\uD2B8\uB97C \uC6C0\uC9C1\uC774\uBA74 \uB098\uBA38\uC9C0\uB3C4 \uB530\uB77C\uC640\uC694. \uC8FC\uAE30\uAC00 \uAC19\uC73C\uBA74 \uBCF4\uC774\uB294 \uBC94\uC704\uAE4C\uC9C0 \uB611\uAC19\uC774, \uB2E4\uB974\uBA74 \uAC19\uC740 \uC2DC\uC810\uC744 \uAC00\uC6B4\uB370\uC5D0 \uB46C\uC694. \uD074\uB9AD\uD55C \uC2DC\uC810\uB3C4 \uD45C\uC2DC\uD574\uC694.",
|
|
550
566
|
hintReplayWatermark: '\uB9AC\uD50C\uB808\uC774 \uC911\uC5D0\uB294 \uAC00\uACA9 \uC601\uC5ED\uC5D0 "\uB9AC\uD50C\uB808\uC774"\uB97C \uD750\uB9AC\uAC8C \uBCF4\uC5EC\uC918\uC694.',
|
|
551
567
|
undo: "\uB418\uB3CC\uB9AC\uAE30",
|
|
552
568
|
tools: "\uB3C4\uAD6C",
|
|
@@ -599,10 +615,6 @@ var STRINGS = {
|
|
|
599
615
|
saveTemplate: "\uC9C0\uAE08 \uBAA8\uC591\uC744 \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
600
616
|
templateName: "\uD15C\uD50C\uB9BF \uC774\uB984",
|
|
601
617
|
noTemplates: "\uC774 \uB3C4\uAD6C\uB85C \uC800\uC7A5\uD55C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694",
|
|
602
|
-
indicatorTemplates: "\uC9C0\uD45C \uD15C\uD50C\uB9BF",
|
|
603
|
-
saveIndicatorTemplate: "\uC9C0\uAE08 \uC9C0\uD45C\uB97C \uD15C\uD50C\uB9BF\uC73C\uB85C \uC800\uC7A5",
|
|
604
|
-
noIndicatorTemplates: "\uC800\uC7A5\uD55C \uC9C0\uD45C \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC5B4\uC694. \uC9C0\uD45C\uB97C \uB123\uC740 \uB4A4 \uC544\uB798\uC5D0\uC11C \uC800\uC7A5\uD558\uBA74 \uB2E4\uB978 \uCC28\uD2B8\uC5D0\uB3C4 \uD55C \uBC88\uC5D0 \uB123\uC744 \uC218 \uC788\uC5B4\uC694.",
|
|
605
|
-
noIndicatorsToSave: "\uC800\uC7A5\uD560 \uC9C0\uD45C\uAC00 \uC5C6\uC5B4\uC694",
|
|
606
618
|
deleteTemplate: "\uD15C\uD50C\uB9BF \uC9C0\uC6B0\uAE30",
|
|
607
619
|
lineWidth: "\uC120 \uAD75\uAE30",
|
|
608
620
|
lineStyle: "\uC120 \uBAA8\uC591",
|
|
@@ -883,6 +895,22 @@ var STRINGS = {
|
|
|
883
895
|
hintPriceAnimation: "A new price slides the last candle and the last-price line to it.",
|
|
884
896
|
hintDrawOnLoad: "Candles draw in from the left when a symbol or interval loads.",
|
|
885
897
|
hintSymbolWatermark: "The symbol and interval, faint in the middle of the price pane.",
|
|
898
|
+
settingsSplit: "Split view",
|
|
899
|
+
splitSyncCrosshair: "Crosshair on every chart",
|
|
900
|
+
hintSplitSyncCrosshair: "Hovering one chart shows a line at the same time on the others.",
|
|
901
|
+
splitSyncSymbol: "Symbol on every chart",
|
|
902
|
+
hintSplitSyncSymbol: "Changing one chart\u2019s symbol changes the others\u2019 too.",
|
|
903
|
+
splitSyncInterval: "Interval on every chart",
|
|
904
|
+
hintSplitSyncInterval: "Changing one chart\u2019s interval changes the others\u2019 too.",
|
|
905
|
+
settingsTimeLink: "One moment",
|
|
906
|
+
timeLinkOff: "Off",
|
|
907
|
+
timeLinkMark: "Mark",
|
|
908
|
+
timeLinkJump: "Jump on click",
|
|
909
|
+
timeLinkFollow: "Move together",
|
|
910
|
+
hintTimeLinkOff: "Each chart moves on its own.",
|
|
911
|
+
hintTimeLinkMark: "A click on a candle marks that time on every chart with a dashed line. Nothing moves.",
|
|
912
|
+
hintTimeLinkJump: "A click on a candle marks that time and takes the other charts there, each keeping its own interval and zoom.",
|
|
913
|
+
hintTimeLinkFollow: "Moving one chart moves the others: the same range at the same interval, the same time in the middle otherwise. Clicks are marked too.",
|
|
886
914
|
hintReplayWatermark: '"Replay", faint in the price pane while a replay runs.',
|
|
887
915
|
undo: "Undo",
|
|
888
916
|
tools: "Tools",
|
|
@@ -935,10 +963,6 @@ var STRINGS = {
|
|
|
935
963
|
saveTemplate: "Save this look as a template",
|
|
936
964
|
templateName: "Template name",
|
|
937
965
|
noTemplates: "No templates for this tool yet",
|
|
938
|
-
indicatorTemplates: "Indicator templates",
|
|
939
|
-
saveIndicatorTemplate: "Save these indicators as a template",
|
|
940
|
-
noIndicatorTemplates: "No indicator templates yet. Add indicators, save them below, and put them on any chart in one go.",
|
|
941
|
-
noIndicatorsToSave: "No indicators to save",
|
|
942
966
|
deleteTemplate: "Delete template",
|
|
943
967
|
lineWidth: "Line width",
|
|
944
968
|
lineStyle: "Line style",
|
|
@@ -3061,6 +3085,17 @@ var WATERMARK_ROWS = [
|
|
|
3061
3085
|
{ key: "symbolWatermark", label: "settingSymbolWatermark", hint: "hintSymbolWatermark" },
|
|
3062
3086
|
{ key: "replayWatermark", label: "settingReplayWatermark", hint: "hintReplayWatermark" }
|
|
3063
3087
|
];
|
|
3088
|
+
var SPLIT_SYNC = [
|
|
3089
|
+
{ key: "crosshair", label: "splitSyncCrosshair", hint: "hintSplitSyncCrosshair" },
|
|
3090
|
+
{ key: "symbol", label: "splitSyncSymbol", hint: "hintSplitSyncSymbol" },
|
|
3091
|
+
{ key: "interval", label: "splitSyncInterval", hint: "hintSplitSyncInterval" }
|
|
3092
|
+
];
|
|
3093
|
+
var TIME_LINK_CHOICES = [
|
|
3094
|
+
{ link: "off", label: "timeLinkOff", hint: "hintTimeLinkOff" },
|
|
3095
|
+
{ link: "mark", label: "timeLinkMark", hint: "hintTimeLinkMark" },
|
|
3096
|
+
{ link: "jump", label: "timeLinkJump", hint: "hintTimeLinkJump" },
|
|
3097
|
+
{ link: "follow", label: "timeLinkFollow", hint: "hintTimeLinkFollow" }
|
|
3098
|
+
];
|
|
3064
3099
|
var MOTION_ROWS = [
|
|
3065
3100
|
{ key: "zoomAnimation", label: "settingZoomAnimation", hint: "hintZoomAnimation" },
|
|
3066
3101
|
{ key: "scrollInertia", label: "settingScrollInertia", hint: "hintScrollInertia" },
|
|
@@ -3204,7 +3239,8 @@ function SettingsDialog({ ctx }) {
|
|
|
3204
3239
|
/* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsDisplay }),
|
|
3205
3240
|
toggles(VIEW_ROWS),
|
|
3206
3241
|
/* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsWatermark }),
|
|
3207
|
-
toggles(WATERMARK_ROWS)
|
|
3242
|
+
toggles(WATERMARK_ROWS),
|
|
3243
|
+
ctx.multi && /* @__PURE__ */ a3(SplitSettings, { multi: ctx.multi, timeLink: settings.timeLink, t: t3 })
|
|
3208
3244
|
] }),
|
|
3209
3245
|
shown === "motion" && /* @__PURE__ */ a3($, { children: [
|
|
3210
3246
|
/* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsTabMotion }),
|
|
@@ -3399,6 +3435,20 @@ function demoBars(price, interval, count, volume) {
|
|
|
3399
3435
|
const won = (v3) => Math.round(v3 + shift);
|
|
3400
3436
|
return bars.map((b) => ({ ...b, open: won(b.open), high: won(b.high), low: won(b.low), close: won(b.close) }));
|
|
3401
3437
|
}
|
|
3438
|
+
function SplitSettings({ multi, timeLink, t: t3 }) {
|
|
3439
|
+
const m3 = useStore(multi.store);
|
|
3440
|
+
return /* @__PURE__ */ a3($, { children: [
|
|
3441
|
+
/* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsSplit }),
|
|
3442
|
+
SPLIT_SYNC.map(({ key, label, hint }) => /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
|
|
3443
|
+
/* @__PURE__ */ a3("span", { class: "fnc-toggle-label", children: t3[label] }),
|
|
3444
|
+
/* @__PURE__ */ a3(Info, { text: t3[hint] }),
|
|
3445
|
+
/* @__PURE__ */ a3("input", { type: "checkbox", role: "switch", class: "fnc-switch", checked: m3.sync[key], onChange: (e3) => multi.setSync({ [key]: e3.currentTarget.checked }) })
|
|
3446
|
+
] })),
|
|
3447
|
+
/* @__PURE__ */ a3("div", { class: "fnc-row fnc-timelink-label", children: t3.settingsTimeLink }),
|
|
3448
|
+
/* @__PURE__ */ a3("div", { class: "fnc-seg fnc-settings-seg fnc-timelink-seg", role: "radiogroup", "aria-label": t3.settingsTimeLink, children: TIME_LINK_CHOICES.map(({ link, label }) => /* @__PURE__ */ a3("button", { type: "button", role: "radio", "aria-checked": timeLink === link, onClick: () => multi.applySettings({ timeLink: link }), children: t3[label] })) }),
|
|
3449
|
+
/* @__PURE__ */ a3("p", { class: "fnc-timelink-note", children: t3[TIME_LINK_CHOICES.find((c3) => c3.link === timeLink)?.hint ?? "hintTimeLinkOff"] })
|
|
3450
|
+
] });
|
|
3451
|
+
}
|
|
3402
3452
|
|
|
3403
3453
|
// src/components/indicator-dialogs.tsx
|
|
3404
3454
|
function Dialog({ title, onClose, children, wide }) {
|
|
@@ -4156,7 +4206,6 @@ var SCALES2 = [
|
|
|
4156
4206
|
];
|
|
4157
4207
|
var SYNC_KEYS = [
|
|
4158
4208
|
{ key: "crosshair", label: "syncCrosshair" },
|
|
4159
|
-
{ key: "time", label: "syncTime" },
|
|
4160
4209
|
{ key: "symbol", label: "syncSymbol" },
|
|
4161
4210
|
{ key: "interval", label: "syncInterval" }
|
|
4162
4211
|
];
|
|
@@ -4306,108 +4355,6 @@ function ToolsMenu({ ctx }) {
|
|
|
4306
4355
|
] });
|
|
4307
4356
|
}
|
|
4308
4357
|
|
|
4309
|
-
// src/components/indicator-templates.tsx
|
|
4310
|
-
var KEY = "fnc-indicator-templates";
|
|
4311
|
-
var MAX = 30;
|
|
4312
|
-
function readIndicatorTemplates() {
|
|
4313
|
-
try {
|
|
4314
|
-
const raw = localStorage.getItem(KEY);
|
|
4315
|
-
const list = raw ? JSON.parse(raw) : [];
|
|
4316
|
-
return Array.isArray(list) ? list.filter((x2) => !!x2 && typeof x2.name === "string" && Array.isArray(x2.indicators)) : [];
|
|
4317
|
-
} catch {
|
|
4318
|
-
return [];
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
function writeIndicatorTemplates(list) {
|
|
4322
|
-
try {
|
|
4323
|
-
localStorage.setItem(KEY, JSON.stringify(list));
|
|
4324
|
-
} catch {
|
|
4325
|
-
}
|
|
4326
|
-
}
|
|
4327
|
-
function IndicatorTemplates({ ctx }) {
|
|
4328
|
-
const s3 = useStore(ctx.store);
|
|
4329
|
-
const t3 = stringsOf(s3);
|
|
4330
|
-
const [open, setOpen] = d2(false);
|
|
4331
|
-
const [list, setList] = d2(() => readIndicatorTemplates());
|
|
4332
|
-
const [naming, setNaming] = d2(null);
|
|
4333
|
-
const ref = T2(null);
|
|
4334
|
-
const menuRef = useKeepInView(open);
|
|
4335
|
-
A2(() => {
|
|
4336
|
-
if (!open) return;
|
|
4337
|
-
setList(readIndicatorTemplates());
|
|
4338
|
-
const onDown = (e3) => !ref.current?.contains(e3.target) && setOpen(false);
|
|
4339
|
-
const onKey = (e3) => e3.key === "Escape" && setOpen(false);
|
|
4340
|
-
document.addEventListener("pointerdown", onDown);
|
|
4341
|
-
document.addEventListener("keydown", onKey);
|
|
4342
|
-
return () => {
|
|
4343
|
-
document.removeEventListener("pointerdown", onDown);
|
|
4344
|
-
document.removeEventListener("keydown", onKey);
|
|
4345
|
-
};
|
|
4346
|
-
}, [open]);
|
|
4347
|
-
const keep = (next) => {
|
|
4348
|
-
setList(next);
|
|
4349
|
-
writeIndicatorTemplates(next);
|
|
4350
|
-
};
|
|
4351
|
-
const current = ctx.chart.getIndicators();
|
|
4352
|
-
const save = () => {
|
|
4353
|
-
const name = (naming ?? "").trim().slice(0, 30);
|
|
4354
|
-
if (!name || current.length === 0) return setNaming(null);
|
|
4355
|
-
const titles = ctx.chart.indicatorLegend().map((i3) => i3.title);
|
|
4356
|
-
keep([{ name, indicators: JSON.parse(JSON.stringify(current)), titles }, ...list.filter((x2) => x2.name !== name)].slice(0, MAX));
|
|
4357
|
-
setNaming(null);
|
|
4358
|
-
};
|
|
4359
|
-
const apply = (tpl) => {
|
|
4360
|
-
ctx.chart.setIndicators(JSON.parse(JSON.stringify(tpl.indicators)));
|
|
4361
|
-
setOpen(false);
|
|
4362
|
-
};
|
|
4363
|
-
return /* @__PURE__ */ a3("div", { class: "fnc-menu-wrap fnc-indtpl-wrap", ref, children: [
|
|
4364
|
-
/* @__PURE__ */ a3(
|
|
4365
|
-
"button",
|
|
4366
|
-
{
|
|
4367
|
-
class: "fnc-btn fnc-btn-indtpl",
|
|
4368
|
-
"data-tip": t3.indicatorTemplates,
|
|
4369
|
-
"aria-label": t3.indicatorTemplates,
|
|
4370
|
-
"aria-haspopup": "menu",
|
|
4371
|
-
"aria-expanded": open,
|
|
4372
|
-
onClick: () => {
|
|
4373
|
-
setNaming(null);
|
|
4374
|
-
setOpen(!open);
|
|
4375
|
-
},
|
|
4376
|
-
children: /* @__PURE__ */ a3(TemplateIcon, {})
|
|
4377
|
-
}
|
|
4378
|
-
),
|
|
4379
|
-
open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-template-menu fnc-indtpl-menu", role: "menu", "aria-label": t3.indicatorTemplates, ref: menuRef, children: [
|
|
4380
|
-
/* @__PURE__ */ a3("div", { class: "fnc-menu-title", children: t3.indicatorTemplates }),
|
|
4381
|
-
list.length === 0 && /* @__PURE__ */ a3("div", { class: "fnc-menu-note", children: t3.noIndicatorTemplates }),
|
|
4382
|
-
list.map((tpl) => /* @__PURE__ */ a3("div", { class: "fnc-template-row", children: [
|
|
4383
|
-
/* @__PURE__ */ a3("button", { class: "fnc-menu-item fnc-indtpl-item", role: "menuitem", onClick: () => apply(tpl), children: [
|
|
4384
|
-
/* @__PURE__ */ a3("span", { class: "fnc-indtpl-name", children: tpl.name }),
|
|
4385
|
-
/* @__PURE__ */ a3("small", { class: "fnc-indtpl-sub", children: tpl.titles.length ? tpl.titles.join(" \xB7 ") : `${tpl.indicators.length}` })
|
|
4386
|
-
] }),
|
|
4387
|
-
/* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.deleteTemplate, "aria-label": `${tpl.name} ${t3.deleteTemplate}`, onClick: () => keep(list.filter((x2) => x2 !== tpl)), children: /* @__PURE__ */ a3(SmallCloseIcon, {}) })
|
|
4388
|
-
] })),
|
|
4389
|
-
/* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
|
|
4390
|
-
naming === null ? /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", disabled: current.length === 0, onClick: () => setNaming(""), children: current.length === 0 ? t3.noIndicatorsToSave : t3.saveIndicatorTemplate }) : /* @__PURE__ */ a3(
|
|
4391
|
-
"input",
|
|
4392
|
-
{
|
|
4393
|
-
class: "fnc-selbar-text fnc-template-name",
|
|
4394
|
-
value: naming,
|
|
4395
|
-
placeholder: t3.templateName,
|
|
4396
|
-
"aria-label": t3.templateName,
|
|
4397
|
-
maxLength: 30,
|
|
4398
|
-
autoFocus: true,
|
|
4399
|
-
onInput: (e3) => setNaming(e3.target.value),
|
|
4400
|
-
onKeyDown: (e3) => {
|
|
4401
|
-
e3.stopPropagation();
|
|
4402
|
-
if (e3.key === "Enter") save();
|
|
4403
|
-
if (e3.key === "Escape") setNaming(null);
|
|
4404
|
-
}
|
|
4405
|
-
}
|
|
4406
|
-
)
|
|
4407
|
-
] })
|
|
4408
|
-
] });
|
|
4409
|
-
}
|
|
4410
|
-
|
|
4411
4358
|
// src/components/toolbar.tsx
|
|
4412
4359
|
function Toolbar({ ctx }) {
|
|
4413
4360
|
const s3 = useStore(ctx.store);
|
|
@@ -4448,7 +4395,6 @@ function Toolbar({ ctx }) {
|
|
|
4448
4395
|
]
|
|
4449
4396
|
}
|
|
4450
4397
|
),
|
|
4451
|
-
/* @__PURE__ */ a3(IndicatorTemplates, { ctx }),
|
|
4452
4398
|
/* @__PURE__ */ a3(ToolsMenu, { ctx })
|
|
4453
4399
|
] }),
|
|
4454
4400
|
/* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
@@ -6338,11 +6284,9 @@ var CSS = (
|
|
|
6338
6284
|
.fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
|
|
6339
6285
|
.fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
|
|
6340
6286
|
.fnc-template-menu { min-width: 220px; }
|
|
6341
|
-
.fnc-
|
|
6342
|
-
.fnc-
|
|
6343
|
-
.fnc-
|
|
6344
|
-
.fnc-indtpl-name { font-weight: 600; }
|
|
6345
|
-
.fnc-template-row .fnc-menu-item .fnc-indtpl-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--fnc-text-2); }
|
|
6287
|
+
.fnc-timelink-seg button { flex: 1; white-space: nowrap; }
|
|
6288
|
+
.fnc-timelink-label { margin-top: 6px; font-size: 13px; color: var(--fnc-text); }
|
|
6289
|
+
.fnc-timelink-note { margin: 6px 2px 2px; font-size: 12px; line-height: 1.5; color: var(--fnc-text-2); }
|
|
6346
6290
|
.fnc-levels-menu { min-width: 340px; }
|
|
6347
6291
|
.fnc-level-text { flex: 1; min-width: 0; width: 110px; height: 28px; padding: 0 8px; font-size: 13px; }
|
|
6348
6292
|
.fnc-options-menu { min-width: 280px; max-height: min(70vh, 560px); overflow-y: auto; }
|
|
@@ -7470,9 +7414,22 @@ function createMultiChart(container, options) {
|
|
|
7470
7414
|
for (const other of visible()) if (other !== pane) other.chart.setSyncedCrosshair(info ? info.time : null);
|
|
7471
7415
|
});
|
|
7472
7416
|
c3.on("visibleRangeChange", () => {
|
|
7473
|
-
if (
|
|
7474
|
-
|
|
7417
|
+
if (panes[driver] !== pane) return;
|
|
7418
|
+
if (c3.settings.timeLink === "follow") followTime(pane);
|
|
7475
7419
|
});
|
|
7420
|
+
c3.on("barClick", ({ time }) => {
|
|
7421
|
+
const link = c3.settings.timeLink;
|
|
7422
|
+
if (time === null || link === "off") return;
|
|
7423
|
+
if (markTime === time) return setMark(null);
|
|
7424
|
+
setMark(time);
|
|
7425
|
+
if (link === "jump" || link === "follow") {
|
|
7426
|
+
for (const other of visible()) if (other !== pane) void other.chart.goToTime(time);
|
|
7427
|
+
}
|
|
7428
|
+
});
|
|
7429
|
+
c3.on("settingsChange", (s3) => {
|
|
7430
|
+
if (s3.timeLink === "off" && markTime !== null) setMark(null);
|
|
7431
|
+
});
|
|
7432
|
+
marks.set(pane, c3.addOverlay({ render: (rc) => drawMark(rc) }));
|
|
7476
7433
|
c3.on("symbolChange", (info) => {
|
|
7477
7434
|
queueState();
|
|
7478
7435
|
if (panes[store.get().active] !== pane) return;
|
|
@@ -7492,12 +7449,41 @@ function createMultiChart(container, options) {
|
|
|
7492
7449
|
void pane.load(spec.symbol, spec.resolution ?? resolution);
|
|
7493
7450
|
return pane;
|
|
7494
7451
|
}
|
|
7495
|
-
|
|
7452
|
+
let markTime = null;
|
|
7453
|
+
const marks = /* @__PURE__ */ new Map();
|
|
7454
|
+
function setMark(time) {
|
|
7455
|
+
markTime = time;
|
|
7456
|
+
for (const m3 of marks.values()) m3.redraw();
|
|
7457
|
+
}
|
|
7458
|
+
function drawMark(rc) {
|
|
7459
|
+
if (markTime === null) return;
|
|
7460
|
+
const x2 = rc.coords.timeToX(markTime);
|
|
7461
|
+
if (!(x2 >= 0 && x2 <= rc.coords.plotWidth)) return;
|
|
7462
|
+
rc.painter.line(x2, 0, x2, rc.coords.height, rc.palette.accent, 1.5, [5, 4]);
|
|
7463
|
+
}
|
|
7464
|
+
const following = /* @__PURE__ */ new Set();
|
|
7465
|
+
function followTime(from) {
|
|
7496
7466
|
const range = from.chart.getVisibleTimeRange();
|
|
7497
7467
|
if (!range) return;
|
|
7468
|
+
const mid = (range.from + range.to) / 2;
|
|
7498
7469
|
const res = from.chart.currentResolution;
|
|
7499
7470
|
for (const other of visible()) {
|
|
7500
|
-
if (other
|
|
7471
|
+
if (other === from) continue;
|
|
7472
|
+
if (other.chart.currentResolution === res) {
|
|
7473
|
+
other.chart.setVisibleTimeRange(range);
|
|
7474
|
+
continue;
|
|
7475
|
+
}
|
|
7476
|
+
const own = other.chart.getVisibleTimeRange();
|
|
7477
|
+
const first = other.chart.bars[0];
|
|
7478
|
+
if (!own || !first) continue;
|
|
7479
|
+
if (mid < first.time) {
|
|
7480
|
+
if (following.has(other)) continue;
|
|
7481
|
+
following.add(other);
|
|
7482
|
+
void other.chart.goToTime(mid).finally(() => following.delete(other));
|
|
7483
|
+
continue;
|
|
7484
|
+
}
|
|
7485
|
+
const span = own.to - own.from;
|
|
7486
|
+
other.chart.setVisibleTimeRange({ from: mid - span / 2, to: mid + span / 2 });
|
|
7501
7487
|
}
|
|
7502
7488
|
}
|
|
7503
7489
|
function ensurePanes(count) {
|
|
@@ -7609,12 +7595,17 @@ function createMultiChart(container, options) {
|
|
|
7609
7595
|
queueState();
|
|
7610
7596
|
}
|
|
7611
7597
|
function setSync(patch) {
|
|
7598
|
+
if (patch.time !== void 0) {
|
|
7599
|
+
const { time, ...rest } = patch;
|
|
7600
|
+
if (time) controls.applySettings({ timeLink: "follow" });
|
|
7601
|
+
else if (panes[store.get().active]?.chart.settings.timeLink === "follow") controls.applySettings({ timeLink: "off" });
|
|
7602
|
+
patch = rest;
|
|
7603
|
+
}
|
|
7612
7604
|
const before = store.get().sync;
|
|
7613
|
-
const sync = { ...before, ...patch };
|
|
7605
|
+
const sync = { ...before, ...patch, time: false };
|
|
7614
7606
|
store.set({ sync });
|
|
7615
7607
|
const active = panes[store.get().active];
|
|
7616
7608
|
if (!sync.crosshair) for (const p3 of panes) p3.chart.setSyncedCrosshair(null);
|
|
7617
|
-
if (sync.time && !before.time) broadcastTime(active);
|
|
7618
7609
|
if (sync.symbol && !before.symbol || sync.interval && !before.interval) {
|
|
7619
7610
|
const info = active.chart.symbolInfo;
|
|
7620
7611
|
const res = active.chart.currentResolution;
|
|
@@ -7728,6 +7719,8 @@ function createMultiChart(container, options) {
|
|
|
7728
7719
|
setLayout(layout);
|
|
7729
7720
|
activate(Math.min(Math.max(0, Number(raw.active) || 0), visibleCount() - 1));
|
|
7730
7721
|
await Promise.all(states.map((state, i3) => panes[i3].chart.load(state)));
|
|
7722
|
+
if (raw.sync?.time && panes.every((p3) => p3.chart.settings.timeLink === "off")) controls.applySettings({ timeLink: "follow" });
|
|
7723
|
+
store.set({ sync: { ...store.get().sync, time: false } });
|
|
7731
7724
|
},
|
|
7732
7725
|
on: (event, listener) => {
|
|
7733
7726
|
let set = listeners.get(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.21",
|
|
4
4
|
"description": "Pro trading UI (toolbar, drawing tools, sheets) for Funnest Charts. Framework-agnostic.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"NOTICE"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@funnest/charts": "0.11.
|
|
45
|
+
"@funnest/charts": "0.11.21"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource preact */
|
|
2
|
-
import type { IndicatorConfig } from '@funnest/charts';
|
|
3
|
-
import type { WidgetContext } from '../context.js';
|
|
4
|
-
export interface IndicatorTemplate {
|
|
5
|
-
name: string;
|
|
6
|
-
indicators: IndicatorConfig[];
|
|
7
|
-
/** What it holds, as the legend names them (for the list). */
|
|
8
|
-
titles: string[];
|
|
9
|
-
}
|
|
10
|
-
export declare function readIndicatorTemplates(): IndicatorTemplate[];
|
|
11
|
-
export declare function IndicatorTemplates({ ctx }: {
|
|
12
|
-
ctx: WidgetContext;
|
|
13
|
-
}): import("preact").JSX.Element;
|