@funnest/charts-ui 0.11.26 → 0.11.28

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
@@ -237,6 +237,8 @@ export interface LayoutSync {
237
237
  symbol: boolean;
238
238
  /** Changing the interval changes it in every pane. */
239
239
  interval: boolean;
240
+ /** The same indicators in every pane: adding, removing or editing one in a pane does it in all. */
241
+ indicators: boolean;
240
242
  }
241
243
  export interface MultiState {
242
244
  layout: LayoutId;
@@ -245,7 +247,7 @@ export interface MultiState {
245
247
  active: number;
246
248
  /** A pane temporarily filling the whole grid. */
247
249
  maximized: number | null;
248
- /** The container is too narrow to split: only the active pane shows, with pane tabs. */
250
+ /** The container is too narrow to split side by side: two panes stack, more show one at a time with pane tabs. */
249
251
  narrow: boolean;
250
252
  }
251
253
  export interface MultiControls {
package/dist/i18n.d.ts CHANGED
@@ -325,6 +325,7 @@ export declare const STRINGS: {
325
325
  syncTime: string;
326
326
  syncSymbol: string;
327
327
  syncInterval: string;
328
+ syncIndicators: string;
328
329
  syncHint: string;
329
330
  maximizePane: string;
330
331
  restorePane: string;
@@ -683,6 +684,7 @@ export declare const STRINGS: {
683
684
  syncTime: string;
684
685
  syncSymbol: string;
685
686
  syncInterval: string;
687
+ syncIndicators: string;
686
688
  syncHint: string;
687
689
  maximizePane: string;
688
690
  restorePane: string;
package/dist/index.js CHANGED
@@ -762,6 +762,7 @@ var STRINGS = {
762
762
  syncTime: "\uC2DC\uAC04 \uBC94\uC704",
763
763
  syncSymbol: "\uC885\uBAA9",
764
764
  syncInterval: "\uC8FC\uAE30",
765
+ syncIndicators: "\uC9C0\uD45C",
765
766
  syncHint: "\uCF1C\uBA74 \uBAA8\uB4E0 \uCE78\uC774 \uAC19\uC774 \uC6C0\uC9C1\uC5EC\uC694",
766
767
  maximizePane: "\uC774 \uCE78 \uD06C\uAC8C \uBCF4\uAE30",
767
768
  restorePane: "\uBD84\uD560 \uD654\uBA74\uC73C\uB85C",
@@ -1120,6 +1121,7 @@ var STRINGS = {
1120
1121
  syncTime: "Time range",
1121
1122
  syncSymbol: "Symbol",
1122
1123
  syncInterval: "Interval",
1124
+ syncIndicators: "Indicators",
1123
1125
  syncHint: "Linked panes move together",
1124
1126
  maximizePane: "Maximize pane",
1125
1127
  restorePane: "Back to split view",
@@ -4299,6 +4301,13 @@ var CSS = (
4299
4301
  /* \u2500\u2500 \uB3C4\uAD6C menu: chart type, split, compare, replay, axis, screenshot, settings \u2500\u2500 */
4300
4302
  .fnc-tools-menu { width: 300px; padding: 8px; gap: 2px; max-height: 72vh; overflow-y: auto; }
4301
4303
  .fnc-tools-section { padding: 8px 6px 6px; font-size: 12px; font-weight: 700; color: var(--fnc-text-2); }
4304
+ .fnc-tools-fold { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 6px; border-radius: 6px; text-align: left; cursor: pointer; }
4305
+ .fnc-tools-fold:hover { background: var(--fnc-surface); color: var(--fnc-text); }
4306
+ .fnc-tools-fold > span:first-child { flex: 1; }
4307
+ .fnc-tools-fold-now { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; color: var(--fnc-text-2); }
4308
+ .fnc-tools-fold-now svg { width: 15px; height: 15px; }
4309
+ .fnc-tools-fold > svg { width: 14px; height: 14px; transition: transform 0.15s; transform: rotate(-90deg); }
4310
+ .fnc-tools-fold[aria-expanded="true"] > svg { transform: none; }
4302
4311
  .fnc-tools-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 0 2px 4px; }
4303
4312
  .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; }
4304
4313
  .fnc-tools-seg[data-count="8"], .fnc-tools-seg[data-count="13"] { grid-template-columns: repeat(4, 1fr); }
@@ -6185,52 +6194,64 @@ var SCALES2 = [
6185
6194
  var SYNC_KEYS = [
6186
6195
  { key: "crosshair", label: "syncCrosshair" },
6187
6196
  { key: "symbol", label: "syncSymbol" },
6188
- { key: "interval", label: "syncInterval" }
6197
+ { key: "interval", label: "syncInterval" },
6198
+ { key: "indicators", label: "syncIndicators" }
6189
6199
  ];
6190
- function LayoutSection({ ctx, multi, close }) {
6200
+ function Fold({ label, open, onToggle, children }) {
6201
+ return /* @__PURE__ */ a3("button", { type: "button", class: "fnc-tools-section fnc-tools-fold", "aria-expanded": open, onClick: onToggle, children: [
6202
+ /* @__PURE__ */ a3("span", { children: label }),
6203
+ /* @__PURE__ */ a3("span", { class: "fnc-tools-fold-now", children }),
6204
+ /* @__PURE__ */ a3(ChevronDownIcon, {})
6205
+ ] });
6206
+ }
6207
+ function LayoutSection({ ctx, multi, close, open, onToggle }) {
6191
6208
  const s3 = useStore(ctx.store);
6192
6209
  const m3 = useStore(multi.store);
6193
6210
  const t3 = stringsOf(s3);
6194
6211
  return /* @__PURE__ */ a3($, { children: [
6195
- /* @__PURE__ */ a3("div", { class: "fnc-tools-section", children: t3.layout }),
6196
- /* @__PURE__ */ a3("div", { class: "fnc-tools-layouts", children: LAYOUT_GROUPS.map((group) => /* @__PURE__ */ a3("div", { class: "fnc-layout-row", children: [
6197
- /* @__PURE__ */ a3("span", { class: "fnc-layout-count", children: group[0].split("-")[0] }),
6198
- group.map((id) => /* @__PURE__ */ a3(
6212
+ /* @__PURE__ */ a3(Fold, { label: t3.layout, open, onToggle, children: /* @__PURE__ */ a3(LayoutGlyph, { id: m3.layout }) }),
6213
+ open && /* @__PURE__ */ a3($, { children: [
6214
+ /* @__PURE__ */ a3("div", { class: "fnc-tools-layouts", children: LAYOUT_GROUPS.map((group) => /* @__PURE__ */ a3("div", { class: "fnc-layout-row", children: [
6215
+ /* @__PURE__ */ a3("span", { class: "fnc-layout-count", children: group[0].split("-")[0] }),
6216
+ group.map((id) => /* @__PURE__ */ a3(
6217
+ "button",
6218
+ {
6219
+ class: "fnc-layout-opt",
6220
+ role: "menuitemradio",
6221
+ "aria-checked": id === m3.layout,
6222
+ "aria-label": `${t3.layout} ${id}`,
6223
+ "data-layout": id,
6224
+ onClick: () => {
6225
+ multi.setLayout(id);
6226
+ close();
6227
+ },
6228
+ children: /* @__PURE__ */ a3(LayoutGlyph, { id })
6229
+ }
6230
+ ))
6231
+ ] })) }),
6232
+ paneCount(LAYOUTS[m3.layout]) > 1 && /* @__PURE__ */ a3("div", { class: "fnc-tools-section", children: t3.sync }),
6233
+ paneCount(LAYOUTS[m3.layout]) > 1 && SYNC_KEYS.map(({ key, label }) => /* @__PURE__ */ a3(
6199
6234
  "button",
6200
6235
  {
6201
- class: "fnc-layout-opt",
6202
- role: "menuitemradio",
6203
- "aria-checked": id === m3.layout,
6204
- "aria-label": `${t3.layout} ${id}`,
6205
- "data-layout": id,
6206
- onClick: () => {
6207
- multi.setLayout(id);
6208
- close();
6209
- },
6210
- children: /* @__PURE__ */ a3(LayoutGlyph, { id })
6236
+ class: "fnc-menu-item fnc-sync-item",
6237
+ role: "menuitemcheckbox",
6238
+ "aria-checked": m3.sync[key],
6239
+ onClick: () => multi.setSync({ [key]: !m3.sync[key] }),
6240
+ children: [
6241
+ /* @__PURE__ */ a3("span", { children: t3[label] }),
6242
+ /* @__PURE__ */ a3("span", { class: "fnc-switch", "data-on": m3.sync[key] ? "true" : "false", "aria-hidden": "true" })
6243
+ ]
6211
6244
  }
6212
6245
  ))
6213
- ] })) }),
6214
- paneCount(LAYOUTS[m3.layout]) > 1 && /* @__PURE__ */ a3("div", { class: "fnc-tools-section", children: t3.sync }),
6215
- paneCount(LAYOUTS[m3.layout]) > 1 && SYNC_KEYS.map(({ key, label }) => /* @__PURE__ */ a3(
6216
- "button",
6217
- {
6218
- class: "fnc-menu-item fnc-sync-item",
6219
- role: "menuitemcheckbox",
6220
- "aria-checked": m3.sync[key],
6221
- onClick: () => multi.setSync({ [key]: !m3.sync[key] }),
6222
- children: [
6223
- /* @__PURE__ */ a3("span", { children: t3[label] }),
6224
- /* @__PURE__ */ a3("span", { class: "fnc-switch", "data-on": m3.sync[key] ? "true" : "false", "aria-hidden": "true" })
6225
- ]
6226
- }
6227
- ))
6246
+ ] })
6228
6247
  ] });
6229
6248
  }
6230
6249
  function ToolsMenu({ ctx }) {
6231
6250
  const s3 = useStore(ctx.store);
6232
6251
  const t3 = stringsOf(s3);
6233
6252
  const [open, setOpen] = d2(false);
6253
+ const [typesOpen, setTypesOpen] = d2(false);
6254
+ const [layoutOpen, setLayoutOpen] = d2(false);
6234
6255
  const [scale, setScale] = d2(ctx.chart.settings.priceScale);
6235
6256
  const ref = T2(null);
6236
6257
  const menuRef = useKeepInView(open);
@@ -6284,8 +6305,14 @@ function ToolsMenu({ ctx }) {
6284
6305
  }
6285
6306
  ),
6286
6307
  open && /* @__PURE__ */ a3("div", { class: "fnc-menu fnc-tools-menu", role: "menu", "aria-label": t3.tools, ref: menuRef, children: [
6287
- /* @__PURE__ */ a3("div", { class: "fnc-tools-section", children: t3.chartType }),
6288
- /* @__PURE__ */ a3("div", { class: "fnc-seg fnc-tools-seg", role: "radiogroup", "aria-label": t3.chartType, "data-count": TYPES.length, children: TYPES.map(({ type, label, icon: Icon2 }) => /* @__PURE__ */ a3(
6308
+ /* @__PURE__ */ a3(Fold, { label: t3.chartType, open: typesOpen, onToggle: () => setTypesOpen(!typesOpen), children: (() => {
6309
+ const now = TYPES.find((x2) => x2.type === s3.chartType) ?? TYPES[0];
6310
+ return /* @__PURE__ */ a3($, { children: [
6311
+ /* @__PURE__ */ a3(now.icon, {}),
6312
+ t3[now.label]
6313
+ ] });
6314
+ })() }),
6315
+ typesOpen && /* @__PURE__ */ a3("div", { class: "fnc-seg fnc-tools-seg", role: "radiogroup", "aria-label": t3.chartType, "data-count": TYPES.length, children: TYPES.map(({ type, label, icon: Icon2 }) => /* @__PURE__ */ a3(
6289
6316
  "button",
6290
6317
  {
6291
6318
  type: "button",
@@ -6302,7 +6329,7 @@ function ToolsMenu({ ctx }) {
6302
6329
  ]
6303
6330
  }
6304
6331
  )) }),
6305
- ctx.multi && /* @__PURE__ */ a3(LayoutSection, { ctx, multi: ctx.multi, close }),
6332
+ ctx.multi && /* @__PURE__ */ a3(LayoutSection, { ctx, multi: ctx.multi, close, open: layoutOpen, onToggle: () => setLayoutOpen(!layoutOpen) }),
6306
6333
  /* @__PURE__ */ a3("div", { class: "fnc-tools-sep" }),
6307
6334
  canSearch && item("fnc-btn-compare", t3.compareSymbol, /* @__PURE__ */ a3(CompareIcon, {}), () => ctx.setSearchOpen(true, "compare"), {
6308
6335
  disabled: s3.compares.length >= 5
@@ -6953,7 +6980,7 @@ function PaneTools({ ctx }) {
6953
6980
  function PaneMaximize({ ctx, multi }) {
6954
6981
  const s3 = useStore(ctx.store);
6955
6982
  const m3 = useStore(multi.store);
6956
- if (s3.layout.plotWidth <= 0 || m3.narrow || m3.layout === "1" && m3.maximized === null) return null;
6983
+ if (s3.layout.plotWidth <= 0 || m3.narrow && paneCount(LAYOUTS[m3.layout]) > 2 || m3.layout === "1" && m3.maximized === null) return null;
6957
6984
  const t3 = stringsOf(s3);
6958
6985
  const maximized = m3.maximized !== null;
6959
6986
  const label = maximized ? t3.restorePane : t3.maximizePane;
@@ -7399,7 +7426,7 @@ function createTradingChart(container, options) {
7399
7426
 
7400
7427
  // src/multi-chart.tsx
7401
7428
  import { browserLocale as browserLocale3, parseChartState } from "@funnest/charts";
7402
- var DEFAULT_SYNC = { crosshair: true, time: false, symbol: false, interval: false };
7429
+ var DEFAULT_SYNC = { crosshair: true, time: false, symbol: false, interval: false, indicators: false };
7403
7430
  function PaneTab({ pane, index, active, onSelect }) {
7404
7431
  const s3 = useStore(pane.store);
7405
7432
  const t3 = stringsOf(s3);
@@ -7412,7 +7439,7 @@ function PaneTab({ pane, index, active, onSelect }) {
7412
7439
  function PaneTabs({ multi, panes }) {
7413
7440
  const m3 = useStore(multi.store);
7414
7441
  const visible = panes().slice(0, paneCount(LAYOUTS[m3.layout]));
7415
- if (!m3.narrow || visible.length < 2) return null;
7442
+ if (!m3.narrow || visible.length < 3) return null;
7416
7443
  return /* @__PURE__ */ a3("div", { class: "fnc-pane-tabs", role: "tablist", children: visible.map((p3, i3) => /* @__PURE__ */ a3(PaneTab, { pane: p3, index: i3, active: i3 === m3.active, onSelect: () => multi.activate(i3) })) });
7417
7444
  }
7418
7445
  function createMultiChart(container, options) {
@@ -7572,12 +7599,22 @@ function createMultiChart(container, options) {
7572
7599
  if (sym && (sym !== other.chart.symbolInfo?.symbol || r3 !== other.chart.currentResolution)) void other.load(sym, r3);
7573
7600
  }
7574
7601
  });
7602
+ c3.on("indicatorsChange", (list) => {
7603
+ if (store.get().sync.indicators && panes[store.get().active] === pane) shareIndicators(pane, list);
7604
+ });
7575
7605
  c3.on("stateChange", queueState);
7576
7606
  panes[index] = pane;
7577
7607
  cells[index] = cell;
7578
7608
  void pane.load(spec.symbol, spec.resolution ?? resolution);
7579
7609
  return pane;
7580
7610
  }
7611
+ function shareIndicators(from, list = from.chart.getIndicators()) {
7612
+ const json = JSON.stringify(list);
7613
+ for (const other of visible()) {
7614
+ if (other === from || JSON.stringify(other.chart.getIndicators()) === json) continue;
7615
+ other.chart.setIndicators(JSON.parse(json));
7616
+ }
7617
+ }
7581
7618
  let markTime = null;
7582
7619
  const marks = /* @__PURE__ */ new Map();
7583
7620
  function setMark(time) {
@@ -7689,8 +7726,9 @@ function createMultiChart(container, options) {
7689
7726
  if (i3 >= count) parking.appendChild(cells[i3]);
7690
7727
  cells[i3].classList.toggle("fnc-pane-active", i3 === s3.active && count > 1);
7691
7728
  }
7692
- const single = s3.maximized ?? (s3.narrow ? s3.active : null);
7693
- const top = single !== null && single < count ? cells[single] : buildNode(LAYOUTS[s3.layout], "", s3.layout);
7729
+ const stacked = s3.narrow && count === 2;
7730
+ const single = s3.maximized ?? (s3.narrow && !stacked ? s3.active : null);
7731
+ const top = single !== null && single < count ? cells[single] : stacked ? buildNode(LAYOUTS["2-rows"], "", "2-rows") : buildNode(LAYOUTS[s3.layout], "", s3.layout);
7694
7732
  top.style.flex = "1 1 0px";
7695
7733
  grid.replaceChildren(top);
7696
7734
  shell.root.classList.toggle("fnc-split-on", count > 1 && single === null);
@@ -7719,6 +7757,7 @@ function createMultiChart(container, options) {
7719
7757
  for (const p3 of panes.slice(count)) p3.chart.setSyncedCrosshair(null);
7720
7758
  store.set({ layout, maximized: null, active: Math.min(s3.active, count - 1) });
7721
7759
  if (s3.active !== store.get().active) bindToolbar();
7760
+ if (s3.sync.indicators) shareIndicators(panes[store.get().active]);
7722
7761
  renderGrid();
7723
7762
  emit("layoutChange", { layout, panes: count });
7724
7763
  queueState();
@@ -7735,6 +7774,7 @@ function createMultiChart(container, options) {
7735
7774
  store.set({ sync });
7736
7775
  const active = panes[store.get().active];
7737
7776
  if (!sync.crosshair) for (const p3 of panes) p3.chart.setSyncedCrosshair(null);
7777
+ if (sync.indicators && !before.indicators) shareIndicators(active);
7738
7778
  if (sync.symbol && !before.symbol || sync.interval && !before.interval) {
7739
7779
  const info = active.chart.symbolInfo;
7740
7780
  const res = active.chart.currentResolution;
@@ -19,7 +19,7 @@ export interface MultiChartOptions extends Omit<TradingChartOptions, 'symbol'> {
19
19
  layout?: LayoutId;
20
20
  /** Default: crosshair on, everything else off. */
21
21
  sync?: Partial<LayoutSync>;
22
- /** Below this container width only the active pane shows, with tabs to switch. Default 640. */
22
+ /** Below this container width two panes stack (top, bottom); more show one at a time, with tabs to switch. Default 640. */
23
23
  narrowWidth?: number;
24
24
  }
25
25
  /** Everything `load()` needs to rebuild the widget: split, sync, sizes and every pane's chart. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnest/charts-ui",
3
- "version": "0.11.26",
3
+ "version": "0.11.28",
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.11.26"
45
+ "@funnest/charts": "0.11.28"
46
46
  },
47
47
  "devDependencies": {
48
48
  "preact": "^11.2.0"