@funnest/charts-ui 0.10.7 → 0.11.0

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.
@@ -1,7 +1,8 @@
1
1
  import type { WidgetContext } from '../context.js';
2
2
  /**
3
- * Chart settings ("차트 설정"). Changes apply immediately (live preview), like TradingView;
4
- * "기본값으로" restores DEFAULT_CHART_SETTINGS.
3
+ * Chart settings ("차트 설정"), in tabs, with a live demo chart beside them (above them on a
4
+ * phone) drawn with the settings as they are now. Changes apply to the chart immediately, like
5
+ * TradingView; "기본값으로" restores DEFAULT_CHART_SETTINGS.
5
6
  */
6
7
  export declare function SettingsDialog({ ctx }: {
7
8
  ctx: WidgetContext;
package/dist/i18n.d.ts CHANGED
@@ -73,6 +73,28 @@ export declare const STRINGS: {
73
73
  scaleNormal: string;
74
74
  scaleLog: string;
75
75
  scalePercent: string;
76
+ scalePercentLong: string;
77
+ scaleIndexed: string;
78
+ scaleIndexedShort: string;
79
+ settingsTabLook: string;
80
+ settingsTabMotion: string;
81
+ settingsWatermark: string;
82
+ settingsPreview: string;
83
+ settingsPreviewHint: string;
84
+ settingZoomAnimation: string;
85
+ settingScrollInertia: string;
86
+ settingAxisAnimation: string;
87
+ settingPriceAnimation: string;
88
+ settingDrawOnLoad: string;
89
+ settingSymbolWatermark: string;
90
+ settingReplayWatermark: string;
91
+ hintZoomAnimation: string;
92
+ hintScrollInertia: string;
93
+ hintAxisAnimation: string;
94
+ hintPriceAnimation: string;
95
+ hintDrawOnLoad: string;
96
+ hintSymbolWatermark: string;
97
+ hintReplayWatermark: string;
76
98
  undo: string;
77
99
  tools: string;
78
100
  horizontalAt: string;
@@ -362,6 +384,28 @@ export declare const STRINGS: {
362
384
  scaleNormal: string;
363
385
  scaleLog: string;
364
386
  scalePercent: string;
387
+ scalePercentLong: string;
388
+ scaleIndexed: string;
389
+ scaleIndexedShort: string;
390
+ settingsTabLook: string;
391
+ settingsTabMotion: string;
392
+ settingsWatermark: string;
393
+ settingsPreview: string;
394
+ settingsPreviewHint: string;
395
+ settingZoomAnimation: string;
396
+ settingScrollInertia: string;
397
+ settingAxisAnimation: string;
398
+ settingPriceAnimation: string;
399
+ settingDrawOnLoad: string;
400
+ settingSymbolWatermark: string;
401
+ settingReplayWatermark: string;
402
+ hintZoomAnimation: string;
403
+ hintScrollInertia: string;
404
+ hintAxisAnimation: string;
405
+ hintPriceAnimation: string;
406
+ hintDrawOnLoad: string;
407
+ hintSymbolWatermark: string;
408
+ hintReplayWatermark: string;
365
409
  undo: string;
366
410
  tools: string;
367
411
  horizontalAt: string;
package/dist/index.js CHANGED
@@ -502,6 +502,28 @@ var STRINGS = {
502
502
  scaleNormal: "\uC77C\uBC18",
503
503
  scaleLog: "\uB85C\uADF8",
504
504
  scalePercent: "%",
505
+ scalePercentLong: "\uD37C\uC13C\uD2B8",
506
+ scaleIndexed: "100 \uAE30\uC900",
507
+ scaleIndexedShort: "100",
508
+ settingsTabLook: "\uBAA8\uC2B5",
509
+ settingsTabMotion: "\uC560\uB2C8\uBA54\uC774\uC158",
510
+ settingsWatermark: "\uC6CC\uD130\uB9C8\uD06C",
511
+ settingsPreview: "\uBBF8\uB9AC\uBCF4\uAE30",
512
+ settingsPreviewHint: "\uBC14\uAFBC \uC124\uC815\uC774 \uBC14\uB85C \uBCF4\uC5EC\uC694. \uB04C\uAC70\uB098 \uD720\uB85C \uC6C0\uC9C1\uC5EC \uBCFC \uC218 \uC788\uC5B4\uC694.",
513
+ settingZoomAnimation: "\uD655\uB300\xB7\uCD95\uC18C \uC560\uB2C8\uBA54\uC774\uC158",
514
+ settingScrollInertia: "\uC774\uB3D9 \uAD00\uC131",
515
+ settingAxisAnimation: "\uAC00\uACA9 \uCD95 \uC560\uB2C8\uBA54\uC774\uC158",
516
+ settingPriceAnimation: "\uAC00\uACA9 \uBCC0\uB3D9 \uC560\uB2C8\uBA54\uC774\uC158",
517
+ settingDrawOnLoad: "\uB85C\uB4DC \uC2DC \uADF8\uB9AC\uAE30 \uD6A8\uACFC",
518
+ settingSymbolWatermark: "\uC885\uBAA9 \uC6CC\uD130\uB9C8\uD06C",
519
+ settingReplayWatermark: "\uB9AC\uD50C\uB808\uC774 \uC6CC\uD130\uB9C8\uD06C",
520
+ hintZoomAnimation: "\uD720\uB85C \uD655\uB300\xB7\uCD95\uC18C\uD560 \uB54C \uD55C \uBC88\uC5D0 \uAC74\uB108\uB6F0\uC9C0 \uC54A\uACE0 \uBD80\uB4DC\uB7FD\uAC8C \uB530\uB77C\uAC00\uC694.",
521
+ hintScrollInertia: "\uB9C8\uC6B0\uC2A4\uB85C \uB04C\uB2E4\uAC00 \uB193\uC73C\uBA74 \uCC28\uD2B8\uAC00 \uC870\uAE08 \uB354 \uBBF8\uB044\uB7EC\uC838\uC694. \uB044\uBA74 \uB193\uC740 \uC790\uB9AC\uC5D0\uC11C \uBC14\uB85C \uBA48\uCDB0\uC694.",
522
+ hintAxisAnimation: "\uBCF4\uC774\uB294 \uCE94\uB4E4\uC5D0 \uB9DE\uCDB0 \uAC00\uACA9 \uCD95 \uBC94\uC704\uAC00 \uBC14\uB014 \uB54C \uAC74\uB108\uB6F0\uC9C0 \uC54A\uACE0 \uBD80\uB4DC\uB7FD\uAC8C \uC6C0\uC9C1\uC5EC\uC694.",
523
+ hintPriceAnimation: "\uC0C8 \uAC00\uACA9\uC774 \uB4E4\uC5B4\uC624\uBA74 \uB9C8\uC9C0\uB9C9 \uCE94\uB4E4\uACFC \uD604\uC7AC\uAC00 \uC120\uC774 \uC0C8 \uAC00\uACA9\uAE4C\uC9C0 \uBBF8\uB044\uB7EC\uC9C0\uB4EF \uC6C0\uC9C1\uC5EC\uC694.",
524
+ hintDrawOnLoad: "\uC885\uBAA9\uC774\uB098 \uC8FC\uAE30\uB97C \uBC14\uAFD4 \uCC28\uD2B8\uB97C \uBD88\uB7EC\uC62C \uB54C \uCE94\uB4E4\uC774 \uC67C\uCABD\uBD80\uD130 \uCC28\uB840\uB85C \uADF8\uB824\uC838\uC694.",
525
+ hintSymbolWatermark: "\uAC00\uACA9 \uC601\uC5ED \uAC00\uC6B4\uB370\uC5D0 \uC885\uBAA9 \uC774\uB984\uACFC \uC8FC\uAE30\uB97C \uD750\uB9AC\uAC8C \uBCF4\uC5EC\uC918\uC694.",
526
+ hintReplayWatermark: '\uB9AC\uD50C\uB808\uC774 \uC911\uC5D0\uB294 \uAC00\uACA9 \uC601\uC5ED\uC5D0 "\uB9AC\uD50C\uB808\uC774"\uB97C \uD750\uB9AC\uAC8C \uBCF4\uC5EC\uC918\uC694.',
505
527
  undo: "\uB418\uB3CC\uB9AC\uAE30",
506
528
  tools: "\uB3C4\uAD6C",
507
529
  horizontalAt: "{price}\uC5D0 \uC218\uD3C9\uC120 \uAE0B\uAE30",
@@ -793,6 +815,28 @@ var STRINGS = {
793
815
  scaleNormal: "Regular",
794
816
  scaleLog: "Log",
795
817
  scalePercent: "%",
818
+ scalePercentLong: "Percent",
819
+ scaleIndexed: "Indexed to 100",
820
+ scaleIndexedShort: "100",
821
+ settingsTabLook: "Appearance",
822
+ settingsTabMotion: "Animation",
823
+ settingsWatermark: "Watermark",
824
+ settingsPreview: "Preview",
825
+ settingsPreviewHint: "Changes show here right away. Drag or scroll to try them.",
826
+ settingZoomAnimation: "Zoom animation",
827
+ settingScrollInertia: "Scroll inertia",
828
+ settingAxisAnimation: "Price axis animation",
829
+ settingPriceAnimation: "Price change animation",
830
+ settingDrawOnLoad: "Draw-in on load",
831
+ settingSymbolWatermark: "Symbol watermark",
832
+ settingReplayWatermark: "Replay watermark",
833
+ hintZoomAnimation: "Wheel zoom eases in instead of jumping.",
834
+ hintScrollInertia: "A mouse drag let go glides on a little. Off: the chart stops where you let go.",
835
+ hintAxisAnimation: "The price axis slides to its new range as the visible candles change, instead of jumping.",
836
+ hintPriceAnimation: "A new price slides the last candle and the last-price line to it.",
837
+ hintDrawOnLoad: "Candles draw in from the left when a symbol or interval loads.",
838
+ hintSymbolWatermark: "The symbol and interval, faint in the middle of the price pane.",
839
+ hintReplayWatermark: '"Replay", faint in the price pane while a replay runs.',
796
840
  undo: "Undo",
797
841
  tools: "Tools",
798
842
  horizontalAt: "Horizontal line at {price}",
@@ -2861,7 +2905,12 @@ function IndicatorSettings({ ctx, id, Dialog: Dialog2 }) {
2861
2905
  }
2862
2906
 
2863
2907
  // src/components/settings-dialog.tsx
2864
- import { CHART_THEMES, DEFAULT_CHART_SETTINGS, matchChartTheme } from "@funnest/charts";
2908
+ import {
2909
+ CHART_THEMES,
2910
+ DEFAULT_CHART_SETTINGS,
2911
+ matchChartTheme,
2912
+ resolutionToMs as resolutionToMs2
2913
+ } from "@funnest/charts";
2865
2914
  function toHex(color) {
2866
2915
  const ctx = document.createElement("canvas").getContext("2d");
2867
2916
  if (!ctx) return "#000000";
@@ -2869,38 +2918,44 @@ function toHex(color) {
2869
2918
  ctx.fillStyle = color;
2870
2919
  return ctx.fillStyle.startsWith("#") ? ctx.fillStyle : "#000000";
2871
2920
  }
2872
- var SECTIONS = [
2873
- {
2874
- title: "settingsDisplay",
2875
- toggles: [
2876
- { key: "highLowMarkers", label: "settingHighLow" },
2877
- { key: "lastPriceLine", label: "settingLastPrice" },
2878
- { key: "countdown", label: "settingCountdown" },
2879
- { key: "extendedPriceLine", label: "settingExtendedPrice" },
2880
- { key: "volume", label: "settingVolume" },
2881
- { key: "navigationButtons", label: "settingNavButtons" },
2882
- { key: "smoothScroll", label: "smoothScroll" },
2883
- { key: "lockView", label: "lockView" },
2884
- { key: "lockRatio", label: "lockRatio" }
2885
- ]
2886
- },
2887
- {
2888
- title: "settingsGrid",
2889
- toggles: [
2890
- { key: "gridHorizontal", label: "settingGridH" },
2891
- { key: "gridVertical", label: "settingGridV" }
2892
- ]
2893
- }
2921
+ var GRID = [
2922
+ { key: "gridHorizontal", label: "settingGridH" },
2923
+ { key: "gridVertical", label: "settingGridV" }
2924
+ ];
2925
+ var SCALE_ROWS = [
2926
+ { key: "lastPriceLine", label: "settingLastPrice" },
2927
+ { key: "countdown", label: "settingCountdown" },
2928
+ { key: "extendedPriceLine", label: "settingExtendedPrice" },
2929
+ { key: "highLowMarkers", label: "settingHighLow" },
2930
+ { key: "lockRatio", label: "lockRatio" }
2931
+ ];
2932
+ var VIEW_ROWS = [
2933
+ { key: "volume", label: "settingVolume" },
2934
+ { key: "navigationButtons", label: "settingNavButtons" },
2935
+ { key: "lockView", label: "lockView" }
2936
+ ];
2937
+ var WATERMARK_ROWS = [
2938
+ { key: "symbolWatermark", label: "settingSymbolWatermark", hint: "hintSymbolWatermark" },
2939
+ { key: "replayWatermark", label: "settingReplayWatermark", hint: "hintReplayWatermark" }
2940
+ ];
2941
+ var MOTION_ROWS = [
2942
+ { key: "zoomAnimation", label: "settingZoomAnimation", hint: "hintZoomAnimation" },
2943
+ { key: "scrollInertia", label: "settingScrollInertia", hint: "hintScrollInertia" },
2944
+ { key: "priceAxisAnimation", label: "settingAxisAnimation", hint: "hintAxisAnimation" },
2945
+ { key: "priceAnimation", label: "settingPriceAnimation", hint: "hintPriceAnimation" },
2946
+ { key: "drawOnLoad", label: "settingDrawOnLoad", hint: "hintDrawOnLoad" }
2894
2947
  ];
2895
2948
  var SCALES = [
2896
2949
  { mode: "normal", label: "scaleNormal" },
2897
- { mode: "log", label: "scaleLog" },
2898
- { mode: "percent", label: "scalePercent" }
2950
+ { mode: "percent", label: "scalePercentLong" },
2951
+ { mode: "indexed", label: "scaleIndexed" },
2952
+ { mode: "log", label: "scaleLog" }
2899
2953
  ];
2900
2954
  function SettingsDialog({ ctx }) {
2901
2955
  const { locale } = useStore(ctx.store);
2902
2956
  const t3 = stringsOf(ctx.store.get());
2903
2957
  const [settings, setSettings] = d2(ctx.chart.settings);
2958
+ const [tab, setTab] = d2("look");
2904
2959
  const [, bump] = d2(0);
2905
2960
  const appToggles = ctx.settingsToggles?.(ctx.chart) ?? [];
2906
2961
  A2(() => ctx.chart.on("settingsChange", setSettings), [ctx.chart]);
@@ -2908,109 +2963,214 @@ function SettingsDialog({ ctx }) {
2908
2963
  const set = (patch) => ctx.chart.setSettings(patch);
2909
2964
  const themeColor = (name) => toHex(getComputedStyle(ctx.root).getPropertyValue(name).trim());
2910
2965
  const currentTheme = matchChartTheme(settings);
2911
- return /* @__PURE__ */ a3("div", { class: "fnc-backdrop", onPointerDown: (e3) => e3.target === e3.currentTarget && close(), children: /* @__PURE__ */ a3("div", { class: "fnc-dialog", role: "dialog", "aria-modal": "true", "aria-label": t3.chartSettings, onKeyDown: (e3) => e3.key === "Escape" && close(), children: [
2966
+ const tabs = [
2967
+ ["look", t3.settingsTabLook],
2968
+ ["scale", t3.settingsScale],
2969
+ ["view", t3.settingsDisplay],
2970
+ ["motion", t3.settingsTabMotion],
2971
+ ...appToggles.length > 0 ? [["symbol", t3.settingsSymbol]] : []
2972
+ ];
2973
+ const shown = tabs.some(([k2]) => k2 === tab) ? tab : "look";
2974
+ const toggles = (rows) => rows.map(({ key, label, hint }) => /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
2975
+ /* @__PURE__ */ a3("span", { class: "fnc-toggle-label", children: t3[label] }),
2976
+ hint && /* @__PURE__ */ a3(Info, { text: t3[hint] }),
2977
+ /* @__PURE__ */ a3("input", { type: "checkbox", role: "switch", class: "fnc-switch", checked: settings[key], onChange: (e3) => set({ [key]: e3.currentTarget.checked }) })
2978
+ ] }));
2979
+ return /* @__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: [
2912
2980
  /* @__PURE__ */ a3("div", { class: "fnc-dialog-head", children: [
2913
2981
  /* @__PURE__ */ a3("b", { children: t3.chartSettings }),
2914
2982
  /* @__PURE__ */ a3("button", { class: "fnc-btn", "aria-label": t3.close, onClick: close, children: /* @__PURE__ */ a3(CloseIcon, {}) })
2915
2983
  ] }),
2916
- /* @__PURE__ */ a3("form", { class: "fnc-form", onSubmit: (e3) => (e3.preventDefault(), close()), children: [
2917
- /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsTheme }),
2918
- /* @__PURE__ */ a3("div", { class: "fnc-themes", role: "radiogroup", "aria-label": t3.settingsTheme, children: CHART_THEMES.map((theme) => {
2919
- const c3 = theme.colors;
2920
- const bg = c3.background ?? themeColor("--fnc-bg");
2921
- const grid = c3.gridColor ?? themeColor("--fnc-border");
2922
- const up = c3.upColor ?? themeColor("--fnc-up");
2923
- const down = c3.downColor ?? themeColor("--fnc-down");
2924
- return /* @__PURE__ */ a3(
2925
- "button",
2926
- {
2927
- type: "button",
2928
- role: "radio",
2929
- class: "fnc-theme",
2930
- "aria-checked": currentTheme?.id === theme.id,
2931
- onClick: () => set({ ...c3 }),
2932
- children: [
2933
- /* @__PURE__ */ a3("svg", { class: "fnc-theme-swatch", viewBox: "0 0 56 36", "aria-hidden": "true", children: [
2934
- /* @__PURE__ */ a3("rect", { x: "0.5", y: "0.5", width: "55", height: "35", rx: "5", fill: bg, stroke: grid }),
2935
- /* @__PURE__ */ a3("path", { d: "M4 12h48M4 24h48", stroke: grid }),
2936
- /* @__PURE__ */ a3("path", { d: "M21 6v24", stroke: up, "stroke-width": "1.5" }),
2937
- /* @__PURE__ */ a3("rect", { x: "17", y: "11", width: "8", height: "13", rx: "1", fill: up }),
2938
- /* @__PURE__ */ a3("path", { d: "M35 8v22", stroke: down, "stroke-width": "1.5" }),
2939
- /* @__PURE__ */ a3("rect", { x: "31", y: "13", width: "8", height: "11", rx: "1", fill: down })
2940
- ] }),
2941
- /* @__PURE__ */ a3("span", { children: theme.name[locale === "en" ? "en" : "ko"] })
2942
- ]
2943
- }
2944
- );
2945
- }) }),
2946
- /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsCandles }),
2947
- ["upColor", "downColor"].map((key) => /* @__PURE__ */ a3("label", { class: "fnc-row", children: [
2948
- /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: key === "upColor" ? t3.settingUpColor : t3.settingDownColor }),
2949
- /* @__PURE__ */ a3(
2950
- "input",
2951
- {
2952
- type: "color",
2953
- class: "fnc-color",
2954
- value: settings[key] ?? themeColor(key === "upColor" ? "--fnc-up" : "--fnc-down"),
2955
- onInput: (e3) => set({ [key]: e3.currentTarget.value })
2956
- }
2957
- ),
2958
- settings[key] && /* @__PURE__ */ a3("button", { type: "button", class: "fnc-link", onClick: () => set({ [key]: null }), children: t3.followTheme })
2959
- ] })),
2960
- /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsScale }),
2961
- /* @__PURE__ */ a3("div", { class: "fnc-row", children: /* @__PURE__ */ a3("div", { class: "fnc-seg", role: "radiogroup", "aria-label": t3.settingsScale, children: SCALES.map(({ mode, label }) => /* @__PURE__ */ a3(
2962
- "button",
2963
- {
2964
- type: "button",
2965
- role: "radio",
2966
- "aria-checked": settings.priceScale === mode,
2967
- onClick: () => set({ priceScale: mode }),
2968
- children: t3[label]
2969
- }
2970
- )) }) }),
2971
- SECTIONS.map((section) => /* @__PURE__ */ a3($, { children: [
2972
- /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3[section.title] }),
2973
- section.toggles.map(({ key, label }) => /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
2974
- /* @__PURE__ */ a3("span", { children: t3[label] }),
2975
- /* @__PURE__ */ a3(
2976
- "input",
2977
- {
2978
- type: "checkbox",
2979
- role: "switch",
2980
- class: "fnc-switch",
2981
- checked: settings[key],
2982
- onChange: (e3) => set({ [key]: e3.currentTarget.checked })
2983
- }
2984
- )
2985
- ] }))
2986
- ] })),
2987
- appToggles.length > 0 && /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsSymbol }),
2988
- appToggles.map((item) => /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
2989
- /* @__PURE__ */ a3("span", { children: [
2990
- item.label,
2991
- item.hint && /* @__PURE__ */ a3("small", { class: "fnc-toggle-hint", children: item.hint })
2992
- ] }),
2993
- /* @__PURE__ */ a3(
2994
- "input",
2995
- {
2996
- type: "checkbox",
2997
- role: "switch",
2998
- class: "fnc-switch",
2999
- checked: item.checked,
3000
- onChange: (e3) => {
3001
- item.onChange(e3.currentTarget.checked);
3002
- bump((n2) => n2 + 1);
3003
- }
3004
- }
3005
- )
3006
- ] })),
3007
- /* @__PURE__ */ a3("div", { class: "fnc-form-actions", children: [
3008
- /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action fnc-action-danger", onClick: () => ctx.chart.setSettings(DEFAULT_CHART_SETTINGS), children: t3.resetDefaults }),
3009
- /* @__PURE__ */ a3("button", { type: "submit", class: "fnc-action fnc-action-primary", children: t3.done })
3010
- ] })
2984
+ /* @__PURE__ */ a3("div", { class: "fnc-settings-body", children: [
2985
+ /* @__PURE__ */ a3("div", { class: "fnc-settings-side", children: [
2986
+ /* @__PURE__ */ a3("div", { class: "fnc-tabs fnc-settings-tabs", role: "tablist", "aria-label": t3.chartSettings, children: tabs.map(([k2, label]) => /* @__PURE__ */ a3("button", { type: "button", class: "fnc-tab", role: "tab", "aria-selected": shown === k2, onClick: () => setTab(k2), children: label })) }),
2987
+ /* @__PURE__ */ a3("form", { class: "fnc-form fnc-settings-form", onSubmit: (e3) => (e3.preventDefault(), close()), children: [
2988
+ shown === "look" && /* @__PURE__ */ a3($, { children: [
2989
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsTheme }),
2990
+ /* @__PURE__ */ a3("div", { class: "fnc-themes", role: "radiogroup", "aria-label": t3.settingsTheme, children: CHART_THEMES.map((theme) => {
2991
+ const c3 = theme.colors;
2992
+ const bg = c3.background ?? themeColor("--fnc-bg");
2993
+ const grid = c3.gridColor ?? themeColor("--fnc-border");
2994
+ const up = c3.upColor ?? themeColor("--fnc-up");
2995
+ const down = c3.downColor ?? themeColor("--fnc-down");
2996
+ return /* @__PURE__ */ a3("button", { type: "button", role: "radio", class: "fnc-theme", "aria-checked": currentTheme?.id === theme.id, onClick: () => set({ ...c3 }), children: [
2997
+ /* @__PURE__ */ a3("svg", { class: "fnc-theme-swatch", viewBox: "0 0 56 36", "aria-hidden": "true", children: [
2998
+ /* @__PURE__ */ a3("rect", { x: "0.5", y: "0.5", width: "55", height: "35", rx: "5", fill: bg, stroke: grid }),
2999
+ /* @__PURE__ */ a3("path", { d: "M4 12h48M4 24h48", stroke: grid }),
3000
+ /* @__PURE__ */ a3("path", { d: "M21 6v24", stroke: up, "stroke-width": "1.5" }),
3001
+ /* @__PURE__ */ a3("rect", { x: "17", y: "11", width: "8", height: "13", rx: "1", fill: up }),
3002
+ /* @__PURE__ */ a3("path", { d: "M35 8v22", stroke: down, "stroke-width": "1.5" }),
3003
+ /* @__PURE__ */ a3("rect", { x: "31", y: "13", width: "8", height: "11", rx: "1", fill: down })
3004
+ ] }),
3005
+ /* @__PURE__ */ a3("span", { children: theme.name[locale === "en" ? "en" : "ko"] })
3006
+ ] });
3007
+ }) }),
3008
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsCandles }),
3009
+ ["upColor", "downColor"].map((key) => /* @__PURE__ */ a3("label", { class: "fnc-row", children: [
3010
+ /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: key === "upColor" ? t3.settingUpColor : t3.settingDownColor }),
3011
+ /* @__PURE__ */ a3("input", { type: "color", class: "fnc-color", value: settings[key] ?? themeColor(key === "upColor" ? "--fnc-up" : "--fnc-down"), onInput: (e3) => set({ [key]: e3.currentTarget.value }) }),
3012
+ settings[key] && /* @__PURE__ */ a3("button", { type: "button", class: "fnc-link", onClick: () => set({ [key]: null }), children: t3.followTheme })
3013
+ ] })),
3014
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsGrid }),
3015
+ toggles(GRID)
3016
+ ] }),
3017
+ shown === "scale" && /* @__PURE__ */ a3($, { children: [
3018
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsScale }),
3019
+ /* @__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] })) }),
3020
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsDisplay }),
3021
+ toggles(SCALE_ROWS)
3022
+ ] }),
3023
+ shown === "view" && /* @__PURE__ */ a3($, { children: [
3024
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsDisplay }),
3025
+ toggles(VIEW_ROWS),
3026
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsWatermark }),
3027
+ toggles(WATERMARK_ROWS)
3028
+ ] }),
3029
+ shown === "motion" && /* @__PURE__ */ a3($, { children: [
3030
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsTabMotion }),
3031
+ toggles(MOTION_ROWS)
3032
+ ] }),
3033
+ shown === "symbol" && appToggles.map((item) => /* @__PURE__ */ a3("label", { class: "fnc-row fnc-toggle-row", children: [
3034
+ /* @__PURE__ */ a3("span", { class: "fnc-toggle-label", children: [
3035
+ item.label,
3036
+ item.hint && /* @__PURE__ */ a3("small", { class: "fnc-toggle-hint", children: item.hint })
3037
+ ] }),
3038
+ /* @__PURE__ */ a3(
3039
+ "input",
3040
+ {
3041
+ type: "checkbox",
3042
+ role: "switch",
3043
+ class: "fnc-switch",
3044
+ checked: item.checked,
3045
+ onChange: (e3) => {
3046
+ item.onChange(e3.currentTarget.checked);
3047
+ bump((n2) => n2 + 1);
3048
+ }
3049
+ }
3050
+ )
3051
+ ] }))
3052
+ ] })
3053
+ ] }),
3054
+ /* @__PURE__ */ a3(Preview, { ctx, settings, t: t3 })
3055
+ ] }),
3056
+ /* @__PURE__ */ a3("div", { class: "fnc-form-actions fnc-settings-actions", children: [
3057
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action fnc-action-danger", onClick: () => ctx.chart.setSettings(DEFAULT_CHART_SETTINGS), children: t3.resetDefaults }),
3058
+ /* @__PURE__ */ a3("button", { type: "button", class: "fnc-action fnc-action-primary", onClick: close, children: t3.done })
3011
3059
  ] })
3012
3060
  ] }) });
3013
3061
  }
3062
+ function Info({ text }) {
3063
+ return /* @__PURE__ */ a3("span", { class: "fnc-info", tabIndex: 0, role: "img", "aria-label": text, onClick: (e3) => e3.preventDefault(), children: [
3064
+ "i",
3065
+ /* @__PURE__ */ a3("span", { class: "fnc-info-tip", "aria-hidden": "true", children: text })
3066
+ ] });
3067
+ }
3068
+ function Preview({ ctx, settings, t: t3 }) {
3069
+ const host = T2(null);
3070
+ const demo = T2(null);
3071
+ const reload = T2(() => {
3072
+ });
3073
+ A2(() => {
3074
+ const el = host.current;
3075
+ if (!el) return;
3076
+ const real = ctx.chart;
3077
+ const locale = ctx.store.get().locale;
3078
+ const resolution = real.currentResolution ?? "1D";
3079
+ const interval = Math.min(resolutionToMs2(resolution), 7 * 864e5);
3080
+ const symbol = {
3081
+ symbol: PREVIEW_SYMBOL,
3082
+ name: locale === "en" ? "Funnest" : "\uD380\uB124\uC2A4\uD2B8",
3083
+ exchange: locale === "en" ? "Demo" : "\uB370\uBAA8",
3084
+ timezone: real.symbolInfo?.timezone ?? "Asia/Seoul",
3085
+ session: "24x7",
3086
+ pricePrecision: 0,
3087
+ tickSize: 1,
3088
+ logoUrl: FUNNEST_LOGO,
3089
+ supportedResolutions: [resolution]
3090
+ };
3091
+ const volume = 12e5;
3092
+ const bars = demoBars(PREVIEW_PRICE, interval, 400, volume);
3093
+ let timer = null;
3094
+ const feed = {
3095
+ resolveSymbol: async () => symbol,
3096
+ getBars: async () => ({ bars: bars.slice(), noMoreData: true }),
3097
+ subscribeBars: (_s, _r, onBar) => {
3098
+ let ticks = 0;
3099
+ timer = setInterval(() => {
3100
+ const last = bars[bars.length - 1];
3101
+ const close = Math.round(last.close + last.close * 25e-4 * (Math.random() - 0.48));
3102
+ if (++ticks % 8 === 0) {
3103
+ bars.push({ time: last.time + interval, open: last.close, high: Math.max(last.close, close), low: Math.min(last.close, close), close, volume: volume * 0.05 * Math.random() });
3104
+ } else {
3105
+ bars[bars.length - 1] = { ...last, close, high: Math.max(last.high, close), low: Math.min(last.low, close), volume: (last.volume ?? 0) + volume * 0.04 * Math.random() };
3106
+ }
3107
+ onBar(bars[bars.length - 1]);
3108
+ }, 450);
3109
+ return () => {
3110
+ if (timer) clearInterval(timer);
3111
+ timer = null;
3112
+ };
3113
+ }
3114
+ };
3115
+ const scheme = ctx.root.closest("[data-color-scheme]")?.dataset.colorScheme === "dark" ? "dark" : "light";
3116
+ const widget = createTradingChart(el, {
3117
+ datafeed: feed,
3118
+ symbol: PREVIEW_SYMBOL,
3119
+ resolution,
3120
+ storageKey: null,
3121
+ searchHotkey: false,
3122
+ drawingToolbar: false,
3123
+ attribution: false,
3124
+ chartType: real.type,
3125
+ colorScheme: scheme,
3126
+ theme: real.themeTokens,
3127
+ locale,
3128
+ settings: real.settings,
3129
+ pauseWhenHidden: false
3130
+ });
3131
+ demo.current = widget.chart;
3132
+ const state = { ...real.save(), symbol: PREVIEW_SYMBOL, resolution, drawings: {}, compares: [] };
3133
+ const load = () => void widget.load(state).catch(() => {
3134
+ });
3135
+ reload.current = load;
3136
+ load();
3137
+ return () => {
3138
+ demo.current = null;
3139
+ widget.destroy();
3140
+ };
3141
+ }, [ctx.chart]);
3142
+ const drawOnLoad = T2(settings.drawOnLoad);
3143
+ A2(() => {
3144
+ demo.current?.setSettings(settings);
3145
+ if (settings.drawOnLoad && !drawOnLoad.current) reload.current();
3146
+ drawOnLoad.current = settings.drawOnLoad;
3147
+ }, [settings]);
3148
+ return /* @__PURE__ */ a3("div", { class: "fnc-settings-preview", children: [
3149
+ /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.settingsPreview }),
3150
+ /* @__PURE__ */ a3("div", { class: "fnc-settings-preview-chart", ref: host }),
3151
+ /* @__PURE__ */ a3("small", { class: "fnc-toggle-hint", children: t3.settingsPreviewHint })
3152
+ ] });
3153
+ }
3154
+ var PREVIEW_SYMBOL = "__fnc_preview";
3155
+ var PREVIEW_PRICE = 12500;
3156
+ var FUNNEST_LOGO = `data:image/svg+xml,${encodeURIComponent(
3157
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#8B6CFF"/><stop offset="1" stop-color="#5A3BF0"/></linearGradient></defs><rect width="32" height="32" rx="9" fill="url(#g)"/><path d="M7 13.5C9.5 21.5 17 23.5 23.4 11.2" fill="none" stroke="#fff" stroke-width="3.2" stroke-linecap="round"/><circle cx="24.6" cy="8.6" r="2.9" fill="#FFD43B"/></svg>'
3158
+ )}`;
3159
+ function demoBars(price, interval, count, volume) {
3160
+ const bars = [];
3161
+ const end = Math.floor(Date.now() / interval) * interval;
3162
+ let close = price * (1 + (Math.random() - 0.5) * 0.04);
3163
+ for (let i3 = count - 1; i3 >= 0; i3--) {
3164
+ const open = close;
3165
+ close = open * (1 + (Math.random() - 0.49) * 0.012);
3166
+ const high = Math.max(open, close) * (1 + Math.random() * 4e-3);
3167
+ const low = Math.min(open, close) * (1 - Math.random() * 4e-3);
3168
+ bars.push({ time: end - i3 * interval, open, high, low, close, volume: volume * (0.3 + Math.random() * 1.4) });
3169
+ }
3170
+ const shift = price - close;
3171
+ const won = (v3) => Math.round(v3 + shift);
3172
+ return bars.map((b) => ({ ...b, open: won(b.open), high: won(b.high), low: won(b.low), close: won(b.close) }));
3173
+ }
3014
3174
 
3015
3175
  // src/components/indicator-dialogs.tsx
3016
3176
  function Dialog({ title, onClose, children, wide }) {
@@ -3130,7 +3290,7 @@ function Dialogs({ ctx }) {
3130
3290
  }
3131
3291
 
3132
3292
  // src/components/interval-picker.tsx
3133
- import { derivedBase as derivedBase2, resolutionToMs as resolutionToMs2 } from "@funnest/charts";
3293
+ import { derivedBase as derivedBase2, resolutionToMs as resolutionToMs3 } from "@funnest/charts";
3134
3294
 
3135
3295
  // src/components/keep-in-view.ts
3136
3296
  var MARGIN = 8;
@@ -3197,7 +3357,7 @@ function IntervalPicker({ ctx }) {
3197
3357
  const supported = s3.symbol?.supportedResolutions;
3198
3358
  const isSupported = (r3) => !supported || supported.includes(r3) || !!derivedBase2(r3, supported);
3199
3359
  const listed = new Set(ctx.intervalGroups.flatMap((g3) => g3.intervals));
3200
- const custom = s3.customIntervals.filter((r3) => !listed.has(r3)).sort((a4, b) => resolutionToMs2(a4) - resolutionToMs2(b));
3360
+ const custom = s3.customIntervals.filter((r3) => !listed.has(r3)).sort((a4, b) => resolutionToMs3(a4) - resolutionToMs3(b));
3201
3361
  const order = [...ctx.intervalGroups.flatMap((g3) => g3.intervals), ...custom];
3202
3362
  const [amount, setAmount] = d2("2");
3203
3363
  const [unit, setUnit] = d2(1);
@@ -3209,7 +3369,7 @@ function IntervalPicker({ ctx }) {
3209
3369
  select(r3);
3210
3370
  };
3211
3371
  const favorites = s3.favoriteIntervals;
3212
- const byTime = (a4, b) => order.includes(a4) && order.includes(b) ? order.indexOf(a4) - order.indexOf(b) : resolutionToMs2(a4) - resolutionToMs2(b);
3372
+ const byTime = (a4, b) => order.includes(a4) && order.includes(b) ? order.indexOf(a4) - order.indexOf(b) : resolutionToMs3(a4) - resolutionToMs3(b);
3213
3373
  const chips = [.../* @__PURE__ */ new Set([...favorites, ...s3.resolution ? [s3.resolution] : []])].sort(byTime);
3214
3374
  const select = (r3) => {
3215
3375
  setOpen(false);
@@ -3794,8 +3954,9 @@ var TYPES = [
3794
3954
  ];
3795
3955
  var SCALES2 = [
3796
3956
  { mode: "normal", label: "scaleNormal" },
3797
- { mode: "log", label: "scaleLog" },
3798
- { mode: "percent", label: "scalePercent" }
3957
+ { mode: "percent", label: "scalePercent" },
3958
+ { mode: "indexed", label: "scaleIndexedShort" },
3959
+ { mode: "log", label: "scaleLog" }
3799
3960
  ];
3800
3961
  var SYNC_KEYS = [
3801
3962
  { key: "crosshair", label: "syncCrosshair" },
@@ -4080,7 +4241,8 @@ function ContextMenu({ ctx }) {
4080
4241
  onSelect: () => ctx.chart.addDrawing({ type: "horizontal", points: [{ time, price }] })
4081
4242
  });
4082
4243
  }
4083
- const { smoothScroll: smooth, lockView, lockRatio } = ctx.chart.settings;
4244
+ const { zoomAnimation, scrollInertia, lockView, lockRatio } = ctx.chart.settings;
4245
+ const smooth = zoomAnimation && scrollInertia;
4084
4246
  items.push(
4085
4247
  { label: t3.goToDateMore, onSelect: () => ctx.store.set({ dialog: { kind: "goToDate" } }) },
4086
4248
  { label: t3.smoothScroll, checked: smooth, onSelect: () => ctx.chart.setSettings({ smoothScroll: !smooth }) },
@@ -5940,6 +6102,92 @@ var CSS = (
5940
6102
  .fnc-seg button[aria-checked='true'] { background: var(--fnc-bg); color: var(--fnc-text); font-weight: 700; box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
5941
6103
  .fnc-seg-sm button { min-width: 36px; height: 26px; padding: 0 6px; font-size: 12px; }
5942
6104
 
6105
+ /* \u2500\u2500 \uCC28\uD2B8 \uC124\uC815: tabs and settings on the left, a live demo chart on the right (on top on a phone) \u2500\u2500 */
6106
+ .fnc-dialog.fnc-settings-dialog { width: min(940px, calc(100% - 32px)); height: min(660px, 100%); max-height: none; }
6107
+ .fnc-settings-body { display: flex; flex: 1; min-height: 0; }
6108
+ .fnc-settings-side { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; border-right: 1px solid var(--fnc-border); }
6109
+ .fnc-settings-side .fnc-settings-tabs { flex: none; padding: 12px 20px 0; }
6110
+ .fnc-root .fnc-dialog form.fnc-settings-form { flex: 1; min-height: 0; overflow-y: auto; }
6111
+ .fnc-settings-preview { display: flex; flex-direction: column; gap: 8px; flex: 1.2 1 0; min-width: 0; padding: 20px; }
6112
+ .fnc-settings-preview-chart { position: relative; flex: 1; min-height: 160px; border: 1px solid var(--fnc-border); border-radius: 12px; overflow: hidden; }
6113
+ /* A phone on its side (short, touch): the whole screen, the settings and the preview side by side. */
6114
+ @media (max-height: 500px) and (pointer: coarse) {
6115
+ .fnc-backdrop:has(> .fnc-settings-dialog) { padding: 0; align-items: stretch; }
6116
+ .fnc-dialog.fnc-settings-dialog { width: 100%; height: 100%; border-radius: 0; }
6117
+ .fnc-settings-dialog .fnc-dialog-head { height: 44px; }
6118
+ .fnc-settings-side .fnc-settings-tabs { gap: 2px; padding: 6px 12px 0; }
6119
+ .fnc-settings-tabs .fnc-tab { flex: 1 1 auto; padding: 0 6px; font-size: 12.5px; }
6120
+ .fnc-settings-preview { padding: 8px 12px; }
6121
+ .fnc-settings-preview .fnc-section, .fnc-settings-preview .fnc-toggle-hint { display: none; }
6122
+ .fnc-settings-preview-chart .fnc-ranges { display: none; }
6123
+ .fnc-form-actions.fnc-settings-actions { padding: 6px 16px; }
6124
+ }
6125
+ /* The preview is the real widget without its toolbar (and drawing bar, off by option). */
6126
+ .fnc-settings-preview-chart > .fnc-root { position: absolute; inset: 0; }
6127
+ .fnc-settings-preview-chart .fnc-toolbar { display: none; }
6128
+ .fnc-form-actions.fnc-settings-actions { position: static; flex: none; margin: 0; padding: 12px 20px; }
6129
+ .fnc-settings-seg { display: flex; }
6130
+ .fnc-settings-seg button { flex: 1; min-width: 0; padding: 0 6px; white-space: nowrap; }
6131
+ .fnc-toggle-label { flex: 1; min-width: 0; }
6132
+ .fnc-info {
6133
+ position: relative;
6134
+ display: inline-flex;
6135
+ align-items: center;
6136
+ justify-content: center;
6137
+ flex: none;
6138
+ width: 18px;
6139
+ height: 18px;
6140
+ border-radius: 50%;
6141
+ background: var(--fnc-surface);
6142
+ color: var(--fnc-text-2);
6143
+ font-size: 11px;
6144
+ font-weight: 700;
6145
+ line-height: 1;
6146
+ cursor: help;
6147
+ }
6148
+ .fnc-info:focus-visible { outline: 2px solid var(--fnc-accent); outline-offset: 2px; }
6149
+ .fnc-info-tip {
6150
+ position: absolute;
6151
+ top: calc(100% + 6px);
6152
+ right: -8px;
6153
+ z-index: 2;
6154
+ width: max-content;
6155
+ max-width: 240px;
6156
+ padding: 8px 10px;
6157
+ border-radius: 8px;
6158
+ background: var(--fnc-text);
6159
+ color: var(--fnc-bg);
6160
+ font-size: 12px;
6161
+ font-weight: 400;
6162
+ line-height: 1.45;
6163
+ text-align: left;
6164
+ white-space: normal;
6165
+ box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
6166
+ opacity: 0;
6167
+ visibility: hidden;
6168
+ pointer-events: none;
6169
+ transition: opacity 0.12s;
6170
+ }
6171
+ .fnc-info:hover .fnc-info-tip, .fnc-info:focus .fnc-info-tip { opacity: 1; visibility: visible; }
6172
+ /* Stacked when the widget is narrow (a phone, or one pane of a split screen). */
6173
+ @container fnc (max-width: 720px) {
6174
+ /* The whole screen: the preview and the settings both need the height. */
6175
+ .fnc-backdrop:has(> .fnc-settings-dialog) { padding: 0; align-items: stretch; }
6176
+ .fnc-dialog.fnc-settings-dialog { width: 100%; height: 100%; border-radius: 0; }
6177
+ .fnc-settings-dialog .fnc-dialog-head { height: 48px; }
6178
+ .fnc-settings-body { flex-direction: column; }
6179
+ .fnc-settings-preview { order: -1; flex: none; padding: 12px 16px 4px; }
6180
+ .fnc-settings-preview .fnc-section, .fnc-settings-preview .fnc-toggle-hint { display: none; }
6181
+ /* Room for the real widget's legend and a few candles; the settings keep the rest. */
6182
+ .fnc-settings-preview-chart { flex: none; height: clamp(170px, 34dvh, 280px); min-height: 0; }
6183
+ .fnc-settings-preview-chart .fnc-ranges { display: none; }
6184
+ .fnc-settings-side { flex: 1; min-height: 0; border-right: 0; }
6185
+ .fnc-settings-side .fnc-settings-tabs { gap: 2px; padding: 8px 12px 0; }
6186
+ /* The four tabs share the width instead of running off the edge. */
6187
+ .fnc-settings-tabs .fnc-tab { flex: 1 1 auto; padding: 0 6px; font-size: 12.5px; }
6188
+ .fnc-form-actions.fnc-settings-actions { padding: 8px 16px; }
6189
+ }
6190
+
5943
6191
  /* \u2500\u2500 Chart themes (settings dialog) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5944
6192
  .fnc-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; padding: 2px 0 6px; }
5945
6193
  .fnc-theme {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.10.7",
3
+ "version": "0.11.0",
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.10.7"
45
+ "@funnest/charts": "0.11.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"