@funnest/charts-ui 0.6.28 → 0.6.29

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,4 +1,4 @@
1
- import type { WidgetContext } from '../context';
1
+ import type { WidgetContext } from '../context.js';
2
2
  /**
3
3
  * Right-click menu on the chart (mouse only): undo/redo, the host's own items
4
4
  * (`contextMenuItems`), a horizontal line at the clicked price, reset and settings.
@@ -1,5 +1,5 @@
1
1
  import { type JSX } from 'preact';
2
- import type { WidgetContext } from '../context';
2
+ import type { WidgetContext } from '../context.js';
3
3
  /** Left vertical tool bar (TradingView layout). On narrow screens it slides in over the chart. */
4
4
  export declare function DrawingToolbar({ ctx }: {
5
5
  ctx: WidgetContext;
@@ -1,4 +1,4 @@
1
- import type { WidgetContext } from '../context';
1
+ import type { WidgetContext } from '../context.js';
2
2
  export declare function Dialogs({ ctx }: {
3
3
  ctx: WidgetContext;
4
4
  }): import("preact").JSX.Element | null;
@@ -1,4 +1,4 @@
1
- import type { WidgetContext } from '../context';
1
+ import type { WidgetContext } from '../context.js';
2
2
  /**
3
3
  * Favorite intervals as toolbar chips + a grouped menu (분 | 시간 | 일) where hovering a row
4
4
  * reveals a ★ to pin/unpin it. On narrow screens only the menu trigger (showing the current
@@ -1,5 +1,5 @@
1
1
  /** @jsxImportSource preact */
2
- import { type LayoutId } from '../layouts';
2
+ import { type LayoutId } from '../layouts.js';
3
3
  /** Mini drawing of a split layout. */
4
4
  export declare function LayoutGlyph({ id }: {
5
5
  id: LayoutId;
@@ -1,5 +1,5 @@
1
1
  import type { JSX } from 'preact';
2
- import type { WidgetContext } from '../context';
2
+ import type { WidgetContext } from '../context.js';
3
3
  export declare function Overlay({ ctx }: {
4
4
  ctx: WidgetContext;
5
5
  }): JSX.Element;
@@ -1,4 +1,4 @@
1
- import type { WidgetContext } from '../context';
1
+ import type { WidgetContext } from '../context.js';
2
2
  /**
3
3
  * Chart settings ("차트 설정"). Changes apply immediately (live preview), like TradingView;
4
4
  * "기본값으로" restores DEFAULT_CHART_SETTINGS.
@@ -1,4 +1,4 @@
1
- import type { WidgetContext } from '../context';
1
+ import type { WidgetContext } from '../context.js';
2
2
  /**
3
3
  * Symbol search: category tabs, an exchange/favorites sidebar (exchange filter shows as a chip
4
4
  * in the input), ★ favorites, recent searches, match highlighting and — when the datafeed
@@ -1,5 +1,5 @@
1
1
  /** @jsxImportSource preact */
2
- import type { WidgetContext } from '../context';
2
+ import type { WidgetContext } from '../context.js';
3
3
  export declare function Toolbar({ ctx }: {
4
4
  ctx: WidgetContext;
5
5
  }): import("preact").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import type { JSX } from 'preact';
2
- import type { WidgetContext } from '../context';
2
+ import type { WidgetContext } from '../context.js';
3
3
  /**
4
4
  * One "도구" button for the chart's less frequent tools, so the toolbar keeps symbol, interval,
5
5
  * market info and 지표 in view: chart type, split layout (+ sync), compare, replay, price axis,
package/dist/context.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { Chart, ChartContextMenu, ChartLayout, ChartType, CompareInfo, CursorMode, Datafeed, Drawing, DrawingType, IndicatorConfig, LegendItem, Locale, ReplayStatus, Resolution, SymbolInfo } from '@funnest/charts';
2
- import type { LayoutId } from './layouts';
3
- import type { WidgetStorage } from './storage';
4
- import type { Strings } from './i18n';
5
- import type { Store } from './store';
2
+ import type { LayoutId } from './layouts.js';
3
+ import type { WidgetStorage } from './storage.js';
4
+ import type { Strings } from './i18n.js';
5
+ import type { Store } from './store.js';
6
6
  export interface UiState {
7
7
  locale: Locale;
8
8
  /** The app's replacements for built-in words (TradingChartOptions.strings). */
package/dist/i18n.d.ts CHANGED
@@ -107,6 +107,9 @@ export declare const STRINGS: {
107
107
  addIndicator: string;
108
108
  indicatorSettings: string;
109
109
  removeIndicator: string;
110
+ moveIndicatorUp: string;
111
+ moveIndicatorDown: string;
112
+ textEditHint: string;
110
113
  hideVolume: string;
111
114
  volumeDesc: string;
112
115
  apply: string;
@@ -268,6 +271,9 @@ export declare const STRINGS: {
268
271
  addIndicator: string;
269
272
  indicatorSettings: string;
270
273
  removeIndicator: string;
274
+ moveIndicatorUp: string;
275
+ moveIndicatorDown: string;
276
+ textEditHint: string;
271
277
  hideVolume: string;
272
278
  volumeDesc: string;
273
279
  apply: string;
package/dist/index.d.ts CHANGED
@@ -3,11 +3,11 @@
3
3
  * Preact is bundled internally; only a vanilla API is exposed, so consumers
4
4
  * need no framework (React/Vue/Svelte/plain HTML all work).
5
5
  */
6
- export { createTradingChart, DEFAULT_FAVORITE_INTERVALS, DEFAULT_INTERVAL_GROUPS, DEFAULT_SEARCH_CATEGORIES, } from './trading-chart';
7
- export { createMultiChart } from './multi-chart';
8
- export type { MultiChart, MultiChartEvents, MultiChartOptions, MultiChartState, PaneSpec } from './multi-chart';
9
- export { LAYOUT_GROUPS, LAYOUTS, MAX_PANES, paneCount } from './layouts';
10
- export type { LayoutId, SplitNode, SplitSizes } from './layouts';
11
- export type { ContextMenuItem, ContextMenuItems, IntervalGroup, LayoutSync, LegendValues, SearchCategory, SearchExchange, ToolsMenuItem, ToolsMenuItems } from './context';
12
- export type { ColorScheme, TradingChart, TradingChartOptions, TradingChartSlots } from './trading-chart';
13
- export { resolutionLabel, STRINGS, stringsOf, type Strings } from './i18n';
6
+ export { createTradingChart, DEFAULT_FAVORITE_INTERVALS, DEFAULT_INTERVAL_GROUPS, DEFAULT_SEARCH_CATEGORIES, } from './trading-chart.js';
7
+ export { createMultiChart } from './multi-chart.js';
8
+ export type { MultiChart, MultiChartEvents, MultiChartOptions, MultiChartState, PaneSpec } from './multi-chart.js';
9
+ export { LAYOUT_GROUPS, LAYOUTS, MAX_PANES, paneCount } from './layouts.js';
10
+ export type { LayoutId, SplitNode, SplitSizes } from './layouts.js';
11
+ export type { ContextMenuItem, ContextMenuItems, IntervalGroup, LayoutSync, LegendValues, SearchCategory, SearchExchange, ToolsMenuItem, ToolsMenuItems } from './context.js';
12
+ export type { ColorScheme, TradingChart, TradingChartOptions, TradingChartSlots } from './trading-chart.js';
13
+ export { resolutionLabel, STRINGS, stringsOf, type Strings } from './i18n.js';
package/dist/index.js CHANGED
@@ -533,6 +533,9 @@ var STRINGS = {
533
533
  addIndicator: "\uC9C0\uD45C \uCD94\uAC00",
534
534
  indicatorSettings: "\uC9C0\uD45C \uC124\uC815",
535
535
  removeIndicator: "\uC9C0\uD45C \uC0AD\uC81C",
536
+ moveIndicatorUp: "\uC704\uB85C \uC62E\uAE30\uAE30",
537
+ moveIndicatorDown: "\uC544\uB798\uB85C \uC62E\uAE30\uAE30",
538
+ textEditHint: "Enter\uB85C \uC800\uC7A5 \xB7 Shift+Enter \uC904\uBC14\uAFC8 \xB7 Esc \uCDE8\uC18C",
536
539
  hideVolume: "\uAC70\uB798\uB7C9 \uC228\uAE30\uAE30",
537
540
  volumeDesc: "\uBD09\uB9C8\uB2E4 \uAC70\uB798\uB41C \uC591 (\uAC00\uACA9 \uC544\uB798 \uC601\uC5ED)",
538
541
  apply: "\uC801\uC6A9",
@@ -696,6 +699,9 @@ var STRINGS = {
696
699
  addIndicator: "Add indicator",
697
700
  indicatorSettings: "Indicator settings",
698
701
  removeIndicator: "Remove indicator",
702
+ moveIndicatorUp: "Move up",
703
+ moveIndicatorDown: "Move down",
704
+ textEditHint: "Enter to save \xB7 Shift+Enter for a new line \xB7 Esc to cancel",
699
705
  hideVolume: "Hide volume",
700
706
  volumeDesc: "How much traded in each bar (pane under the price)",
701
707
  apply: "Apply",
@@ -1119,14 +1125,14 @@ function DrawingToolbar({ ctx }) {
1119
1125
  F2(() => {
1120
1126
  const el = barRef.current;
1121
1127
  if (!el) return;
1122
- const fit = () => {
1128
+ const fit2 = () => {
1123
1129
  el.removeAttribute("data-fit");
1124
1130
  if (el.scrollHeight <= el.clientHeight) return;
1125
1131
  el.dataset.fit = "compact";
1126
1132
  if (el.scrollHeight > el.clientHeight) el.dataset.fit = "scroll";
1127
1133
  };
1128
- fit();
1129
- const ro = new ResizeObserver(fit);
1134
+ fit2();
1135
+ const ro = new ResizeObserver(fit2);
1130
1136
  ro.observe(el);
1131
1137
  return () => ro.disconnect();
1132
1138
  }, []);
@@ -1863,7 +1869,7 @@ function useKeepInView(open) {
1863
1869
  const el = ref.current;
1864
1870
  if (!open || !el) return;
1865
1871
  el.style.translate = "";
1866
- const fit = () => {
1872
+ const fit2 = () => {
1867
1873
  el.style.translate = "";
1868
1874
  el.style.maxHeight = "";
1869
1875
  const r3 = el.getBoundingClientRect();
@@ -1880,9 +1886,9 @@ function useKeepInView(open) {
1880
1886
  if (r3.left + dx < minX) dx = minX - r3.left;
1881
1887
  if (dx) el.style.translate = `${Math.round(dx)}px 0`;
1882
1888
  };
1883
- fit();
1884
- window.addEventListener("resize", fit);
1885
- return () => window.removeEventListener("resize", fit);
1889
+ fit2();
1890
+ window.addEventListener("resize", fit2);
1891
+ return () => window.removeEventListener("resize", fit2);
1886
1892
  }, [open]);
1887
1893
  return ref;
1888
1894
  }
@@ -2800,6 +2806,14 @@ function IndicatorItem({ ctx, item }) {
2800
2806
  /* @__PURE__ */ a3("span", { class: "fnc-ind-title", children: item.title }),
2801
2807
  item.visible && item.values.map((v3) => /* @__PURE__ */ a3("b", { style: { color: v3.color }, "data-tip": v3.label, children: v3.value })),
2802
2808
  /* @__PURE__ */ a3("span", { class: "fnc-ind-actions", children: [
2809
+ ctx.chart.canMoveIndicator(item.id, -1) && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.moveIndicatorUp, "aria-label": `${item.title} ${t3.moveIndicatorUp}`, onClick: (e3) => {
2810
+ e3.stopPropagation();
2811
+ ctx.chart.moveIndicator(item.id, -1);
2812
+ }, children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }),
2813
+ ctx.chart.canMoveIndicator(item.id, 1) && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.moveIndicatorDown, "aria-label": `${item.title} ${t3.moveIndicatorDown}`, onClick: (e3) => {
2814
+ e3.stopPropagation();
2815
+ ctx.chart.moveIndicator(item.id, 1);
2816
+ }, children: /* @__PURE__ */ a3(ChevronDownIcon, {}) }),
2803
2817
  /* @__PURE__ */ a3(
2804
2818
  "button",
2805
2819
  {
@@ -2852,6 +2866,8 @@ function VolumeItem({ ctx, value }) {
2852
2866
  /* @__PURE__ */ a3("span", { class: "fnc-ind-title", children: t3.settingVolume }),
2853
2867
  value !== null && /* @__PURE__ */ a3("b", { class: "fnc-flat", children: value }),
2854
2868
  /* @__PURE__ */ a3("span", { class: "fnc-ind-actions", children: [
2869
+ ctx.chart.canMoveIndicator("volume", -1) && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.moveIndicatorUp, "aria-label": `${t3.settingVolume} ${t3.moveIndicatorUp}`, onClick: () => ctx.chart.moveIndicator("volume", -1), children: /* @__PURE__ */ a3(ChevronUpIcon, {}) }),
2870
+ ctx.chart.canMoveIndicator("volume", 1) && /* @__PURE__ */ a3("button", { class: "fnc-ind-btn", "data-tip": t3.moveIndicatorDown, "aria-label": `${t3.settingVolume} ${t3.moveIndicatorDown}`, onClick: () => ctx.chart.moveIndicator("volume", 1), children: /* @__PURE__ */ a3(ChevronDownIcon, {}) }),
2855
2871
  /* @__PURE__ */ a3(
2856
2872
  "button",
2857
2873
  {
@@ -3105,6 +3121,93 @@ function ReplayBar({ ctx }) {
3105
3121
  button(t3.replayExit, () => ctx.chart.stopReplay(), /* @__PURE__ */ a3(SmallCloseIcon, {}))
3106
3122
  ] });
3107
3123
  }
3124
+ var TEXT_MAX = 200;
3125
+ function TextEditor({ ctx }) {
3126
+ const t3 = stringsOf(useStore(ctx.store));
3127
+ const [edit, setEdit] = d2(null);
3128
+ const ref = T2(null);
3129
+ A2(() => {
3130
+ let pressed = false;
3131
+ let pending = null;
3132
+ const down = () => pressed = true;
3133
+ const up = () => {
3134
+ pressed = false;
3135
+ const open = pending;
3136
+ pending = null;
3137
+ if (open) setTimeout(open, 0);
3138
+ };
3139
+ window.addEventListener("pointerdown", down, true);
3140
+ window.addEventListener("pointerup", up, true);
3141
+ window.addEventListener("pointercancel", up, true);
3142
+ const off = ctx.chart.on("drawingTextEdit", ({ id, x: x2, y: y3 }) => {
3143
+ const open = () => {
3144
+ const d3 = ctx.chart.getDrawings().find((x3) => x3.id === id);
3145
+ if (d3) setEdit({ id, x: x2, y: y3, before: d3.style?.text ?? "" });
3146
+ };
3147
+ if (pressed) pending = open;
3148
+ else open();
3149
+ });
3150
+ return () => {
3151
+ off();
3152
+ window.removeEventListener("pointerdown", down, true);
3153
+ window.removeEventListener("pointerup", up, true);
3154
+ window.removeEventListener("pointercancel", up, true);
3155
+ };
3156
+ }, [ctx.chart]);
3157
+ F2(() => {
3158
+ const el = ref.current;
3159
+ if (!el || !edit) return;
3160
+ el.value = edit.before;
3161
+ el.focus();
3162
+ el.select();
3163
+ fit(el);
3164
+ }, [edit]);
3165
+ if (!edit) return null;
3166
+ const write = (text) => {
3167
+ const d3 = ctx.chart.getDrawings().find((x2) => x2.id === edit.id);
3168
+ if (d3) ctx.chart.updateDrawing(edit.id, { style: { ...d3.style, text } });
3169
+ };
3170
+ const close = (keep) => {
3171
+ if (!keep) write(edit.before);
3172
+ setEdit(null);
3173
+ };
3174
+ const width = 220;
3175
+ const left = Math.max(4, Math.min(edit.x - 8, ctx.chart.layout.plotWidth - width - 4));
3176
+ return /* @__PURE__ */ a3("div", { class: "fnc-text-edit", style: { left: `${left}px`, top: `${Math.max(4, edit.y - 18)}px`, width: `${width}px` }, children: [
3177
+ /* @__PURE__ */ a3(
3178
+ "textarea",
3179
+ {
3180
+ ref,
3181
+ rows: 1,
3182
+ maxLength: TEXT_MAX,
3183
+ "aria-label": t3.drawingText,
3184
+ placeholder: t3.textPlaceholder,
3185
+ onInput: (e3) => {
3186
+ const el = e3.target;
3187
+ fit(el);
3188
+ write(el.value);
3189
+ },
3190
+ onKeyDown: (e3) => {
3191
+ e3.stopPropagation();
3192
+ if (e3.key === "Escape") {
3193
+ e3.preventDefault();
3194
+ close(false);
3195
+ } else if (e3.key === "Enter" && !e3.shiftKey && !e3.isComposing) {
3196
+ e3.preventDefault();
3197
+ close(true);
3198
+ }
3199
+ },
3200
+ onBlur: () => close(true),
3201
+ onPointerDown: (e3) => e3.stopPropagation()
3202
+ }
3203
+ ),
3204
+ /* @__PURE__ */ a3("small", { children: t3.textEditHint })
3205
+ ] });
3206
+ }
3207
+ function fit(el) {
3208
+ el.style.height = "auto";
3209
+ el.style.height = `${Math.min(el.scrollHeight, 5 * 20 + 8)}px`;
3210
+ }
3108
3211
  function Overlay({ ctx }) {
3109
3212
  return /* @__PURE__ */ a3($, { children: [
3110
3213
  /* @__PURE__ */ a3(Attribution, { ctx }),
@@ -3112,6 +3215,7 @@ function Overlay({ ctx }) {
3112
3215
  /* @__PURE__ */ a3(NavControls, { ctx }),
3113
3216
  /* @__PURE__ */ a3(ReplayBar, { ctx }),
3114
3217
  /* @__PURE__ */ a3(SelectionBar, { ctx }),
3218
+ /* @__PURE__ */ a3(TextEditor, { ctx }),
3115
3219
  /* @__PURE__ */ a3(PaneTools, { ctx }),
3116
3220
  /* @__PURE__ */ a3(ContextMenu, { ctx })
3117
3221
  ] });
@@ -3359,6 +3463,9 @@ var CSS = (
3359
3463
  .fnc-part-reset { margin-top: 4px; border-top: 1px solid var(--fnc-border); color: var(--fnc-text-2); }
3360
3464
  .fnc-selbar-text { width: 150px; height: 28px; padding: 0 8px; border: 1px solid var(--fnc-border); border-radius: var(--fnc-radius); background: var(--fnc-surface); color: var(--fnc-text); font: inherit; font-size: 13px; outline: none; }
3361
3465
  .fnc-selbar-text:focus { border-color: var(--fnc-text-2); }
3466
+ .fnc-text-edit { position: absolute; z-index: 30; display: flex; flex-direction: column; gap: 4px; pointer-events: auto; }
3467
+ .fnc-text-edit textarea { width: 100%; min-height: 32px; padding: 6px 8px; border: 1px solid var(--fnc-text-2); border-radius: var(--fnc-radius); background: var(--fnc-surface); color: var(--fnc-text); font: inherit; font-size: 13px; line-height: 20px; resize: none; outline: none; box-shadow: var(--fnc-shadow, 0 6px 20px rgba(0,0,0,.25)); }
3468
+ .fnc-text-edit small { color: var(--fnc-text-3, var(--fnc-text-2)); font-size: 11px; white-space: nowrap; text-shadow: 0 0 3px var(--fnc-bg, transparent); }
3362
3469
  .fnc-overlay { pointer-events: none; }
3363
3470
  .fnc-overlay button { pointer-events: auto; }
3364
3471
 
@@ -1,9 +1,9 @@
1
1
  /** @jsxImportSource preact */
2
2
  import { type Chart, type ChartState, type Locale, type Resolution, type ThemeTokens } from '@funnest/charts';
3
- import type { LayoutSync } from './context';
4
- import { type LayoutId, type SplitSizes } from './layouts';
5
- import { type ColorScheme, type TradingChartSlots } from './shell';
6
- import { type TradingChartOptions } from './trading-chart';
3
+ import type { LayoutSync } from './context.js';
4
+ import { type LayoutId, type SplitSizes } from './layouts.js';
5
+ import { type ColorScheme, type TradingChartSlots } from './shell.js';
6
+ import { type TradingChartOptions } from './trading-chart.js';
7
7
  export interface PaneSpec {
8
8
  symbol: string;
9
9
  /** Default: the widget's `resolution`, else '1D'. */
package/dist/pane.d.ts CHANGED
@@ -1,9 +1,9 @@
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';
4
- import { type Shell } from './shell';
5
- import type { Strings } from './i18n';
6
- import { Store } from './store';
3
+ import type { ContextMenuItems, IntervalGroup, LegendValues, MultiControls, SearchCategory, SearchExchange, ToolsMenuItems, UiState, WidgetContext } from './context.js';
4
+ import { type Shell } from './shell.js';
5
+ import type { Strings } from './i18n.js';
6
+ import { Store } from './store.js';
7
7
  export interface PaneConfig {
8
8
  datafeed: Datafeed;
9
9
  chartOptions: Omit<ChartOptions, 'datafeed' | 'theme'>;
package/dist/shell.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type CursorMode, type DirectionPreset, type DrawingDefaults, type DrawingType, type Resolution, type ThemeTokens } from '@funnest/charts';
2
- import type { UiState } from './context';
3
- import { type WidgetStorage } from './storage';
4
- import type { Store } from './store';
2
+ import type { UiState } from './context.js';
3
+ import { type WidgetStorage } from './storage.js';
4
+ import type { Store } from './store.js';
5
5
  export type ColorScheme = 'light' | 'dark' | 'system';
6
6
  /**
7
7
  * Empty elements inside the widget layout where the host app mounts its own UI (any framework):
@@ -1,9 +1,9 @@
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';
4
- import type { Strings } from './i18n';
5
- import { type ColorScheme, type TradingChartSlots } from './shell';
6
- export type { ColorScheme, TradingChartSlots } from './shell';
3
+ import type { ContextMenuItems, IntervalGroup, LegendValues, SearchCategory, SearchExchange, ToolsMenuItems } from './context.js';
4
+ import type { Strings } from './i18n.js';
5
+ import { type ColorScheme, type TradingChartSlots } from './shell.js';
6
+ export type { ColorScheme, TradingChartSlots } from './shell.js';
7
7
  /** Interval menu: 분 | 시간 | 일. '12M' is shown as 1년. */
8
8
  export declare const DEFAULT_INTERVAL_GROUPS: readonly IntervalGroup[];
9
9
  /** Toolbar chips until the user stars their own. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.6.28",
3
+ "version": "0.6.29",
4
4
  "description": "Pro trading UI (toolbar, drawing tools, sheets) for Funnest Charts. Framework-agnostic.",
5
5
  "keywords": [
6
6
  "chart",
@@ -42,7 +42,7 @@
42
42
  "NOTICE"
43
43
  ],
44
44
  "dependencies": {
45
- "@funnest/charts": "0.6.28"
45
+ "@funnest/charts": "0.6.29"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"