@funnest/charts-ui 0.8.2 → 0.8.4

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,9 @@
1
+ import type { WidgetContext } from '../context.js';
2
+ /**
3
+ * 날짜로 이동 (from the right-click menu): a date — typed, or picked on a month calendar (‹ › a
4
+ * month, « » a year) — and 이동. Older history is loaded first when the date is before what's
5
+ * on the chart; the view keeps its zoom, centered on that day.
6
+ */
7
+ export declare function GoToDateDialog({ ctx }: {
8
+ ctx: WidgetContext;
9
+ }): import("preact").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { WidgetContext } from '../context.js';
2
+ /**
3
+ * The + at the right edge of the plot, on the crosshair's price (mouse only, like most chart
4
+ * sites): a menu of what to do at that price — the app's rows (`priceAxisActions`: an alert…)
5
+ * and a horizontal line. The button holds still while the pointer is on it or its menu is open.
6
+ */
7
+ export declare function PriceAxisPlus({ ctx }: {
8
+ ctx: WidgetContext;
9
+ }): import("preact").JSX.Element | null;
package/dist/context.d.ts CHANGED
@@ -34,6 +34,8 @@ export interface UiState {
34
34
  id: string;
35
35
  } | {
36
36
  kind: 'chartSettings';
37
+ } | {
38
+ kind: 'goToDate';
37
39
  } | null;
38
40
  /** Intervals pinned as toolbar chips (★ in the interval menu). */
39
41
  favoriteIntervals: Resolution[];
@@ -61,12 +63,34 @@ export type ContextMenuItem = {
61
63
  label: string;
62
64
  shortcut?: string;
63
65
  disabled?: boolean;
66
+ /** 'alert': a bell before the label. */
67
+ icon?: 'alert';
68
+ /** A setting that's on or off: a check mark, and it reads as a checkbox. */
69
+ checked?: boolean;
64
70
  onSelect(): void;
65
71
  } | 'separator';
66
72
  /** Extra right-click items for a click on `chart` (e.g. "create an alert at this price"). */
67
73
  export type ContextMenuItems = (target: ChartContextMenu & {
68
74
  chart: Chart;
69
75
  }) => ContextMenuItem[];
76
+ /**
77
+ * Rows of the + menu on the price axis, at the crosshair's price (mouse only) — e.g. "이 가격에
78
+ * 알림 만들기". A horizontal line at that price is always offered after them.
79
+ */
80
+ export type PriceAxisActions = (target: {
81
+ price: number;
82
+ chart: Chart;
83
+ }) => ContextMenuItem[];
84
+ /** A button an app adds to the bar of a selected drawing. `icon` 'alert' shows a bell (the label is its tooltip); without one, the label. */
85
+ export interface DrawingAction {
86
+ label: string;
87
+ icon?: 'alert';
88
+ /** On (e.g. the drawing already has an alert): drawn filled, and aria-pressed. */
89
+ pressed?: boolean;
90
+ onSelect(): void;
91
+ }
92
+ /** The app's buttons for the selected drawing (e.g. 알림 on a trend line), or none. */
93
+ export type DrawingActions = (drawing: Drawing, chart: Chart) => DrawingAction[];
70
94
  /**
71
95
  * A row an app adds to the 도구 (tools) menu, above 차트 설정 — e.g. its own display settings.
72
96
  * `icon` is SVG markup (16×16, stroke="currentColor"), from the app itself.
@@ -125,6 +149,8 @@ export interface WidgetContext {
125
149
  /** Show the Funnest logo badge on the chart. */
126
150
  attribution: boolean;
127
151
  contextMenuItems: ContextMenuItems | undefined;
152
+ priceAxisActions: PriceAxisActions | undefined;
153
+ drawingActions: DrawingActions | undefined;
128
154
  toolsMenuItems: ToolsMenuItems | undefined;
129
155
  legendValues: LegendValues;
130
156
  /** The app's own indicator browser for the 지표 button (instead of the built-in picker). */
package/dist/i18n.d.ts CHANGED
@@ -69,6 +69,7 @@ export declare const STRINGS: {
69
69
  undo: string;
70
70
  tools: string;
71
71
  horizontalAt: string;
72
+ atThisPrice: string;
72
73
  resetChart: string;
73
74
  chartSettingsMore: string;
74
75
  redo: string;
@@ -179,6 +180,13 @@ export declare const STRINGS: {
179
180
  range5Y: string;
180
181
  rangeAll: string;
181
182
  goToDate: string;
183
+ goToDateMore: string;
184
+ smoothScroll: string;
185
+ today: string;
186
+ prevMonth: string;
187
+ nextMonth: string;
188
+ prevYear: string;
189
+ nextYear: string;
182
190
  goTo: string;
183
191
  customInterval: string;
184
192
  addInterval: string;
@@ -259,6 +267,7 @@ export declare const STRINGS: {
259
267
  undo: string;
260
268
  tools: string;
261
269
  horizontalAt: string;
270
+ atThisPrice: string;
262
271
  resetChart: string;
263
272
  chartSettingsMore: string;
264
273
  redo: string;
@@ -369,6 +378,13 @@ export declare const STRINGS: {
369
378
  range5Y: string;
370
379
  rangeAll: string;
371
380
  goToDate: string;
381
+ goToDateMore: string;
382
+ smoothScroll: string;
383
+ today: string;
384
+ prevMonth: string;
385
+ nextMonth: string;
386
+ prevYear: string;
387
+ nextYear: string;
372
388
  goTo: string;
373
389
  customInterval: string;
374
390
  addInterval: string;
package/dist/icons.d.ts CHANGED
@@ -4,6 +4,8 @@ export declare const CameraIcon: () => import("preact").JSX.Element;
4
4
  export declare const ExpandIcon: () => import("preact").JSX.Element;
5
5
  export declare const CollapseIcon: () => import("preact").JSX.Element;
6
6
  export declare const MinusIcon: () => import("preact").JSX.Element;
7
+ export declare const CheckIcon: () => import("preact").JSX.Element;
8
+ export declare const BellIcon: () => import("preact").JSX.Element;
7
9
  export declare const PlusIcon: () => import("preact").JSX.Element;
8
10
  export declare const ChevronLeftIcon: () => import("preact").JSX.Element;
9
11
  export declare const ChevronRightIcon: () => import("preact").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@ export { createMultiChart } from './multi-chart.js';
8
8
  export type { MultiChart, MultiChartEvents, MultiChartOptions, MultiChartState, PaneSpec } from './multi-chart.js';
9
9
  export { LAYOUT_GROUPS, LAYOUTS, MAX_PANES, paneCount } from './layouts.js';
10
10
  export type { LayoutId, SplitNode, SplitSizes } from './layouts.js';
11
- export type { ContextMenuItem, ContextMenuItems, IntervalGroup, LayoutSync, LegendValues, SearchCategory, SearchExchange, ToolsMenuItem, ToolsMenuItems } from './context.js';
11
+ export type { ContextMenuItem, ContextMenuItems, DrawingAction, DrawingActions, IntervalGroup, PriceAxisActions, LayoutSync, LegendValues, SearchCategory, SearchExchange, ToolsMenuItem, ToolsMenuItems } from './context.js';
12
12
  export type { ColorScheme, TradingChart, TradingChartOptions, TradingChartSlots } from './trading-chart.js';
13
13
  export { resolutionLabel, STRINGS, stringsOf, type Strings } from './i18n.js';
package/dist/index.js CHANGED
@@ -495,6 +495,7 @@ var STRINGS = {
495
495
  undo: "\uB418\uB3CC\uB9AC\uAE30",
496
496
  tools: "\uB3C4\uAD6C",
497
497
  horizontalAt: "{price}\uC5D0 \uC218\uD3C9\uC120 \uAE0B\uAE30",
498
+ atThisPrice: "\uC774 \uAC00\uACA9\uC5D0\uC11C\u2026",
498
499
  resetChart: "\uCC28\uD2B8 \uCD08\uAE30\uD654",
499
500
  chartSettingsMore: "\uCC28\uD2B8 \uC124\uC815\u2026",
500
501
  redo: "\uB2E4\uC2DC \uC2E4\uD589",
@@ -607,6 +608,13 @@ var STRINGS = {
607
608
  range5Y: "5\uB144",
608
609
  rangeAll: "\uC804\uCCB4",
609
610
  goToDate: "\uB0A0\uC9DC\uB85C \uC774\uB3D9",
611
+ goToDateMore: "\uB0A0\uC9DC\uB85C \uC774\uB3D9\u2026",
612
+ smoothScroll: "\uBD80\uB4DC\uB7EC\uC6B4 \uC2A4\uD06C\uB864\xB7\uD655\uB300",
613
+ today: "\uC624\uB298",
614
+ prevMonth: "\uC774\uC804 \uB2EC",
615
+ nextMonth: "\uB2E4\uC74C \uB2EC",
616
+ prevYear: "1\uB144 \uC804",
617
+ nextYear: "1\uB144 \uD6C4",
610
618
  goTo: "\uC774\uB3D9",
611
619
  customInterval: "\uC9C1\uC811 \uCD94\uAC00",
612
620
  addInterval: "\uCD94\uAC00",
@@ -687,6 +695,7 @@ var STRINGS = {
687
695
  undo: "Undo",
688
696
  tools: "Tools",
689
697
  horizontalAt: "Horizontal line at {price}",
698
+ atThisPrice: "At this price\u2026",
690
699
  resetChart: "Reset chart",
691
700
  chartSettingsMore: "Chart settings\u2026",
692
701
  redo: "Redo",
@@ -797,6 +806,13 @@ var STRINGS = {
797
806
  range5Y: "5Y",
798
807
  rangeAll: "All",
799
808
  goToDate: "Go to date",
809
+ goToDateMore: "Go to date\u2026",
810
+ smoothScroll: "Smooth scroll & zoom",
811
+ today: "Today",
812
+ prevMonth: "Previous month",
813
+ nextMonth: "Next month",
814
+ prevYear: "A year back",
815
+ nextYear: "A year ahead",
800
816
  goTo: "Go",
801
817
  customInterval: "Add custom",
802
818
  addInterval: "Add",
@@ -858,6 +874,11 @@ var CameraIcon = () => /* @__PURE__ */ a3(Icon, { children: [
858
874
  var ExpandIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M4 8V4h4M16 8V4h-4M4 12v4h4M16 12v4h-4" }) });
859
875
  var CollapseIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M8 4v4H4M12 4v4h4M8 16v-4H4M12 16v-4h4" }) });
860
876
  var MinusIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: /* @__PURE__ */ a3("path", { d: "M5 10h10" }) });
877
+ var CheckIcon = () => /* @__PURE__ */ a3(Icon, { size: 16, children: /* @__PURE__ */ a3("path", { d: "M4.5 10.5l3.5 3.5 7.5-8" }) });
878
+ var BellIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: [
879
+ /* @__PURE__ */ a3("path", { d: "M5.5 13.5V9a4.5 4.5 0 0 1 9 0v4.5l1.2 1.5H4.3z" }),
880
+ /* @__PURE__ */ a3("path", { d: "M8.5 17a1.6 1.6 0 0 0 3 0" })
881
+ ] });
861
882
  var PlusIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: /* @__PURE__ */ a3("path", { d: "M5 10h10M10 5v10" }) });
862
883
  var ChevronLeftIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: /* @__PURE__ */ a3("path", { d: "M12 5l-5 5 5 5" }) });
863
884
  var ChevronRightIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: /* @__PURE__ */ a3("path", { d: "M8 5l5 5-5 5" }) });
@@ -1374,6 +1395,7 @@ function SelectionBar({ ctx }) {
1374
1395
  };
1375
1396
  const locked = !!style.locked;
1376
1397
  const dash = style.dash ?? "solid";
1398
+ const actions = ctx.drawingActions?.(d3, ctx.chart) ?? [];
1377
1399
  const startMove = (e3) => {
1378
1400
  e3.preventDefault();
1379
1401
  const start = [e3.clientX, e3.clientY];
@@ -1516,6 +1538,21 @@ function SelectionBar({ ctx }) {
1516
1538
  }
1517
1539
  )) })
1518
1540
  ] }),
1541
+ actions.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
1542
+ actions.map((a4) => /* @__PURE__ */ a3(
1543
+ "button",
1544
+ {
1545
+ class: `fnc-btn fnc-selbar-action${a4.icon ? "" : " is-text"}${a4.pressed ? " is-on" : ""}`,
1546
+ "data-tip": a4.label,
1547
+ "aria-label": a4.label,
1548
+ "aria-pressed": a4.pressed,
1549
+ onClick: () => {
1550
+ a4.onSelect();
1551
+ ctx.chart.selectDrawing(null);
1552
+ },
1553
+ children: a4.icon === "alert" ? /* @__PURE__ */ a3(BellIcon, {}) : a4.label
1554
+ }
1555
+ )),
1519
1556
  /* @__PURE__ */ a3("div", { class: "fnc-sep" }),
1520
1557
  /* @__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 }) }),
1521
1558
  /* @__PURE__ */ a3(
@@ -1637,6 +1674,139 @@ import {
1637
1674
  SERIES_COLORS
1638
1675
  } from "@funnest/charts";
1639
1676
 
1677
+ // src/components/go-to-date.tsx
1678
+ var DAY2 = 864e5;
1679
+ var ymd = (t3) => new Date(t3).toISOString().slice(0, 10);
1680
+ function parseYmd(text) {
1681
+ const m3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
1682
+ if (!m3) return Number.NaN;
1683
+ const t3 = Date.UTC(Number(m3[1]), Number(m3[2]) - 1, Number(m3[3]));
1684
+ return ymd(t3) === text ? t3 : Number.NaN;
1685
+ }
1686
+ function formatTyped(text) {
1687
+ const d3 = text.replace(/\D/g, "").slice(0, 8);
1688
+ return [d3.slice(0, 4), d3.slice(4, 6), d3.slice(6, 8)].filter(Boolean).join("-");
1689
+ }
1690
+ function GoToDateDialog({ ctx }) {
1691
+ const s3 = useStore(ctx.store);
1692
+ const t3 = stringsOf(s3);
1693
+ const today = Date.now();
1694
+ const start = ctx.chart.getVisibleTimeRange()?.from ?? today;
1695
+ const [text, setText] = d2(ymd(start));
1696
+ const [month, setMonth] = d2(() => {
1697
+ const d3 = new Date(start);
1698
+ return { y: d3.getUTCFullYear(), m: d3.getUTCMonth() };
1699
+ });
1700
+ const [busy, setBusy] = d2(false);
1701
+ const input = T2(null);
1702
+ const close = () => ctx.store.set({ dialog: null });
1703
+ A2(() => input.current?.select(), []);
1704
+ const picked = parseYmd(text);
1705
+ const valid = Number.isFinite(picked) && picked <= today;
1706
+ const locale = s3.locale === "en" ? "en-US" : "ko-KR";
1707
+ const title = new Intl.DateTimeFormat(locale, { year: "numeric", month: "long", timeZone: "UTC" }).format(Date.UTC(month.y, month.m, 1));
1708
+ const weekdays = w2(() => {
1709
+ const f4 = new Intl.DateTimeFormat(locale, { weekday: "narrow", timeZone: "UTC" });
1710
+ return Array.from({ length: 7 }, (_3, i3) => f4.format(Date.UTC(2023, 0, 1 + i3)));
1711
+ }, [locale]);
1712
+ const first = Date.UTC(month.y, month.m, 1);
1713
+ const lead = new Date(first).getUTCDay();
1714
+ const days = new Date(Date.UTC(month.y, month.m + 1, 0)).getUTCDate();
1715
+ const cells = [...Array.from({ length: lead }, () => null), ...Array.from({ length: days }, (_3, i3) => first + i3 * DAY2)];
1716
+ const shift = (months) => setMonth(({ y: y3, m: m3 }) => {
1717
+ const d3 = new Date(Date.UTC(y3, m3 + months, 1));
1718
+ return { y: d3.getUTCFullYear(), m: d3.getUTCMonth() };
1719
+ });
1720
+ const pick = (time) => {
1721
+ setText(ymd(time));
1722
+ const d3 = new Date(time);
1723
+ setMonth({ y: d3.getUTCFullYear(), m: d3.getUTCMonth() });
1724
+ };
1725
+ const go = async () => {
1726
+ if (!valid || busy) return;
1727
+ setBusy(true);
1728
+ try {
1729
+ await ctx.chart.goToTime(picked);
1730
+ close();
1731
+ } finally {
1732
+ setBusy(false);
1733
+ }
1734
+ };
1735
+ return /* @__PURE__ */ a3("div", { class: "fnc-backdrop", onPointerDown: (e3) => e3.target === e3.currentTarget && close(), children: /* @__PURE__ */ a3("div", { class: "fnc-dialog fnc-goto-dialog", role: "dialog", "aria-modal": "true", "aria-label": t3.goToDate, onKeyDown: (e3) => e3.key === "Escape" && close(), children: [
1736
+ /* @__PURE__ */ a3("div", { class: "fnc-dialog-head", children: [
1737
+ /* @__PURE__ */ a3("b", { children: t3.goToDate }),
1738
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "aria-label": t3.close, onClick: close, children: /* @__PURE__ */ a3(CloseIcon, {}) })
1739
+ ] }),
1740
+ /* @__PURE__ */ a3(
1741
+ "form",
1742
+ {
1743
+ class: "fnc-goto-body",
1744
+ onSubmit: (e3) => {
1745
+ e3.preventDefault();
1746
+ void go();
1747
+ },
1748
+ children: [
1749
+ /* @__PURE__ */ a3(
1750
+ "input",
1751
+ {
1752
+ ref: input,
1753
+ class: "fnc-input fnc-goto-input",
1754
+ value: text,
1755
+ inputMode: "numeric",
1756
+ placeholder: "YYYY-MM-DD",
1757
+ "aria-label": t3.goToDate,
1758
+ "aria-invalid": text.length === 10 && !valid,
1759
+ onInput: (e3) => {
1760
+ const next = formatTyped(e3.target.value);
1761
+ setText(next);
1762
+ const time = parseYmd(next);
1763
+ if (Number.isFinite(time)) {
1764
+ const d3 = new Date(time);
1765
+ setMonth({ y: d3.getUTCFullYear(), m: d3.getUTCMonth() });
1766
+ }
1767
+ },
1768
+ onKeyDown: (e3) => e3.stopPropagation()
1769
+ }
1770
+ ),
1771
+ /* @__PURE__ */ a3("div", { class: "fnc-cal", role: "group", "aria-label": title, children: [
1772
+ /* @__PURE__ */ a3("div", { class: "fnc-cal-head", children: [
1773
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.prevYear, "data-tip": t3.prevYear, onClick: () => shift(-12), children: "\xAB" }),
1774
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.prevMonth, "data-tip": t3.prevMonth, onClick: () => shift(-1), children: /* @__PURE__ */ a3(ChevronLeftIcon, {}) }),
1775
+ /* @__PURE__ */ a3("b", { children: title }),
1776
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.nextMonth, "data-tip": t3.nextMonth, disabled: first + days * DAY2 > today, onClick: () => shift(1), children: /* @__PURE__ */ a3(ChevronRightIcon, {}) }),
1777
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.nextYear, "data-tip": t3.nextYear, disabled: Date.UTC(month.y + 1, month.m, 1) > today, onClick: () => shift(12), children: "\xBB" })
1778
+ ] }),
1779
+ /* @__PURE__ */ a3("div", { class: "fnc-cal-grid", children: [
1780
+ weekdays.map((w3) => /* @__PURE__ */ a3("span", { class: "fnc-cal-wd", children: w3 })),
1781
+ cells.map(
1782
+ (time) => time === null ? /* @__PURE__ */ a3("span", {}) : /* @__PURE__ */ a3(
1783
+ "button",
1784
+ {
1785
+ type: "button",
1786
+ class: `fnc-cal-day${ymd(time) === text ? " is-on" : ""}${ymd(time) === ymd(today) ? " is-today" : ""}`,
1787
+ disabled: time > today,
1788
+ "aria-pressed": ymd(time) === text,
1789
+ onClick: () => pick(time),
1790
+ onDblClick: () => {
1791
+ pick(time);
1792
+ void ctx.chart.goToTime(time).then(close);
1793
+ },
1794
+ children: new Date(time).getUTCDate()
1795
+ }
1796
+ )
1797
+ )
1798
+ ] })
1799
+ ] }),
1800
+ /* @__PURE__ */ a3("div", { class: "fnc-goto-actions", children: [
1801
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn fnc-goto-today", onClick: () => pick(Date.UTC(new Date(today).getUTCFullYear(), new Date(today).getUTCMonth(), new Date(today).getUTCDate())), children: t3.today }),
1802
+ /* @__PURE__ */ a3("button", { type: "submit", class: "fnc-btn fnc-goto-go", disabled: !valid || busy, children: t3.goTo })
1803
+ ] })
1804
+ ]
1805
+ }
1806
+ )
1807
+ ] }) });
1808
+ }
1809
+
1640
1810
  // src/components/settings-dialog.tsx
1641
1811
  import { CHART_THEMES, DEFAULT_CHART_SETTINGS, matchChartTheme } from "@funnest/charts";
1642
1812
  function toHex(color) {
@@ -1654,7 +1824,8 @@ var SECTIONS = [
1654
1824
  { key: "lastPriceLine", label: "settingLastPrice" },
1655
1825
  { key: "countdown", label: "settingCountdown" },
1656
1826
  { key: "volume", label: "settingVolume" },
1657
- { key: "navigationButtons", label: "settingNavButtons" }
1827
+ { key: "navigationButtons", label: "settingNavButtons" },
1828
+ { key: "smoothScroll", label: "smoothScroll" }
1658
1829
  ]
1659
1830
  },
1660
1831
  {
@@ -2026,6 +2197,7 @@ function Dialogs({ ctx }) {
2026
2197
  if (dialog?.kind === "indicators") return /* @__PURE__ */ a3(IndicatorPicker, { ctx });
2027
2198
  if (dialog?.kind === "indicatorSettings") return /* @__PURE__ */ a3(IndicatorSettings, { ctx, id: dialog.id });
2028
2199
  if (dialog?.kind === "chartSettings") return /* @__PURE__ */ a3(SettingsDialog, { ctx });
2200
+ if (dialog?.kind === "goToDate") return /* @__PURE__ */ a3(GoToDateDialog, { ctx });
2029
2201
  return null;
2030
2202
  }
2031
2203
 
@@ -2918,7 +3090,7 @@ function Toolbar({ ctx }) {
2918
3090
  import { browserLocale, createChart } from "@funnest/charts";
2919
3091
 
2920
3092
  // src/components/overlay.tsx
2921
- import { formatCompact, formatPrice as formatPrice3 } from "@funnest/charts";
3093
+ import { formatCompact, formatPrice as formatPrice4 } from "@funnest/charts";
2922
3094
 
2923
3095
  // src/components/context-menu.tsx
2924
3096
  import { formatPrice as formatPrice2 } from "@funnest/charts";
@@ -2975,7 +3147,11 @@ function ContextMenu({ ctx }) {
2975
3147
  onSelect: () => ctx.chart.addDrawing({ type: "horizontal", points: [{ time, price }] })
2976
3148
  });
2977
3149
  }
3150
+ const smooth = ctx.chart.settings.smoothScroll;
2978
3151
  items.push(
3152
+ { label: t3.goToDateMore, onSelect: () => ctx.store.set({ dialog: { kind: "goToDate" } }) },
3153
+ { label: t3.smoothScroll, checked: smooth, onSelect: () => ctx.chart.setSettings({ smoothScroll: !smooth }) },
3154
+ "separator",
2979
3155
  { label: t3.resetChart, onSelect: () => ctx.chart.resetView() },
2980
3156
  { label: t3.chartSettingsMore, onSelect: () => ctx.store.set({ dialog: { kind: "chartSettings" } }) }
2981
3157
  );
@@ -2983,22 +3159,106 @@ function ContextMenu({ ctx }) {
2983
3159
  (item) => item === "separator" ? /* @__PURE__ */ a3("div", { class: "fnc-ctx-sep", role: "separator" }) : /* @__PURE__ */ a3(
2984
3160
  "button",
2985
3161
  {
2986
- class: "fnc-menu-item",
2987
- role: "menuitem",
3162
+ class: `fnc-menu-item${item.checked !== void 0 ? " fnc-menu-check" : ""}`,
3163
+ role: item.checked !== void 0 ? "menuitemcheckbox" : "menuitem",
3164
+ "aria-checked": item.checked,
2988
3165
  disabled: item.disabled,
2989
3166
  onClick: () => {
2990
3167
  setTarget(null);
2991
3168
  item.onSelect();
2992
3169
  },
2993
3170
  children: [
3171
+ item.icon === "alert" && /* @__PURE__ */ a3(BellIcon, {}),
2994
3172
  /* @__PURE__ */ a3("span", { children: item.label }),
2995
- item.shortcut && /* @__PURE__ */ a3("kbd", { children: item.shortcut })
3173
+ item.shortcut && /* @__PURE__ */ a3("kbd", { children: item.shortcut }),
3174
+ item.checked && /* @__PURE__ */ a3(CheckIcon, {})
2996
3175
  ]
2997
3176
  }
2998
3177
  )
2999
3178
  ) });
3000
3179
  }
3001
3180
 
3181
+ // src/components/price-axis-plus.tsx
3182
+ import { formatPrice as formatPrice3 } from "@funnest/charts";
3183
+ function PriceAxisPlus({ ctx }) {
3184
+ const s3 = useStore(ctx.store);
3185
+ const t3 = stringsOf(s3);
3186
+ const [at, setAt] = d2(null);
3187
+ const [open, setOpen] = d2(false);
3188
+ const held = T2(false);
3189
+ const ref = T2(null);
3190
+ A2(
3191
+ () => ctx.chart.on("crosshairMove", (info) => {
3192
+ if (held.current) return;
3193
+ setAt(info && info.source === "mouse" && info.pane === "main" && info.y >= 0 ? { y: info.y, price: info.value } : null);
3194
+ }),
3195
+ [ctx.chart]
3196
+ );
3197
+ A2(() => {
3198
+ if (!open) return;
3199
+ const close = () => {
3200
+ setOpen(false);
3201
+ held.current = false;
3202
+ };
3203
+ const onDown = (e3) => !ref.current?.contains(e3.target) && close();
3204
+ const onKey = (e3) => e3.key === "Escape" && close();
3205
+ document.addEventListener("pointerdown", onDown, true);
3206
+ document.addEventListener("keydown", onKey);
3207
+ return () => {
3208
+ document.removeEventListener("pointerdown", onDown, true);
3209
+ document.removeEventListener("keydown", onKey);
3210
+ };
3211
+ }, [open]);
3212
+ const { plotWidth, panesHeight } = s3.layout;
3213
+ if (!ctx.priceAxisActions || !at || plotWidth <= 0 || at.y > panesHeight || s3.replay.active) return null;
3214
+ const precision = s3.symbol?.pricePrecision ?? 2;
3215
+ const price = Number(at.price.toFixed(precision));
3216
+ const items = open ? [
3217
+ ...ctx.priceAxisActions({ price, chart: ctx.chart }),
3218
+ {
3219
+ label: t3.horizontalAt.replace("{price}", formatPrice3(price, precision)),
3220
+ icon: "line",
3221
+ onSelect: () => {
3222
+ const time = ctx.chart.bars[ctx.chart.bars.length - 1]?.time ?? Date.now();
3223
+ ctx.chart.addDrawing({ type: "horizontal", points: [{ time, price }] });
3224
+ }
3225
+ }
3226
+ ] : [];
3227
+ return /* @__PURE__ */ a3(
3228
+ "div",
3229
+ {
3230
+ class: "fnc-axis-plus",
3231
+ ref,
3232
+ style: { left: `${plotWidth - 26}px`, top: `${Math.round(at.y) - 11}px` },
3233
+ onPointerEnter: () => held.current = true,
3234
+ onPointerLeave: () => !open && (held.current = false),
3235
+ children: [
3236
+ /* @__PURE__ */ a3("button", { class: "fnc-axis-plus-btn", "data-tip": t3.atThisPrice, "aria-label": t3.atThisPrice, "aria-expanded": open, onClick: () => setOpen(!open), children: /* @__PURE__ */ a3(PlusIcon, {}) }),
3237
+ open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-axis-plus-menu", role: "menu", children: items.map(
3238
+ (item) => item === "separator" ? /* @__PURE__ */ a3("div", { class: "fnc-ctx-sep", role: "separator" }) : /* @__PURE__ */ a3(
3239
+ "button",
3240
+ {
3241
+ class: "fnc-menu-item",
3242
+ role: "menuitem",
3243
+ disabled: "disabled" in item ? item.disabled : false,
3244
+ onClick: () => {
3245
+ setOpen(false);
3246
+ held.current = false;
3247
+ setAt(null);
3248
+ item.onSelect();
3249
+ },
3250
+ children: [
3251
+ item.icon === "alert" ? /* @__PURE__ */ a3(BellIcon, {}) : item.icon === "line" ? /* @__PURE__ */ a3(HorizontalLineIcon, {}) : null,
3252
+ /* @__PURE__ */ a3("span", { children: item.label })
3253
+ ]
3254
+ }
3255
+ )
3256
+ ) })
3257
+ ]
3258
+ }
3259
+ );
3260
+ }
3261
+
3002
3262
  // src/components/overlay.tsx
3003
3263
  var ZOOM_STEP = 1.25;
3004
3264
  var CONTROL_OFFSET = 52;
@@ -3145,7 +3405,7 @@ function Legend({ ctx }) {
3145
3405
  const bars = ctx.chart.bars;
3146
3406
  const bar = hover?.bar ?? bars[bars.length - 1];
3147
3407
  const prev = hover ? hover.prev : bars[bars.length - 2];
3148
- const fmt = (p3) => formatPrice3(p3, s3.symbol.pricePrecision);
3408
+ const fmt = (p3) => formatPrice4(p3, s3.symbol.pricePrecision);
3149
3409
  let values = null;
3150
3410
  if (bar && (ctx.legendValues === "always" || hover)) {
3151
3411
  const cls = dirClass(bar.close - bar.open);
@@ -3442,6 +3702,7 @@ function Overlay({ ctx }) {
3442
3702
  /* @__PURE__ */ a3(Attribution, { ctx }),
3443
3703
  /* @__PURE__ */ a3(Legend, { ctx }),
3444
3704
  /* @__PURE__ */ a3(NavControls, { ctx }),
3705
+ /* @__PURE__ */ a3(PriceAxisPlus, { ctx }),
3445
3706
  /* @__PURE__ */ a3(ReplayBar, { ctx }),
3446
3707
  /* @__PURE__ */ a3(SelectionBar, { ctx }),
3447
3708
  /* @__PURE__ */ a3(TextEditor, { ctx }),
@@ -4130,6 +4391,42 @@ var CSS = (
4130
4391
  @media (hover: none) {
4131
4392
  .fnc-nav { display: none; }
4132
4393
  }
4394
+ /* A setting in a menu (\uBD80\uB4DC\uB7EC\uC6B4 \uC2A4\uD06C\uB864\xB7\uD655\uB300): the check at the end. */
4395
+ .fnc-menu-check svg { margin-left: auto; color: var(--fnc-accent); }
4396
+
4397
+ /* \uB0A0\uC9DC\uB85C \uC774\uB3D9: a date typed or picked on a month calendar. */
4398
+ .fnc-goto-dialog { width: min(320px, calc(100% - 32px)); }
4399
+ .fnc-goto-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
4400
+ .fnc-goto-input { height: 38px; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
4401
+ .fnc-goto-input[aria-invalid="true"] { box-shadow: 0 0 0 1px var(--fnc-down, #f04452); }
4402
+ .fnc-cal-head { display: flex; align-items: center; gap: 2px; }
4403
+ .fnc-cal-head b { flex: 1; text-align: center; font-size: 14px; }
4404
+ .fnc-cal-head .fnc-btn { width: 30px; height: 30px; font-size: 16px; }
4405
+ .fnc-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 4px; }
4406
+ .fnc-cal-wd { padding: 4px 0; text-align: center; font-size: 11px; color: var(--fnc-text-2); }
4407
+ .fnc-cal-day { height: 34px; border-radius: var(--fnc-radius); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--fnc-text); }
4408
+ .fnc-cal-day:hover:not(:disabled) { background: var(--fnc-surface); }
4409
+ .fnc-cal-day.is-today { box-shadow: inset 0 0 0 1px var(--fnc-border); }
4410
+ .fnc-cal-day.is-on { background: var(--fnc-accent); color: #fff; font-weight: 700; }
4411
+ .fnc-cal-day:disabled { opacity: 0.3; cursor: default; }
4412
+ .fnc-goto-actions { display: flex; gap: 8px; }
4413
+ .fnc-goto-dialog .fnc-goto-today { flex: none; width: auto; white-space: nowrap; height: 36px; padding: 0 16px; border-radius: var(--fnc-radius); background: var(--fnc-surface); font-weight: 600; }
4414
+ .fnc-goto-dialog .fnc-goto-go { flex: 1; height: 36px; }
4415
+
4416
+ /* The + on the price axis at the crosshair price, and its menu (mouse only). */
4417
+ .fnc-axis-plus { position: absolute; z-index: 25; }
4418
+ .fnc-axis-plus-btn { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: var(--fnc-bg); color: var(--fnc-text-2); box-shadow: 0 0 0 1px var(--fnc-border); }
4419
+ .fnc-axis-plus-btn:hover, .fnc-axis-plus-btn[aria-expanded="true"] { color: var(--fnc-text); background: var(--fnc-surface); }
4420
+ .fnc-axis-plus-menu { position: absolute; top: 26px; left: auto; right: 0; min-width: 200px; white-space: nowrap; }
4421
+ @media (hover: none) {
4422
+ .fnc-axis-plus { display: none; }
4423
+ }
4424
+ .fnc-selbar-action.is-text { width: auto; padding: 0 8px; font-size: 12px; font-weight: 600; }
4425
+ .fnc-selbar-action.is-on { color: var(--fnc-accent); }
4426
+ .fnc-selbar-action.is-on svg path:first-child { fill: currentColor; }
4427
+ .fnc-axis-plus-menu .fnc-menu-item, .fnc-ctx-menu .fnc-menu-item:has(svg) { color: var(--fnc-text); font-weight: 600; }
4428
+ .fnc-axis-plus-menu .fnc-menu-item svg, .fnc-ctx-menu .fnc-menu-item svg { flex: none; color: var(--fnc-text-2); }
4429
+
4133
4430
  /* \uAE30\uAC04 \xB7 \uB0A0\uC9DC\uB85C \uC774\uB3D9: a row under the chart. */
4134
4431
  .fnc-rangebar-host { flex: none; border-top: 1px solid var(--fnc-border); }
4135
4432
  .fnc-rangebar-host:empty { display: none; }
@@ -5042,6 +5339,8 @@ function createPane(shell, config) {
5042
5339
  drawingToolbar: config.drawingToolbar,
5043
5340
  attribution: config.attribution,
5044
5341
  contextMenuItems: config.contextMenuItems,
5342
+ priceAxisActions: config.priceAxisActions,
5343
+ drawingActions: config.drawingActions,
5045
5344
  toolsMenuItems: config.toolsMenuItems,
5046
5345
  legendValues: config.legendValues ?? "always",
5047
5346
  onIndicatorsClick: config.onIndicatorsClick,
@@ -5128,6 +5427,8 @@ function createTradingChart(container, options) {
5128
5427
  attribution = true,
5129
5428
  colorScheme = "system",
5130
5429
  contextMenuItems,
5430
+ priceAxisActions,
5431
+ drawingActions,
5131
5432
  toolsMenuItems,
5132
5433
  legendValues,
5133
5434
  onIndicatorsClick,
@@ -5162,6 +5463,8 @@ function createTradingChart(container, options) {
5162
5463
  drawingToolbar,
5163
5464
  attribution,
5164
5465
  contextMenuItems,
5466
+ priceAxisActions,
5467
+ drawingActions,
5165
5468
  toolsMenuItems,
5166
5469
  legendValues,
5167
5470
  onIndicatorsClick,
@@ -5240,6 +5543,8 @@ function createMultiChart(container, options) {
5240
5543
  attribution = true,
5241
5544
  colorScheme = "system",
5242
5545
  contextMenuItems,
5546
+ priceAxisActions,
5547
+ drawingActions,
5243
5548
  toolsMenuItems,
5244
5549
  legendValues,
5245
5550
  onIndicatorsClick,
@@ -5316,6 +5621,8 @@ function createMultiChart(container, options) {
5316
5621
  // One badge for the whole widget, not one per pane.
5317
5622
  attribution: attribution && index === 0,
5318
5623
  contextMenuItems,
5624
+ priceAxisActions,
5625
+ drawingActions,
5319
5626
  toolsMenuItems,
5320
5627
  legendValues,
5321
5628
  onIndicatorsClick,
package/dist/pane.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource preact */
2
2
  import { type Chart, type ChartOptions, type ChartType, type Datafeed, type Resolution } from '@funnest/charts';
3
- import type { ContextMenuItems, IntervalGroup, LegendValues, MultiControls, SearchCategory, SearchExchange, ToolsMenuItems, UiState, WidgetContext } from './context.js';
3
+ import type { ContextMenuItems, DrawingActions, IntervalGroup, LegendValues, MultiControls, PriceAxisActions, SearchCategory, SearchExchange, ToolsMenuItems, UiState, WidgetContext } from './context.js';
4
4
  import { type Shell } from './shell.js';
5
5
  import type { Strings } from './i18n.js';
6
6
  import { Store } from './store.js';
@@ -20,6 +20,8 @@ export interface PaneConfig {
20
20
  /** Ctrl/⌘+K opens this widget's symbol search (its footer shows the hint only then). */
21
21
  searchHotkey: boolean;
22
22
  contextMenuItems?: ContextMenuItems | undefined;
23
+ priceAxisActions?: PriceAxisActions | undefined;
24
+ drawingActions?: DrawingActions | undefined;
23
25
  toolsMenuItems?: ToolsMenuItems | undefined;
24
26
  legendValues?: LegendValues | undefined;
25
27
  onIndicatorsClick?: ((chart: Chart) => void) | undefined;
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource preact */
2
2
  import { type Chart, type ChartOptions, type ChartType, type Datafeed, type DirectionPreset, type Locale, type ChartState, type Resolution, type ThemeTokens } from '@funnest/charts';
3
- import type { ContextMenuItems, IntervalGroup, LegendValues, SearchCategory, SearchExchange, ToolsMenuItems } from './context.js';
3
+ import type { ContextMenuItems, DrawingActions, IntervalGroup, LegendValues, PriceAxisActions, SearchCategory, SearchExchange, ToolsMenuItems } from './context.js';
4
4
  import type { Strings } from './i18n.js';
5
5
  import { type ColorScheme, type TradingChartSlots } from './shell.js';
6
6
  export type { ColorScheme, TradingChartSlots } from './shell.js';
@@ -58,6 +58,10 @@ export interface TradingChartOptions extends Omit<ChartOptions, 'datafeed'> {
58
58
  * e.g. "이 가격에 알림 만들기". Called on every right-click with the price and time under the pointer.
59
59
  */
60
60
  contextMenuItems?: ContextMenuItems;
61
+ /** Rows of the price axis's + menu at the crosshair price (e.g. "이 가격에 알림 만들기"); without it there's no +. */
62
+ priceAxisActions?: PriceAxisActions;
63
+ /** Buttons on the bar of a selected drawing (e.g. 알림 on a trend line) — how phones reach drawing actions. */
64
+ drawingActions?: DrawingActions;
61
65
  /**
62
66
  * Extra rows for the 도구 (tools) menu, above 차트 설정 — e.g. the app's own display settings.
63
67
  * Called each time the menu opens, with the pane's chart.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
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.8.2"
45
+ "@funnest/charts": "0.8.4"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"