@funnest/charts-ui 0.8.7 → 0.9.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.
package/dist/context.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface UiState {
29
29
  /** Open dialog: indicator picker, or settings for one indicator id. */
30
30
  dialog: {
31
31
  kind: 'indicators';
32
+ on?: string;
32
33
  } | {
33
34
  kind: 'indicatorSettings';
34
35
  id: string;
package/dist/i18n.d.ts CHANGED
@@ -28,6 +28,11 @@ export declare const STRINGS: {
28
28
  stepLine: string;
29
29
  baseline: string;
30
30
  area: string;
31
+ volumeCandles: string;
32
+ renko: string;
33
+ kagi: string;
34
+ lineBreak: string;
35
+ pointFigure: string;
31
36
  drawingTools: string;
32
37
  cursor: string;
33
38
  trendline: string;
@@ -115,6 +120,8 @@ export declare const STRINGS: {
115
120
  addIndicator: string;
116
121
  indicatorSettings: string;
117
122
  removeIndicator: string;
123
+ addIndicatorOn: string;
124
+ onIndicatorSection: string;
118
125
  moveIndicatorUp: string;
119
126
  moveIndicatorDown: string;
120
127
  textEditHint: string;
@@ -228,6 +235,11 @@ export declare const STRINGS: {
228
235
  stepLine: string;
229
236
  baseline: string;
230
237
  area: string;
238
+ volumeCandles: string;
239
+ renko: string;
240
+ kagi: string;
241
+ lineBreak: string;
242
+ pointFigure: string;
231
243
  drawingTools: string;
232
244
  cursor: string;
233
245
  trendline: string;
@@ -315,6 +327,8 @@ export declare const STRINGS: {
315
327
  addIndicator: string;
316
328
  indicatorSettings: string;
317
329
  removeIndicator: string;
330
+ addIndicatorOn: string;
331
+ onIndicatorSection: string;
318
332
  moveIndicatorUp: string;
319
333
  moveIndicatorDown: string;
320
334
  textEditHint: string;
package/dist/icons.d.ts CHANGED
@@ -27,8 +27,14 @@ export declare const OhlcBarsIcon: () => import("preact").JSX.Element;
27
27
  export declare const StepLineIcon: () => import("preact").JSX.Element;
28
28
  export declare const BaselineIcon: () => import("preact").JSX.Element;
29
29
  export declare const AreaChartIcon: () => import("preact").JSX.Element;
30
+ export declare const VolumeCandlesIcon: () => import("preact").JSX.Element;
31
+ export declare const RenkoIcon: () => import("preact").JSX.Element;
32
+ export declare const KagiIcon: () => import("preact").JSX.Element;
33
+ export declare const LineBreakIcon: () => import("preact").JSX.Element;
34
+ export declare const PointFigureIcon: () => import("preact").JSX.Element;
30
35
  export declare const IndicatorIcon: () => import("preact").JSX.Element;
31
36
  export declare const GearIcon: () => import("preact").JSX.Element;
37
+ export declare const SmallPlusIcon: () => import("preact").JSX.Element;
32
38
  export declare const SmallCloseIcon: () => import("preact").JSX.Element;
33
39
  export declare const EyeIcon: () => import("preact").JSX.Element;
34
40
  export declare const EyeOffIcon: () => import("preact").JSX.Element;
package/dist/index.js CHANGED
@@ -454,6 +454,11 @@ var STRINGS = {
454
454
  stepLine: "\uACC4\uB2E8\uC120",
455
455
  baseline: "\uBCA0\uC774\uC2A4\uB77C\uC778",
456
456
  area: "\uC601\uC5ED",
457
+ volumeCandles: "\uAC70\uB798\uB7C9 \uCE94\uB4E4",
458
+ renko: "\uB80C\uCF54",
459
+ kagi: "\uCE74\uAE30",
460
+ lineBreak: "\uB77C\uC778 \uBE0C\uB808\uC774\uD06C",
461
+ pointFigure: "P&F",
457
462
  drawingTools: "\uADF8\uB9AC\uAE30 \uB3C4\uAD6C",
458
463
  cursor: "\uCEE4\uC11C",
459
464
  trendline: "\uCD94\uC138\uC120",
@@ -541,6 +546,8 @@ var STRINGS = {
541
546
  addIndicator: "\uC9C0\uD45C \uCD94\uAC00",
542
547
  indicatorSettings: "\uC9C0\uD45C \uC124\uC815",
543
548
  removeIndicator: "\uC9C0\uD45C \uC0AD\uC81C",
549
+ addIndicatorOn: "\uC774 \uC9C0\uD45C \uC704\uC5D0 \uC9C0\uD45C \uCD94\uAC00",
550
+ onIndicatorSection: "{name} \uC704\uC5D0 \uD45C\uC2DC",
544
551
  moveIndicatorUp: "\uC704\uB85C \uC62E\uAE30\uAE30",
545
552
  moveIndicatorDown: "\uC544\uB798\uB85C \uC62E\uAE30\uAE30",
546
553
  textEditHint: "Enter\uB85C \uC800\uC7A5 \xB7 Shift+Enter \uC904\uBC14\uAFC8 \xB7 Esc \uCDE8\uC18C",
@@ -656,6 +663,11 @@ var STRINGS = {
656
663
  stepLine: "Step line",
657
664
  baseline: "Baseline",
658
665
  area: "Area",
666
+ volumeCandles: "Volume candles",
667
+ renko: "Renko",
668
+ kagi: "Kagi",
669
+ lineBreak: "Line break",
670
+ pointFigure: "Point & figure",
659
671
  drawingTools: "Drawing tools",
660
672
  cursor: "Cursor",
661
673
  trendline: "Trend line",
@@ -743,6 +755,8 @@ var STRINGS = {
743
755
  addIndicator: "Add indicator",
744
756
  indicatorSettings: "Indicator settings",
745
757
  removeIndicator: "Remove indicator",
758
+ addIndicatorOn: "Add indicator on this",
759
+ onIndicatorSection: "Drawn on {name}",
746
760
  moveIndicatorUp: "Move up",
747
761
  moveIndicatorDown: "Move down",
748
762
  textEditHint: "Enter to save \xB7 Shift+Enter for a new line \xB7 Esc to cancel",
@@ -935,6 +949,34 @@ var AreaChartIcon = () => /* @__PURE__ */ a3(Icon, { children: [
935
949
  /* @__PURE__ */ a3("path", { d: "M3 14l4.5-5 3.5 3 6-7" }),
936
950
  /* @__PURE__ */ a3("path", { d: "M3 14l4.5-5 3.5 3 6-7V17H3z", fill: "currentColor", "fill-opacity": "0.25", stroke: "none" })
937
951
  ] });
952
+ var VolumeCandlesIcon = () => /* @__PURE__ */ a3(Icon, { children: [
953
+ /* @__PURE__ */ a3("path", { d: "M4.5 4v12M10 3v14M15.5 6v9" }),
954
+ /* @__PURE__ */ a3("rect", { x: "3.6", y: "7", width: "1.8", height: "5", rx: "0.5", fill: "currentColor" }),
955
+ /* @__PURE__ */ a3("rect", { x: "7", y: "6", width: "6", height: "7", rx: "0.8", fill: "currentColor" }),
956
+ /* @__PURE__ */ a3("rect", { x: "14", y: "8", width: "3", height: "4", rx: "0.6" })
957
+ ] });
958
+ var RenkoIcon = () => /* @__PURE__ */ a3(Icon, { children: [
959
+ /* @__PURE__ */ a3("rect", { x: "2.5", y: "11", width: "4", height: "4", rx: "0.5", fill: "currentColor" }),
960
+ /* @__PURE__ */ a3("rect", { x: "7.5", y: "7", width: "4", height: "4", rx: "0.5", fill: "currentColor" }),
961
+ /* @__PURE__ */ a3("rect", { x: "12.5", y: "3", width: "4", height: "4", rx: "0.5", fill: "currentColor" }),
962
+ /* @__PURE__ */ a3("rect", { x: "12.5", y: "7.5", width: "4", height: "4", rx: "0.5" })
963
+ ] });
964
+ var KagiIcon = () => /* @__PURE__ */ a3(Icon, { children: [
965
+ /* @__PURE__ */ a3("path", { d: "M3 15V8h4v5h4V4h5v8" }),
966
+ /* @__PURE__ */ a3("path", { d: "M11 4v5", "stroke-width": "2.8" })
967
+ ] });
968
+ var LineBreakIcon = () => /* @__PURE__ */ a3(Icon, { children: [
969
+ /* @__PURE__ */ a3("rect", { x: "2.5", y: "11", width: "3.5", height: "5", rx: "0.5", fill: "currentColor" }),
970
+ /* @__PURE__ */ a3("rect", { x: "6.5", y: "6", width: "3.5", height: "5", rx: "0.5", fill: "currentColor" }),
971
+ /* @__PURE__ */ a3("rect", { x: "10.5", y: "3", width: "3.5", height: "3", rx: "0.5", fill: "currentColor" }),
972
+ /* @__PURE__ */ a3("rect", { x: "14.5", y: "3", width: "3.5", height: "9", rx: "0.5" })
973
+ ] });
974
+ var PointFigureIcon = () => /* @__PURE__ */ a3(Icon, { children: [
975
+ /* @__PURE__ */ a3("path", { d: "M3 12l3 3M6 12l-3 3M3 8l3 3M6 8l-3 3M3 4l3 3M6 4l-3 3", "stroke-width": "1.3" }),
976
+ /* @__PURE__ */ a3("circle", { cx: "11", cy: "7.5", r: "1.6" }),
977
+ /* @__PURE__ */ a3("circle", { cx: "11", cy: "11.5", r: "1.6" }),
978
+ /* @__PURE__ */ a3("path", { d: "M14 10l3 3M17 10l-3 3M14 6l3 3M17 6l-3 3", "stroke-width": "1.3" })
979
+ ] });
938
980
  var IndicatorIcon = () => /* @__PURE__ */ a3(Icon, { children: [
939
981
  /* @__PURE__ */ a3("path", { d: "M3 15.5l4-5 3 2.5 3.5-5L17 11" }),
940
982
  /* @__PURE__ */ a3("path", { d: "M3 4.5v11.5h14" })
@@ -943,6 +985,7 @@ var GearIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
943
985
  /* @__PURE__ */ a3("circle", { cx: "10", cy: "10", r: "2.4" }),
944
986
  /* @__PURE__ */ a3("path", { d: "M10 3v2M10 15v2M3 10h2M15 10h2M5 5l1.4 1.4M13.6 13.6L15 15M5 15l1.4-1.4M13.6 6.4L15 5" })
945
987
  ] });
988
+ var SmallPlusIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M5 10h10M10 5v10" }) });
946
989
  var SmallCloseIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: /* @__PURE__ */ a3("path", { d: "M6 6l8 8M14 6l-8 8" }) });
947
990
  var EyeIcon = () => /* @__PURE__ */ a3(Icon, { size: 14, children: [
948
991
  /* @__PURE__ */ a3("path", { d: "M2 10s3-5.5 8-5.5S18 10 18 10s-3 5.5-8 5.5S2 10 2 10z" }),
@@ -1987,6 +2030,35 @@ function Dialog({ title, onClose, children, wide }) {
1987
2030
  ) });
1988
2031
  }
1989
2032
  var SEARCH_THRESHOLD = 8;
2033
+ function paramsOnIndicator(def) {
2034
+ if (!Array.isArray(def.defaults.lines)) return void 0;
2035
+ return { lines: [{ period: def.type === "ema" ? 9 : 14, source: "close" }] };
2036
+ }
2037
+ function IndicatorOnPicker({ ctx, on }) {
2038
+ const { locale } = useStore(ctx.store);
2039
+ const t3 = stringsOf(ctx.store.get());
2040
+ const close = () => ctx.store.set({ dialog: null });
2041
+ const host = ctx.chart.indicatorLegend().find((i3) => i3.id === on);
2042
+ if (!host) return null;
2043
+ const defs = ctx.chart.indicatorsOnIndicator();
2044
+ return /* @__PURE__ */ a3(Dialog, { title: t3.addIndicatorOn, onClose: close, children: /* @__PURE__ */ a3("div", { class: "fnc-sr-list fnc-scroll", children: [
2045
+ /* @__PURE__ */ a3("div", { class: "fnc-sr-section", children: t3.onIndicatorSection.replace("{name}", host.title) }),
2046
+ defs.map((def) => /* @__PURE__ */ a3(
2047
+ "button",
2048
+ {
2049
+ class: "fnc-sr-row",
2050
+ onClick: () => {
2051
+ ctx.chart.addIndicatorOn(on, def.type, paramsOnIndicator(def));
2052
+ close();
2053
+ },
2054
+ children: /* @__PURE__ */ a3("span", { class: "fnc-sr-main", children: [
2055
+ /* @__PURE__ */ a3("span", { class: "fnc-sr-name", children: def.name[locale] }),
2056
+ /* @__PURE__ */ a3("span", { class: "fnc-sr-meta", children: def.description[locale] })
2057
+ ] })
2058
+ }
2059
+ ))
2060
+ ] }) });
2061
+ }
1990
2062
  function IndicatorPicker({ ctx }) {
1991
2063
  const { locale } = useStore(ctx.store);
1992
2064
  const t3 = stringsOf(ctx.store.get());
@@ -2085,6 +2157,7 @@ function IndicatorSettings({ ctx, id }) {
2085
2157
  const config = indicators.find((c3) => c3.id === id);
2086
2158
  const def = config ? ctx.chart.indicatorDefinition(config.type) ?? null : null;
2087
2159
  const hasLines = !!def?.params.some((p3) => p3.kind === "lines");
2160
+ const onIndicator = !!config?.on;
2088
2161
  const [lines, setLines] = d2(() => {
2089
2162
  if (!config || !def || !hasLines) return [];
2090
2163
  const defaults = defaultSeries(def, config.params);
@@ -2155,7 +2228,7 @@ function IndicatorSettings({ ctx, id }) {
2155
2228
  i3 + 1
2156
2229
  ] }),
2157
2230
  /* @__PURE__ */ a3(StyleControls, { t: t3, row: l3, onChange: (p3) => updateLine(i3, p3) }),
2158
- /* @__PURE__ */ a3(SourceSelect, { value: l3.source, locale, label: t3.source, onChange: (source) => updateLine(i3, { source }) }),
2231
+ !onIndicator && /* @__PURE__ */ a3(SourceSelect, { value: l3.source, locale, label: t3.source, onChange: (source) => updateLine(i3, { source }) }),
2159
2232
  /* @__PURE__ */ a3(
2160
2233
  "input",
2161
2234
  {
@@ -2174,7 +2247,7 @@ function IndicatorSettings({ ctx, id }) {
2174
2247
  ] })
2175
2248
  ] }) : /* @__PURE__ */ a3($, { children: [
2176
2249
  /* @__PURE__ */ a3("div", { class: "fnc-section", children: t3.inputs }),
2177
- def.params.map((spec) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2250
+ def.params.filter((spec) => !(onIndicator && spec.kind === "source")).map((spec) => /* @__PURE__ */ a3("div", { class: "fnc-row", children: [
2178
2251
  /* @__PURE__ */ a3("span", { class: "fnc-row-label fnc-row-label-wide", children: spec.label[locale] }),
2179
2252
  spec.kind === "source" ? /* @__PURE__ */ a3(
2180
2253
  SourceSelect,
@@ -2221,7 +2294,7 @@ function IndicatorSettings({ ctx, id }) {
2221
2294
  }
2222
2295
  function Dialogs({ ctx }) {
2223
2296
  const { dialog } = useStore(ctx.store);
2224
- if (dialog?.kind === "indicators") return /* @__PURE__ */ a3(IndicatorPicker, { ctx });
2297
+ if (dialog?.kind === "indicators") return dialog.on ? /* @__PURE__ */ a3(IndicatorOnPicker, { ctx, on: dialog.on }) : /* @__PURE__ */ a3(IndicatorPicker, { ctx });
2225
2298
  if (dialog?.kind === "indicatorSettings") return /* @__PURE__ */ a3(IndicatorSettings, { ctx, id: dialog.id });
2226
2299
  if (dialog?.kind === "chartSettings") return /* @__PURE__ */ a3(SettingsDialog, { ctx });
2227
2300
  if (dialog?.kind === "goToDate") return /* @__PURE__ */ a3(GoToDateDialog, { ctx });
@@ -2884,7 +2957,12 @@ var TYPES = [
2884
2957
  { type: "line", label: "line", icon: LineChartIcon },
2885
2958
  { type: "step", label: "stepLine", icon: StepLineIcon },
2886
2959
  { type: "baseline", label: "baseline", icon: BaselineIcon },
2887
- { type: "area", label: "area", icon: AreaChartIcon }
2960
+ { type: "area", label: "area", icon: AreaChartIcon },
2961
+ { type: "volumeCandles", label: "volumeCandles", icon: VolumeCandlesIcon },
2962
+ { type: "renko", label: "renko", icon: RenkoIcon },
2963
+ { type: "kagi", label: "kagi", icon: KagiIcon },
2964
+ { type: "lineBreak", label: "lineBreak", icon: LineBreakIcon },
2965
+ { type: "pnf", label: "pointFigure", icon: PointFigureIcon }
2888
2966
  ];
2889
2967
  var SCALES2 = [
2890
2968
  { mode: "normal", label: "scaleNormal" },
@@ -3330,6 +3408,19 @@ function IndicatorItem({ ctx, item }) {
3330
3408
  e3.stopPropagation();
3331
3409
  ctx.chart.moveIndicator(item.id, 1);
3332
3410
  }, children: /* @__PURE__ */ a3(ChevronDownIcon, {}) }),
3411
+ item.hostable && ctx.chart.indicatorsOnIndicator().length > 0 && /* @__PURE__ */ a3(
3412
+ "button",
3413
+ {
3414
+ class: "fnc-ind-btn",
3415
+ "data-tip": t3.addIndicatorOn,
3416
+ "aria-label": `${item.title} ${t3.addIndicatorOn}`,
3417
+ onClick: (e3) => {
3418
+ e3.stopPropagation();
3419
+ ctx.store.set({ dialog: { kind: "indicators", on: item.id } });
3420
+ },
3421
+ children: /* @__PURE__ */ a3(SmallPlusIcon, {})
3422
+ }
3423
+ ),
3333
3424
  /* @__PURE__ */ a3(
3334
3425
  "button",
3335
3426
  {
@@ -3477,7 +3568,7 @@ function Legend({ ctx }) {
3477
3568
  }
3478
3569
  const items = s3.indicators.length ? ctx.chart.indicatorLegend(hover?.index) : [];
3479
3570
  const overlayItems = items.filter((i3) => i3.overlay);
3480
- const paneLegends = s3.layout.panes.filter((p3) => p3.kind === "indicator").map((pane) => ({ pane, item: items.find((i3) => i3.id === pane.id) }));
3571
+ const paneLegends = s3.layout.panes.filter((p3) => p3.kind === "indicator").map((pane) => ({ pane, item: items.find((i3) => i3.id === pane.id), kids: items.filter((i3) => i3.parent === pane.id) }));
3481
3572
  const volumePane = s3.layout.panes.find((p3) => p3.kind === "volume");
3482
3573
  return /* @__PURE__ */ a3($, { children: [
3483
3574
  /* @__PURE__ */ a3("div", { class: "fnc-legend", ref, children: [
@@ -3512,7 +3603,10 @@ function Legend({ ctx }) {
3512
3603
  ] }),
3513
3604
  volumePane && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${volumePane.top + 4}px` }, children: /* @__PURE__ */ a3(VolumeItem, { ctx, value: bar?.volume !== void 0 ? formatCompact(bar.volume, s3.locale) : null }) }),
3514
3605
  paneLegends.map(
3515
- ({ pane, item }) => item && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: /* @__PURE__ */ a3(IndicatorItem, { ctx, item }) })
3606
+ ({ pane, item, kids }) => item && /* @__PURE__ */ a3("div", { class: "fnc-legend fnc-pane-legend", style: { top: `${pane.top + 4}px` }, children: [
3607
+ /* @__PURE__ */ a3(IndicatorItem, { ctx, item }),
3608
+ kids.map((kid) => /* @__PURE__ */ a3(IndicatorItem, { ctx, item: kid }))
3609
+ ] })
3516
3610
  )
3517
3611
  ] });
3518
3612
  }
@@ -4780,9 +4874,9 @@ var CSS = (
4780
4874
  .fnc-tools-menu { width: 300px; padding: 8px; gap: 2px; max-height: 72vh; overflow-y: auto; }
4781
4875
  .fnc-tools-section { padding: 8px 6px 6px; font-size: 12px; font-weight: 700; color: var(--fnc-text-2); }
4782
4876
  .fnc-tools-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 0 2px 4px; }
4783
- .fnc-tools-seg[data-count="5"], .fnc-tools-seg[data-count="8"] { display: grid; grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); gap: 2px; }
4784
- .fnc-tools-seg[data-count="8"] { grid-template-columns: repeat(4, 1fr); }
4785
- .fnc-tools-seg[data-count="5"] button, .fnc-tools-seg[data-count="8"] button { flex-direction: column; gap: 2px; height: auto; min-height: 40px; padding: 5px 4px; font-size: 12px; white-space: normal; word-break: keep-all; text-align: center; line-height: 1.25; }
4877
+ .fnc-tools-seg[data-count="5"], .fnc-tools-seg[data-count="8"], .fnc-tools-seg[data-count="13"] { display: grid; grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); gap: 2px; }
4878
+ .fnc-tools-seg[data-count="8"], .fnc-tools-seg[data-count="13"] { grid-template-columns: repeat(4, 1fr); }
4879
+ .fnc-tools-seg[data-count="5"] button, .fnc-tools-seg[data-count="8"] button, .fnc-tools-seg[data-count="13"] button { flex-direction: column; gap: 2px; height: auto; min-height: 40px; padding: 5px 4px; font-size: 12px; white-space: normal; word-break: keep-all; text-align: center; line-height: 1.25; }
4786
4880
  .fnc-tools-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 6px; }
4787
4881
  .fnc-tools-seg svg { width: 16px; height: 16px; flex: none; }
4788
4882
  .fnc-tools-layouts { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 4px; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.8.7",
3
+ "version": "0.9.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.8.7"
45
+ "@funnest/charts": "0.9.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"