@funnest/charts-ui 0.8.3 → 0.8.5

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;
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[];
@@ -60,8 +62,11 @@ export interface UiState {
60
62
  export type ContextMenuItem = {
61
63
  label: string;
62
64
  shortcut?: string;
63
- disabled?: boolean; /** 'alert': a bell before the label. */
65
+ disabled?: boolean;
66
+ /** 'alert': a bell before the label. */
64
67
  icon?: 'alert';
68
+ /** A setting that's on or off: a check mark, and it reads as a checkbox. */
69
+ checked?: boolean;
65
70
  onSelect(): void;
66
71
  } | 'separator';
67
72
  /** Extra right-click items for a click on `chart` (e.g. "create an alert at this price"). */
package/dist/i18n.d.ts CHANGED
@@ -62,6 +62,7 @@ export declare const STRINGS: {
62
62
  settingVolume: string;
63
63
  settingNavButtons: string;
64
64
  settingCountdown: string;
65
+ settingExtendedPrice: string;
65
66
  settingsScale: string;
66
67
  scaleNormal: string;
67
68
  scaleLog: string;
@@ -180,6 +181,13 @@ export declare const STRINGS: {
180
181
  range5Y: string;
181
182
  rangeAll: string;
182
183
  goToDate: string;
184
+ goToDateMore: string;
185
+ smoothScroll: string;
186
+ today: string;
187
+ prevMonth: string;
188
+ nextMonth: string;
189
+ prevYear: string;
190
+ nextYear: string;
183
191
  goTo: string;
184
192
  customInterval: string;
185
193
  addInterval: string;
@@ -253,6 +261,7 @@ export declare const STRINGS: {
253
261
  settingVolume: string;
254
262
  settingNavButtons: string;
255
263
  settingCountdown: string;
264
+ settingExtendedPrice: string;
256
265
  settingsScale: string;
257
266
  scaleNormal: string;
258
267
  scaleLog: string;
@@ -371,6 +380,13 @@ export declare const STRINGS: {
371
380
  range5Y: string;
372
381
  rangeAll: string;
373
382
  goToDate: string;
383
+ goToDateMore: string;
384
+ smoothScroll: string;
385
+ today: string;
386
+ prevMonth: string;
387
+ nextMonth: string;
388
+ prevYear: string;
389
+ nextYear: string;
374
390
  goTo: string;
375
391
  customInterval: string;
376
392
  addInterval: string;
package/dist/icons.d.ts CHANGED
@@ -4,6 +4,7 @@ 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;
7
8
  export declare const BellIcon: () => import("preact").JSX.Element;
8
9
  export declare const PlusIcon: () => import("preact").JSX.Element;
9
10
  export declare const ChevronLeftIcon: () => import("preact").JSX.Element;
package/dist/index.js CHANGED
@@ -488,6 +488,7 @@ var STRINGS = {
488
488
  settingVolume: "\uAC70\uB798\uB7C9",
489
489
  settingNavButtons: "\uD655\uB300\xB7\uC774\uB3D9 \uBC84\uD2BC",
490
490
  settingCountdown: "\uBD09 \uB9C8\uAC10\uAE4C\uC9C0 \uB0A8\uC740 \uC2DC\uAC04",
491
+ settingExtendedPrice: "\uC7A5\uC678 \uAC00\uACA9\uC120 (\uD504\uB9AC\xB7\uC560\uD504\uD130\uB9C8\uCF13)",
491
492
  settingsScale: "\uAC00\uACA9 \uCD95",
492
493
  scaleNormal: "\uC77C\uBC18",
493
494
  scaleLog: "\uB85C\uADF8",
@@ -608,6 +609,13 @@ var STRINGS = {
608
609
  range5Y: "5\uB144",
609
610
  rangeAll: "\uC804\uCCB4",
610
611
  goToDate: "\uB0A0\uC9DC\uB85C \uC774\uB3D9",
612
+ goToDateMore: "\uB0A0\uC9DC\uB85C \uC774\uB3D9\u2026",
613
+ smoothScroll: "\uBD80\uB4DC\uB7EC\uC6B4 \uC2A4\uD06C\uB864\xB7\uD655\uB300",
614
+ today: "\uC624\uB298",
615
+ prevMonth: "\uC774\uC804 \uB2EC",
616
+ nextMonth: "\uB2E4\uC74C \uB2EC",
617
+ prevYear: "1\uB144 \uC804",
618
+ nextYear: "1\uB144 \uD6C4",
611
619
  goTo: "\uC774\uB3D9",
612
620
  customInterval: "\uC9C1\uC811 \uCD94\uAC00",
613
621
  addInterval: "\uCD94\uAC00",
@@ -681,6 +689,7 @@ var STRINGS = {
681
689
  settingVolume: "Volume",
682
690
  settingNavButtons: "Zoom & scroll buttons",
683
691
  settingCountdown: "Time to bar close",
692
+ settingExtendedPrice: "Pre / after-market price line",
684
693
  settingsScale: "Price scale",
685
694
  scaleNormal: "Regular",
686
695
  scaleLog: "Log",
@@ -799,6 +808,13 @@ var STRINGS = {
799
808
  range5Y: "5Y",
800
809
  rangeAll: "All",
801
810
  goToDate: "Go to date",
811
+ goToDateMore: "Go to date\u2026",
812
+ smoothScroll: "Smooth scroll & zoom",
813
+ today: "Today",
814
+ prevMonth: "Previous month",
815
+ nextMonth: "Next month",
816
+ prevYear: "A year back",
817
+ nextYear: "A year ahead",
802
818
  goTo: "Go",
803
819
  customInterval: "Add custom",
804
820
  addInterval: "Add",
@@ -860,6 +876,7 @@ var CameraIcon = () => /* @__PURE__ */ a3(Icon, { children: [
860
876
  var ExpandIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M4 8V4h4M16 8V4h-4M4 12v4h4M16 12v4h-4" }) });
861
877
  var CollapseIcon = () => /* @__PURE__ */ a3(Icon, { children: /* @__PURE__ */ a3("path", { d: "M8 4v4H4M12 4v4h4M8 16v-4H4M12 16v-4h4" }) });
862
878
  var MinusIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: /* @__PURE__ */ a3("path", { d: "M5 10h10" }) });
879
+ var CheckIcon = () => /* @__PURE__ */ a3(Icon, { size: 16, children: /* @__PURE__ */ a3("path", { d: "M4.5 10.5l3.5 3.5 7.5-8" }) });
863
880
  var BellIcon = () => /* @__PURE__ */ a3(Icon, { size: 18, children: [
864
881
  /* @__PURE__ */ a3("path", { d: "M5.5 13.5V9a4.5 4.5 0 0 1 9 0v4.5l1.2 1.5H4.3z" }),
865
882
  /* @__PURE__ */ a3("path", { d: "M8.5 17a1.6 1.6 0 0 0 3 0" })
@@ -1659,6 +1676,139 @@ import {
1659
1676
  SERIES_COLORS
1660
1677
  } from "@funnest/charts";
1661
1678
 
1679
+ // src/components/go-to-date.tsx
1680
+ var DAY2 = 864e5;
1681
+ var ymd = (t3) => new Date(t3).toISOString().slice(0, 10);
1682
+ function parseYmd(text) {
1683
+ const m3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
1684
+ if (!m3) return Number.NaN;
1685
+ const t3 = Date.UTC(Number(m3[1]), Number(m3[2]) - 1, Number(m3[3]));
1686
+ return ymd(t3) === text ? t3 : Number.NaN;
1687
+ }
1688
+ function formatTyped(text) {
1689
+ const d3 = text.replace(/\D/g, "").slice(0, 8);
1690
+ return [d3.slice(0, 4), d3.slice(4, 6), d3.slice(6, 8)].filter(Boolean).join("-");
1691
+ }
1692
+ function GoToDateDialog({ ctx }) {
1693
+ const s3 = useStore(ctx.store);
1694
+ const t3 = stringsOf(s3);
1695
+ const today = Date.now();
1696
+ const start = ctx.chart.getVisibleTimeRange()?.from ?? today;
1697
+ const [text, setText] = d2(ymd(start));
1698
+ const [month, setMonth] = d2(() => {
1699
+ const d3 = new Date(start);
1700
+ return { y: d3.getUTCFullYear(), m: d3.getUTCMonth() };
1701
+ });
1702
+ const [busy, setBusy] = d2(false);
1703
+ const input = T2(null);
1704
+ const close = () => ctx.store.set({ dialog: null });
1705
+ A2(() => input.current?.select(), []);
1706
+ const picked = parseYmd(text);
1707
+ const valid = Number.isFinite(picked) && picked <= today;
1708
+ const locale = s3.locale === "en" ? "en-US" : "ko-KR";
1709
+ const title = new Intl.DateTimeFormat(locale, { year: "numeric", month: "long", timeZone: "UTC" }).format(Date.UTC(month.y, month.m, 1));
1710
+ const weekdays = w2(() => {
1711
+ const f4 = new Intl.DateTimeFormat(locale, { weekday: "narrow", timeZone: "UTC" });
1712
+ return Array.from({ length: 7 }, (_3, i3) => f4.format(Date.UTC(2023, 0, 1 + i3)));
1713
+ }, [locale]);
1714
+ const first = Date.UTC(month.y, month.m, 1);
1715
+ const lead = new Date(first).getUTCDay();
1716
+ const days = new Date(Date.UTC(month.y, month.m + 1, 0)).getUTCDate();
1717
+ const cells = [...Array.from({ length: lead }, () => null), ...Array.from({ length: days }, (_3, i3) => first + i3 * DAY2)];
1718
+ const shift = (months) => setMonth(({ y: y3, m: m3 }) => {
1719
+ const d3 = new Date(Date.UTC(y3, m3 + months, 1));
1720
+ return { y: d3.getUTCFullYear(), m: d3.getUTCMonth() };
1721
+ });
1722
+ const pick = (time) => {
1723
+ setText(ymd(time));
1724
+ const d3 = new Date(time);
1725
+ setMonth({ y: d3.getUTCFullYear(), m: d3.getUTCMonth() });
1726
+ };
1727
+ const go = async () => {
1728
+ if (!valid || busy) return;
1729
+ setBusy(true);
1730
+ try {
1731
+ await ctx.chart.goToTime(picked);
1732
+ close();
1733
+ } finally {
1734
+ setBusy(false);
1735
+ }
1736
+ };
1737
+ 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: [
1738
+ /* @__PURE__ */ a3("div", { class: "fnc-dialog-head", children: [
1739
+ /* @__PURE__ */ a3("b", { children: t3.goToDate }),
1740
+ /* @__PURE__ */ a3("button", { class: "fnc-btn", "aria-label": t3.close, onClick: close, children: /* @__PURE__ */ a3(CloseIcon, {}) })
1741
+ ] }),
1742
+ /* @__PURE__ */ a3(
1743
+ "form",
1744
+ {
1745
+ class: "fnc-goto-body",
1746
+ onSubmit: (e3) => {
1747
+ e3.preventDefault();
1748
+ void go();
1749
+ },
1750
+ children: [
1751
+ /* @__PURE__ */ a3(
1752
+ "input",
1753
+ {
1754
+ ref: input,
1755
+ class: "fnc-input fnc-goto-input",
1756
+ value: text,
1757
+ inputMode: "numeric",
1758
+ placeholder: "YYYY-MM-DD",
1759
+ "aria-label": t3.goToDate,
1760
+ "aria-invalid": text.length === 10 && !valid,
1761
+ onInput: (e3) => {
1762
+ const next = formatTyped(e3.target.value);
1763
+ setText(next);
1764
+ const time = parseYmd(next);
1765
+ if (Number.isFinite(time)) {
1766
+ const d3 = new Date(time);
1767
+ setMonth({ y: d3.getUTCFullYear(), m: d3.getUTCMonth() });
1768
+ }
1769
+ },
1770
+ onKeyDown: (e3) => e3.stopPropagation()
1771
+ }
1772
+ ),
1773
+ /* @__PURE__ */ a3("div", { class: "fnc-cal", role: "group", "aria-label": title, children: [
1774
+ /* @__PURE__ */ a3("div", { class: "fnc-cal-head", children: [
1775
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.prevYear, "data-tip": t3.prevYear, onClick: () => shift(-12), children: "\xAB" }),
1776
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-btn", "aria-label": t3.prevMonth, "data-tip": t3.prevMonth, onClick: () => shift(-1), children: /* @__PURE__ */ a3(ChevronLeftIcon, {}) }),
1777
+ /* @__PURE__ */ a3("b", { children: title }),
1778
+ /* @__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, {}) }),
1779
+ /* @__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" })
1780
+ ] }),
1781
+ /* @__PURE__ */ a3("div", { class: "fnc-cal-grid", children: [
1782
+ weekdays.map((w3) => /* @__PURE__ */ a3("span", { class: "fnc-cal-wd", children: w3 })),
1783
+ cells.map(
1784
+ (time) => time === null ? /* @__PURE__ */ a3("span", {}) : /* @__PURE__ */ a3(
1785
+ "button",
1786
+ {
1787
+ type: "button",
1788
+ class: `fnc-cal-day${ymd(time) === text ? " is-on" : ""}${ymd(time) === ymd(today) ? " is-today" : ""}`,
1789
+ disabled: time > today,
1790
+ "aria-pressed": ymd(time) === text,
1791
+ onClick: () => pick(time),
1792
+ onDblClick: () => {
1793
+ pick(time);
1794
+ void ctx.chart.goToTime(time).then(close);
1795
+ },
1796
+ children: new Date(time).getUTCDate()
1797
+ }
1798
+ )
1799
+ )
1800
+ ] })
1801
+ ] }),
1802
+ /* @__PURE__ */ a3("div", { class: "fnc-goto-actions", children: [
1803
+ /* @__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 }),
1804
+ /* @__PURE__ */ a3("button", { type: "submit", class: "fnc-btn fnc-goto-go", disabled: !valid || busy, children: t3.goTo })
1805
+ ] })
1806
+ ]
1807
+ }
1808
+ )
1809
+ ] }) });
1810
+ }
1811
+
1662
1812
  // src/components/settings-dialog.tsx
1663
1813
  import { CHART_THEMES, DEFAULT_CHART_SETTINGS, matchChartTheme } from "@funnest/charts";
1664
1814
  function toHex(color) {
@@ -1675,8 +1825,10 @@ var SECTIONS = [
1675
1825
  { key: "highLowMarkers", label: "settingHighLow" },
1676
1826
  { key: "lastPriceLine", label: "settingLastPrice" },
1677
1827
  { key: "countdown", label: "settingCountdown" },
1828
+ { key: "extendedPriceLine", label: "settingExtendedPrice" },
1678
1829
  { key: "volume", label: "settingVolume" },
1679
- { key: "navigationButtons", label: "settingNavButtons" }
1830
+ { key: "navigationButtons", label: "settingNavButtons" },
1831
+ { key: "smoothScroll", label: "smoothScroll" }
1680
1832
  ]
1681
1833
  },
1682
1834
  {
@@ -2048,6 +2200,7 @@ function Dialogs({ ctx }) {
2048
2200
  if (dialog?.kind === "indicators") return /* @__PURE__ */ a3(IndicatorPicker, { ctx });
2049
2201
  if (dialog?.kind === "indicatorSettings") return /* @__PURE__ */ a3(IndicatorSettings, { ctx, id: dialog.id });
2050
2202
  if (dialog?.kind === "chartSettings") return /* @__PURE__ */ a3(SettingsDialog, { ctx });
2203
+ if (dialog?.kind === "goToDate") return /* @__PURE__ */ a3(GoToDateDialog, { ctx });
2051
2204
  return null;
2052
2205
  }
2053
2206
 
@@ -2997,7 +3150,11 @@ function ContextMenu({ ctx }) {
2997
3150
  onSelect: () => ctx.chart.addDrawing({ type: "horizontal", points: [{ time, price }] })
2998
3151
  });
2999
3152
  }
3153
+ const smooth = ctx.chart.settings.smoothScroll;
3000
3154
  items.push(
3155
+ { label: t3.goToDateMore, onSelect: () => ctx.store.set({ dialog: { kind: "goToDate" } }) },
3156
+ { label: t3.smoothScroll, checked: smooth, onSelect: () => ctx.chart.setSettings({ smoothScroll: !smooth }) },
3157
+ "separator",
3001
3158
  { label: t3.resetChart, onSelect: () => ctx.chart.resetView() },
3002
3159
  { label: t3.chartSettingsMore, onSelect: () => ctx.store.set({ dialog: { kind: "chartSettings" } }) }
3003
3160
  );
@@ -3005,8 +3162,9 @@ function ContextMenu({ ctx }) {
3005
3162
  (item) => item === "separator" ? /* @__PURE__ */ a3("div", { class: "fnc-ctx-sep", role: "separator" }) : /* @__PURE__ */ a3(
3006
3163
  "button",
3007
3164
  {
3008
- class: "fnc-menu-item",
3009
- role: "menuitem",
3165
+ class: `fnc-menu-item${item.checked !== void 0 ? " fnc-menu-check" : ""}`,
3166
+ role: item.checked !== void 0 ? "menuitemcheckbox" : "menuitem",
3167
+ "aria-checked": item.checked,
3010
3168
  disabled: item.disabled,
3011
3169
  onClick: () => {
3012
3170
  setTarget(null);
@@ -3015,7 +3173,8 @@ function ContextMenu({ ctx }) {
3015
3173
  children: [
3016
3174
  item.icon === "alert" && /* @__PURE__ */ a3(BellIcon, {}),
3017
3175
  /* @__PURE__ */ a3("span", { children: item.label }),
3018
- item.shortcut && /* @__PURE__ */ a3("kbd", { children: item.shortcut })
3176
+ item.shortcut && /* @__PURE__ */ a3("kbd", { children: item.shortcut }),
3177
+ item.checked && /* @__PURE__ */ a3(CheckIcon, {})
3019
3178
  ]
3020
3179
  }
3021
3180
  )
@@ -4235,6 +4394,28 @@ var CSS = (
4235
4394
  @media (hover: none) {
4236
4395
  .fnc-nav { display: none; }
4237
4396
  }
4397
+ /* A setting in a menu (\uBD80\uB4DC\uB7EC\uC6B4 \uC2A4\uD06C\uB864\xB7\uD655\uB300): the check at the end. */
4398
+ .fnc-menu-check svg { margin-left: auto; color: var(--fnc-accent); }
4399
+
4400
+ /* \uB0A0\uC9DC\uB85C \uC774\uB3D9: a date typed or picked on a month calendar. */
4401
+ .fnc-goto-dialog { width: min(320px, calc(100% - 32px)); }
4402
+ .fnc-goto-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 16px; }
4403
+ .fnc-goto-input { height: 38px; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
4404
+ .fnc-goto-input[aria-invalid="true"] { box-shadow: 0 0 0 1px var(--fnc-down, #f04452); }
4405
+ .fnc-cal-head { display: flex; align-items: center; gap: 2px; }
4406
+ .fnc-cal-head b { flex: 1; text-align: center; font-size: 14px; }
4407
+ .fnc-cal-head .fnc-btn { width: 30px; height: 30px; font-size: 16px; }
4408
+ .fnc-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 4px; }
4409
+ .fnc-cal-wd { padding: 4px 0; text-align: center; font-size: 11px; color: var(--fnc-text-2); }
4410
+ .fnc-cal-day { height: 34px; border-radius: var(--fnc-radius); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--fnc-text); }
4411
+ .fnc-cal-day:hover:not(:disabled) { background: var(--fnc-surface); }
4412
+ .fnc-cal-day.is-today { box-shadow: inset 0 0 0 1px var(--fnc-border); }
4413
+ .fnc-cal-day.is-on { background: var(--fnc-accent); color: #fff; font-weight: 700; }
4414
+ .fnc-cal-day:disabled { opacity: 0.3; cursor: default; }
4415
+ .fnc-goto-actions { display: flex; gap: 8px; }
4416
+ .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; }
4417
+ .fnc-goto-dialog .fnc-goto-go { flex: 1; height: 36px; }
4418
+
4238
4419
  /* The + on the price axis at the crosshair price, and its menu (mouse only). */
4239
4420
  .fnc-axis-plus { position: absolute; z-index: 25; }
4240
4421
  .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); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
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.3"
45
+ "@funnest/charts": "0.8.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"