@funnest/charts-ui 0.6.27 → 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 +4 -1
- package/dist/i18n.d.ts +12 -0
- package/dist/icons.d.ts +4 -0
- package/dist/index.js +87 -2
- package/dist/shell.d.ts +4 -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';
|
|
@@ -45,6 +45,8 @@ export interface UiState {
|
|
|
45
45
|
keepDrawing: boolean;
|
|
46
46
|
/** Every drawing hidden (the drawing bar's 👁). */
|
|
47
47
|
drawingsHidden: boolean;
|
|
48
|
+
/** How the pointer looks (the drawing bar's cursor menu; same in every pane). */
|
|
49
|
+
cursorMode: CursorMode;
|
|
48
50
|
canUndo: boolean;
|
|
49
51
|
canRedo: boolean;
|
|
50
52
|
compares: CompareInfo[];
|
|
@@ -137,6 +139,7 @@ export interface WidgetContext {
|
|
|
137
139
|
toggleFavoriteInterval(resolution: Resolution): void;
|
|
138
140
|
toggleFavoriteTool(tool: DrawingType): void;
|
|
139
141
|
setKeepDrawing(on: boolean): void;
|
|
142
|
+
setCursorMode(mode: CursorMode): void;
|
|
140
143
|
/** Hides or shows the drawings of every pane. */
|
|
141
144
|
setDrawingsHidden(hidden: boolean): void;
|
|
142
145
|
setSearchOpen(open: boolean, target?: 'symbol' | 'compare'): void;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export declare const STRINGS: {
|
|
|
30
30
|
fibonacci: string;
|
|
31
31
|
removeAll: string;
|
|
32
32
|
keepDrawing: string;
|
|
33
|
+
cursorModes: string;
|
|
34
|
+
cursorCross: string;
|
|
35
|
+
cursorDot: string;
|
|
36
|
+
cursorArrow: string;
|
|
37
|
+
cursorDemo: string;
|
|
38
|
+
cursorEraser: string;
|
|
33
39
|
lockAll: string;
|
|
34
40
|
unlockAll: string;
|
|
35
41
|
hideAll: string;
|
|
@@ -185,6 +191,12 @@ export declare const STRINGS: {
|
|
|
185
191
|
fibonacci: string;
|
|
186
192
|
removeAll: string;
|
|
187
193
|
keepDrawing: string;
|
|
194
|
+
cursorModes: string;
|
|
195
|
+
cursorCross: string;
|
|
196
|
+
cursorDot: string;
|
|
197
|
+
cursorArrow: string;
|
|
198
|
+
cursorDemo: string;
|
|
199
|
+
cursorEraser: string;
|
|
188
200
|
lockAll: string;
|
|
189
201
|
unlockAll: string;
|
|
190
202
|
hideAll: string;
|
package/dist/icons.d.ts
CHANGED
|
@@ -61,6 +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
|
+
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;
|
|
64
68
|
/** 연속 그리기: a pencil that keeps going. */
|
|
65
69
|
export declare const KeepDrawingIcon: () => import("preact").JSX.Element;
|
|
66
70
|
export declare const DrawingsEyeIcon: ({ off }: {
|
package/dist/index.js
CHANGED
|
@@ -456,6 +456,12 @@ var STRINGS = {
|
|
|
456
456
|
fibonacci: "\uD53C\uBCF4\uB098\uCE58 \uB418\uB3CC\uB9BC",
|
|
457
457
|
removeAll: "\uADF8\uB9AC\uAE30 \uBAA8\uB450 \uC0AD\uC81C",
|
|
458
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",
|
|
459
465
|
lockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uADF8\uAE30",
|
|
460
466
|
unlockAll: "\uADF8\uB9BC \uBAA8\uB450 \uC7A0\uAE08 \uD480\uAE30",
|
|
461
467
|
hideAll: "\uADF8\uB9BC \uBAA8\uB450 \uC228\uAE30\uAE30",
|
|
@@ -613,6 +619,12 @@ var STRINGS = {
|
|
|
613
619
|
fibonacci: "Fib retracement",
|
|
614
620
|
removeAll: "Remove all drawings",
|
|
615
621
|
keepDrawing: "Stay in drawing mode",
|
|
622
|
+
cursorModes: "Cursors",
|
|
623
|
+
cursorCross: "Cross",
|
|
624
|
+
cursorDot: "Dot",
|
|
625
|
+
cursorArrow: "Arrow",
|
|
626
|
+
cursorDemo: "Demonstration",
|
|
627
|
+
cursorEraser: "Eraser",
|
|
616
628
|
lockAll: "Lock all drawings",
|
|
617
629
|
unlockAll: "Unlock all drawings",
|
|
618
630
|
hideAll: "Hide all drawings",
|
|
@@ -904,6 +916,16 @@ var LockIcon = ({ open = false }) => /* @__PURE__ */ a3(Icon, { children: [
|
|
|
904
916
|
/* @__PURE__ */ a3("rect", { x: "4.5", y: "9", width: "11", height: "8", rx: "1.8" }),
|
|
905
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" })
|
|
906
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
|
+
] });
|
|
907
929
|
var KeepDrawingIcon = () => /* @__PURE__ */ a3(Icon, { children: [
|
|
908
930
|
/* @__PURE__ */ a3("path", { d: "M3.5 13.5 11 6l3 3-7.5 7.5H3.5z" }),
|
|
909
931
|
/* @__PURE__ */ a3("path", { d: "M13 3.5a3.5 3.5 0 0 1 3.5 3.5M15 2l1.5 1.5L15 5" })
|
|
@@ -1036,6 +1058,59 @@ function ToolGroup({
|
|
|
1036
1058
|
}) })
|
|
1037
1059
|
] });
|
|
1038
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
|
+
}
|
|
1039
1114
|
function DrawingToolbar({ ctx }) {
|
|
1040
1115
|
const s3 = useStore(ctx.store);
|
|
1041
1116
|
const t3 = stringsOf(s3);
|
|
@@ -1077,7 +1152,7 @@ function DrawingToolbar({ ctx }) {
|
|
|
1077
1152
|
"data-open": s3.drawbarOpen,
|
|
1078
1153
|
"data-collapsed": s3.drawbarCollapsed,
|
|
1079
1154
|
children: [
|
|
1080
|
-
/* @__PURE__ */ a3(
|
|
1155
|
+
/* @__PURE__ */ a3(CursorGroup, { ctx, open: openGroup === "__cursor", onOpen: (open) => setOpenGroup(open ? "__cursor" : null), onPick: () => pick(null) }),
|
|
1081
1156
|
favorites.length > 0 && /* @__PURE__ */ a3($, { children: [
|
|
1082
1157
|
favorites.map((def) => /* @__PURE__ */ a3(
|
|
1083
1158
|
"button",
|
|
@@ -4328,6 +4403,7 @@ function createShell(container, options) {
|
|
|
4328
4403
|
let favoriteTools = storage.get("favorite-tools", []);
|
|
4329
4404
|
let keepDrawing = storage.get("keep-drawing", false);
|
|
4330
4405
|
let drawingDefaults = storage.get("drawing-defaults", {});
|
|
4406
|
+
let cursorMode = storage.get("cursor-mode", "cross");
|
|
4331
4407
|
const broadcast = (patch) => {
|
|
4332
4408
|
for (const p3 of panes()) p3.store.set(patch);
|
|
4333
4409
|
};
|
|
@@ -4348,7 +4424,13 @@ function createShell(container, options) {
|
|
|
4348
4424
|
slots,
|
|
4349
4425
|
storage,
|
|
4350
4426
|
theme: () => theme,
|
|
4351
|
-
sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, drawbarCollapsed, favoriteTools, keepDrawing }),
|
|
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
|
+
},
|
|
4352
4434
|
drawingDefaults: () => drawingDefaults,
|
|
4353
4435
|
saveDrawingDefaults: (defaults) => {
|
|
4354
4436
|
drawingDefaults = defaults;
|
|
@@ -4469,6 +4551,7 @@ function createPane(shell, config) {
|
|
|
4469
4551
|
});
|
|
4470
4552
|
chart.setChartType(config.chartType);
|
|
4471
4553
|
chart.setKeepDrawingTool(shell.sharedState().keepDrawing);
|
|
4554
|
+
chart.setCursorMode(shell.sharedState().cursorMode);
|
|
4472
4555
|
chart.setDrawingDefaults(shell.drawingDefaults());
|
|
4473
4556
|
const canvasVars = (s3) => {
|
|
4474
4557
|
const muted = s3.textColor && /^#[0-9a-f]{6}$/i.test(s3.textColor) ? `${s3.textColor}99` : null;
|
|
@@ -4530,6 +4613,7 @@ function createPane(shell, config) {
|
|
|
4530
4613
|
chart.on("indicatorsChange", (indicators) => store.set({ indicators })),
|
|
4531
4614
|
chart.on("magnetChange", (magnet) => store.set({ magnet })),
|
|
4532
4615
|
chart.on("drawingsHiddenChange", (drawingsHidden) => store.set({ drawingsHidden })),
|
|
4616
|
+
chart.on("cursorModeChange", (cursorMode) => store.set({ cursorMode })),
|
|
4533
4617
|
// A color or style picked for a drawing: remembered for the tool, in every pane.
|
|
4534
4618
|
chart.on("drawingDefaultsChange", (defaults) => shell.saveDrawingDefaults(defaults)),
|
|
4535
4619
|
chart.on("chartTypeChange", (chartType) => store.set({ chartType })),
|
|
@@ -4575,6 +4659,7 @@ function createPane(shell, config) {
|
|
|
4575
4659
|
toggleFavoriteInterval: shell.toggleFavoriteInterval,
|
|
4576
4660
|
toggleFavoriteTool: shell.toggleFavoriteTool,
|
|
4577
4661
|
setKeepDrawing: shell.setKeepDrawing,
|
|
4662
|
+
setCursorMode: shell.setCursorMode,
|
|
4578
4663
|
setDrawingsHidden: shell.setDrawingsHidden,
|
|
4579
4664
|
setSearchOpen: (open, target = "symbol") => store.set(open ? { searchOpen: true, searchTarget: target } : { searchOpen: false }),
|
|
4580
4665
|
screenshot: () => {
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DirectionPreset, type DrawingDefaults, type DrawingType, 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';
|
|
@@ -33,6 +33,7 @@ export interface ShellPane {
|
|
|
33
33
|
setKeepDrawingTool(on: boolean): void;
|
|
34
34
|
setDrawingsHidden(hidden: boolean): void;
|
|
35
35
|
setDrawingDefaults(defaults: DrawingDefaults): void;
|
|
36
|
+
setCursorMode(mode: CursorMode): void;
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
export interface ShellOptions {
|
|
@@ -61,7 +62,8 @@ export interface Shell {
|
|
|
61
62
|
readonly storage: WidgetStorage;
|
|
62
63
|
theme(): ThemeTokens;
|
|
63
64
|
/** Initial UI-state fields owned by the shell (same for every pane). */
|
|
64
|
-
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing'>;
|
|
65
|
+
sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing' | 'cursorMode'>;
|
|
66
|
+
setCursorMode(mode: CursorMode): void;
|
|
65
67
|
/** Each tool's last color / style (saved; every pane starts with it). */
|
|
66
68
|
drawingDefaults(): DrawingDefaults;
|
|
67
69
|
saveDrawingDefaults(defaults: DrawingDefaults): 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"
|