@funnest/charts-ui 0.6.26 → 0.6.27
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 +12 -0
- package/dist/i18n.d.ts +16 -0
- package/dist/icons.d.ts +5 -0
- package/dist/index.js +149 -6
- package/dist/shell.d.ts +11 -2
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface UiState {
|
|
|
20
20
|
drawingTool: DrawingType | null;
|
|
21
21
|
selection: Drawing | null;
|
|
22
22
|
drawingCount: number;
|
|
23
|
+
/** Every drawing of this pane is locked (the drawing bar's lock-all shows as pressed). */
|
|
24
|
+
drawingsLocked: boolean;
|
|
23
25
|
/** Narrow screens: the drawing bar is hidden until toggled from the toolbar. */
|
|
24
26
|
drawbarOpen: boolean;
|
|
25
27
|
magnet: boolean;
|
|
@@ -37,6 +39,12 @@ export interface UiState {
|
|
|
37
39
|
favoriteIntervals: Resolution[];
|
|
38
40
|
/** Desktop: the left drawing bar folded away (a small tab brings it back). */
|
|
39
41
|
drawbarCollapsed: boolean;
|
|
42
|
+
/** Tools pinned at the top of the drawing bar (★ in a tool list). */
|
|
43
|
+
favoriteTools: DrawingType[];
|
|
44
|
+
/** 연속 그리기: tools stay armed after each drawing. */
|
|
45
|
+
keepDrawing: boolean;
|
|
46
|
+
/** Every drawing hidden (the drawing bar's 👁). */
|
|
47
|
+
drawingsHidden: boolean;
|
|
40
48
|
canUndo: boolean;
|
|
41
49
|
canRedo: boolean;
|
|
42
50
|
compares: CompareInfo[];
|
|
@@ -127,6 +135,10 @@ export interface WidgetContext {
|
|
|
127
135
|
selectSymbol(symbol: string): void;
|
|
128
136
|
selectResolution(resolution: Resolution): void;
|
|
129
137
|
toggleFavoriteInterval(resolution: Resolution): void;
|
|
138
|
+
toggleFavoriteTool(tool: DrawingType): void;
|
|
139
|
+
setKeepDrawing(on: boolean): void;
|
|
140
|
+
/** Hides or shows the drawings of every pane. */
|
|
141
|
+
setDrawingsHidden(hidden: boolean): void;
|
|
130
142
|
setSearchOpen(open: boolean, target?: 'symbol' | 'compare'): void;
|
|
131
143
|
screenshot(): void;
|
|
132
144
|
toggleFullscreen(): void;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -29,6 +29,14 @@ export declare const STRINGS: {
|
|
|
29
29
|
horizontal: string;
|
|
30
30
|
fibonacci: string;
|
|
31
31
|
removeAll: string;
|
|
32
|
+
keepDrawing: string;
|
|
33
|
+
lockAll: string;
|
|
34
|
+
unlockAll: string;
|
|
35
|
+
hideAll: string;
|
|
36
|
+
showAll: string;
|
|
37
|
+
favoriteTool: string;
|
|
38
|
+
unfavoriteTool: string;
|
|
39
|
+
fontSize: string;
|
|
32
40
|
collapseDrawbar: string;
|
|
33
41
|
chartSettings: string;
|
|
34
42
|
settingsTheme: string;
|
|
@@ -176,6 +184,14 @@ export declare const STRINGS: {
|
|
|
176
184
|
horizontal: string;
|
|
177
185
|
fibonacci: string;
|
|
178
186
|
removeAll: string;
|
|
187
|
+
keepDrawing: string;
|
|
188
|
+
lockAll: string;
|
|
189
|
+
unlockAll: string;
|
|
190
|
+
hideAll: string;
|
|
191
|
+
showAll: string;
|
|
192
|
+
favoriteTool: string;
|
|
193
|
+
unfavoriteTool: string;
|
|
194
|
+
fontSize: string;
|
|
179
195
|
collapseDrawbar: string;
|
|
180
196
|
chartSettings: string;
|
|
181
197
|
settingsTheme: string;
|
package/dist/icons.d.ts
CHANGED
|
@@ -61,5 +61,10 @@ export declare const PaletteIcon: () => import("preact").JSX.Element;
|
|
|
61
61
|
export declare const LockIcon: ({ open }: {
|
|
62
62
|
open?: boolean;
|
|
63
63
|
}) => import("preact").JSX.Element;
|
|
64
|
+
/** 연속 그리기: a pencil that keeps going. */
|
|
65
|
+
export declare const KeepDrawingIcon: () => import("preact").JSX.Element;
|
|
66
|
+
export declare const DrawingsEyeIcon: ({ off }: {
|
|
67
|
+
off?: boolean;
|
|
68
|
+
}) => import("preact").JSX.Element;
|
|
64
69
|
export declare const CopyIcon: () => import("preact").JSX.Element;
|
|
65
70
|
export declare const TextIcon: () => import("preact").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -455,6 +455,14 @@ var STRINGS = {
|
|
|
455
455
|
horizontal: "\uC218\uD3C9\uC120",
|
|
456
456
|
fibonacci: "\uD53C\uBCF4\uB098\uCE58 \uB418\uB3CC\uB9BC",
|
|
457
457
|
removeAll: "\uADF8\uB9AC\uAE30 \uBAA8\uB450 \uC0AD\uC81C",
|
|
458
|
+
keepDrawing: "\uC5F0\uC18D \uADF8\uB9AC\uAE30 (\uB3C4\uAD6C \uC720\uC9C0)",
|
|
459
|
+
lockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uADF8\uAE30",
|
|
460
|
+
unlockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uAE08 \uD480\uAE30",
|
|
461
|
+
hideAll: "\uADF8\uB9BC \uBAA8\uB450 \uC228\uAE30\uAE30",
|
|
462
|
+
showAll: "\uADF8\uB9BC \uBAA8\uB450 \uBCF4\uC774\uAE30",
|
|
463
|
+
favoriteTool: "\uC990\uACA8\uCC3E\uAE30\uC5D0 \uCD94\uAC00",
|
|
464
|
+
unfavoriteTool: "\uC990\uACA8\uCC3E\uAE30\uC5D0\uC11C \uBE7C\uAE30",
|
|
465
|
+
fontSize: "\uAE00\uC790 \uD06C\uAE30",
|
|
458
466
|
collapseDrawbar: "\uADF8\uB9AC\uAE30 \uB3C4\uAD6C \uC811\uAE30",
|
|
459
467
|
chartSettings: "\uCC28\uD2B8 \uC124\uC815",
|
|
460
468
|
settingsTheme: "\uD14C\uB9C8",
|
|
@@ -604,6 +612,14 @@ var STRINGS = {
|
|
|
604
612
|
horizontal: "Horizontal line",
|
|
605
613
|
fibonacci: "Fib retracement",
|
|
606
614
|
removeAll: "Remove all drawings",
|
|
615
|
+
keepDrawing: "Stay in drawing mode",
|
|
616
|
+
lockAll: "Lock all drawings",
|
|
617
|
+
unlockAll: "Unlock all drawings",
|
|
618
|
+
hideAll: "Hide all drawings",
|
|
619
|
+
showAll: "Show all drawings",
|
|
620
|
+
favoriteTool: "Add to favorites",
|
|
621
|
+
unfavoriteTool: "Remove from favorites",
|
|
622
|
+
fontSize: "Text size",
|
|
607
623
|
collapseDrawbar: "Hide drawing tools",
|
|
608
624
|
chartSettings: "Chart settings",
|
|
609
625
|
settingsTheme: "Theme",
|
|
@@ -888,6 +904,15 @@ var LockIcon = ({ open = false }) => /* @__PURE__ */ a3(Icon, { children: [
|
|
|
888
904
|
/* @__PURE__ */ a3("rect", { x: "4.5", y: "9", width: "11", height: "8", rx: "1.8" }),
|
|
889
905
|
/* @__PURE__ */ a3("path", { d: open ? "M7 9V6.5a3 3 0 0 1 5.8-1" : "M7 9V6.5a3 3 0 0 1 6 0V9" })
|
|
890
906
|
] });
|
|
907
|
+
var KeepDrawingIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
908
|
+
/* @__PURE__ */ a3("path", { d: "M3.5 13.5 11 6l3 3-7.5 7.5H3.5z" }),
|
|
909
|
+
/* @__PURE__ */ a3("path", { d: "M13 3.5a3.5 3.5 0 0 1 3.5 3.5M15 2l1.5 1.5L15 5" })
|
|
910
|
+
] });
|
|
911
|
+
var DrawingsEyeIcon = ({ off = false }) => /* @__PURE__ */ a3(Icon, { children: [
|
|
912
|
+
/* @__PURE__ */ a3("path", { d: "M2 10s3-5.5 8-5.5S18 10 18 10s-3 5.5-8 5.5S2 10 2 10z" }),
|
|
913
|
+
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.3" }),
|
|
914
|
+
off && /* @__PURE__ */ a3("path", { d: "M3.5 3.5l13 13" })
|
|
915
|
+
] });
|
|
891
916
|
var CopyIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
892
917
|
/* @__PURE__ */ a3("rect", { x: "7", y: "7", width: "9.5", height: "9.5", rx: "1.8" }),
|
|
893
918
|
/* @__PURE__ */ a3("path", { d: "M13 7V5a1.5 1.5 0 0 0-1.5-1.5h-6A1.5 1.5 0 0 0 4 5v6a1.5 1.5 0 0 0 1.5 1.5H7" })
|
|
@@ -990,9 +1015,22 @@ function ToolGroup({
|
|
|
990
1015
|
const heading = section && section !== tools[i3 - 1]?.section?.[s3.locale];
|
|
991
1016
|
return /* @__PURE__ */ a3($, { children: [
|
|
992
1017
|
heading && /* @__PURE__ */ a3("div", { class: `fnc-tool-section${i3 > 0 ? " is-after" : ""}`, role: "presentation", children: section }),
|
|
993
|
-
/* @__PURE__ */ a3("
|
|
994
|
-
/* @__PURE__ */ a3(
|
|
995
|
-
|
|
1018
|
+
/* @__PURE__ */ a3("div", { class: "fnc-tool-row", children: [
|
|
1019
|
+
/* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitemradio", "aria-checked": def.type === current.type, onClick: () => pick(def), children: [
|
|
1020
|
+
/* @__PURE__ */ a3(ToolIcon, { def, locale: s3.locale }),
|
|
1021
|
+
/* @__PURE__ */ a3("span", { children: def.name[s3.locale] })
|
|
1022
|
+
] }),
|
|
1023
|
+
/* @__PURE__ */ a3(
|
|
1024
|
+
"button",
|
|
1025
|
+
{
|
|
1026
|
+
class: "fnc-tool-fav",
|
|
1027
|
+
"aria-pressed": s3.favoriteTools.includes(def.type),
|
|
1028
|
+
"aria-label": `${s3.favoriteTools.includes(def.type) ? t3.unfavoriteTool : t3.favoriteTool}: ${def.name[s3.locale]}`,
|
|
1029
|
+
"data-tip": s3.favoriteTools.includes(def.type) ? t3.unfavoriteTool : t3.favoriteTool,
|
|
1030
|
+
onClick: () => ctx.toggleFavoriteTool(def.type),
|
|
1031
|
+
children: /* @__PURE__ */ a3(StarIcon, { filled: s3.favoriteTools.includes(def.type) })
|
|
1032
|
+
}
|
|
1033
|
+
)
|
|
996
1034
|
] })
|
|
997
1035
|
] }, def.type);
|
|
998
1036
|
}) })
|
|
@@ -1017,7 +1055,11 @@ function DrawingToolbar({ ctx }) {
|
|
|
1017
1055
|
ro.observe(el);
|
|
1018
1056
|
return () => ro.disconnect();
|
|
1019
1057
|
}, []);
|
|
1020
|
-
const
|
|
1058
|
+
const defs = ctx.chart.drawingDefinitions();
|
|
1059
|
+
const groups = toolGroups(defs);
|
|
1060
|
+
const favorites = s3.favoriteTools.map((type) => defs.find((d3) => d3.type === type)).filter((d3) => !!d3);
|
|
1061
|
+
const allLocked = s3.drawingsLocked;
|
|
1062
|
+
const lockAll = () => ctx.chart.setDrawings(ctx.chart.getDrawings().map((d3) => ({ ...d3, style: { ...d3.style, locked: !allLocked } })));
|
|
1021
1063
|
const pick = (tool) => {
|
|
1022
1064
|
ctx.chart.setDrawingTool(tool);
|
|
1023
1065
|
if (tool && ctx.store.get().drawbarOpen) ctx.store.set({ drawbarOpen: false });
|
|
@@ -1036,6 +1078,21 @@ function DrawingToolbar({ ctx }) {
|
|
|
1036
1078
|
"data-collapsed": s3.drawbarCollapsed,
|
|
1037
1079
|
children: [
|
|
1038
1080
|
/* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.cursor, "aria-label": t3.cursor, "aria-pressed": s3.drawingTool === null, onClick: () => pick(null), children: /* @__PURE__ */ a3(CursorIcon, {}) }),
|
|
1081
|
+
favorites.length > 0 && /* @__PURE__ */ a3($, { children: [
|
|
1082
|
+
favorites.map((def) => /* @__PURE__ */ a3(
|
|
1083
|
+
"button",
|
|
1084
|
+
{
|
|
1085
|
+
class: "fnc-btn fnc-fav-tool",
|
|
1086
|
+
"data-tip": def.name[s3.locale],
|
|
1087
|
+
"aria-label": def.name[s3.locale],
|
|
1088
|
+
"aria-pressed": s3.drawingTool === def.type,
|
|
1089
|
+
onClick: () => pick(s3.drawingTool === def.type ? null : def.type),
|
|
1090
|
+
children: /* @__PURE__ */ a3(ToolIcon, { def, locale: s3.locale })
|
|
1091
|
+
},
|
|
1092
|
+
`fav-${def.type}`
|
|
1093
|
+
)),
|
|
1094
|
+
/* @__PURE__ */ a3("div", { class: "fnc-hsep" })
|
|
1095
|
+
] }),
|
|
1039
1096
|
groups.map(([key, tools]) => /* @__PURE__ */ a3(
|
|
1040
1097
|
ToolGroup,
|
|
1041
1098
|
{
|
|
@@ -1059,6 +1116,31 @@ function DrawingToolbar({ ctx }) {
|
|
|
1059
1116
|
children: /* @__PURE__ */ a3(MagnetIcon, {})
|
|
1060
1117
|
}
|
|
1061
1118
|
),
|
|
1119
|
+
/* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.keepDrawing, "aria-label": t3.keepDrawing, "aria-pressed": s3.keepDrawing, onClick: () => ctx.setKeepDrawing(!s3.keepDrawing), children: /* @__PURE__ */ a3(KeepDrawingIcon, {}) }),
|
|
1120
|
+
/* @__PURE__ */ a3(
|
|
1121
|
+
"button",
|
|
1122
|
+
{
|
|
1123
|
+
class: "fnc-btn",
|
|
1124
|
+
"data-tip": allLocked ? t3.unlockAll : t3.lockAll,
|
|
1125
|
+
"aria-label": allLocked ? t3.unlockAll : t3.lockAll,
|
|
1126
|
+
"aria-pressed": allLocked,
|
|
1127
|
+
disabled: s3.drawingCount === 0,
|
|
1128
|
+
onClick: lockAll,
|
|
1129
|
+
children: /* @__PURE__ */ a3(LockIcon, { open: !allLocked })
|
|
1130
|
+
}
|
|
1131
|
+
),
|
|
1132
|
+
/* @__PURE__ */ a3(
|
|
1133
|
+
"button",
|
|
1134
|
+
{
|
|
1135
|
+
class: "fnc-btn",
|
|
1136
|
+
"data-tip": s3.drawingsHidden ? t3.showAll : t3.hideAll,
|
|
1137
|
+
"aria-label": s3.drawingsHidden ? t3.showAll : t3.hideAll,
|
|
1138
|
+
"aria-pressed": s3.drawingsHidden,
|
|
1139
|
+
disabled: s3.drawingCount === 0 && !s3.drawingsHidden,
|
|
1140
|
+
onClick: () => ctx.setDrawingsHidden(!s3.drawingsHidden),
|
|
1141
|
+
children: /* @__PURE__ */ a3(DrawingsEyeIcon, { off: s3.drawingsHidden })
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1062
1144
|
/* @__PURE__ */ a3(
|
|
1063
1145
|
"button",
|
|
1064
1146
|
{
|
|
@@ -1088,6 +1170,7 @@ function DrawingToolbar({ ctx }) {
|
|
|
1088
1170
|
}
|
|
1089
1171
|
var SWATCHES = ["#3182F6", "#F04452", "#12B886", "#FF9F0A", "#7048E8"];
|
|
1090
1172
|
var WIDTHS = [1, 2, 3, 4];
|
|
1173
|
+
var FONT_SIZES = [10, 12, 14, 16, 20, 24, 32];
|
|
1091
1174
|
var DASH_ORDER = ["solid", "dashed", "dotted"];
|
|
1092
1175
|
var RECENT_KEY = "fnc-drawing-colors";
|
|
1093
1176
|
var POS_KEY = "fnc-selbar-pos";
|
|
@@ -1260,6 +1343,25 @@ function SelectionBar({ ctx }) {
|
|
|
1260
1343
|
onKeyDown: (e3) => e3.stopPropagation()
|
|
1261
1344
|
}
|
|
1262
1345
|
),
|
|
1346
|
+
def?.text && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1347
|
+
/* @__PURE__ */ a3("button", { class: "fnc-btn fnc-selbar-font", "data-tip": t3.fontSize, "aria-label": t3.fontSize, "aria-expanded": menu === "font", onClick: () => setMenu(menu === "font" ? null : "font"), children: style.fontSize ?? 14 }),
|
|
1348
|
+
menu === "font" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop", role: "menu", children: FONT_SIZES.map((size) => /* @__PURE__ */ a3(
|
|
1349
|
+
"button",
|
|
1350
|
+
{
|
|
1351
|
+
class: "fnc-menu-item",
|
|
1352
|
+
role: "menuitemradio",
|
|
1353
|
+
"aria-checked": (style.fontSize ?? 14) === size,
|
|
1354
|
+
onClick: () => {
|
|
1355
|
+
setStyle({ fontSize: size });
|
|
1356
|
+
setMenu(null);
|
|
1357
|
+
},
|
|
1358
|
+
children: /* @__PURE__ */ a3("span", { children: [
|
|
1359
|
+
size,
|
|
1360
|
+
"px"
|
|
1361
|
+
] })
|
|
1362
|
+
}
|
|
1363
|
+
)) })
|
|
1364
|
+
] }),
|
|
1263
1365
|
/* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
1264
1366
|
/* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": locked ? t3.unlock : t3.lock, "aria-label": locked ? t3.unlock : t3.lock, "aria-pressed": locked, onClick: () => setStyle({ locked: !locked }), children: /* @__PURE__ */ a3(LockIcon, { open: !locked }) }),
|
|
1265
1367
|
/* @__PURE__ */ a3(
|
|
@@ -3959,6 +4061,14 @@ var CSS = (
|
|
|
3959
4061
|
.fnc-tool-section { padding: 8px 10px 4px; color: var(--fnc-text-2); font-size: 11px; font-weight: 600; }
|
|
3960
4062
|
.fnc-tool-section.is-after { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--fnc-border); }
|
|
3961
4063
|
.fnc-tool-menu .fnc-menu-item { white-space: nowrap; }
|
|
4064
|
+
.fnc-tool-row { position: relative; display: flex; align-items: center; }
|
|
4065
|
+
.fnc-tool-row .fnc-menu-item { flex: 1; padding-right: 36px; }
|
|
4066
|
+
.fnc-tool-fav { position: absolute; right: 6px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: var(--fnc-text-2); opacity: 0; cursor: pointer; }
|
|
4067
|
+
.fnc-tool-row:hover .fnc-tool-fav, .fnc-tool-fav:focus-visible, .fnc-tool-fav[aria-pressed='true'] { opacity: 1; }
|
|
4068
|
+
.fnc-tool-fav[aria-pressed='true'] { color: #FFB400; }
|
|
4069
|
+
.fnc-tool-fav:hover { background: var(--fnc-surface); color: var(--fnc-text); }
|
|
4070
|
+
@media (hover: none) { .fnc-tool-fav { opacity: 1; } }
|
|
4071
|
+
.fnc-selbar-font { min-width: 32px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
|
3962
4072
|
.fnc-tool-letter { font-size: 13px; font-weight: 700; }
|
|
3963
4073
|
.fnc-svg-icon { display: inline-flex; }
|
|
3964
4074
|
.fnc-svg-icon svg { width: 20px; height: 20px; }
|
|
@@ -4215,6 +4325,9 @@ function createShell(container, options) {
|
|
|
4215
4325
|
darkQuery?.addEventListener?.("change", onSchemeChange);
|
|
4216
4326
|
let favoriteIntervals = storage.get("favorite-intervals", [...options.favoriteIntervals]);
|
|
4217
4327
|
let drawbarCollapsed = storage.get("drawbar-collapsed", false);
|
|
4328
|
+
let favoriteTools = storage.get("favorite-tools", []);
|
|
4329
|
+
let keepDrawing = storage.get("keep-drawing", false);
|
|
4330
|
+
let drawingDefaults = storage.get("drawing-defaults", {});
|
|
4218
4331
|
const broadcast = (patch) => {
|
|
4219
4332
|
for (const p3 of panes()) p3.store.set(patch);
|
|
4220
4333
|
};
|
|
@@ -4235,7 +4348,27 @@ function createShell(container, options) {
|
|
|
4235
4348
|
slots,
|
|
4236
4349
|
storage,
|
|
4237
4350
|
theme: () => theme,
|
|
4238
|
-
sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, drawbarCollapsed }),
|
|
4351
|
+
sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, drawbarCollapsed, favoriteTools, keepDrawing }),
|
|
4352
|
+
drawingDefaults: () => drawingDefaults,
|
|
4353
|
+
saveDrawingDefaults: (defaults) => {
|
|
4354
|
+
drawingDefaults = defaults;
|
|
4355
|
+
storage.set("drawing-defaults", defaults);
|
|
4356
|
+
for (const p3 of panes()) p3.chart.setDrawingDefaults(defaults);
|
|
4357
|
+
},
|
|
4358
|
+
toggleFavoriteTool: (tool) => {
|
|
4359
|
+
favoriteTools = favoriteTools.includes(tool) ? favoriteTools.filter((x2) => x2 !== tool) : [...favoriteTools, tool];
|
|
4360
|
+
storage.set("favorite-tools", favoriteTools);
|
|
4361
|
+
broadcast({ favoriteTools });
|
|
4362
|
+
},
|
|
4363
|
+
setKeepDrawing: (on) => {
|
|
4364
|
+
keepDrawing = on;
|
|
4365
|
+
storage.set("keep-drawing", on);
|
|
4366
|
+
for (const p3 of panes()) p3.chart.setKeepDrawingTool(on);
|
|
4367
|
+
broadcast({ keepDrawing });
|
|
4368
|
+
},
|
|
4369
|
+
setDrawingsHidden: (hidden) => {
|
|
4370
|
+
for (const p3 of panes()) p3.chart.setDrawingsHidden(hidden);
|
|
4371
|
+
},
|
|
4239
4372
|
setPanes: (get) => {
|
|
4240
4373
|
panes = get;
|
|
4241
4374
|
},
|
|
@@ -4335,6 +4468,8 @@ function createPane(shell, config) {
|
|
|
4335
4468
|
displayTimezone: config.displayTimezone
|
|
4336
4469
|
});
|
|
4337
4470
|
chart.setChartType(config.chartType);
|
|
4471
|
+
chart.setKeepDrawingTool(shell.sharedState().keepDrawing);
|
|
4472
|
+
chart.setDrawingDefaults(shell.drawingDefaults());
|
|
4338
4473
|
const canvasVars = (s3) => {
|
|
4339
4474
|
const muted = s3.textColor && /^#[0-9a-f]{6}$/i.test(s3.textColor) ? `${s3.textColor}99` : null;
|
|
4340
4475
|
const vars = [
|
|
@@ -4374,8 +4509,10 @@ function createPane(shell, config) {
|
|
|
4374
4509
|
drawingTool: null,
|
|
4375
4510
|
selection: null,
|
|
4376
4511
|
drawingCount: 0,
|
|
4512
|
+
drawingsLocked: false,
|
|
4377
4513
|
drawbarOpen: false,
|
|
4378
4514
|
magnet: chart.magnetEnabled,
|
|
4515
|
+
drawingsHidden: chart.drawingsHidden,
|
|
4379
4516
|
indicators: chart.getIndicators(),
|
|
4380
4517
|
dialog: null,
|
|
4381
4518
|
...shell.sharedState()
|
|
@@ -4389,9 +4526,12 @@ function createPane(shell, config) {
|
|
|
4389
4526
|
chart.on("dataChange", syncRealtime),
|
|
4390
4527
|
chart.on("drawingToolChange", (drawingTool) => store.set({ drawingTool })),
|
|
4391
4528
|
chart.on("selectionChange", (selection) => store.set({ selection })),
|
|
4392
|
-
chart.on("drawingsChange", (drawings) => store.set({ drawingCount: drawings.length })),
|
|
4529
|
+
chart.on("drawingsChange", (drawings) => store.set({ drawingCount: drawings.length, drawingsLocked: drawings.length > 0 && drawings.every((d3) => d3.style?.locked) })),
|
|
4393
4530
|
chart.on("indicatorsChange", (indicators) => store.set({ indicators })),
|
|
4394
4531
|
chart.on("magnetChange", (magnet) => store.set({ magnet })),
|
|
4532
|
+
chart.on("drawingsHiddenChange", (drawingsHidden) => store.set({ drawingsHidden })),
|
|
4533
|
+
// A color or style picked for a drawing: remembered for the tool, in every pane.
|
|
4534
|
+
chart.on("drawingDefaultsChange", (defaults) => shell.saveDrawingDefaults(defaults)),
|
|
4395
4535
|
chart.on("chartTypeChange", (chartType) => store.set({ chartType })),
|
|
4396
4536
|
chart.on("historyChange", ({ canUndo, canRedo }) => store.set({ canUndo, canRedo })),
|
|
4397
4537
|
chart.on("comparesChange", (compares) => store.set({ compares })),
|
|
@@ -4433,6 +4573,9 @@ function createPane(shell, config) {
|
|
|
4433
4573
|
if (current) void load(current.symbol, res);
|
|
4434
4574
|
},
|
|
4435
4575
|
toggleFavoriteInterval: shell.toggleFavoriteInterval,
|
|
4576
|
+
toggleFavoriteTool: shell.toggleFavoriteTool,
|
|
4577
|
+
setKeepDrawing: shell.setKeepDrawing,
|
|
4578
|
+
setDrawingsHidden: shell.setDrawingsHidden,
|
|
4436
4579
|
setSearchOpen: (open, target = "symbol") => store.set(open ? { searchOpen: true, searchTarget: target } : { searchOpen: false }),
|
|
4437
4580
|
screenshot: () => {
|
|
4438
4581
|
const s3 = store.get();
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DirectionPreset, type Resolution, type ThemeTokens } from '@funnest/charts';
|
|
1
|
+
import { type DirectionPreset, type DrawingDefaults, type DrawingType, type Resolution, type ThemeTokens } from '@funnest/charts';
|
|
2
2
|
import type { UiState } from './context';
|
|
3
3
|
import { type WidgetStorage } from './storage';
|
|
4
4
|
import type { Store } from './store';
|
|
@@ -30,6 +30,9 @@ export interface ShellPane {
|
|
|
30
30
|
readonly store: Store<UiState>;
|
|
31
31
|
readonly chart: {
|
|
32
32
|
setTheme(theme: Partial<ThemeTokens>): void;
|
|
33
|
+
setKeepDrawingTool(on: boolean): void;
|
|
34
|
+
setDrawingsHidden(hidden: boolean): void;
|
|
35
|
+
setDrawingDefaults(defaults: DrawingDefaults): void;
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
export interface ShellOptions {
|
|
@@ -58,7 +61,13 @@ export interface Shell {
|
|
|
58
61
|
readonly storage: WidgetStorage;
|
|
59
62
|
theme(): ThemeTokens;
|
|
60
63
|
/** Initial UI-state fields owned by the shell (same for every pane). */
|
|
61
|
-
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed'>;
|
|
64
|
+
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing'>;
|
|
65
|
+
/** Each tool's last color / style (saved; every pane starts with it). */
|
|
66
|
+
drawingDefaults(): DrawingDefaults;
|
|
67
|
+
saveDrawingDefaults(defaults: DrawingDefaults): void;
|
|
68
|
+
toggleFavoriteTool(tool: DrawingType): void;
|
|
69
|
+
setKeepDrawing(on: boolean): void;
|
|
70
|
+
setDrawingsHidden(hidden: boolean): void;
|
|
62
71
|
setPanes(panes: () => readonly ShellPane[]): void;
|
|
63
72
|
setTheme(patch: Partial<ThemeTokens>): void;
|
|
64
73
|
setColorScheme(scheme: ColorScheme): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnest/charts-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
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.6.
|
|
45
|
+
"@funnest/charts": "0.6.27"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|