@funnest/charts-ui 0.11.34 → 0.11.36

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.
@@ -0,0 +1,23 @@
1
+ /** @jsxImportSource preact */
2
+ import type { ComponentChildren } from 'preact';
3
+ import type { Strings } from '../i18n.js';
4
+ /** Rows of the board: grays, three lighter rows, the hues, two darker rows. */
5
+ export declare const PALETTE: readonly (readonly string[])[];
6
+ export declare function recentColors(): string[];
7
+ /** A color picked with the browser's picker: first among the recent ones (shared by every field). */
8
+ export declare function rememberColor(color: string): string[];
9
+ /**
10
+ * A button (`children`: what it shows) that opens the board under it — or above when there's no room
11
+ * — placed in the viewport, so a scrolling list or a menu it sits in can't clip it.
12
+ */
13
+ export declare function ColorPicker({ value, label, t, onPick, class: cls, style, tip, children, }: {
14
+ /** #rrggbb (anything else: nothing marked). */
15
+ value: string;
16
+ label: string;
17
+ t: Pick<Strings, 'paletteCustom' | 'paletteRecent'>;
18
+ onPick(color: string): void;
19
+ class?: string;
20
+ style?: Record<string, string>;
21
+ tip?: string;
22
+ children?: ComponentChildren;
23
+ }): import("preact").JSX.Element;
@@ -0,0 +1,16 @@
1
+ /** Asks the widget's tooltip to hide (shell.ts bindTooltips listens for it). */
2
+ export declare const HIDE_TIP = "fnc-hide-tip";
3
+ /**
4
+ * The drawing bar's tool lists open when a mouse rests on the group (the corner button still opens
5
+ * them with a click, and touch only by tapping). One opened this way closes when the pointer has
6
+ * left the group and its list for a moment; one opened with a click stays until a click outside.
7
+ * Spread the returned handlers on the group's element (its list is inside it).
8
+ */
9
+ export declare function useHoverOpen(open: boolean, onOpen: (open: boolean) => void, group?: {
10
+ current: HTMLElement | null;
11
+ }): {
12
+ onPointerEnter: (e: PointerEvent) => void;
13
+ onPointerLeave: (e: PointerEvent) => void;
14
+ /** The corner button: opens or closes the list — or, when hovering opened it, keeps it open until a click outside. */
15
+ toggle: () => void;
16
+ };
package/dist/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Chart, ChartContextMenu, ChartLayout, ChartSettings, ChartType, CompareInfo, CursorMode, Datafeed, Drawing, DrawingType, IndicatorConfig, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
1
+ import type { Chart, ChartContextMenu, ChartLayout, ChartSettings, ChartType, CompareInfo, CursorMode, Datafeed, Drawing, DrawingType, IndicatorConfig, MagnetMode, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
2
2
  import type { LayoutId } from './layouts.js';
3
3
  import type { WidgetStorage } from './storage.js';
4
4
  import type { Strings } from './i18n.js';
@@ -24,7 +24,11 @@ export interface UiState {
24
24
  drawingsLocked: boolean;
25
25
  /** Narrow screens: the drawing bar is hidden until toggled from the toolbar. */
26
26
  drawbarOpen: boolean;
27
+ /** 자석 on (weak or strong). */
27
28
  magnet: boolean;
29
+ magnetMode: MagnetMode;
30
+ /** The strength the magnet button turns on with. */
31
+ magnetStrength: 'weak' | 'strong';
28
32
  indicators: IndicatorConfig[];
29
33
  /** Open dialog: indicator picker, or settings for one indicator id. */
30
34
  dialog: {
@@ -216,6 +220,8 @@ export interface WidgetContext {
216
220
  toggleFavoriteTool(tool: DrawingType): void;
217
221
  setKeepDrawing(on: boolean): void;
218
222
  setCursorMode(mode: CursorMode): void;
223
+ /** 자석 (every pane; kept). */
224
+ setMagnetMode(mode: MagnetMode): void;
219
225
  /** Hides or shows the drawings of every pane. */
220
226
  setDrawingsHidden(hidden: boolean): void;
221
227
  setSearchOpen(open: boolean, target?: 'symbol' | 'compare'): void;
package/dist/i18n.d.ts CHANGED
@@ -168,6 +168,15 @@ export declare const STRINGS: {
168
168
  done: string;
169
169
  expandDrawbar: string;
170
170
  magnet: string;
171
+ magnetModes: string;
172
+ magnetWeak: string;
173
+ magnetWeakSub: string;
174
+ magnetStrong: string;
175
+ magnetStrongSub: string;
176
+ palette: string;
177
+ paletteCustom: string;
178
+ paletteRecent: string;
179
+ resetDrawingLook: string;
171
180
  remove: string;
172
181
  color: string;
173
182
  customColor: string;
@@ -273,6 +282,8 @@ export declare const STRINGS: {
273
282
  lockView: string;
274
283
  unlockView: string;
275
284
  lockRatio: string;
285
+ settingAutoScale: string;
286
+ hintAutoScale: string;
276
287
  levelValuesLabel: string;
277
288
  note: string;
278
289
  noteText: string;
@@ -528,6 +539,15 @@ export declare const STRINGS: {
528
539
  done: string;
529
540
  expandDrawbar: string;
530
541
  magnet: string;
542
+ magnetModes: string;
543
+ magnetWeak: string;
544
+ magnetWeakSub: string;
545
+ magnetStrong: string;
546
+ magnetStrongSub: string;
547
+ palette: string;
548
+ paletteCustom: string;
549
+ paletteRecent: string;
550
+ resetDrawingLook: string;
531
551
  remove: string;
532
552
  color: string;
533
553
  customColor: string;
@@ -633,6 +653,8 @@ export declare const STRINGS: {
633
653
  lockView: string;
634
654
  unlockView: string;
635
655
  lockRatio: string;
656
+ settingAutoScale: string;
657
+ hintAutoScale: string;
636
658
  levelValuesLabel: string;
637
659
  note: string;
638
660
  noteText: string;
package/dist/icons.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare const SmallCloseIcon: () => import("preact").JSX.Element;
45
45
  export declare const EyeIcon: () => import("preact").JSX.Element;
46
46
  export declare const EyeOffIcon: () => import("preact").JSX.Element;
47
47
  export declare const ChevronUpIcon: () => import("preact").JSX.Element;
48
+ /** A sturdy horseshoe: wide arms, the poles filled in (a thin U read as faint next to the other tools). */
48
49
  export declare const MagnetIcon: () => import("preact").JSX.Element;
49
50
  export declare const StarIcon: ({ filled }: {
50
51
  filled?: boolean;
package/dist/index.js CHANGED
@@ -603,6 +603,15 @@ var STRINGS = {
603
603
  done: "\uC644\uB8CC",
604
604
  expandDrawbar: "\uADF8\uB9AC\uAE30 \uB3C4\uAD6C \uD3BC\uCE58\uAE30",
605
605
  magnet: "\uC790\uC11D \uBAA8\uB4DC (\uC2DC\xB7\uACE0\xB7\uC800\xB7\uC885\uAC00\uC5D0 \uBD99\uC774\uAE30)",
606
+ magnetModes: "\uC790\uC11D \uC138\uAE30",
607
+ magnetWeak: "\uC57D\uD55C \uC790\uC11D",
608
+ magnetWeakSub: "\uC2DC\xB7\uACE0\xB7\uC800\xB7\uC885\uAC00 \uAC00\uAE4C\uC774 \uAC14\uC744 \uB54C\uB9CC \uBD99\uC5B4\uC694",
609
+ magnetStrong: "\uAC15\uD55C \uC790\uC11D",
610
+ magnetStrongSub: "\uD56D\uC0C1 \uAC00\uC7A5 \uAC00\uAE4C\uC6B4 \uC2DC\xB7\uACE0\xB7\uC800\xB7\uC885\uAC00\uC5D0 \uBD99\uC5B4\uC694",
611
+ palette: "\uC0C9 \uACE0\uB974\uAE30",
612
+ paletteCustom: "\uC9C1\uC811 \uACE0\uB974\uAE30",
613
+ paletteRecent: "\uCD5C\uADFC\uC5D0 \uC4F4 \uC0C9",
614
+ resetDrawingLook: "\uAE30\uBCF8 \uBAA8\uC591\uC73C\uB85C \uB418\uB3CC\uB9AC\uAE30",
606
615
  remove: "\uC0AD\uC81C",
607
616
  color: "\uC0C9\uC0C1",
608
617
  customColor: "\uB2E4\uB978 \uC0C9",
@@ -708,6 +717,8 @@ var STRINGS = {
708
717
  lockView: "\uCC28\uD2B8 \uACE0\uC815",
709
718
  unlockView: "\uCC28\uD2B8 \uACE0\uC815 \uD480\uAE30",
710
719
  lockRatio: "\uAC00\uACA9 \uCD95 \uBE44\uC728 \uACE0\uC815",
720
+ settingAutoScale: "\uC790\uB3D9 \uB9DE\uCDA4",
721
+ hintAutoScale: "\uD654\uBA74\uC5D0 \uBCF4\uC774\uB294 \uCE94\uB4E4\uC5D0 \uB9DE\uCDB0 \uAC00\uACA9 \uCD95\uC744 \uB298\uC774\uACE0 \uC904\uC5EC\uC694. \uAC00\uACA9 \uCD95\uC744 \uB04C\uC5B4 \uC9C1\uC811 \uB9DE\uCD94\uBA74 \uAEBC\uC9C0\uACE0, \uAC00\uACA9 \uCD95\uC744 \uB354\uBE14\uD074\uB9AD\uD558\uBA74 \uB2E4\uC2DC \uCF1C\uC838\uC694.",
711
722
  levelValuesLabel: "\uAE30\uC900\uC120 \uAC12",
712
723
  note: "\uD14D\uC2A4\uD2B8",
713
724
  noteText: "\uD14D\uC2A4\uD2B8 \uC785\uB825",
@@ -965,6 +976,15 @@ var STRINGS = {
965
976
  done: "Done",
966
977
  expandDrawbar: "Show drawing tools",
967
978
  magnet: "Magnet (snap to OHLC)",
979
+ magnetModes: "Magnet strength",
980
+ magnetWeak: "Weak magnet",
981
+ magnetWeakSub: "Snaps only near an open, high, low or close",
982
+ magnetStrong: "Strong magnet",
983
+ magnetStrongSub: "Always snaps to the nearest open, high, low or close",
984
+ palette: "Pick a color",
985
+ paletteCustom: "Custom\u2026",
986
+ paletteRecent: "Recent",
987
+ resetDrawingLook: "Back to the default look",
968
988
  remove: "Remove",
969
989
  color: "Color",
970
990
  customColor: "Other color",
@@ -1070,6 +1090,8 @@ var STRINGS = {
1070
1090
  lockView: "Lock chart",
1071
1091
  unlockView: "Unlock chart",
1072
1092
  lockRatio: "Lock price to bar ratio",
1093
+ settingAutoScale: "Auto (fit to screen)",
1094
+ hintAutoScale: "The price axis stretches to fit the candles on screen. Dragging the axis turns it off; double-click the axis to turn it back on.",
1073
1095
  levelValuesLabel: "Level values",
1074
1096
  note: "Text",
1075
1097
  noteText: "Type text",
@@ -1245,8 +1267,200 @@ function IntervalVisibilityEditor({ t: t3, value, onChange }) {
1245
1267
  }) });
1246
1268
  }
1247
1269
 
1248
- // src/components/keep-in-view.ts
1270
+ // src/components/color-picker.tsx
1271
+ var GRAYS = ["#FFFFFF", "#F2F4F6", "#D1D6DB", "#B0B8C1", "#8B95A1", "#6B7684", "#4E5968", "#333D4B", "#191F28", "#000000"];
1272
+ var HUES = ["#F04452", "#FF9F0A", "#FFD43B", "#94D82D", "#12B886", "#15AABF", "#3182F6", "#4C6EF5", "#7048E8", "#E64980"];
1273
+ var hex = (n2) => Math.round(Math.max(0, Math.min(255, n2))).toString(16).padStart(2, "0");
1274
+ function mix(color, t3) {
1275
+ const v3 = [1, 3, 5].map((i3) => parseInt(color.slice(i3, i3 + 2), 16));
1276
+ const to = t3 > 0 ? 255 : 0;
1277
+ const k2 = Math.abs(t3);
1278
+ return `#${v3.map((c3) => hex(c3 + (to - c3) * k2)).join("")}`.toUpperCase();
1279
+ }
1280
+ var PALETTE = [GRAYS, ...[0.75, 0.5, 0.25].map((t3) => HUES.map((c3) => mix(c3, t3))), HUES, ...[-0.25, -0.5].map((t3) => HUES.map((c3) => mix(c3, t3)))];
1281
+ var RECENT_KEY = "fnc-drawing-colors";
1282
+ var RECENT_MAX = 10;
1283
+ function recentColors() {
1284
+ try {
1285
+ const list = JSON.parse(localStorage.getItem(RECENT_KEY) ?? "[]");
1286
+ return Array.isArray(list) ? list.filter((c3) => typeof c3 === "string" && /^#[0-9a-f]{6}$/i.test(c3)).slice(0, RECENT_MAX) : [];
1287
+ } catch {
1288
+ return [];
1289
+ }
1290
+ }
1291
+ function rememberColor(color) {
1292
+ const next = [color, ...recentColors().filter((c3) => c3.toLowerCase() !== color.toLowerCase())].slice(0, RECENT_MAX);
1293
+ try {
1294
+ localStorage.setItem(RECENT_KEY, JSON.stringify(next));
1295
+ } catch {
1296
+ }
1297
+ return next;
1298
+ }
1249
1299
  var MARGIN = 8;
1300
+ var same = (a4, b) => a4.slice(0, 7).toLowerCase() === b.slice(0, 7).toLowerCase();
1301
+ function ColorPicker({
1302
+ value,
1303
+ label,
1304
+ t: t3,
1305
+ onPick,
1306
+ class: cls,
1307
+ style,
1308
+ tip,
1309
+ children
1310
+ }) {
1311
+ const [open, setOpen] = d2(false);
1312
+ const [recent, setRecent] = d2([]);
1313
+ const wrap = T2(null);
1314
+ const button = T2(null);
1315
+ const pop = T2(null);
1316
+ A2(() => {
1317
+ if (!open) return;
1318
+ setRecent(recentColors());
1319
+ const close = (e3) => !wrap.current?.contains(e3.target) && setOpen(false);
1320
+ const esc = (e3) => {
1321
+ if (e3.key !== "Escape") return;
1322
+ e3.stopPropagation();
1323
+ setOpen(false);
1324
+ button.current?.focus();
1325
+ };
1326
+ document.addEventListener("pointerdown", close, true);
1327
+ document.addEventListener("keydown", esc, true);
1328
+ return () => {
1329
+ document.removeEventListener("pointerdown", close, true);
1330
+ document.removeEventListener("keydown", esc, true);
1331
+ };
1332
+ }, [open]);
1333
+ F2(() => {
1334
+ const el = pop.current;
1335
+ const a4 = button.current;
1336
+ if (!open || !el || !a4) return;
1337
+ const place = () => {
1338
+ const r3 = a4.getBoundingClientRect();
1339
+ el.style.left = "0px";
1340
+ el.style.top = "0px";
1341
+ const origin = el.getBoundingClientRect();
1342
+ const vw = document.documentElement.clientWidth;
1343
+ const vh = document.documentElement.clientHeight;
1344
+ const below = r3.bottom + 6;
1345
+ const top = below + el.offsetHeight + MARGIN <= vh ? below : Math.max(MARGIN, r3.top - 6 - el.offsetHeight);
1346
+ const left = Math.max(MARGIN, Math.min(vw - MARGIN - el.offsetWidth, r3.left));
1347
+ el.style.left = `${Math.round(left - origin.left)}px`;
1348
+ el.style.top = `${Math.round(top - origin.top)}px`;
1349
+ };
1350
+ place();
1351
+ window.addEventListener("resize", place);
1352
+ window.addEventListener("scroll", place, true);
1353
+ return () => {
1354
+ window.removeEventListener("resize", place);
1355
+ window.removeEventListener("scroll", place, true);
1356
+ };
1357
+ }, [open]);
1358
+ const pick = (color) => {
1359
+ onPick(color);
1360
+ setOpen(false);
1361
+ };
1362
+ const swatch = (color) => /* @__PURE__ */ a3(
1363
+ "button",
1364
+ {
1365
+ type: "button",
1366
+ class: "fnc-palette-cell",
1367
+ role: "option",
1368
+ style: { background: color },
1369
+ "aria-label": color,
1370
+ "aria-selected": same(color, value),
1371
+ onClick: () => pick(color)
1372
+ },
1373
+ color
1374
+ );
1375
+ return /* @__PURE__ */ a3("span", { class: "fnc-palette-wrap", ref: wrap, children: [
1376
+ /* @__PURE__ */ a3(
1377
+ "button",
1378
+ {
1379
+ type: "button",
1380
+ ref: button,
1381
+ class: cls,
1382
+ style,
1383
+ "data-tip": tip,
1384
+ "aria-label": label,
1385
+ "aria-haspopup": "listbox",
1386
+ "aria-expanded": open,
1387
+ onClick: () => setOpen(!open),
1388
+ children
1389
+ }
1390
+ ),
1391
+ open && /* @__PURE__ */ a3("div", { class: "fnc-palette", ref: pop, role: "dialog", "aria-label": label, onKeyDown: (e3) => e3.key !== "Escape" && e3.stopPropagation(), children: [
1392
+ /* @__PURE__ */ a3("div", { class: "fnc-palette-grid", role: "listbox", "aria-label": label, children: PALETTE.map((row2) => row2.map(swatch)) }),
1393
+ recent.length > 0 && /* @__PURE__ */ a3($, { children: [
1394
+ /* @__PURE__ */ a3("div", { class: "fnc-palette-title", children: t3.paletteRecent }),
1395
+ /* @__PURE__ */ a3("div", { class: "fnc-palette-grid", role: "listbox", "aria-label": t3.paletteRecent, children: recent.map(swatch) })
1396
+ ] }),
1397
+ /* @__PURE__ */ a3("label", { class: "fnc-palette-custom", children: [
1398
+ /* @__PURE__ */ a3("span", { class: "fnc-palette-custom-chip", style: { background: /^#[0-9a-f]{6}/i.test(value) ? value.slice(0, 7) : "#3182F6" } }),
1399
+ /* @__PURE__ */ a3("span", { children: t3.paletteCustom }),
1400
+ /* @__PURE__ */ a3(
1401
+ "input",
1402
+ {
1403
+ type: "color",
1404
+ value: /^#[0-9a-f]{6}/i.test(value) ? value.slice(0, 7) : "#3182f6",
1405
+ onInput: (e3) => onPick(e3.target.value),
1406
+ onChange: (e3) => setRecent(rememberColor(e3.target.value))
1407
+ }
1408
+ )
1409
+ ] })
1410
+ ] })
1411
+ ] });
1412
+ }
1413
+
1414
+ // src/components/hover-open.ts
1415
+ var HIDE_TIP = "fnc-hide-tip";
1416
+ var OPEN_MS = 140;
1417
+ var CLOSE_MS = 260;
1418
+ function useHoverOpen(open, onOpen, group) {
1419
+ const timer = T2(null);
1420
+ const byHover = T2(false);
1421
+ const clear = () => {
1422
+ if (timer.current) clearTimeout(timer.current);
1423
+ timer.current = null;
1424
+ };
1425
+ A2(() => {
1426
+ if (open) {
1427
+ group?.current?.dispatchEvent(new CustomEvent(HIDE_TIP, { bubbles: true }));
1428
+ return;
1429
+ }
1430
+ byHover.current = false;
1431
+ clear();
1432
+ }, [open]);
1433
+ A2(() => clear, []);
1434
+ return {
1435
+ onPointerEnter: (e3) => {
1436
+ if (e3.pointerType !== "mouse") return;
1437
+ clear();
1438
+ if (open) return;
1439
+ timer.current = setTimeout(() => {
1440
+ byHover.current = true;
1441
+ onOpen(true);
1442
+ }, OPEN_MS);
1443
+ },
1444
+ onPointerLeave: (e3) => {
1445
+ if (e3.pointerType !== "mouse") return;
1446
+ clear();
1447
+ if (!open || !byHover.current) return;
1448
+ timer.current = setTimeout(() => onOpen(false), CLOSE_MS);
1449
+ },
1450
+ /** The corner button: opens or closes the list — or, when hovering opened it, keeps it open until a click outside. */
1451
+ toggle: () => {
1452
+ clear();
1453
+ if (open && byHover.current) {
1454
+ byHover.current = false;
1455
+ return;
1456
+ }
1457
+ onOpen(!open);
1458
+ }
1459
+ };
1460
+ }
1461
+
1462
+ // src/components/keep-in-view.ts
1463
+ var MARGIN2 = 8;
1250
1464
  function useKeepInView(open) {
1251
1465
  const ref = T2(null);
1252
1466
  F2(() => {
@@ -1258,13 +1472,13 @@ function useKeepInView(open) {
1258
1472
  el.style.maxHeight = "";
1259
1473
  const r3 = el.getBoundingClientRect();
1260
1474
  const root = el.closest(".fnc-root")?.getBoundingClientRect();
1261
- const maxY = Math.min(document.documentElement.clientHeight, root?.bottom ?? Infinity) - MARGIN;
1475
+ const maxY = Math.min(document.documentElement.clientHeight, root?.bottom ?? Infinity) - MARGIN2;
1262
1476
  if (r3.bottom > maxY) {
1263
1477
  el.style.maxHeight = `${Math.max(120, Math.floor(maxY - r3.top))}px`;
1264
1478
  el.style.overflowY = "auto";
1265
1479
  }
1266
- const minX = Math.max(0, root?.left ?? 0) + MARGIN;
1267
- const maxX = Math.min(document.documentElement.clientWidth, root?.right ?? Infinity) - MARGIN;
1480
+ const minX = Math.max(0, root?.left ?? 0) + MARGIN2;
1481
+ const maxX = Math.min(document.documentElement.clientWidth, root?.right ?? Infinity) - MARGIN2;
1268
1482
  let dx = 0;
1269
1483
  if (r3.right > maxX) dx = maxX - r3.right;
1270
1484
  if (r3.left + dx < minX) dx = minX - r3.left;
@@ -1289,7 +1503,7 @@ function useBesideAnchor(open, anchor) {
1289
1503
  el.style.top = "0px";
1290
1504
  const origin = el.getBoundingClientRect();
1291
1505
  const vh = document.documentElement.clientHeight;
1292
- const top = Math.max(MARGIN, Math.min(r3.top, vh - MARGIN - el.offsetHeight));
1506
+ const top = Math.max(MARGIN2, Math.min(r3.top, vh - MARGIN2 - el.offsetHeight));
1293
1507
  el.style.left = `${Math.round(r3.right + 8 - origin.left)}px`;
1294
1508
  el.style.top = `${Math.round(top - origin.top)}px`;
1295
1509
  };
@@ -1450,8 +1664,8 @@ var EyeIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
1450
1664
  var EyeOffIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M3 3l14 14M8.2 5a8 8 0 0 1 1.8-.5c5 0 8 5.5 8 5.5a14 14 0 0 1-2.2 2.9M5.4 6.4A14 14 0 0 0 2 10s3 5.5 8 5.5a7.7 7.7 0 0 0 3.6-.9" }) });
1451
1665
  var ChevronUpIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M5 12l5-5 5 5" }) });
1452
1666
  var MagnetIcon = () => /* @__PURE__ */ a3(Icon, { children: [
1453
- /* @__PURE__ */ a3("path", { d: "M5 4h3v6.5a2 2 0 0 0 4 0V4h3v6.5a5 5 0 0 1-10 0z" }),
1454
- /* @__PURE__ */ a3("path", { d: "M5 7h3M12 7h3" })
1667
+ /* @__PURE__ */ a3("path", { d: "M3 3h4.5v7a2.5 2.5 0 0 0 5 0V3H17v7a7 7 0 0 1-14 0z" }),
1668
+ /* @__PURE__ */ a3("path", { d: "M3 3h4.5v3.2H3zM12.5 3H17v3.2h-4.5z", fill: "currentColor" })
1455
1669
  ] });
1456
1670
  var StarIcon = ({ filled = false }) => /* @__PURE__ */ a3(Icon, { size: 16, children: /* @__PURE__ */ a3(
1457
1671
  "path",
@@ -1619,6 +1833,7 @@ function ToolGroup({
1619
1833
  const name = current.name[s3.locale];
1620
1834
  const ref = T2(null);
1621
1835
  const menu = useBesideAnchor(open, ref);
1836
+ const hover = useHoverOpen(open, onOpen, ref);
1622
1837
  A2(() => {
1623
1838
  if (!open) return;
1624
1839
  const close = (e3) => !ref.current?.contains(e3.target) && onOpen(false);
@@ -1635,9 +1850,9 @@ function ToolGroup({
1635
1850
  onOpen(false);
1636
1851
  onPick(def.type);
1637
1852
  };
1638
- return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, children: [
1853
+ return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, ...tools.length > 1 ? { onPointerEnter: hover.onPointerEnter, onPointerLeave: hover.onPointerLeave } : {}, children: [
1639
1854
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": name, "aria-label": name, "aria-pressed": !!armed, onClick: () => pick(current), children: /* @__PURE__ */ a3(ToolIcon, { def: current, locale: s3.locale }) }),
1640
- tools.length > 1 && /* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.moreTools}: ${name}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => onOpen(!open), children: [
1855
+ tools.length > 1 && /* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.moreTools}: ${name}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: hover.toggle, children: [
1641
1856
  /* @__PURE__ */ a3("span", { class: "fnc-tool-corner", children: /* @__PURE__ */ a3(CornerIcon, {}) }),
1642
1857
  /* @__PURE__ */ a3("span", { class: "fnc-tool-chevron", children: /* @__PURE__ */ a3(ChevronRightIcon, {}) })
1643
1858
  ] }),
@@ -1685,6 +1900,7 @@ function CursorGroup({ ctx, open, onOpen, onPick }) {
1685
1900
  const t3 = stringsOf(s3);
1686
1901
  const ref = T2(null);
1687
1902
  const menu = useBesideAnchor(open, ref);
1903
+ const hover = useHoverOpen(open, onOpen, ref);
1688
1904
  const current = CURSORS.find((c3) => c3.mode === s3.cursorMode) ?? CURSORS[0];
1689
1905
  A2(() => {
1690
1906
  if (!open) return;
@@ -1698,9 +1914,9 @@ function CursorGroup({ ctx, open, onOpen, onPick }) {
1698
1914
  };
1699
1915
  }, [open]);
1700
1916
  const name = `${t3.cursor}: ${t3[current.label]}`;
1701
- return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, children: [
1917
+ return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, onPointerEnter: hover.onPointerEnter, onPointerLeave: hover.onPointerLeave, children: [
1702
1918
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": name, "aria-label": name, "aria-pressed": s3.drawingTool === null, onClick: onPick, children: /* @__PURE__ */ a3(current.Icon, {}) }),
1703
- /* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.cursorModes}: ${t3[current.label]}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => onOpen(!open), children: [
1919
+ /* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.cursorModes}: ${t3[current.label]}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: hover.toggle, children: [
1704
1920
  /* @__PURE__ */ a3("span", { class: "fnc-tool-corner", children: /* @__PURE__ */ a3(CornerIcon, {}) }),
1705
1921
  /* @__PURE__ */ a3("span", { class: "fnc-tool-chevron", children: /* @__PURE__ */ a3(ChevronRightIcon, {}) })
1706
1922
  ] }),
@@ -1727,6 +1943,60 @@ function CursorGroup({ ctx, open, onOpen, onPick }) {
1727
1943
  ] })
1728
1944
  ] });
1729
1945
  }
1946
+ function MagnetGroup({ ctx, open, onOpen }) {
1947
+ const s3 = useStore(ctx.store);
1948
+ const t3 = stringsOf(s3);
1949
+ const ref = T2(null);
1950
+ const menu = useBesideAnchor(open, ref);
1951
+ const hover = useHoverOpen(open, onOpen, ref);
1952
+ A2(() => {
1953
+ if (!open) return;
1954
+ const close = (e3) => !ref.current?.contains(e3.target) && onOpen(false);
1955
+ const esc = (e3) => e3.key === "Escape" && onOpen(false);
1956
+ document.addEventListener("pointerdown", close, true);
1957
+ document.addEventListener("keydown", esc);
1958
+ return () => {
1959
+ document.removeEventListener("pointerdown", close, true);
1960
+ document.removeEventListener("keydown", esc);
1961
+ };
1962
+ }, [open]);
1963
+ const strengths = [
1964
+ { mode: "weak", label: t3.magnetWeak, sub: t3.magnetWeakSub },
1965
+ { mode: "strong", label: t3.magnetStrong, sub: t3.magnetStrongSub }
1966
+ ];
1967
+ const now = strengths.find((x2) => x2.mode === (s3.magnet ? s3.magnetMode : s3.magnetStrength));
1968
+ const name = s3.magnet ? `${t3.magnet}: ${now.label}` : t3.magnet;
1969
+ return /* @__PURE__ */ a3("div", { class: "fnc-tool-group", ref, "data-open": open, onPointerEnter: hover.onPointerEnter, onPointerLeave: hover.onPointerLeave, children: [
1970
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": name, "aria-label": name, "aria-pressed": s3.magnet, "data-magnet": s3.magnet ? s3.magnetMode : "off", onClick: () => ctx.setMagnetMode(s3.magnet ? "off" : s3.magnetStrength), children: /* @__PURE__ */ a3(MagnetIcon, {}) }),
1971
+ /* @__PURE__ */ a3("button", { class: "fnc-tool-more", "aria-label": `${t3.magnetModes}: ${now.label}`, "aria-haspopup": "menu", "aria-expanded": open, onClick: hover.toggle, children: [
1972
+ /* @__PURE__ */ a3("span", { class: "fnc-tool-corner", children: /* @__PURE__ */ a3(CornerIcon, {}) }),
1973
+ /* @__PURE__ */ a3("span", { class: "fnc-tool-chevron", children: /* @__PURE__ */ a3(ChevronRightIcon, {}) })
1974
+ ] }),
1975
+ open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-tool-menu fnc-magnet-menu", role: "menu", ref: menu, children: [
1976
+ /* @__PURE__ */ a3("div", { class: "fnc-tool-section", role: "presentation", children: t3.magnetModes }),
1977
+ strengths.map((x2) => /* @__PURE__ */ a3(
1978
+ "button",
1979
+ {
1980
+ class: "fnc-menu-item fnc-magnet-item",
1981
+ role: "menuitemradio",
1982
+ "aria-checked": s3.magnet && s3.magnetMode === x2.mode,
1983
+ onClick: () => {
1984
+ ctx.setMagnetMode(x2.mode);
1985
+ onOpen(false);
1986
+ },
1987
+ children: [
1988
+ /* @__PURE__ */ a3(MagnetIcon, {}),
1989
+ /* @__PURE__ */ a3("span", { children: [
1990
+ /* @__PURE__ */ a3("b", { children: x2.label }),
1991
+ /* @__PURE__ */ a3("small", { children: x2.sub })
1992
+ ] })
1993
+ ]
1994
+ },
1995
+ x2.mode
1996
+ ))
1997
+ ] })
1998
+ ] });
1999
+ }
1730
2000
  function DrawingToolbar({ ctx }) {
1731
2001
  const s3 = useStore(ctx.store);
1732
2002
  const t3 = stringsOf(s3);
@@ -1781,7 +2051,7 @@ function DrawingToolbar({ ctx }) {
1781
2051
  onScroll: checkMore,
1782
2052
  children: [
1783
2053
  more.up && /* @__PURE__ */ a3("button", { class: "fnc-drawbar-more is-up", "aria-label": t3.moreToolsUp, onClick: () => scrollBar(-160), children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }),
1784
- /* @__PURE__ */ a3(CursorGroup, { ctx, open: openGroup === "__cursor", onOpen: (open) => setOpenGroup(open ? "__cursor" : null), onPick: () => pick(null) }),
2054
+ /* @__PURE__ */ a3(CursorGroup, { ctx, open: openGroup === "__cursor", onOpen: (open) => setOpenGroup((cur) => open ? "__cursor" : cur === "__cursor" ? null : cur), onPick: () => pick(null) }),
1785
2055
  favorites.length > 0 && /* @__PURE__ */ a3($, { children: [
1786
2056
  favorites.map((def) => /* @__PURE__ */ a3(
1787
2057
  "button",
@@ -1803,23 +2073,13 @@ function DrawingToolbar({ ctx }) {
1803
2073
  ctx,
1804
2074
  tools,
1805
2075
  open: openGroup === key,
1806
- onOpen: (open) => setOpenGroup(open ? key : null),
2076
+ onOpen: (open) => setOpenGroup((cur) => open ? key : cur === key ? null : cur),
1807
2077
  onPick: pick
1808
2078
  },
1809
2079
  key
1810
2080
  )),
1811
2081
  /* @__PURE__ */ a3("div", { class: "fnc-hsep" }),
1812
- /* @__PURE__ */ a3(
1813
- "button",
1814
- {
1815
- class: "fnc-btn",
1816
- "data-tip": t3.magnet,
1817
- "aria-label": t3.magnet,
1818
- "aria-pressed": s3.magnet,
1819
- onClick: () => ctx.chart.setMagnet(!s3.magnet),
1820
- children: /* @__PURE__ */ a3(MagnetIcon, {})
1821
- }
1822
- ),
2082
+ /* @__PURE__ */ a3(MagnetGroup, { ctx, open: openGroup === "__magnet", onOpen: (open) => setOpenGroup((cur) => open ? "__magnet" : cur === "__magnet" ? null : cur) }),
1823
2083
  /* @__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, {}) }),
1824
2084
  /* @__PURE__ */ a3(
1825
2085
  "button",
@@ -1877,7 +2137,6 @@ var SWATCHES = ["#3182F6", "#F04452", "#12B886", "#FF9F0A", "#7048E8"];
1877
2137
  var WIDTHS = [1, 2, 3, 4];
1878
2138
  var FONT_SIZES = [10, 12, 14, 16, 20, 24, 32];
1879
2139
  var DASH_ORDER = ["solid", "dashed", "dotted"];
1880
- var RECENT_KEY = "fnc-drawing-colors";
1881
2140
  var POS_KEY = "fnc-selbar-pos";
1882
2141
  var TEMPLATES_KEY = "fnc-drawing-templates";
1883
2142
  var TEMPLATES_MAX = 20;
@@ -1956,11 +2215,10 @@ function SelectionBar({ ctx }) {
1956
2215
  const t3 = stringsOf(s3);
1957
2216
  const d3 = s3.selection;
1958
2217
  const [offset, setOffset] = d2(() => readJson(POS_KEY, [0, 0]));
1959
- const [recent, setRecent] = d2(() => readJson(RECENT_KEY, []));
2218
+ const [recent, setRecent] = d2(() => recentColors().slice(0, 3));
1960
2219
  const [menu, setMenu] = d2(null);
1961
2220
  const [templates, setTemplates] = d2(() => readJson(TEMPLATES_KEY, {}));
1962
2221
  const [naming, setNaming] = d2(null);
1963
- const colorInput = T2(null);
1964
2222
  if (!d3 || s3.layout.plotWidth <= 0) return null;
1965
2223
  const def = ctx.chart.drawingDefinitions().find((x2) => x2.type === d3.type);
1966
2224
  const style = d3.style ?? {};
@@ -1985,11 +2243,6 @@ function SelectionBar({ ctx }) {
1985
2243
  setStyleRaw(rest);
1986
2244
  };
1987
2245
  const slotColor = (key, fallback) => style.colors?.[key] ?? d3.color ?? fallback;
1988
- const addRecent = (color) => {
1989
- const next = [color, ...recent.filter((c3) => c3 !== color)].slice(0, 3);
1990
- setRecent(next);
1991
- writeJson(RECENT_KEY, next);
1992
- };
1993
2246
  const locked = !!style.locked;
1994
2247
  const dash = style.dash ?? "solid";
1995
2248
  const mine = templates[d3.type] ?? [];
@@ -2006,6 +2259,14 @@ function SelectionBar({ ctx }) {
2006
2259
  setNaming(null);
2007
2260
  setMenu(null);
2008
2261
  };
2262
+ const resetLook = () => {
2263
+ const { text, locked: lock, hidden, intervals } = style;
2264
+ ctx.chart.updateDrawing(d3.id, {
2265
+ color: null,
2266
+ style: { ...text !== void 0 ? { text } : {}, ...lock ? { locked: lock } : {}, ...hidden ? { hidden } : {}, ...intervals ? { intervals } : {} }
2267
+ });
2268
+ setMenu(null);
2269
+ };
2009
2270
  const applyTemplate = (tpl) => {
2010
2271
  const { text, locked: lock, hidden } = style;
2011
2272
  ctx.chart.updateDrawing(d3.id, {
@@ -2046,36 +2307,29 @@ function SelectionBar({ ctx }) {
2046
2307
  }
2047
2308
  ),
2048
2309
  !def?.levels && !def?.plain && [...SWATCHES, ...recent.filter((c3) => !SWATCHES.includes(c3))].map((color) => /* @__PURE__ */ a3("button", { class: "fnc-swatch", style: { background: color }, "data-tip": t3.color, "aria-label": `${t3.color} ${color}`, "aria-pressed": current === color, onClick: () => pickColor(color) })),
2049
- !def?.levels && !def?.plain && /* @__PURE__ */ a3("label", { class: "fnc-swatch fnc-swatch-add", "data-tip": t3.customColor, "aria-label": t3.customColor, children: [
2050
- /* @__PURE__ */ a3("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ a3("path", { d: "M5 1.5v7M1.5 5h7", stroke: "currentColor", "stroke-width": "1.5", "stroke-linecap": "round" }) }),
2051
- /* @__PURE__ */ a3(
2052
- "input",
2053
- {
2054
- ref: colorInput,
2055
- type: "color",
2056
- value: /^#[0-9a-f]{6}$/i.test(current) ? current : "#3182f6",
2057
- onInput: (e3) => pickColor(e3.target.value),
2058
- onChange: (e3) => addRecent(e3.target.value)
2059
- }
2060
- )
2061
- ] }),
2310
+ !def?.levels && !def?.plain && /* @__PURE__ */ a3(
2311
+ ColorPicker,
2312
+ {
2313
+ class: "fnc-swatch fnc-swatch-add",
2314
+ value: current,
2315
+ label: t3.palette,
2316
+ tip: t3.palette,
2317
+ t: t3,
2318
+ onPick: (color) => {
2319
+ pickColor(color);
2320
+ setRecent(recentColors().slice(0, 3));
2321
+ },
2322
+ children: /* @__PURE__ */ a3("svg", { width: "10", height: "10", viewBox: "0 0 10 10", "aria-hidden": "true", children: /* @__PURE__ */ a3("path", { d: "M5 1.5v7M1.5 5h7", stroke: "currentColor", "stroke-width": "1.5", "stroke-linecap": "round" }) })
2323
+ }
2324
+ ),
2062
2325
  slots.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-selbar-menu", children: [
2063
2326
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "data-tip": t3.partColors, "aria-label": t3.partColors, "aria-expanded": menu === "colors", onClick: () => setMenu(menu === "colors" ? null : "colors"), children: /* @__PURE__ */ a3(PaletteIcon, {}) }),
2064
2327
  menu === "colors" && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-selbar-pop fnc-part-menu", role: "menu", children: [
2065
2328
  slots.map((slot) => {
2066
2329
  const c3 = slotColor(slot.key, slot.color);
2067
- return /* @__PURE__ */ a3("label", { class: "fnc-menu-item fnc-part", children: [
2068
- /* @__PURE__ */ a3("span", { class: "fnc-swatch", style: { background: c3 } }),
2069
- /* @__PURE__ */ a3("span", { children: slot.name[s3.locale] }),
2070
- /* @__PURE__ */ a3(
2071
- "input",
2072
- {
2073
- type: "color",
2074
- "aria-label": `${slot.name[s3.locale]} ${t3.color}`,
2075
- value: /^#[0-9a-f]{6}$/i.test(c3) ? c3 : "#3182f6",
2076
- onInput: (e3) => setStyle({ colors: { ...style.colors, [slot.key]: e3.target.value } })
2077
- }
2078
- )
2330
+ return /* @__PURE__ */ a3("div", { class: "fnc-menu-item fnc-part", children: [
2331
+ /* @__PURE__ */ a3(ColorPicker, { class: "fnc-swatch", style: { background: c3 }, value: c3, label: `${slot.name[s3.locale]} ${t3.color}`, t: t3, onPick: (color) => setStyle({ colors: { ...style.colors, [slot.key]: color } }) }),
2332
+ /* @__PURE__ */ a3("span", { children: slot.name[s3.locale] })
2079
2333
  ] });
2080
2334
  }),
2081
2335
  /* @__PURE__ */ a3(
@@ -2171,15 +2425,18 @@ function SelectionBar({ ctx }) {
2171
2425
  }
2172
2426
  }
2173
2427
  ),
2174
- /* @__PURE__ */ a3("label", { class: "fnc-swatch fnc-level-color", style: { background: l3.color }, "data-tip": t3.levelColor, children: /* @__PURE__ */ a3(
2175
- "input",
2428
+ /* @__PURE__ */ a3(
2429
+ ColorPicker,
2176
2430
  {
2177
- type: "color",
2178
- "aria-label": `${t3.levelColor} ${l3.value}`,
2179
- value: /^#[0-9a-f]{6}$/i.test(l3.color ?? "") ? l3.color : "#3182f6",
2180
- onInput: (e3) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, color: e3.target.value } : x2))
2431
+ class: "fnc-swatch fnc-level-color",
2432
+ style: { background: l3.color ?? "#3182F6" },
2433
+ tip: t3.levelColor,
2434
+ value: l3.color ?? "",
2435
+ label: `${t3.levelColor} ${l3.value}`,
2436
+ t: t3,
2437
+ onPick: (color) => setLevels(levelRows.map((x2, j2) => j2 === i3 ? { ...x2, color } : x2))
2181
2438
  }
2182
- ) }),
2439
+ ),
2183
2440
  /* @__PURE__ */ a3(
2184
2441
  "input",
2185
2442
  {
@@ -2325,7 +2582,10 @@ function SelectionBar({ ctx }) {
2325
2582
  )
2326
2583
  ] })),
2327
2584
  /* @__PURE__ */ a3("div", { class: "fnc-menu-sep" }),
2328
- naming === null ? /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: () => setNaming(""), children: t3.saveTemplate }) : /* @__PURE__ */ a3(
2585
+ naming === null ? /* @__PURE__ */ a3($, { children: [
2586
+ /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: () => setNaming(""), children: t3.saveTemplate }),
2587
+ /* @__PURE__ */ a3("button", { class: "fnc-menu-item", role: "menuitem", onClick: resetLook, children: t3.resetDrawingLook })
2588
+ ] }) : /* @__PURE__ */ a3(
2329
2589
  "input",
2330
2590
  {
2331
2591
  class: "fnc-selbar-text fnc-template-name",
@@ -2398,13 +2658,14 @@ function SelectionBar({ ctx }) {
2398
2658
  ),
2399
2659
  /* @__PURE__ */ a3("div", { class: "fnc-note-row", children: [
2400
2660
  /* @__PURE__ */ a3(
2401
- "input",
2661
+ ColorPicker,
2402
2662
  {
2403
- type: "color",
2404
- class: "fnc-color",
2405
- "aria-label": t3.textColor,
2406
- value: /^#[0-9a-f]{6}$/i.test(style.textColor ?? d3.color ?? "") ? style.textColor ?? d3.color : "#3182f6",
2407
- onInput: (e3) => setStyle({ textColor: e3.target.value })
2663
+ class: "fnc-color fnc-color-btn",
2664
+ style: { background: style.textColor ?? d3.color ?? "#3182F6" },
2665
+ value: style.textColor ?? d3.color ?? "",
2666
+ label: t3.textColor,
2667
+ t: t3,
2668
+ onPick: (textColor) => setStyle({ textColor })
2408
2669
  }
2409
2670
  ),
2410
2671
  /* @__PURE__ */ a3("select", { class: "fnc-select", "aria-label": t3.fontSize, value: String(style.fontSize ?? 14), onChange: (e3) => setStyle({ fontSize: Number(e3.target.value) }), children: [10, 11, 12, 14, 16, 20, 24, 28, 32, 40].map((n2) => /* @__PURE__ */ a3("option", { value: String(n2), children: [
@@ -2735,14 +2996,14 @@ var PRECISIONS = [0, 1, 2, 3, 4, 5, 6, 7, 8];
2735
2996
  var TIMEFRAMES = ["3", "5", "15", "30", "60", "120", "240", "1D", "1W", "1M"];
2736
2997
  var hex6 = (c3) => /^#[0-9a-f]{6}/i.test(c3) ? c3.slice(0, 7) : "#3182f6";
2737
2998
  var alphaOf = (c3) => /^#[0-9a-f]{8}$/i.test(c3) ? Math.round(parseInt(c3.slice(7, 9), 16) / 255 * 100) : 100;
2738
- var withAlpha = (hex, pct) => {
2739
- const base = hex6(hex);
2999
+ var withAlpha = (hex2, pct) => {
3000
+ const base = hex6(hex2);
2740
3001
  return pct >= 100 ? base : `${base}${Math.round(Math.max(0, pct) / 100 * 255).toString(16).padStart(2, "0")}`;
2741
3002
  };
2742
- function ColorField({ value, label, onChange }) {
3003
+ function ColorField({ value, label, t: t3, onChange }) {
2743
3004
  const pct = alphaOf(value);
2744
3005
  return /* @__PURE__ */ a3("span", { class: "fnc-color-field", children: [
2745
- /* @__PURE__ */ a3("input", { type: "color", class: "fnc-color", value: hex6(value), "aria-label": label, onInput: (e3) => onChange(withAlpha(e3.currentTarget.value, pct)) }),
3006
+ /* @__PURE__ */ a3(ColorPicker, { class: "fnc-color fnc-color-btn", style: { background: hex6(value) }, value: hex6(value), label, t: t3, onPick: (c3) => onChange(withAlpha(c3, pct)) }),
2746
3007
  /* @__PURE__ */ a3(
2747
3008
  "input",
2748
3009
  {
@@ -2976,7 +3237,7 @@ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
2976
3237
  /* @__PURE__ */ a3("div", { class: "fnc-rows", children: rows.map((r3, i3) => /* @__PURE__ */ a3("div", { class: "fnc-row fnc-style-row", children: [
2977
3238
  /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: r3.visible, "aria-label": r3.visible ? t3.hide : t3.show, onChange: (e3) => patchRow(i3, { visible: e3.currentTarget.checked }) }),
2978
3239
  /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", title: r3.label, children: r3.label }),
2979
- /* @__PURE__ */ a3(ColorField, { value: /^#[0-9a-f]{6}/i.test(r3.color) ? r3.color : hex6(r3.color), label: t3.color, onChange: (color) => patchRow(i3, { color }) }),
3240
+ /* @__PURE__ */ a3(ColorField, { t: t3, value: /^#[0-9a-f]{6}/i.test(r3.color) ? r3.color : hex6(r3.color), label: t3.color, onChange: (color) => patchRow(i3, { color }) }),
2980
3241
  /* @__PURE__ */ a3("select", { class: "fnc-select fnc-select-width", value: r3.width, "aria-label": t3.lineWidth, onChange: (e3) => patchRow(i3, { width: Number(e3.currentTarget.value) }), children: WIDTHS2.map((w3) => /* @__PURE__ */ a3("option", { value: w3, children: [
2981
3242
  w3,
2982
3243
  "px"
@@ -2988,7 +3249,7 @@ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
2988
3249
  hasLevels && /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2989
3250
  /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: display.levels !== false, "aria-label": t3.indLevels, onChange: (e3) => setD({ levels: e3.currentTarget.checked ? void 0 : false }) }),
2990
3251
  /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.indLevels }),
2991
- /* @__PURE__ */ a3(ColorField, { value: display.levelColor ?? "#8b95a1", label: t3.color, onChange: (levelColor) => setD({ levelColor }) })
3252
+ /* @__PURE__ */ a3(ColorField, { t: t3, value: display.levelColor ?? "#8b95a1", label: t3.color, onChange: (levelColor) => setD({ levelColor }) })
2992
3253
  ] }),
2993
3254
  hasLevels && display.levels !== false && /* @__PURE__ */ a3("div", { class: "fnc-row fnc-level-values", children: [
2994
3255
  /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.levelValuesLabel }),
@@ -3006,8 +3267,8 @@ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
3006
3267
  const n2 = Number(e3.currentTarget.value);
3007
3268
  const next = probe.levels.map((x2, j2) => display.levelValues?.[j2] ?? (typeof x2 === "number" ? x2 : x2.value));
3008
3269
  next[i3] = Number.isFinite(n2) ? n2 : own;
3009
- const same = next.every((x2, j2) => x2 === (typeof probe.levels[j2] === "number" ? probe.levels[j2] : probe.levels[j2].value));
3010
- setD({ levelValues: same ? void 0 : next });
3270
+ const same2 = next.every((x2, j2) => x2 === (typeof probe.levels[j2] === "number" ? probe.levels[j2] : probe.levels[j2].value));
3271
+ setD({ levelValues: same2 ? void 0 : next });
3011
3272
  }
3012
3273
  },
3013
3274
  `${i3}:${v3 ?? own}`
@@ -3017,7 +3278,7 @@ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
3017
3278
  hasFill && /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
3018
3279
  /* @__PURE__ */ a3("input", { type: "checkbox", class: "fnc-check", checked: display.fill !== false, "aria-label": t3.fillBand, onChange: (e3) => setD({ fill: e3.currentTarget.checked ? void 0 : false }) }),
3019
3280
  /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: t3.fillBand }),
3020
- /* @__PURE__ */ a3(ColorField, { value: display.fillColor ?? (/^#[0-9a-f]{6}$/i.test(probe.fill?.color ?? "") ? `${probe.fill.color}26` : "#3182f626"), label: t3.color, onChange: (fillColor) => setD({ fillColor }) })
3281
+ /* @__PURE__ */ a3(ColorField, { t: t3, value: display.fillColor ?? (/^#[0-9a-f]{6}$/i.test(probe.fill?.color ?? "") ? `${probe.fill.color}26` : "#3182f626"), label: t3.color, onChange: (fillColor) => setD({ fillColor }) })
3021
3282
  ] })
3022
3283
  ] }),
3023
3284
  /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.outputValues }),
@@ -3784,7 +4045,6 @@ var CSS = (
3784
4045
  }
3785
4046
  .fnc-tip[data-side='bottom'] { transform: translateY(-4px); }
3786
4047
  .fnc-tip[data-side='top'] { transform: translateY(4px); }
3787
- .fnc-tip[data-side='right'] { transform: translateX(-4px); }
3788
4048
  .fnc-tip.is-on {
3789
4049
  opacity: 1;
3790
4050
  visibility: visible;
@@ -4182,7 +4442,16 @@ var CSS = (
4182
4442
  .fnc-btn-label span { display: none; }
4183
4443
  .fnc-toolbar .fnc-btn-label { padding: 0 6px; }
4184
4444
  }
4445
+ /* A narrower widget (beside a book and an order panel): the pinned intervals stay, as a strip that
4446
+ scrolls sideways and gives up room before the buttons do; phones (\u2264 480px) keep only the menu. */
4185
4447
  @container fnc (max-width: 940px) {
4448
+ .fnc-interval-picker { flex: 0 1 auto; min-width: 88px; }
4449
+ .fnc-intervals { flex: 0 1 auto; }
4450
+ .fnc-chip { padding: 0 8px; }
4451
+ /* The host's toolbar content (market stats) gives up its room first. */
4452
+ .fnc-toolbar > .fnc-slot-host:not(.fnc-slot-host-fixed) { flex-shrink: 100; }
4453
+ }
4454
+ @container fnc (max-width: 480px) {
4186
4455
  .fnc-intervals { display: none; }
4187
4456
  .fnc-interval-current { display: inline; }
4188
4457
  }
@@ -4746,6 +5015,46 @@ var CSS = (
4746
5015
  .fnc-rows .fnc-input-period { order: 11; }
4747
5016
  .fnc-rows .fnc-ind-btn { margin-left: auto; }
4748
5017
  }
5018
+
5019
+ /* \u2500\u2500 \uC0C9 \uACE0\uB974\uAE30 (color-picker.tsx): a board of ready colors, the recent ones, and the browser's picker \u2500\u2500 */
5020
+ .fnc-palette-wrap { display: inline-flex; flex: none; }
5021
+ .fnc-palette-wrap > button { padding: 0; border: 0; font: inherit; }
5022
+ .fnc-palette-wrap > .fnc-swatch { border-radius: 50%; cursor: pointer; }
5023
+ .fnc-palette {
5024
+ position: fixed;
5025
+ z-index: 60;
5026
+ display: flex;
5027
+ flex-direction: column;
5028
+ gap: 6px;
5029
+ width: max-content;
5030
+ padding: 10px;
5031
+ border-radius: 12px;
5032
+ background: var(--fnc-bg);
5033
+ color: var(--fnc-text);
5034
+ box-shadow: 0 8px 28px rgb(0 0 0 / 0.16), 0 0 0 1px var(--fnc-border);
5035
+ cursor: default;
5036
+ }
5037
+ .fnc-palette-grid { display: grid; grid-template-columns: repeat(10, 20px); gap: 4px; }
5038
+ .fnc-palette-cell { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px; cursor: pointer; box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.22); }
5039
+ .fnc-palette-cell:hover { transform: scale(1.12); }
5040
+ .fnc-palette-cell[aria-selected='true'] { box-shadow: 0 0 0 2px var(--fnc-bg), 0 0 0 4px var(--fnc-text); }
5041
+ .fnc-palette-cell:focus-visible { outline: 2px solid var(--fnc-accent); outline-offset: 1px; }
5042
+ .fnc-palette-title { padding-top: 4px; font-size: 11px; font-weight: 600; color: var(--fnc-text-2); }
5043
+ .fnc-palette-custom { position: relative; display: flex; align-items: center; gap: 8px; height: 32px; margin-top: 2px; padding: 0 8px; border-top: 1px solid var(--fnc-border); font-size: 13px; color: var(--fnc-text); cursor: pointer; }
5044
+ .fnc-palette-custom:hover { background: var(--fnc-surface); border-radius: 8px; }
5045
+ .fnc-palette-custom-chip { width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgb(127 127 127 / 0.3); }
5046
+ .fnc-palette-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
5047
+ .fnc-color-btn { box-shadow: inset 0 0 0 3px var(--fnc-bg); }
5048
+ .fnc-part { gap: 10px; }
5049
+
5050
+ /* \uC790\uC11D \uC138\uAE30: two lines each (name, what it does). */
5051
+ .fnc-magnet-item { align-items: flex-start; white-space: normal; }
5052
+ .fnc-magnet-item > svg { flex: none; margin-top: 2px; }
5053
+ .fnc-magnet-item > span { display: flex; flex-direction: column; gap: 2px; }
5054
+ .fnc-magnet-item b { font-weight: 600; }
5055
+ .fnc-magnet-item small { font-size: 12px; color: var(--fnc-text-2); }
5056
+ .fnc-magnet-menu { min-width: 260px; }
5057
+ .fnc-tool-menu .fnc-magnet-item { white-space: normal; }
4749
5058
  `
4750
5059
  );
4751
5060
  var STYLE_ID = "fnc-styles";
@@ -4794,10 +5103,10 @@ function bindTooltips(root) {
4794
5103
  const h3 = tip.offsetHeight;
4795
5104
  const vw = window.innerWidth;
4796
5105
  const vh = window.innerHeight;
4797
- let side = el.closest(".fnc-drawbar") ? "right" : el.closest(".fnc-nav") ? "top" : "bottom";
5106
+ let side = el.closest(".fnc-nav") ? "top" : "bottom";
4798
5107
  if (side === "bottom" && r3.bottom + h3 + 10 > vh) side = "top";
4799
- let left = side === "right" ? r3.right + 8 : r3.left + r3.width / 2 - w3 / 2;
4800
- const top = side === "right" ? r3.top + r3.height / 2 - h3 / 2 : side === "top" ? r3.top - h3 - 6 : r3.bottom + 6;
5108
+ let left = el.closest(".fnc-drawbar") ? r3.left : r3.left + r3.width / 2 - w3 / 2;
5109
+ const top = side === "top" ? r3.top - h3 - 6 : r3.bottom + 6;
4801
5110
  left = Math.max(4, Math.min(vw - w3 - 4, left));
4802
5111
  tip.style.left = `${Math.round(left)}px`;
4803
5112
  tip.style.top = `${Math.round(top)}px`;
@@ -4805,7 +5114,7 @@ function bindTooltips(root) {
4805
5114
  };
4806
5115
  const show = (el) => {
4807
5116
  const text = el.dataset.tip;
4808
- if (!text || !el.isConnected) return;
5117
+ if (!text || !el.isConnected || el.closest('.fnc-tool-group[data-open="true"]')) return;
4809
5118
  tip.textContent = text;
4810
5119
  el.setAttribute("aria-describedby", tip.id);
4811
5120
  place(el);
@@ -4841,6 +5150,7 @@ function bindTooltips(root) {
4841
5150
  root.addEventListener("wheel", hide, { passive: true });
4842
5151
  root.addEventListener("focusin", onFocus);
4843
5152
  root.addEventListener("focusout", hide);
5153
+ root.addEventListener("fnc-hide-tip", hide);
4844
5154
  return () => {
4845
5155
  hide();
4846
5156
  root.removeEventListener("pointerover", onOver);
@@ -4849,6 +5159,7 @@ function bindTooltips(root) {
4849
5159
  root.removeEventListener("wheel", hide);
4850
5160
  root.removeEventListener("focusin", onFocus);
4851
5161
  root.removeEventListener("focusout", hide);
5162
+ root.removeEventListener("fnc-hide-tip", hide);
4852
5163
  tip.remove();
4853
5164
  };
4854
5165
  }
@@ -4899,11 +5210,19 @@ function createShell(container, options) {
4899
5210
  let keepDrawing = storage.get("keep-drawing", false);
4900
5211
  let drawingDefaults = storage.get("drawing-defaults", {});
4901
5212
  let cursorMode = storage.get("cursor-mode", "cross");
5213
+ const isMagnet = (m3) => m3 === "off" || m3 === "weak" || m3 === "strong";
5214
+ let magnetMode = isMagnet(storage.get("magnet", "off")) ? storage.get("magnet", "off") : "off";
5215
+ let magnetStrength = storage.get("magnet-strength", "strong") === "weak" ? "weak" : "strong";
5216
+ const magnetState = () => ({ magnet: magnetMode !== "off", magnetMode, magnetStrength });
5217
+ const applyMagnet = () => {
5218
+ for (const p3 of panes()) p3.chart.setMagnetMode(magnetMode);
5219
+ broadcast(magnetState());
5220
+ };
4902
5221
  const broadcast = (patch) => {
4903
5222
  for (const p3 of panes()) p3.store.set(patch);
4904
5223
  };
4905
5224
  const prefListeners = /* @__PURE__ */ new Set();
4906
- const prefs = () => ({ favoriteIntervals: [...favoriteIntervals], customIntervals: [...customIntervals], favoriteTools: [...favoriteTools], keepDrawing, drawingDefaults: { ...drawingDefaults }, cursorMode });
5225
+ const prefs = () => ({ favoriteIntervals: [...favoriteIntervals], customIntervals: [...customIntervals], favoriteTools: [...favoriteTools], keepDrawing, drawingDefaults: { ...drawingDefaults }, cursorMode, magnet: magnetMode, magnetStrength });
4907
5226
  const changed = () => {
4908
5227
  const now = prefs();
4909
5228
  for (const l3 of prefListeners) l3(now);
@@ -4926,7 +5245,15 @@ function createShell(container, options) {
4926
5245
  slots,
4927
5246
  storage,
4928
5247
  theme: () => theme,
4929
- sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, customIntervals, drawbarCollapsed, favoriteTools, keepDrawing, cursorMode }),
5248
+ sharedState: () => ({ fullscreen: isFullscreen(), favoriteIntervals, customIntervals, drawbarCollapsed, favoriteTools, keepDrawing, cursorMode, ...magnetState() }),
5249
+ setMagnetMode: (mode) => {
5250
+ if (!isMagnet(mode)) return;
5251
+ magnetMode = mode;
5252
+ storage.set("magnet", mode);
5253
+ if (mode !== "off") storage.set("magnet-strength", magnetStrength = mode);
5254
+ applyMagnet();
5255
+ changed();
5256
+ },
4930
5257
  setCursorMode: (mode) => {
4931
5258
  cursorMode = mode;
4932
5259
  storage.set("cursor-mode", mode);
@@ -5026,7 +5353,12 @@ function createShell(container, options) {
5026
5353
  storage.set("cursor-mode", cursorMode = patch.cursorMode);
5027
5354
  for (const p3 of panes()) p3.chart.setCursorMode(cursorMode);
5028
5355
  }
5029
- broadcast({ favoriteIntervals, customIntervals, favoriteTools, keepDrawing, cursorMode });
5356
+ if (patch.magnetStrength === "weak" || patch.magnetStrength === "strong") storage.set("magnet-strength", magnetStrength = patch.magnetStrength);
5357
+ if (isMagnet(patch.magnet)) {
5358
+ storage.set("magnet", magnetMode = patch.magnet);
5359
+ applyMagnet();
5360
+ }
5361
+ broadcast({ favoriteIntervals, customIntervals, favoriteTools, keepDrawing, cursorMode, ...magnetState() });
5030
5362
  },
5031
5363
  onPreferences: (listener) => {
5032
5364
  prefListeners.add(listener);
@@ -5184,7 +5516,7 @@ function SettingsDialog({ ctx }) {
5184
5516
  const colorRow = ({ key, label, shown: shown2, seeThrough }) => /* @__PURE__ */ a3("div", { class: "fnc-row fnc-color-row", children: [
5185
5517
  /* @__PURE__ */ a3("span", { class: "fnc-toggle-label", children: t3[label] }),
5186
5518
  settings[key] && /* @__PURE__ */ a3("button", { type: "button", class: "fnc-color-reset", title: t3.followTheme, "aria-label": `${t3[label]} ${t3.followTheme}`, onClick: () => set({ [key]: null }), children: /* @__PURE__ */ a3(ResetIcon, {}) }),
5187
- /* @__PURE__ */ a3(Swatch, { label: t3[label], color: toHex(shown2(palette)), seeThrough, onPick: (c3) => set({ [key]: c3 }) })
5519
+ /* @__PURE__ */ a3(Swatch, { t: t3, label: t3[label], color: toHex(shown2(palette)), seeThrough, onPick: (c3) => set({ [key]: c3 }) })
5188
5520
  ] });
5189
5521
  const tabs = [
5190
5522
  ["look", t3.settingsTabLook],
@@ -5220,6 +5552,25 @@ function SettingsDialog({ ctx }) {
5220
5552
  hint && /* @__PURE__ */ a3(Info, { text: t3[hint] }),
5221
5553
  /* @__PURE__ */ a3("input", { type: "checkbox", role: "switch", class: "fnc-switch", checked: settings[key], onChange: (e3) => setRow(key, e3.currentTarget.checked) })
5222
5554
  ] }));
5555
+ const [autoScale, setAutoScale] = d2(() => ctx.chart.priceAutoScale);
5556
+ const autoScaleRow = /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
5557
+ /* @__PURE__ */ a3("span", { class: "fnc-toggle-label", children: t3.settingAutoScale }),
5558
+ /* @__PURE__ */ a3(Info, { text: t3.hintAutoScale }),
5559
+ /* @__PURE__ */ a3(
5560
+ "input",
5561
+ {
5562
+ type: "checkbox",
5563
+ role: "switch",
5564
+ class: "fnc-switch",
5565
+ checked: autoScale,
5566
+ disabled: settings.lockView,
5567
+ onChange: (e3) => {
5568
+ ctx.chart.setPriceAutoScale(e3.currentTarget.checked);
5569
+ setAutoScale(ctx.chart.priceAutoScale);
5570
+ }
5571
+ }
5572
+ )
5573
+ ] });
5223
5574
  const anchor = T2(null);
5224
5575
  const layer = usePageLayer(anchor, settings);
5225
5576
  const dialog = /* @__PURE__ */ a3("div", { class: "fnc-backdrop", onPointerDown: (e3) => e3.target === e3.currentTarget && close(), children: /* @__PURE__ */ a3("div", { class: "fnc-dialog fnc-settings-dialog", role: "dialog", "aria-modal": "true", "aria-label": t3.chartSettings, onKeyDown: (e3) => e3.key === "Escape" && close(), children: [
@@ -5279,8 +5630,8 @@ function SettingsDialog({ ctx }) {
5279
5630
  ]
5280
5631
  }
5281
5632
  ),
5282
- /* @__PURE__ */ a3(Swatch, { label: t3.settingBackground, color: toHex(palette.background), onPick: (c3) => set({ background: c3 }) }),
5283
- settings.backgroundStyle === "gradient" && /* @__PURE__ */ a3(Swatch, { label: t3.bgGradientBottom, color: toHex(palette.backgroundBottom ?? palette.background), onPick: (c3) => set({ backgroundBottom: c3 }) })
5633
+ /* @__PURE__ */ a3(Swatch, { t: t3, label: t3.settingBackground, color: toHex(palette.background), onPick: (c3) => set({ background: c3 }) }),
5634
+ settings.backgroundStyle === "gradient" && /* @__PURE__ */ a3(Swatch, { t: t3, label: t3.bgGradientBottom, color: toHex(palette.backgroundBottom ?? palette.background), onPick: (c3) => set({ backgroundBottom: c3 }) })
5284
5635
  ] }),
5285
5636
  CHART_COLORS.map(colorRow),
5286
5637
  /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsCandles }),
@@ -5293,6 +5644,7 @@ function SettingsDialog({ ctx }) {
5293
5644
  shown === "scale" && /* @__PURE__ */ a3($, { children: [
5294
5645
  /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsAxis }),
5295
5646
  /* @__PURE__ */ a3("div", { class: "fnc-seg fnc-settings-seg", role: "radiogroup", "aria-label": t3.settingsScale, children: SCALES.map(({ mode, label }) => /* @__PURE__ */ a3("button", { type: "button", role: "radio", "aria-checked": settings.priceScale === mode, onClick: () => set({ priceScale: mode }), children: t3[label] })) }),
5647
+ autoScaleRow,
5296
5648
  toggles(AXIS_ROWS),
5297
5649
  /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsPriceMarks }),
5298
5650
  toggles(PRICE_MARK_ROWS),
@@ -5384,11 +5736,8 @@ function usePageLayer(anchor, settings) {
5384
5736
  }, [layer, settings]);
5385
5737
  return layer;
5386
5738
  }
5387
- function Swatch({ label, color, seeThrough, onPick }) {
5388
- return /* @__PURE__ */ a3("label", { class: seeThrough ? "fnc-swatch-pick is-see-through" : "fnc-swatch-pick", title: label, children: [
5389
- /* @__PURE__ */ a3("span", { style: { background: color } }),
5390
- /* @__PURE__ */ a3("input", { type: "color", "aria-label": label, value: color, onInput: (e3) => onPick(e3.currentTarget.value) })
5391
- ] });
5739
+ function Swatch({ label, color, seeThrough, t: t3, onPick }) {
5740
+ return /* @__PURE__ */ a3(ColorPicker, { class: seeThrough ? "fnc-swatch-pick is-see-through" : "fnc-swatch-pick", tip: label, value: color, label, t: t3, onPick, children: /* @__PURE__ */ a3("span", { style: { background: color } }) });
5392
5741
  }
5393
5742
  function Info({ text }) {
5394
5743
  return /* @__PURE__ */ a3("span", { class: "fnc-info", tabIndex: 0, role: "img", "aria-label": text, onClick: (e3) => e3.preventDefault(), children: [
@@ -5730,8 +6079,24 @@ function IntervalPicker({ ctx }) {
5730
6079
  setOpen(false);
5731
6080
  ctx.selectResolution(r3);
5732
6081
  };
6082
+ const strip = T2(null);
6083
+ F2(() => {
6084
+ const el = strip.current;
6085
+ if (!el) return;
6086
+ const reveal = () => {
6087
+ const on = el.querySelector('[aria-pressed="true"]');
6088
+ if (!on || el.scrollWidth <= el.clientWidth) return;
6089
+ const left = on.offsetLeft - el.offsetLeft;
6090
+ if (left < el.scrollLeft) el.scrollLeft = left;
6091
+ else if (left + on.offsetWidth > el.scrollLeft + el.clientWidth) el.scrollLeft = left + on.offsetWidth - el.clientWidth;
6092
+ };
6093
+ reveal();
6094
+ const ro = new ResizeObserver(reveal);
6095
+ ro.observe(el);
6096
+ return () => ro.disconnect();
6097
+ }, [s3.resolution, chips.join(",")]);
5733
6098
  return /* @__PURE__ */ a3("div", { class: "fnc-interval-picker", ref, children: [
5734
- /* @__PURE__ */ a3("div", { class: "fnc-intervals", children: chips.map((r3) => /* @__PURE__ */ a3(
6099
+ /* @__PURE__ */ a3("div", { class: "fnc-intervals", ref: strip, children: chips.map((r3) => /* @__PURE__ */ a3(
5735
6100
  "button",
5736
6101
  {
5737
6102
  class: favorites.includes(r3) ? "fnc-chip" : "fnc-chip fnc-chip-extra",
@@ -6534,7 +6899,7 @@ function MenuIcon({ name }) {
6534
6899
  }
6535
6900
 
6536
6901
  // src/components/context-menu.tsx
6537
- var MARGIN2 = 8;
6902
+ var MARGIN3 = 8;
6538
6903
  function ContextMenu({ ctx }) {
6539
6904
  const s3 = useStore(ctx.store);
6540
6905
  const t3 = stringsOf(s3);
@@ -6564,8 +6929,8 @@ function ContextMenu({ ctx }) {
6564
6929
  const w3 = el.offsetWidth;
6565
6930
  const h3 = el.offsetHeight;
6566
6931
  const { width, height } = stage.getBoundingClientRect();
6567
- const x2 = target.x + w3 + MARGIN2 > width ? Math.max(MARGIN2, target.x - w3) : target.x;
6568
- const y3 = target.y + h3 + MARGIN2 > height ? Math.max(MARGIN2, target.y - h3) : target.y;
6932
+ const x2 = target.x + w3 + MARGIN3 > width ? Math.max(MARGIN3, target.x - w3) : target.x;
6933
+ const y3 = target.y + h3 + MARGIN3 > height ? Math.max(MARGIN3, target.y - h3) : target.y;
6569
6934
  el.style.transform = `translate(${Math.round(x2)}px, ${Math.round(y3)}px)`;
6570
6935
  }, [target]);
6571
6936
  if (!target) return null;
@@ -7207,6 +7572,7 @@ function createPane(shell, config) {
7207
7572
  chart.setChartType(config.chartType);
7208
7573
  chart.setKeepDrawingTool(shell.sharedState().keepDrawing);
7209
7574
  chart.setCursorMode(shell.sharedState().cursorMode);
7575
+ chart.setMagnetMode(shell.sharedState().magnetMode);
7210
7576
  chart.setDrawingDefaults(shell.drawingDefaults());
7211
7577
  const canvasVars = (s3) => {
7212
7578
  const muted = s3.textColor && /^#[0-9a-f]{6}$/i.test(s3.textColor) ? `${s3.textColor}99` : null;
@@ -7249,7 +7615,6 @@ function createPane(shell, config) {
7249
7615
  drawingCount: 0,
7250
7616
  drawingsLocked: false,
7251
7617
  drawbarOpen: false,
7252
- magnet: chart.magnetEnabled,
7253
7618
  drawingsHidden: chart.drawingsHidden,
7254
7619
  indicators: chart.getIndicators(),
7255
7620
  dialog: null,
@@ -7266,7 +7631,7 @@ function createPane(shell, config) {
7266
7631
  chart.on("selectionChange", (selection) => store.set({ selection })),
7267
7632
  chart.on("drawingsChange", (drawings) => store.set({ drawingCount: drawings.length, drawingsLocked: drawings.length > 0 && drawings.every((d3) => d3.style?.locked) })),
7268
7633
  chart.on("indicatorsChange", (indicators) => store.set({ indicators })),
7269
- chart.on("magnetChange", (magnet) => store.set({ magnet })),
7634
+ chart.on("magnetModeChange", (magnetMode) => store.set({ magnet: magnetMode !== "off", magnetMode })),
7270
7635
  chart.on("drawingsHiddenChange", (drawingsHidden) => store.set({ drawingsHidden })),
7271
7636
  chart.on("cursorModeChange", (cursorMode) => store.set({ cursorMode })),
7272
7637
  // A color or style picked for a drawing: remembered for the tool, in every pane.
@@ -7321,6 +7686,7 @@ function createPane(shell, config) {
7321
7686
  toggleFavoriteTool: shell.toggleFavoriteTool,
7322
7687
  setKeepDrawing: shell.setKeepDrawing,
7323
7688
  setCursorMode: shell.setCursorMode,
7689
+ setMagnetMode: shell.setMagnetMode,
7324
7690
  setDrawingsHidden: shell.setDrawingsHidden,
7325
7691
  setSearchOpen: (open, target = "symbol") => store.set(open ? { searchOpen: true, searchTarget: target } : { searchOpen: false }),
7326
7692
  screenshot: () => {
package/dist/shell.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { type CursorMode, type DirectionPreset, type DrawingDefaults, type DrawingType, type Resolution, type ThemeTokens } from '@funnest/charts';
1
+ import { type CursorMode, type DirectionPreset, type DrawingDefaults, type DrawingType, type MagnetMode, type Resolution, type ThemeTokens } from '@funnest/charts';
2
2
  import type { UiState } from './context.js';
3
3
  import { type WidgetStorage } from './storage.js';
4
4
  import type { Store } from './store.js';
5
5
  export type ColorScheme = 'light' | 'dark' | 'system';
6
6
  /**
7
7
  * A person's widget preferences (what follows them, not the device): pinned and added intervals,
8
- * favorite drawing tools, keep-drawing, each tool's last style, the cursor. `preferences()` reads
8
+ * favorite drawing tools, keep-drawing, each tool's last style and settings, the cursor, the magnet. `preferences()` reads
9
9
  * them, `setPreferences()` puts them (another device's), and `preferencesChange` tells when they
10
10
  * change here — so an app can keep them on its users' accounts.
11
11
  */
@@ -16,6 +16,10 @@ export interface WidgetPreferences {
16
16
  keepDrawing: boolean;
17
17
  drawingDefaults: DrawingDefaults;
18
18
  cursorMode: CursorMode;
19
+ /** 자석: off, weak or strong (kept, so it's on again after a reload). */
20
+ magnet: MagnetMode;
21
+ /** The strength the magnet button turns on with (the last one picked). */
22
+ magnetStrength: 'weak' | 'strong';
19
23
  }
20
24
  /**
21
25
  * Empty elements inside the widget layout where the host app mounts its own UI (any framework):
@@ -48,6 +52,7 @@ export interface ShellPane {
48
52
  setDrawingsHidden(hidden: boolean): void;
49
53
  setDrawingDefaults(defaults: DrawingDefaults): void;
50
54
  setCursorMode(mode: CursorMode): void;
55
+ setMagnetMode(mode: MagnetMode): void;
51
56
  };
52
57
  }
53
58
  export interface ShellOptions {
@@ -78,8 +83,10 @@ export interface Shell {
78
83
  readonly storage: WidgetStorage;
79
84
  theme(): ThemeTokens;
80
85
  /** Initial UI-state fields owned by the shell (same for every pane). */
81
- sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'customIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing' | 'cursorMode'>;
86
+ sharedState(): Pick<UiState, 'fullscreen' | 'favoriteIntervals' | 'customIntervals' | 'drawbarCollapsed' | 'favoriteTools' | 'keepDrawing' | 'cursorMode' | 'magnet' | 'magnetMode' | 'magnetStrength'>;
82
87
  setCursorMode(mode: CursorMode): void;
88
+ /** 자석 for every pane (kept). */
89
+ setMagnetMode(mode: MagnetMode): void;
83
90
  /** Each tool's last color / style (saved; every pane starts with it). */
84
91
  drawingDefaults(): DrawingDefaults;
85
92
  saveDrawingDefaults(defaults: DrawingDefaults): void;
@@ -105,8 +112,8 @@ export interface Shell {
105
112
  /**
106
113
  * One tooltip per widget for every element with `data-tip` (instead of native `title`, whose look
107
114
  * and delay can't be styled). Shows after 350ms of hover or on keyboard focus; moving between
108
- * tipped elements shows the next one at once. Sides: right of the drawing bar, above the
109
- * navigation buttons, otherwise below (flipped up near the bottom edge).
115
+ * tipped elements shows the next one at once. Below the element (the drawing bar's too: its tool
116
+ * lists open to the right), above the navigation buttons, flipped up near the bottom edge.
110
117
  */
111
118
  /** Hover / focus tips for every [data-tip] inside `root` (the widget, or a dialog's page layer). */
112
119
  export declare function bindTooltips(root: HTMLElement): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.11.34",
3
+ "version": "0.11.36",
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.34"
45
+ "@funnest/charts": "0.11.36"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"