@funnest/charts-ui 0.6.26 → 0.6.28
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 +16 -1
- package/dist/i18n.d.ts +28 -0
- package/dist/icons.d.ts +9 -0
- package/dist/index.js +235 -7
- package/dist/shell.d.ts +13 -2
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Chart, ChartContextMenu, ChartLayout, ChartType, CompareInfo, Datafeed, Drawing, DrawingType, IndicatorConfig, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
|
|
1
|
+
import type { Chart, ChartContextMenu, ChartLayout, ChartType, CompareInfo, CursorMode, Datafeed, Drawing, DrawingType, IndicatorConfig, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
|
|
2
2
|
import type { LayoutId } from './layouts';
|
|
3
3
|
import type { WidgetStorage } from './storage';
|
|
4
4
|
import type { Strings } from './i18n';
|
|
@@ -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,14 @@ 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;
|
|
48
|
+
/** How the pointer looks (the drawing bar's cursor menu; same in every pane). */
|
|
49
|
+
cursorMode: CursorMode;
|
|
40
50
|
canUndo: boolean;
|
|
41
51
|
canRedo: boolean;
|
|
42
52
|
compares: CompareInfo[];
|
|
@@ -127,6 +137,11 @@ export interface WidgetContext {
|
|
|
127
137
|
selectSymbol(symbol: string): void;
|
|
128
138
|
selectResolution(resolution: Resolution): void;
|
|
129
139
|
toggleFavoriteInterval(resolution: Resolution): void;
|
|
140
|
+
toggleFavoriteTool(tool: DrawingType): void;
|
|
141
|
+
setKeepDrawing(on: boolean): void;
|
|
142
|
+
setCursorMode(mode: CursorMode): void;
|
|
143
|
+
/** Hides or shows the drawings of every pane. */
|
|
144
|
+
setDrawingsHidden(hidden: boolean): void;
|
|
130
145
|
setSearchOpen(open: boolean, target?: 'symbol' | 'compare'): void;
|
|
131
146
|
screenshot(): void;
|
|
132
147
|
toggleFullscreen(): void;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -29,6 +29,20 @@ export declare const STRINGS: {
|
|
|
29
29
|
horizontal: string;
|
|
30
30
|
fibonacci: string;
|
|
31
31
|
removeAll: string;
|
|
32
|
+
keepDrawing: string;
|
|
33
|
+
cursorModes: string;
|
|
34
|
+
cursorCross: string;
|
|
35
|
+
cursorDot: string;
|
|
36
|
+
cursorArrow: string;
|
|
37
|
+
cursorDemo: string;
|
|
38
|
+
cursorEraser: string;
|
|
39
|
+
lockAll: string;
|
|
40
|
+
unlockAll: string;
|
|
41
|
+
hideAll: string;
|
|
42
|
+
showAll: string;
|
|
43
|
+
favoriteTool: string;
|
|
44
|
+
unfavoriteTool: string;
|
|
45
|
+
fontSize: string;
|
|
32
46
|
collapseDrawbar: string;
|
|
33
47
|
chartSettings: string;
|
|
34
48
|
settingsTheme: string;
|
|
@@ -176,6 +190,20 @@ export declare const STRINGS: {
|
|
|
176
190
|
horizontal: string;
|
|
177
191
|
fibonacci: string;
|
|
178
192
|
removeAll: string;
|
|
193
|
+
keepDrawing: string;
|
|
194
|
+
cursorModes: string;
|
|
195
|
+
cursorCross: string;
|
|
196
|
+
cursorDot: string;
|
|
197
|
+
cursorArrow: string;
|
|
198
|
+
cursorDemo: string;
|
|
199
|
+
cursorEraser: string;
|
|
200
|
+
lockAll: string;
|
|
201
|
+
unlockAll: string;
|
|
202
|
+
hideAll: string;
|
|
203
|
+
showAll: string;
|
|
204
|
+
favoriteTool: string;
|
|
205
|
+
unfavoriteTool: string;
|
|
206
|
+
fontSize: string;
|
|
179
207
|
collapseDrawbar: string;
|
|
180
208
|
chartSettings: string;
|
|
181
209
|
settingsTheme: string;
|
package/dist/icons.d.ts
CHANGED
|
@@ -61,5 +61,14 @@ 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
|
+
export declare const CrossCursorIcon: () => import("preact").JSX.Element;
|
|
65
|
+
export declare const DotCursorIcon: () => import("preact").JSX.Element;
|
|
66
|
+
export declare const DemoCursorIcon: () => import("preact").JSX.Element;
|
|
67
|
+
export declare const EraserIcon: () => import("preact").JSX.Element;
|
|
68
|
+
/** 연속 그리기: a pencil that keeps going. */
|
|
69
|
+
export declare const KeepDrawingIcon: () => import("preact").JSX.Element;
|
|
70
|
+
export declare const DrawingsEyeIcon: ({ off }: {
|
|
71
|
+
off?: boolean;
|
|
72
|
+
}) => import("preact").JSX.Element;
|
|
64
73
|
export declare const CopyIcon: () => import("preact").JSX.Element;
|
|
65
74
|
export declare const TextIcon: () => import("preact").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -455,6 +455,20 @@ 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
|
+
cursorModes: "\uCEE4\uC11C \uC885\uB958",
|
|
460
|
+
cursorCross: "\uC2ED\uC790",
|
|
461
|
+
cursorDot: "\uC810",
|
|
462
|
+
cursorArrow: "\uD654\uC0B4\uD45C",
|
|
463
|
+
cursorDemo: "\uB370\uBAA8 \uCEE4\uC11C",
|
|
464
|
+
cursorEraser: "\uC9C0\uC6B0\uAC1C",
|
|
465
|
+
lockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uADF8\uAE30",
|
|
466
|
+
unlockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uAE08 \uD480\uAE30",
|
|
467
|
+
hideAll: "\uADF8\uB9BC \uBAA8\uB450 \uC228\uAE30\uAE30",
|
|
468
|
+
showAll: "\uADF8\uB9BC \uBAA8\uB450 \uBCF4\uC774\uAE30",
|
|
469
|
+
favoriteTool: "\uC990\uACA8\uCC3E\uAE30\uC5D0 \uCD94\uAC00",
|
|
470
|
+
unfavoriteTool: "\uC990\uACA8\uCC3E\uAE30\uC5D0\uC11C \uBE7C\uAE30",
|
|
471
|
+
fontSize: "\uAE00\uC790 \uD06C\uAE30",
|
|
458
472
|
collapseDrawbar: "\uADF8\uB9AC\uAE30 \uB3C4\uAD6C \uC811\uAE30",
|
|
459
473
|
chartSettings: "\uCC28\uD2B8 \uC124\uC815",
|
|
460
474
|
settingsTheme: "\uD14C\uB9C8",
|
|
@@ -604,6 +618,20 @@ var STRINGS = {
|
|
|
604
618
|
horizontal: "Horizontal line",
|
|
605
619
|
fibonacci: "Fib retracement",
|
|
606
620
|
removeAll: "Remove all drawings",
|
|
621
|
+
keepDrawing: "Stay in drawing mode",
|
|
622
|
+
cursorModes: "Cursors",
|
|
623
|
+
cursorCross: "Cross",
|
|
624
|
+
cursorDot: "Dot",
|
|
625
|
+
cursorArrow: "Arrow",
|
|
626
|
+
cursorDemo: "Demonstration",
|
|
627
|
+
cursorEraser: "Eraser",
|
|
628
|
+
lockAll: "Lock all drawings",
|
|
629
|
+
unlockAll: "Unlock all drawings",
|
|
630
|
+
hideAll: "Hide all drawings",
|
|
631
|
+
showAll: "Show all drawings",
|
|
632
|
+
favoriteTool: "Add to favorites",
|
|
633
|
+
unfavoriteTool: "Remove from favorites",
|
|
634
|
+
fontSize: "Text size",
|
|
607
635
|
collapseDrawbar: "Hide drawing tools",
|
|
608
636
|
chartSettings: "Chart settings",
|
|
609
637
|
settingsTheme: "Theme",
|
|
@@ -888,6 +916,25 @@ var LockIcon = ({ open = false }) => /* @__PURE__ */ a3(Icon, { children: [
|
|
|
888
916
|
/* @__PURE__ */ a3("rect", { x: "4.5", y: "9", width: "11", height: "8", rx: "1.8" }),
|
|
889
917
|
/* @__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
918
|
] });
|
|
919
|
+
var CrossCursorIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M10 3v14M3 10h14" }) });
|
|
920
|
+
var DotCursorIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.6", fill: "currentColor" }) });
|
|
921
|
+
var DemoCursorIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
922
|
+
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "6.5", opacity: "0.5" }),
|
|
923
|
+
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.2", fill: "currentColor" })
|
|
924
|
+
] });
|
|
925
|
+
var EraserIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
926
|
+
/* @__PURE__ */ a3("path", { d: "M3 13.5 11.5 5l5 5L9.5 17H6z" }),
|
|
927
|
+
/* @__PURE__ */ a3("path", { d: "M7 9.5l5 5" })
|
|
928
|
+
] });
|
|
929
|
+
var KeepDrawingIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
930
|
+
/* @__PURE__ */ a3("path", { d: "M3.5 13.5 11 6l3 3-7.5 7.5H3.5z" }),
|
|
931
|
+
/* @__PURE__ */ a3("path", { d: "M13 3.5a3.5 3.5 0 0 1 3.5 3.5M15 2l1.5 1.5L15 5" })
|
|
932
|
+
] });
|
|
933
|
+
var DrawingsEyeIcon = ({ off = false }) => /* @__PURE__ */ a3(Icon, { children: [
|
|
934
|
+
/* @__PURE__ */ a3("path", { d: "M2 10s3-5.5 8-5.5S18 10 18 10s-3 5.5-8 5.5S2 10 2 10z" }),
|
|
935
|
+
/* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.3" }),
|
|
936
|
+
off && /* @__PURE__ */ a3("path", { d: "M3.5 3.5l13 13" })
|
|
937
|
+
] });
|
|
891
938
|
var CopyIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
892
939
|
/* @__PURE__ */ a3("rect", { x: "7", y: "7", width: "9.5", height: "9.5", rx: "1.8" }),
|
|
893
940
|
/* @__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,14 +1037,80 @@ function ToolGroup({
|
|
|
990
1037
|
const heading = section && section !== tools[i3 - 1]?.section?.[s3.locale];
|
|
991
1038
|
return /* @__PURE__ */ a3($, { children: [
|
|
992
1039
|
heading && /* @__PURE__ */ a3("div", { class: `fnc-tool-section${i3 > 0 ? " is-after" : ""}`, role: "presentation", children: section }),
|
|
993
|
-
/* @__PURE__ */ a3("
|
|
994
|
-
/* @__PURE__ */ a3(
|
|
995
|
-
|
|
1040
|
+
/* @__PURE__ */ a3("div", { class: "fnc-tool-row", children: [
|
|
1041
|
+
/* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitemradio", "aria-checked": def.type === current.type, onClick: () => pick(def), children: [
|
|
1042
|
+
/* @__PURE__ */ a3(ToolIcon, { def, locale: s3.locale }),
|
|
1043
|
+
/* @__PURE__ */ a3("span", { children: def.name[s3.locale] })
|
|
1044
|
+
] }),
|
|
1045
|
+
/* @__PURE__ */ a3(
|
|
1046
|
+
"button",
|
|
1047
|
+
{
|
|
1048
|
+
class: "fnc-tool-fav",
|
|
1049
|
+
"aria-pressed": s3.favoriteTools.includes(def.type),
|
|
1050
|
+
"aria-label": `${s3.favoriteTools.includes(def.type) ? t3.unfavoriteTool : t3.favoriteTool}: ${def.name[s3.locale]}`,
|
|
1051
|
+
"data-tip": s3.favoriteTools.includes(def.type) ? t3.unfavoriteTool : t3.favoriteTool,
|
|
1052
|
+
onClick: () => ctx.toggleFavoriteTool(def.type),
|
|
1053
|
+
children: /* @__PURE__ */ a3(StarIcon, { filled: s3.favoriteTools.includes(def.type) })
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
996
1056
|
] })
|
|
997
1057
|
] }, def.type);
|
|
998
1058
|
}) })
|
|
999
1059
|
] });
|
|
1000
1060
|
}
|
|
1061
|
+
var CURSORS = [
|
|
1062
|
+
{ mode: "cross", label: "cursorCross", Icon: CrossCursorIcon },
|
|
1063
|
+
{ mode: "dot", label: "cursorDot", Icon: DotCursorIcon },
|
|
1064
|
+
{ mode: "arrow", label: "cursorArrow", Icon: CursorIcon },
|
|
1065
|
+
{ mode: "demo", label: "cursorDemo", Icon: DemoCursorIcon },
|
|
1066
|
+
{ mode: "eraser", label: "cursorEraser", Icon: EraserIcon }
|
|
1067
|
+
];
|
|
1068
|
+
function CursorGroup({ ctx, open, onOpen, onPick }) {
|
|
1069
|
+
const s3 = useStore(ctx.store);
|
|
1070
|
+
const t3 = stringsOf(s3);
|
|
1071
|
+
const ref = T2(null);
|
|
1072
|
+
const current = CURSORS.find((c3) => c3.mode === s3.cursorMode) ?? CURSORS[0];
|
|
1073
|
+
A2(() => {
|
|
1074
|
+
if (!open) return;
|
|
1075
|
+
const close = (e3) => !ref.current?.contains(e3.target) && onOpen(false);
|
|
1076
|
+
const esc = (e3) => e3.key === "Escape" && onOpen(false);
|
|
1077
|
+
document.addEventListener("pointerdown", close, true);
|
|
1078
|
+
document.addEventListener("keydown", esc);
|
|
1079
|
+
return () => {
|
|
1080
|
+
document.removeEventListener("pointerdown", close, true);
|
|
1081
|
+
document.removeEventListener("keydown", esc);
|
|
1082
|
+
};
|
|
1083
|
+
}, [open]);
|
|
1084
|
+
const name = `${t3.cursor}: ${t3[current.label]}`;
|
|
1085
|
+
return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, children: [
|
|
1086
|
+
/* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": name, "aria-label": name, "aria-pressed": s3.drawingTool === null, onClick: onPick, children: /* @__PURE__ */ a3(current.Icon, {}) }),
|
|
1087
|
+
/* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.cursorModes}: ${t3[current.label]}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => onOpen(!open), children: [
|
|
1088
|
+
/* @__PURE__ */ a3("span", { class: "fnc-tool-corner", children: /* @__PURE__ */ a3(CornerIcon, {}) }),
|
|
1089
|
+
/* @__PURE__ */ a3("span", { class: "fnc-tool-chevron", children: /* @__PURE__ */ a3(ChevronRightIcon, {}) })
|
|
1090
|
+
] }),
|
|
1091
|
+
open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-tool-menu", role: "menu", children: [
|
|
1092
|
+
/* @__PURE__ */ a3("div", { class: "fnc-tool-section", role: "presentation", children: t3.cursorModes }),
|
|
1093
|
+
CURSORS.map((c3) => /* @__PURE__ */ a3(
|
|
1094
|
+
"button",
|
|
1095
|
+
{
|
|
1096
|
+
class: "fnc-menu-item",
|
|
1097
|
+
role: "menuitemradio",
|
|
1098
|
+
"aria-checked": c3.mode === current.mode,
|
|
1099
|
+
onClick: () => {
|
|
1100
|
+
ctx.setCursorMode(c3.mode);
|
|
1101
|
+
onOpen(false);
|
|
1102
|
+
onPick();
|
|
1103
|
+
},
|
|
1104
|
+
children: [
|
|
1105
|
+
/* @__PURE__ */ a3(c3.Icon, {}),
|
|
1106
|
+
/* @__PURE__ */ a3("span", { children: t3[c3.label] })
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
c3.mode
|
|
1110
|
+
))
|
|
1111
|
+
] })
|
|
1112
|
+
] });
|
|
1113
|
+
}
|
|
1001
1114
|
function DrawingToolbar({ ctx }) {
|
|
1002
1115
|
const s3 = useStore(ctx.store);
|
|
1003
1116
|
const t3 = stringsOf(s3);
|
|
@@ -1017,7 +1130,11 @@ function DrawingToolbar({ ctx }) {
|
|
|
1017
1130
|
ro.observe(el);
|
|
1018
1131
|
return () => ro.disconnect();
|
|
1019
1132
|
}, []);
|
|
1020
|
-
const
|
|
1133
|
+
const defs = ctx.chart.drawingDefinitions();
|
|
1134
|
+
const groups = toolGroups(defs);
|
|
1135
|
+
const favorites = s3.favoriteTools.map((type) => defs.find((d3) => d3.type === type)).filter((d3) => !!d3);
|
|
1136
|
+
const allLocked = s3.drawingsLocked;
|
|
1137
|
+
const lockAll = () => ctx.chart.setDrawings(ctx.chart.getDrawings().map((d3) => ({ ...d3, style: { ...d3.style, locked: !allLocked } })));
|
|
1021
1138
|
const pick = (tool) => {
|
|
1022
1139
|
ctx.chart.setDrawingTool(tool);
|
|
1023
1140
|
if (tool && ctx.store.get().drawbarOpen) ctx.store.set({ drawbarOpen: false });
|
|
@@ -1035,7 +1152,22 @@ function DrawingToolbar({ ctx }) {
|
|
|
1035
1152
|
"data-open": s3.drawbarOpen,
|
|
1036
1153
|
"data-collapsed": s3.drawbarCollapsed,
|
|
1037
1154
|
children: [
|
|
1038
|
-
/* @__PURE__ */ a3(
|
|
1155
|
+
/* @__PURE__ */ a3(CursorGroup, { ctx, open: openGroup === "__cursor", onOpen: (open) => setOpenGroup(open ? "__cursor" : null), onPick: () => pick(null) }),
|
|
1156
|
+
favorites.length > 0 && /* @__PURE__ */ a3($, { children: [
|
|
1157
|
+
favorites.map((def) => /* @__PURE__ */ a3(
|
|
1158
|
+
"button",
|
|
1159
|
+
{
|
|
1160
|
+
class: "fnc-btn fnc-fav-tool",
|
|
1161
|
+
"data-tip": def.name[s3.locale],
|
|
1162
|
+
"aria-label": def.name[s3.locale],
|
|
1163
|
+
"aria-pressed": s3.drawingTool === def.type,
|
|
1164
|
+
onClick: () => pick(s3.drawingTool === def.type ? null : def.type),
|
|
1165
|
+
children: /* @__PURE__ */ a3(ToolIcon, { def, locale: s3.locale })
|
|
1166
|
+
},
|
|
1167
|
+
`fav-${def.type}`
|
|
1168
|
+
)),
|
|
1169
|
+
/* @__PURE__ */ a3("div", { class: "fnc-hsep" })
|
|
1170
|
+
] }),
|
|
1039
1171
|
groups.map(([key, tools]) => /* @__PURE__ */ a3(
|
|
1040
1172
|
ToolGroup,
|
|
1041
1173
|
{
|
|
@@ -1059,6 +1191,31 @@ function DrawingToolbar({ ctx }) {
|
|
|
1059
1191
|
children: /* @__PURE__ */ a3(MagnetIcon, {})
|
|
1060
1192
|
}
|
|
1061
1193
|
),
|
|
1194
|
+
/* @__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, {}) }),
|
|
1195
|
+
/* @__PURE__ */ a3(
|
|
1196
|
+
"button",
|
|
1197
|
+
{
|
|
1198
|
+
class: "fnc-btn",
|
|
1199
|
+
"data-tip": allLocked ? t3.unlockAll : t3.lockAll,
|
|
1200
|
+
"aria-label": allLocked ? t3.unlockAll : t3.lockAll,
|
|
1201
|
+
"aria-pressed": allLocked,
|
|
1202
|
+
disabled: s3.drawingCount === 0,
|
|
1203
|
+
onClick: lockAll,
|
|
1204
|
+
children: /* @__PURE__ */ a3(LockIcon, { open: !allLocked })
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1207
|
+
/* @__PURE__ */ a3(
|
|
1208
|
+
"button",
|
|
1209
|
+
{
|
|
1210
|
+
class: "fnc-btn",
|
|
1211
|
+
"data-tip": s3.drawingsHidden ? t3.showAll : t3.hideAll,
|
|
1212
|
+
"aria-label": s3.drawingsHidden ? t3.showAll : t3.hideAll,
|
|
1213
|
+
"aria-pressed": s3.drawingsHidden,
|
|
1214
|
+
disabled: s3.drawingCount === 0 && !s3.drawingsHidden,
|
|
1215
|
+
onClick: () => ctx.setDrawingsHidden(!s3.drawingsHidden),
|
|
1216
|
+
children: /* @__PURE__ */ a3(DrawingsEyeIcon, { off: s3.drawingsHidden })
|
|
1217
|
+
}
|
|
1218
|
+
),
|
|
1062
1219
|
/* @__PURE__ */ a3(
|
|
1063
1220
|
"button",
|
|
1064
1221
|
{
|
|
@@ -1088,6 +1245,7 @@ function DrawingToolbar({ ctx }) {
|
|
|
1088
1245
|
}
|
|
1089
1246
|
var SWATCHES = ["#3182F6", "#F04452", "#12B886", "#FF9F0A", "#7048E8"];
|
|
1090
1247
|
var WIDTHS = [1, 2, 3, 4];
|
|
1248
|
+
var FONT_SIZES = [10, 12, 14, 16, 20, 24, 32];
|
|
1091
1249
|
var DASH_ORDER = ["solid", "dashed", "dotted"];
|
|
1092
1250
|
var RECENT_KEY = "fnc-drawing-colors";
|
|
1093
1251
|
var POS_KEY = "fnc-selbar-pos";
|
|
@@ -1260,6 +1418,25 @@ function SelectionBar({ ctx }) {
|
|
|
1260
1418
|
onKeyDown: (e3) => e3.stopPropagation()
|
|
1261
1419
|
}
|
|
1262
1420
|
),
|
|
1421
|
+
def?.text && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
|
|
1422
|
+
/* @__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 }),
|
|
1423
|
+
menu === "font" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop", role: "menu", children: FONT_SIZES.map((size) => /* @__PURE__ */ a3(
|
|
1424
|
+
"button",
|
|
1425
|
+
{
|
|
1426
|
+
class: "fnc-menu-item",
|
|
1427
|
+
role: "menuitemradio",
|
|
1428
|
+
"aria-checked": (style.fontSize ?? 14) === size,
|
|
1429
|
+
onClick: () => {
|
|
1430
|
+
setStyle({ fontSize: size });
|
|
1431
|
+
setMenu(null);
|
|
1432
|
+
},
|
|
1433
|
+
children: /* @__PURE__ */ a3("span", { children: [
|
|
1434
|
+
size,
|
|
1435
|
+
"px"
|
|
1436
|
+
] })
|
|
1437
|
+
}
|
|
1438
|
+
)) })
|
|
1439
|
+
] }),
|
|
1263
1440
|
/* @__PURE__ */ a3("div", { class: "fnc-sep" }),
|
|
1264
1441
|
/* @__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
1442
|
/* @__PURE__ */ a3(
|
|
@@ -3959,6 +4136,14 @@ var CSS = (
|
|
|
3959
4136
|
.fnc-tool-section { padding: 8px 10px 4px; color: var(--fnc-text-2); font-size: 11px; font-weight: 600; }
|
|
3960
4137
|
.fnc-tool-section.is-after { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--fnc-border); }
|
|
3961
4138
|
.fnc-tool-menu .fnc-menu-item { white-space: nowrap; }
|
|
4139
|
+
.fnc-tool-row { position: relative; display: flex; align-items: center; }
|
|
4140
|
+
.fnc-tool-row .fnc-menu-item { flex: 1; padding-right: 36px; }
|
|
4141
|
+
.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; }
|
|
4142
|
+
.fnc-tool-row:hover .fnc-tool-fav, .fnc-tool-fav:focus-visible, .fnc-tool-fav[aria-pressed='true'] { opacity: 1; }
|
|
4143
|
+
.fnc-tool-fav[aria-pressed='true'] { color: #FFB400; }
|
|
4144
|
+
.fnc-tool-fav:hover { background: var(--fnc-surface); color: var(--fnc-text); }
|
|
4145
|
+
@media (hover: none) { .fnc-tool-fav { opacity: 1; } }
|
|
4146
|
+
.fnc-selbar-font { min-width: 32px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
|
3962
4147
|
.fnc-tool-letter { font-size: 13px; font-weight: 700; }
|
|
3963
4148
|
.fnc-svg-icon { display: inline-flex; }
|
|
3964
4149
|
.fnc-svg-icon svg { width: 20px; height: 20px; }
|
|
@@ -4215,6 +4400,10 @@ function createShell(container, options) {
|
|
|
4215
4400
|
darkQuery?.addEventListener?.("change", onSchemeChange);
|
|
4216
4401
|
let favoriteIntervals = storage.get("favorite-intervals", [...options.favoriteIntervals]);
|
|
4217
4402
|
let drawbarCollapsed = storage.get("drawbar-collapsed", false);
|
|
4403
|
+
let favoriteTools = storage.get("favorite-tools", []);
|
|
4404
|
+
let keepDrawing = storage.get("keep-drawing", false);
|
|
4405
|
+
let drawingDefaults = storage.get("drawing-defaults", {});
|
|
4406
|
+
let cursorMode = storage.get("cursor-mode", "cross");
|
|
4218
4407
|
const broadcast = (patch) => {
|
|
4219
4408
|
for (const p3 of panes()) p3.store.set(patch);
|
|
4220
4409
|
};
|
|
@@ -4235,7 +4424,33 @@ function createShell(container, options) {
|
|
|
4235
4424
|
slots,
|
|
4236
4425
|
storage,
|
|
4237
4426
|
theme: () => theme,
|
|
4238
|
-
sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, drawbarCollapsed }),
|
|
4427
|
+
sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, drawbarCollapsed, favoriteTools, keepDrawing, cursorMode }),
|
|
4428
|
+
setCursorMode: (mode) => {
|
|
4429
|
+
cursorMode = mode;
|
|
4430
|
+
storage.set("cursor-mode", mode);
|
|
4431
|
+
for (const p3 of panes()) p3.chart.setCursorMode(mode);
|
|
4432
|
+
broadcast({ cursorMode });
|
|
4433
|
+
},
|
|
4434
|
+
drawingDefaults: () => drawingDefaults,
|
|
4435
|
+
saveDrawingDefaults: (defaults) => {
|
|
4436
|
+
drawingDefaults = defaults;
|
|
4437
|
+
storage.set("drawing-defaults", defaults);
|
|
4438
|
+
for (const p3 of panes()) p3.chart.setDrawingDefaults(defaults);
|
|
4439
|
+
},
|
|
4440
|
+
toggleFavoriteTool: (tool) => {
|
|
4441
|
+
favoriteTools = favoriteTools.includes(tool) ? favoriteTools.filter((x2) => x2 !== tool) : [...favoriteTools, tool];
|
|
4442
|
+
storage.set("favorite-tools", favoriteTools);
|
|
4443
|
+
broadcast({ favoriteTools });
|
|
4444
|
+
},
|
|
4445
|
+
setKeepDrawing: (on) => {
|
|
4446
|
+
keepDrawing = on;
|
|
4447
|
+
storage.set("keep-drawing", on);
|
|
4448
|
+
for (const p3 of panes()) p3.chart.setKeepDrawingTool(on);
|
|
4449
|
+
broadcast({ keepDrawing });
|
|
4450
|
+
},
|
|
4451
|
+
setDrawingsHidden: (hidden) => {
|
|
4452
|
+
for (const p3 of panes()) p3.chart.setDrawingsHidden(hidden);
|
|
4453
|
+
},
|
|
4239
4454
|
setPanes: (get) => {
|
|
4240
4455
|
panes = get;
|
|
4241
4456
|
},
|
|
@@ -4335,6 +4550,9 @@ function createPane(shell, config) {
|
|
|
4335
4550
|
displayTimezone: config.displayTimezone
|
|
4336
4551
|
});
|
|
4337
4552
|
chart.setChartType(config.chartType);
|
|
4553
|
+
chart.setKeepDrawingTool(shell.sharedState().keepDrawing);
|
|
4554
|
+
chart.setCursorMode(shell.sharedState().cursorMode);
|
|
4555
|
+
chart.setDrawingDefaults(shell.drawingDefaults());
|
|
4338
4556
|
const canvasVars = (s3) => {
|
|
4339
4557
|
const muted = s3.textColor && /^#[0-9a-f]{6}$/i.test(s3.textColor) ? `${s3.textColor}99` : null;
|
|
4340
4558
|
const vars = [
|
|
@@ -4374,8 +4592,10 @@ function createPane(shell, config) {
|
|
|
4374
4592
|
drawingTool: null,
|
|
4375
4593
|
selection: null,
|
|
4376
4594
|
drawingCount: 0,
|
|
4595
|
+
drawingsLocked: false,
|
|
4377
4596
|
drawbarOpen: false,
|
|
4378
4597
|
magnet: chart.magnetEnabled,
|
|
4598
|
+
drawingsHidden: chart.drawingsHidden,
|
|
4379
4599
|
indicators: chart.getIndicators(),
|
|
4380
4600
|
dialog: null,
|
|
4381
4601
|
...shell.sharedState()
|
|
@@ -4389,9 +4609,13 @@ function createPane(shell, config) {
|
|
|
4389
4609
|
chart.on("dataChange", syncRealtime),
|
|
4390
4610
|
chart.on("drawingToolChange", (drawingTool) => store.set({ drawingTool })),
|
|
4391
4611
|
chart.on("selectionChange", (selection) => store.set({ selection })),
|
|
4392
|
-
chart.on("drawingsChange", (drawings) => store.set({ drawingCount: drawings.length })),
|
|
4612
|
+
chart.on("drawingsChange", (drawings) => store.set({ drawingCount: drawings.length, drawingsLocked: drawings.length > 0 && drawings.every((d3) => d3.style?.locked) })),
|
|
4393
4613
|
chart.on("indicatorsChange", (indicators) => store.set({ indicators })),
|
|
4394
4614
|
chart.on("magnetChange", (magnet) => store.set({ magnet })),
|
|
4615
|
+
chart.on("drawingsHiddenChange", (drawingsHidden) => store.set({ drawingsHidden })),
|
|
4616
|
+
chart.on("cursorModeChange", (cursorMode) => store.set({ cursorMode })),
|
|
4617
|
+
// A color or style picked for a drawing: remembered for the tool, in every pane.
|
|
4618
|
+
chart.on("drawingDefaultsChange", (defaults) => shell.saveDrawingDefaults(defaults)),
|
|
4395
4619
|
chart.on("chartTypeChange", (chartType) => store.set({ chartType })),
|
|
4396
4620
|
chart.on("historyChange", ({ canUndo, canRedo }) => store.set({ canUndo, canRedo })),
|
|
4397
4621
|
chart.on("comparesChange", (compares) => store.set({ compares })),
|
|
@@ -4433,6 +4657,10 @@ function createPane(shell, config) {
|
|
|
4433
4657
|
if (current) void load(current.symbol, res);
|
|
4434
4658
|
},
|
|
4435
4659
|
toggleFavoriteInterval: shell.toggleFavoriteInterval,
|
|
4660
|
+
toggleFavoriteTool: shell.toggleFavoriteTool,
|
|
4661
|
+
setKeepDrawing: shell.setKeepDrawing,
|
|
4662
|
+
setCursorMode: shell.setCursorMode,
|
|
4663
|
+
setDrawingsHidden: shell.setDrawingsHidden,
|
|
4436
4664
|
setSearchOpen: (open, target = "symbol") => store.set(open ? { searchOpen: true, searchTarget: target } : { searchOpen: false }),
|
|
4437
4665
|
screenshot: () => {
|
|
4438
4666
|
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 CursorMode, 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,10 @@ 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;
|
|
36
|
+
setCursorMode(mode: CursorMode): void;
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
39
|
export interface ShellOptions {
|
|
@@ -58,7 +62,14 @@ export interface Shell {
|
|
|
58
62
|
readonly storage: WidgetStorage;
|
|
59
63
|
theme(): ThemeTokens;
|
|
60
64
|
/** Initial UI-state fields owned by the shell (same for every pane). */
|
|
61
|
-
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed'>;
|
|
65
|
+
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing' | 'cursorMode'>;
|
|
66
|
+
setCursorMode(mode: CursorMode): void;
|
|
67
|
+
/** Each tool's last color / style (saved; every pane starts with it). */
|
|
68
|
+
drawingDefaults(): DrawingDefaults;
|
|
69
|
+
saveDrawingDefaults(defaults: DrawingDefaults): void;
|
|
70
|
+
toggleFavoriteTool(tool: DrawingType): void;
|
|
71
|
+
setKeepDrawing(on: boolean): void;
|
|
72
|
+
setDrawingsHidden(hidden: boolean): void;
|
|
62
73
|
setPanes(panes: () => readonly ShellPane[]): void;
|
|
63
74
|
setTheme(patch: Partial<ThemeTokens>): void;
|
|
64
75
|
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.28",
|
|
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.28"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"preact": "^11.2.0"
|