@luxalgo/vela 0.5.1 → 0.5.2

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.
Files changed (45) hide show
  1. package/dist/{DataProvider-DGesjOJT.d.ts → DataProvider-DTOEXKTI.d.ts} +1 -1
  2. package/dist/{DataProvider-BBQ3Hr21.d.cts → DataProvider-gnzv-dgc.d.cts} +1 -1
  3. package/dist/{chunk-ULIX6AE2.js → chunk-ATPU5CI6.js} +1 -1
  4. package/dist/{chunk-S6F6SQ2L.js → chunk-B5TIKQJ5.js} +60 -7
  5. package/dist/{chunk-EP6NDJYK.js → chunk-LJLZR44Y.js} +4 -2
  6. package/dist/{chunk-AIW3EJUE.js → chunk-P556H6EA.js} +329 -10
  7. package/dist/{chunk-FNOMKHEZ.js → chunk-RRFGWZNJ.js} +1321 -363
  8. package/dist/{chunk-5SE4PL3H.js → chunk-Y7TK4ZWK.js} +1363 -48
  9. package/dist/{contributions-BlV3kb0O.d.cts → contributions-Ci_i3IN2.d.cts} +33 -2
  10. package/dist/{contributions-6N0rbrPC.d.ts → contributions-b6AVrqqG.d.ts} +33 -2
  11. package/dist/{history-DX3Zne3a.d.cts → history-Cf1lVsap.d.cts} +15 -3
  12. package/dist/{history-BTd52YMA.d.ts → history-Ci3M0xLV.d.ts} +15 -3
  13. package/dist/index.cjs +1374 -366
  14. package/dist/index.d.cts +52 -19
  15. package/dist/index.d.ts +52 -19
  16. package/dist/index.js +4 -4
  17. package/dist/{options-DbQholFV.d.cts → options-XTBpbx0s.d.cts} +47 -1
  18. package/dist/{options-DbQholFV.d.ts → options-XTBpbx0s.d.ts} +47 -1
  19. package/dist/{plugin-TN3n-9YN.d.ts → plugin-CnNd7cuF.d.ts} +172 -25
  20. package/dist/{plugin-O34MbXf-.d.cts → plugin-DfH4Y-Om.d.cts} +172 -25
  21. package/dist/plugin.cjs +53 -7
  22. package/dist/plugin.d.cts +4 -4
  23. package/dist/plugin.d.ts +4 -4
  24. package/dist/plugin.js +2 -2
  25. package/dist/providers/binance.d.cts +2 -2
  26. package/dist/providers/binance.d.ts +2 -2
  27. package/dist/providers/coinbase.d.cts +2 -2
  28. package/dist/providers/coinbase.d.ts +2 -2
  29. package/dist/providers/hyperliquid.d.cts +2 -2
  30. package/dist/providers/hyperliquid.d.ts +2 -2
  31. package/dist/ui.cjs +332 -9
  32. package/dist/ui.d.cts +64 -2
  33. package/dist/ui.d.ts +64 -2
  34. package/dist/ui.js +3 -3
  35. package/dist/vela.global.js +1374 -366
  36. package/dist/vela.global.min.js +84 -34
  37. package/dist/widget.cjs +3348 -550
  38. package/dist/widget.d.cts +65 -7
  39. package/dist/widget.d.ts +65 -7
  40. package/dist/widget.js +169 -18
  41. package/dist/workspace.cjs +4251 -1400
  42. package/dist/workspace.d.cts +45 -9
  43. package/dist/workspace.d.ts +45 -9
  44. package/dist/workspace.js +226 -22
  45. package/package.json +1 -1
@@ -482,14 +482,15 @@ var Vela = (function (exports) {
482
482
  svg24('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>')
483
483
  );
484
484
  registerIcon("chevron-right", S('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));
485
+ registerIcon("chevron-left", S('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));
485
486
  registerIcon("chevron-down", S('<path d="M3.5 6 8 10.5 12.5 6"/>'));
486
487
  registerIcon("chevron-up", S('<path d="M3.5 10 8 5.5 12.5 10"/>'));
487
488
  registerIcon("chevrons-right", S('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));
488
489
  registerIcon("chevrons-left", S('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));
489
490
  registerIcon("check", S('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));
490
491
  registerIcon("close", S('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));
491
- registerIcon("eye", S('<path d="M1.5 8s2.5-4.2 6.5-4.2S14.5 8 14.5 8 12 12.2 8 12.2 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));
492
- registerIcon("eye-off", S('<path d="M1.5 8s2.5-4.2 6.5-4.2S14.5 8 14.5 8 12 12.2 8 12.2 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));
492
+ registerIcon("eye", S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));
493
+ registerIcon("eye-off", S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));
493
494
  registerIcon("lock", S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));
494
495
  registerIcon("unlock", S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));
495
496
  registerIcon("trash", S('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));
@@ -512,6 +513,7 @@ var Vela = (function (exports) {
512
513
  registerIcon("star-filled", S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>', 'fill="currentColor"'));
513
514
  registerIcon("grip", S('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>', 'fill="currentColor" stroke="none"'));
514
515
  registerIcon("kebab", S('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>', 'fill="currentColor" stroke="none"'));
516
+ registerIcon("burger", S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
515
517
  registerIcon("reset", S('<rect x="6" y="6" width="4" height="4" rx="0.8"/><path d="M2.2 8a5.8 5.8 0 1 0 1.9-4.3L2.2 5.3"/><path d="M2.2 2.2v3.1h3.1"/>'));
516
518
  registerIcon("pane-collapse", S('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));
517
519
  registerIcon("pane-expand", S('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));
@@ -1890,10 +1892,10 @@ var Vela = (function (exports) {
1890
1892
  }
1891
1893
 
1892
1894
  // src/core/drawings/types/FixedRangeVolumeProfile.ts
1893
- var OUTSIDE_UP = `${BULLISH}BF`;
1894
- var OUTSIDE_DOWN = `${BEARISH}BF`;
1895
- var VA_UP = `${BULLISH}66`;
1896
- var VA_DOWN = `${BEARISH}66`;
1895
+ var OUTSIDE_UP = `${BULLISH}66`;
1896
+ var OUTSIDE_DOWN = `${BEARISH}66`;
1897
+ var VA_UP = `${BULLISH}BF`;
1898
+ var VA_DOWN = `${BEARISH}BF`;
1897
1899
  function defaultFrvpStyle() {
1898
1900
  return {
1899
1901
  rows: 24,
@@ -1911,7 +1913,8 @@ var Vela = (function (exports) {
1911
1913
  valColor: NEUTRAL,
1912
1914
  valStyle: "solid",
1913
1915
  showPoc: true,
1914
- pocColor: ACCENT,
1916
+ pocColor: void 0,
1917
+ // theme contrast ink until the user picks a color
1915
1918
  pocStyle: "solid",
1916
1919
  showDevelopingPoc: false,
1917
1920
  developingPocColor: ACCENT,
@@ -7053,6 +7056,47 @@ var Vela = (function (exports) {
7053
7056
  };
7054
7057
 
7055
7058
  // src/chart-types/registry.ts
7059
+ function normalizeSettingsRow(r) {
7060
+ switch (r.kind) {
7061
+ case "row":
7062
+ return { label: r.label, toggle: r.toggle, controls: r.controls, when: r.when };
7063
+ case "toggle": {
7064
+ const controls = [];
7065
+ if (r.number) controls.push({ kind: "number", ...r.number });
7066
+ for (const c of r.colors ?? []) controls.push({ kind: "color", ...c });
7067
+ if (r.width) controls.push({ kind: "width", ...r.width });
7068
+ return { label: r.label, toggle: { key: r.key, defval: r.defval }, controls, when: r.when };
7069
+ }
7070
+ case "number":
7071
+ return { label: r.label, controls: [{ kind: "number", key: r.key, label: r.label, defval: r.defval, min: r.min, max: r.max, step: r.step }], when: r.when };
7072
+ case "color":
7073
+ return { label: r.label, controls: [{ kind: "color", key: r.key, label: r.label, defval: r.defval }], when: r.when };
7074
+ case "select":
7075
+ return { label: r.label, controls: [{ kind: "select", key: r.key, label: r.label, options: r.options, defval: r.defval }], when: r.when };
7076
+ case "range":
7077
+ return {
7078
+ label: r.label,
7079
+ controls: [
7080
+ { kind: "number", key: r.minKey, label: `${r.label} \u2014 min`, defval: r.defval, min: r.min, max: r.max, step: r.step, placeholder: r.placeholder },
7081
+ { kind: "hint", text: "\u2013" },
7082
+ { kind: "number", key: r.maxKey, label: `${r.label} \u2014 max`, defval: r.defval, min: r.min, max: r.max, step: r.step, placeholder: r.placeholder }
7083
+ ],
7084
+ when: r.when
7085
+ };
7086
+ }
7087
+ }
7088
+ function settingsRowValueKeys(r) {
7089
+ if (r.kind === "heading" || r.kind === "header") return [];
7090
+ const n = normalizeSettingsRow(r);
7091
+ const keys = [];
7092
+ if (n.toggle) keys.push({ key: n.toggle.key, type: "boolean", defval: n.toggle.defval });
7093
+ for (const c of n.controls) {
7094
+ if (c.kind === "hint") continue;
7095
+ if (c.kind === "color" || c.kind === "select") keys.push({ key: c.key, type: "string", defval: c.defval });
7096
+ else keys.push({ key: c.key, type: "number", defval: c.defval });
7097
+ }
7098
+ return keys;
7099
+ }
7056
7100
  function settingsRowVisible(when, bag) {
7057
7101
  if (!when) return true;
7058
7102
  const conds = Array.isArray(when) ? when : [when];
@@ -7157,6 +7201,9 @@ var Vela = (function (exports) {
7157
7201
  this.barTransform = null;
7158
7202
  // ── chart-type data engines (SDK): one lazily-created engine per style id ──
7159
7203
  this.typeEngines = /* @__PURE__ */ new Map();
7204
+ /** Last-seen chart-type settings per type id (dialog edits + persisted restores) —
7205
+ * replayed into a data engine whenever one is (re)created. */
7206
+ this.typeSettings = /* @__PURE__ */ new Map();
7160
7207
  /** The style id whose data engine is currently ACTIVE (drives suspend/resume + pokes). */
7161
7208
  this.activeEngineStyle = null;
7162
7209
  /** The chart's current price style (tracked from the renderer's change events + initial read). */
@@ -7219,7 +7266,10 @@ var Vela = (function (exports) {
7219
7266
  this.renderer.onRemoveIndicator((id) => this.removeIndicator(id));
7220
7267
  this.renderer.onToggleIndicatorVisible?.((id, visible) => this.setVisible(id, visible));
7221
7268
  this.paneActionUnsub = this.renderer.onPaneAction?.((a) => this.handlePaneAction(a)) ?? null;
7222
- this.renderer.onChartTypeSettingsChange?.((typeId, values) => this.typeEngines.get(typeId)?.onSettings?.(values));
7269
+ this.renderer.onChartTypeSettingsChange?.((typeId, values) => {
7270
+ this.typeSettings.set(typeId, values);
7271
+ this.typeEngines.get(typeId)?.onSettings?.(values);
7272
+ });
7223
7273
  this.renderer.onMoveIndicator?.((id, target) => this.moveIndicator(id, target));
7224
7274
  this.renderer.onThemeSelect?.((name) => this.setTheme(resolveTheme(name)));
7225
7275
  this.viewportUnsub = this.renderer.onViewportChange((range) => this.onViewportChange(range));
@@ -7707,6 +7757,8 @@ var Vela = (function (exports) {
7707
7757
  if (!def?.dataEngine) return;
7708
7758
  const engine = def.dataEngine();
7709
7759
  this.typeEngines.set(id, engine);
7760
+ const stored = this.typeSettings.get(id);
7761
+ if (stored) engine.onSettings?.(stored);
7710
7762
  engine.start({
7711
7763
  symbol: this.config.market.symbol ?? "TEST",
7712
7764
  timeframe: this.config.market.timeframe ?? "60",
@@ -8178,6 +8230,7 @@ var Vela = (function (exports) {
8178
8230
  return {
8179
8231
  id: record.id,
8180
8232
  title: record.title,
8233
+ ...d.shortTitle ? { shorttitle: d.shortTitle } : {},
8181
8234
  overlay: d.overlay,
8182
8235
  paneHint: d.paneHint,
8183
8236
  native: { type: record.native.type },
@@ -8638,6 +8691,28 @@ var Vela = (function (exports) {
8638
8691
  setLegendActions(provider) {
8639
8692
  this.renderer.setLegendActions?.(provider);
8640
8693
  }
8694
+ /**
8695
+ * Replace the indicator legend's fold toggle with a host action (or restore it with
8696
+ * `null`) — multi-chart shells point the chip at their indicator overview instead of
8697
+ * unfolding rows in place. Silent no-op on a renderer without a foldable legend.
8698
+ */
8699
+ setLegendOverviewAction(action) {
8700
+ this.renderer.setLegendOverviewAction?.(action);
8701
+ return this;
8702
+ }
8703
+ /** Whether the active renderer can open a per-indicator settings dialog. */
8704
+ get supportsIndicatorSettings() {
8705
+ return typeof this.renderer.openIndicatorSettings === "function";
8706
+ }
8707
+ /**
8708
+ * Open one indicator's settings dialog — the programmatic twin of the legend gear
8709
+ * (see {@link supportsIndicatorSettings}). Silent no-op without the seam or for an
8710
+ * unknown id.
8711
+ */
8712
+ openIndicatorSettings(indicatorId) {
8713
+ this.renderer.openIndicatorSettings?.(indicatorId);
8714
+ return this;
8715
+ }
8641
8716
  /**
8642
8717
  * Export the current chart as a PNG data URL, or null if the active renderer
8643
8718
  * doesn't support it (warns). DOM overlays (tables, legend) are not included.
@@ -8684,6 +8759,10 @@ var Vela = (function (exports) {
8684
8759
  onCrosshairMove(cb) {
8685
8760
  return this.renderer.onCrosshairMove(cb);
8686
8761
  }
8762
+ /** Touch long-press on a price or time axis strip — silent no-op without the seam. */
8763
+ onAxisLongPress(cb) {
8764
+ return this.renderer.onAxisLongPress?.(cb) ?? (() => void 0);
8765
+ }
8687
8766
  /**
8688
8767
  * The current data-window readout — the hovered bar's date/time and OHLCV plus every
8689
8768
  * indicator's value there, each already formatted on its pane's scale (the latest bar when
@@ -8749,6 +8828,13 @@ var Vela = (function (exports) {
8749
8828
  this.renderer.setSettingsSections?.(sections);
8750
8829
  return this;
8751
8830
  }
8831
+ /** Tell the renderer's own chrome which size class the host shell is in —
8832
+ * `'mobile'` switches its dialogs/toolbars to the touch-first presentation.
8833
+ * Silent no-op on a renderer without adaptive chrome. */
8834
+ setLayoutMode(mode) {
8835
+ this.renderer.setLayoutMode?.(mode);
8836
+ return this;
8837
+ }
8752
8838
  };
8753
8839
 
8754
8840
  // src/core/renderer-defaults.ts
@@ -9700,7 +9786,7 @@ var Vela = (function (exports) {
9700
9786
  const doc = anchor.ownerDocument;
9701
9787
  tip = doc.createElement("div");
9702
9788
  tip.textContent = text;
9703
- tip.style.cssText = "position:absolute;z-index:25;pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);" + (opts.wrap ? "max-width:260px;" : "white-space:nowrap;");
9789
+ tip.style.cssText = "position:absolute;z-index:var(--vela-z-tooltip);pointer-events:none;background:var(--vela-bg);border:1px solid var(--vela-border);color:var(--vela-fg);border-radius:var(--vela-radius-md);padding:4px 9px;box-shadow:var(--vela-shadow);font:var(--vela-font-size-md) var(--vela-font);" + (opts.wrap ? "max-width:260px;" : "white-space:nowrap;");
9704
9790
  applyChromeTokens(tip, opts.theme());
9705
9791
  opts.host.appendChild(tip);
9706
9792
  const a = anchor.getBoundingClientRect();
@@ -9714,16 +9800,17 @@ var Vela = (function (exports) {
9714
9800
  tip.style.top = `${a.bottom - h.top + 6}px`;
9715
9801
  }
9716
9802
  };
9717
- const arm = () => {
9803
+ const arm = (e) => {
9804
+ if (e.pointerType !== "mouse") return;
9718
9805
  clear();
9719
9806
  timer = window.setTimeout(show, opts.delayMs ?? 700);
9720
9807
  };
9721
- anchor.addEventListener("mouseenter", arm);
9722
- anchor.addEventListener("mouseleave", clear);
9808
+ anchor.addEventListener("pointerenter", arm);
9809
+ anchor.addEventListener("pointerleave", clear);
9723
9810
  anchor.addEventListener("pointerdown", clear);
9724
9811
  return () => {
9725
- anchor.removeEventListener("mouseenter", arm);
9726
- anchor.removeEventListener("mouseleave", clear);
9812
+ anchor.removeEventListener("pointerenter", arm);
9813
+ anchor.removeEventListener("pointerleave", clear);
9727
9814
  anchor.removeEventListener("pointerdown", clear);
9728
9815
  clear();
9729
9816
  };
@@ -9790,14 +9877,22 @@ var Vela = (function (exports) {
9790
9877
 
9791
9878
  // src/renderers/shared/InputsUI.ts
9792
9879
  var SOURCES = ["close", "open", "high", "low", "hl2", "hlc3", "ohlc4", "volume"];
9793
- var STATUS_KEYFRAMES = "@keyframes vela-ind-spin{to{transform:rotate(360deg)}}@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}";
9794
- var LEGEND_ICON_PX = 13;
9880
+ var STATUS_KEYFRAMES = "@keyframes vela-ind-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.3;transform:scale(.6)}}";
9881
+ var LEGEND_ICON_PX = 16;
9882
+ var LEGEND_CTL_PX = 18;
9883
+ var LEGEND_ROW_PAD_Y = 2;
9884
+ var LEGEND_ROW_PAD_X = 6;
9885
+ var LEGEND_TITLE_VALUES_GAP_PX = 6;
9886
+ var LEGEND_ACTION_GAP_PX = 6;
9887
+ var LEGEND_CTL_CSS = `cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border:none;line-height:0;padding:0;width:${LEGEND_CTL_PX}px;height:${LEGEND_CTL_PX}px;border-radius:3px;box-sizing:border-box;flex:none;`;
9888
+ var LEGEND_ROW_MIN_H = LEGEND_CTL_PX + LEGEND_ROW_PAD_Y * 2;
9795
9889
  var EYE_SVG = iconAt("eye", LEGEND_ICON_PX);
9796
9890
  var EYE_OFF_SVG = iconAt("eye-off", LEGEND_ICON_PX);
9797
9891
  var GEAR_SVG = iconAt("gear", LEGEND_ICON_PX);
9798
- var CLOSE_SVG = iconAt("close", 11);
9892
+ var CLOSE_SVG = iconAt("close", LEGEND_ICON_PX);
9799
9893
  var FOLD_SVG = iconAt("chevron-up", LEGEND_ICON_PX);
9800
9894
  var UNFOLD_SVG = iconAt("chevron-down", LEGEND_ICON_PX);
9895
+ var OVERVIEW_SVG = iconAt("objects", LEGEND_ICON_PX);
9801
9896
  var InputsUI = class {
9802
9897
  constructor(container, theme, paneBoundsOf) {
9803
9898
  this.container = container;
@@ -9818,6 +9913,8 @@ var Vela = (function (exports) {
9818
9913
  this.onToggleVisible = null;
9819
9914
  /** Host symbol picker for `input.symbol`; when set the control opens the host's ticker UI. */
9820
9915
  this.symbolPicker = null;
9916
+ /** Mobile chrome: the inputs dialog opens fullscreen and the legends render compact. */
9917
+ this.mobileLayout = false;
9821
9918
  /** Pane move/merge hook — when set, rows get a "Move to" menu + become drag-to-pane sources. */
9822
9919
  this.moveApi = null;
9823
9920
  /** Host-contributed legend actions, resolved PER ROW at render time (see setLegendActions). */
@@ -9839,9 +9936,18 @@ var Vela = (function (exports) {
9839
9936
  /** Titles switched off entirely (a settings toggle): every pane's legend container
9840
9937
  * hides — rows, fold chevron and all — unlike the fold, which leaves its chip. */
9841
9938
  this.titlesVisible = true;
9939
+ /** Plot values shown beside the titles chart-wide (a settings toggle); a row's own
9940
+ * context-menu choice ({@link LegendRow.showValues}) overrides it per indicator. */
9941
+ this.valuesVisible = true;
9942
+ /** Open legend-row context menu (kept so it can be torn down). */
9943
+ this.rowMenu = null;
9842
9944
  /** The single fold toggle, on the price-pane legend: a bordered ^ chevron under the
9843
9945
  * rows, or the bordered "˅ N" chip (N counts every pane's indicators) when folded. */
9844
9946
  this.foldToggle = null;
9947
+ /** Host-provided replacement for the fold toggle (multi-chart shells route it to
9948
+ * their indicator overview, e.g. an object tree). While set, the legend stays
9949
+ * folded and the chip runs this instead of unfolding inline. */
9950
+ this.overviewAction = null;
9845
9951
  /** Esc-to-close for the settings modal (bound so focus can sit anywhere). */
9846
9952
  this.onDialogKey = (e) => {
9847
9953
  if (e.key === "Escape") {
@@ -9865,6 +9971,9 @@ var Vela = (function (exports) {
9865
9971
  this.onMoveMenuOutside = (e) => {
9866
9972
  if (this.moveMenu && !this.moveMenu.contains(e.target)) this.closeMoveMenu();
9867
9973
  };
9974
+ this.onRowMenuOutside = (e) => {
9975
+ if (this.rowMenu && !this.rowMenu.contains(e.target)) this.closeRowMenu();
9976
+ };
9868
9977
  if (!container.style.position) container.style.position = "relative";
9869
9978
  if (typeof document !== "undefined") document.addEventListener("click", this.onDocClick);
9870
9979
  }
@@ -9872,6 +9981,36 @@ var Vela = (function (exports) {
9872
9981
  this.dialogHost = host;
9873
9982
  if (host && getComputedStyle(host).position === "static") host.style.position = "relative";
9874
9983
  }
9984
+ /** The host shell's chrome size class — mobile makes the inputs dialog fullscreen
9985
+ * (an open dialog re-presents on the flip) and folds the legend behind its chip by
9986
+ * default (a phone-width plot has no room for the rows). */
9987
+ setLayoutMode(mode) {
9988
+ const mobile = mode === "mobile";
9989
+ if (mobile === this.mobileLayout) return;
9990
+ this.mobileLayout = mobile;
9991
+ if (this.overviewAction === null) this.legendFolded = mobile;
9992
+ this.syncFoldToggle();
9993
+ if (this.openId !== null) {
9994
+ const id = this.openId;
9995
+ this.closeOpenDialog();
9996
+ this.openDialog(id);
9997
+ }
9998
+ }
9999
+ /** Replace the fold toggle's behavior with a HOST action (or restore it with null):
10000
+ * the chip stays — objects icon + indicator count — but a press runs the action
10001
+ * (a multi-chart shell opens its indicator overview) instead of unfolding the rows,
10002
+ * which stay hidden while the override is in force. */
10003
+ setLegendOverviewAction(action) {
10004
+ if (action === this.overviewAction) return;
10005
+ this.overviewAction = action;
10006
+ this.legendFolded = action !== null ? true : this.mobileLayout;
10007
+ this.syncFoldToggle();
10008
+ }
10009
+ /** Open the settings dialog of one indicator (the legend gear's programmatic twin) —
10010
+ * no-op for an unknown id. */
10011
+ openSettingsFor(id) {
10012
+ if (this.rows.has(id)) this.openDialog(id);
10013
+ }
9875
10014
  /** Attach a themed chrome tooltip to a control, recording its disposer under `id`. */
9876
10015
  tip(store, id, anchor, text, wrap = false) {
9877
10016
  const list = store.get(id) ?? [];
@@ -9899,12 +10038,12 @@ var Vela = (function (exports) {
9899
10038
  }
9900
10039
  setTheme(theme) {
9901
10040
  this.theme = theme;
10041
+ for (const lg of this.legends.values()) applyChromeTokens(lg, theme);
9902
10042
  for (const row of this.rows.values()) {
9903
- const open = row.controlsEl.style.display !== "none";
9904
- row.el.style.background = open ? theme.background : this.idleRowFill();
10043
+ row.el.style.background = row.highlighted ? theme.background : this.idleRowFill();
9905
10044
  row.el.style.color = theme.textColor;
9906
10045
  }
9907
- if (this.foldToggle) this.foldToggle.style.background = theme.background;
10046
+ if (this.foldToggle) this.syncFoldToggle();
9908
10047
  }
9909
10048
  /** Provide (or clear) the host symbol picker that `input.symbol` opens on activation. */
9910
10049
  setSymbolPicker(picker) {
@@ -9935,7 +10074,7 @@ var Vela = (function (exports) {
9935
10074
  btn.innerHTML = iconAt(action.icon, LEGEND_ICON_PX);
9936
10075
  btn.className = "vela-ind-ctl";
9937
10076
  btn.dataset.legendAction = action.id;
9938
- btn.style.cssText = "cursor:pointer;display:inline-flex;align-items:center;background:transparent;border:none;line-height:0;padding:0 1px;";
10077
+ btn.style.cssText = LEGEND_CTL_CSS;
9939
10078
  btn.addEventListener("click", (e) => {
9940
10079
  e.stopPropagation();
9941
10080
  action.run();
@@ -9953,6 +10092,54 @@ var Vela = (function (exports) {
9953
10092
  this.titlesVisible = visible;
9954
10093
  this.reposition();
9955
10094
  }
10095
+ /**
10096
+ * Show/hide the plot values chart-wide (the settings dialog's Indicators → Values
10097
+ * toggle). "All" is meant literally: per-row context-menu overrides are cleared, so
10098
+ * every legend follows the new state.
10099
+ */
10100
+ setValuesVisible(visible) {
10101
+ this.valuesVisible = visible;
10102
+ for (const row of this.rows.values()) {
10103
+ row.showValues = null;
10104
+ this.renderRowValues(row);
10105
+ }
10106
+ }
10107
+ /**
10108
+ * Push the current plot values of every indicator at once (the renderer calls this per
10109
+ * paint). Rows absent from the map (e.g. a hidden indicator) show no values. Cheap on
10110
+ * unchanged frames: each row diffs against its last rendered values before touching DOM.
10111
+ */
10112
+ setPlotValues(values) {
10113
+ for (const row of this.rows.values()) {
10114
+ const next = values.get(row.id) ?? [];
10115
+ const key = next.map((v) => `${v.value}|${v.color}`).join("\0");
10116
+ if (key === row.plotValuesKey) continue;
10117
+ row.plotValues = next;
10118
+ row.plotValuesKey = key;
10119
+ this.renderRowValues(row);
10120
+ }
10121
+ }
10122
+ /** Whether a row currently shows its values: its own override, else the chart-wide flag. */
10123
+ rowValuesShown(row) {
10124
+ return row.showValues ?? this.valuesVisible;
10125
+ }
10126
+ /** (Re)build one row's values readout from its stored plot values + visibility. A
10127
+ * highlighted (hovered/selected) row shows only the title + controls — no values. */
10128
+ renderRowValues(row) {
10129
+ if (!this.rowValuesShown(row) || row.plotValues.length === 0 || row.highlighted) {
10130
+ row.valuesEl.style.display = "none";
10131
+ row.valuesEl.replaceChildren();
10132
+ return;
10133
+ }
10134
+ row.valuesEl.style.display = "inline-flex";
10135
+ row.valuesEl.replaceChildren();
10136
+ for (const v of row.plotValues) {
10137
+ const span = document.createElement("span");
10138
+ span.textContent = v.value;
10139
+ span.style.color = v.color;
10140
+ row.valuesEl.appendChild(span);
10141
+ }
10142
+ }
9956
10143
  // ── legend move/merge (menu + drag) ─────────────────────────────────────
9957
10144
  /** Open the "Move to" menu for a row, anchored under its move button. */
9958
10145
  openMoveMenu(id, anchor) {
@@ -10004,6 +10191,48 @@ var Vela = (function (exports) {
10004
10191
  this.moveMenu?.remove();
10005
10192
  this.moveMenu = null;
10006
10193
  }
10194
+ // ── legend row context menu (right-click) ───────────────────────────────
10195
+ /** Open the row's action menu at the pointer. One entry today: the values toggle. */
10196
+ openRowMenu(id, x, y) {
10197
+ this.closeRowMenu();
10198
+ this.closeMoveMenu();
10199
+ const row = this.rows.get(id);
10200
+ if (!row) return;
10201
+ const menu = document.createElement("div");
10202
+ menu.style.cssText = `position:fixed;z-index:var(--vela-z-tooltip);min-width:170px;padding:4px;border-radius:var(--vela-radius-md);background:var(--vela-surface-elev);color:${this.theme.textColor};border:1px solid var(--vela-border);box-shadow:var(--vela-shadow);font-size:var(--vela-font-size-md);`;
10203
+ applyChromeTokens(menu, this.theme);
10204
+ const item = document.createElement("button");
10205
+ item.type = "button";
10206
+ item.className = "vela-ind-menuitem";
10207
+ item.style.cssText = "display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:6px 10px;border:none;border-radius:var(--vela-radius-sm);color:inherit;cursor:pointer;white-space:nowrap;";
10208
+ const check = document.createElement("span");
10209
+ check.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;flex:none;line-height:0;";
10210
+ check.innerHTML = this.rowValuesShown(row) ? CHECK_SVG : "";
10211
+ const label = document.createElement("span");
10212
+ label.textContent = "Indicator values";
10213
+ item.append(check, label);
10214
+ item.addEventListener("click", (e) => {
10215
+ e.stopPropagation();
10216
+ this.closeRowMenu();
10217
+ row.showValues = !this.rowValuesShown(row);
10218
+ this.renderRowValues(row);
10219
+ });
10220
+ menu.appendChild(item);
10221
+ document.body.appendChild(menu);
10222
+ const mw = menu.offsetWidth || 180;
10223
+ const mh = menu.offsetHeight || 40;
10224
+ menu.style.left = `${Math.min(x, window.innerWidth - mw - 6)}px`;
10225
+ menu.style.top = `${Math.min(y, window.innerHeight - mh - 6)}px`;
10226
+ this.rowMenu = menu;
10227
+ setTimeout(() => {
10228
+ if (typeof document !== "undefined") document.addEventListener("pointerdown", this.onRowMenuOutside, true);
10229
+ }, 0);
10230
+ }
10231
+ closeRowMenu() {
10232
+ if (typeof document !== "undefined") document.removeEventListener("pointerdown", this.onRowMenuOutside, true);
10233
+ this.rowMenu?.remove();
10234
+ this.rowMenu = null;
10235
+ }
10007
10236
  /** Move a legend row to another pane (indicator merged/moved), tidying an emptied container. */
10008
10237
  setPane(id, paneId) {
10009
10238
  const row = this.rows.get(id);
@@ -10025,7 +10254,8 @@ var Vela = (function (exports) {
10025
10254
  if (!lg) {
10026
10255
  lg = document.createElement("div");
10027
10256
  lg.dataset.velaPane = paneId;
10028
- lg.style.cssText = "position:absolute;left:10px;z-index:5;display:flex;flex-direction:column;align-items:flex-start;gap:3px;pointer-events:none;font:12px -apple-system,Segoe UI,sans-serif;";
10257
+ lg.style.cssText = "position:absolute;left:10px;z-index:5;display:flex;flex-direction:column;align-items:flex-start;gap:0;pointer-events:none;font:12px -apple-system,Segoe UI,sans-serif;";
10258
+ applyChromeTokens(lg, this.theme);
10029
10259
  this.positionLegend(lg, paneId);
10030
10260
  this.container.appendChild(lg);
10031
10261
  this.legends.set(paneId, lg);
@@ -10061,15 +10291,16 @@ var Vela = (function (exports) {
10061
10291
  */
10062
10292
  syncFoldToggle() {
10063
10293
  const count = this.rows.size;
10064
- if (count < 2) {
10294
+ const minRows = this.overviewAction !== null || this.mobileLayout ? 1 : 2;
10295
+ if (count < minRows) {
10065
10296
  const wasFolded = this.legendFolded;
10066
- this.legendFolded = false;
10297
+ if (count > 0) this.legendFolded = false;
10067
10298
  if (this.foldToggle) {
10068
10299
  this.foldToggle.remove();
10069
10300
  this.foldToggle = null;
10070
10301
  this.disposeTips(this.rowTips, "fold");
10071
10302
  }
10072
- if (wasFolded) this.reposition();
10303
+ if (wasFolded && count > 0) this.reposition();
10073
10304
  return;
10074
10305
  }
10075
10306
  let btn = this.foldToggle;
@@ -10077,25 +10308,30 @@ var Vela = (function (exports) {
10077
10308
  btn = document.createElement("button");
10078
10309
  btn.type = "button";
10079
10310
  btn.className = "vela-ind-fold";
10080
- this.tip(this.rowTips, "fold", btn, () => this.legendFolded ? "Show indicator legend" : "Hide indicator legend");
10311
+ this.tip(this.rowTips, "fold", btn, () => this.overviewAction !== null ? "Indicators" : this.legendFolded ? "Show indicator legend" : "Hide indicator legend");
10081
10312
  btn.addEventListener("click", () => {
10313
+ if (this.overviewAction !== null) {
10314
+ this.overviewAction();
10315
+ return;
10316
+ }
10082
10317
  this.legendFolded = !this.legendFolded;
10083
10318
  this.syncFoldToggle();
10084
10319
  });
10085
10320
  this.foldToggle = btn;
10086
10321
  }
10087
10322
  const folded = this.legendFolded;
10088
- btn.setAttribute("aria-label", folded ? "Show indicator legend" : "Hide indicator legend");
10089
- btn.style.cssText = `pointer-events:auto;display:inline-flex;align-items:center;gap:4px;background:${this.theme.background};border:1px solid var(--vela-border);border-radius:4px;padding:2px 6px;margin-top:6px;cursor:pointer;font:inherit;line-height:0;`;
10323
+ btn.setAttribute("aria-label", this.overviewAction !== null ? "Indicators" : folded ? "Show indicator legend" : "Hide indicator legend");
10324
+ const ink = this.theme.textColor;
10325
+ btn.style.cssText = `pointer-events:auto;display:inline-flex;align-items:center;gap:4px;background:${this.theme.background};color:${ink};border:1px solid ${this.theme.borderColor};border-radius:4px;padding:2px 6px;margin-top:6px;cursor:pointer;font:inherit;line-height:0;`;
10090
10326
  btn.replaceChildren();
10091
10327
  const icon2 = document.createElement("span");
10092
- icon2.style.cssText = "display:inline-flex;align-items:center;line-height:0;";
10093
- icon2.innerHTML = folded ? UNFOLD_SVG : FOLD_SVG;
10328
+ icon2.style.cssText = "display:inline-flex;align-items:center;line-height:0;opacity:0.7;";
10329
+ icon2.innerHTML = this.overviewAction !== null ? OVERVIEW_SVG : folded ? UNFOLD_SVG : FOLD_SVG;
10094
10330
  btn.appendChild(icon2);
10095
10331
  if (folded) {
10096
10332
  const label = document.createElement("span");
10097
10333
  label.textContent = String(count);
10098
- label.style.cssText = "font-weight:600;line-height:normal;font-size:12px;color:var(--vela-fg-bright);";
10334
+ label.style.cssText = `font-weight:600;line-height:normal;font-size:12px;color:${ink};`;
10099
10335
  btn.appendChild(label);
10100
10336
  }
10101
10337
  this.legendFor("price").appendChild(btn);
@@ -10103,9 +10339,11 @@ var Vela = (function (exports) {
10103
10339
  }
10104
10340
  /** Create or update an indicator's legend row (in the legend for its pane). */
10105
10341
  upsert(id, title, inputs, values, paneId = "price", opts = {}) {
10342
+ const settingsTitle = opts.settingsTitle ?? title;
10106
10343
  const existing = this.rows.get(id);
10107
10344
  if (existing) {
10108
10345
  existing.title = title;
10346
+ existing.settingsTitle = settingsTitle;
10109
10347
  existing.inputs = inputs;
10110
10348
  existing.values = { ...values };
10111
10349
  existing.titleEl.textContent = title;
@@ -10118,8 +10356,7 @@ var Vela = (function (exports) {
10118
10356
  }
10119
10357
  ensureDialogStyles();
10120
10358
  const el = document.createElement("div");
10121
- el.style.cssText = `pointer-events:auto;display:flex;align-items:center;gap:6px;background:${this.idleRowFill()};border-radius:4px;padding:2px 7px;margin-left:-7px;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`;
10122
- el.addEventListener("mouseenter", () => this.setRowHighlighted(id, true));
10359
+ el.style.cssText = `pointer-events:auto;display:flex;align-items:center;background:${this.idleRowFill()};border-radius:4px;padding:${LEGEND_ROW_PAD_Y}px ${LEGEND_ROW_PAD_X}px;margin-left:-${LEGEND_ROW_PAD_X}px;min-height:${LEGEND_ROW_MIN_H}px;box-sizing:border-box;color:${this.theme.textColor};user-select:none;-webkit-user-select:none;`;
10123
10360
  el.addEventListener("mouseleave", () => {
10124
10361
  if (this.selectedId !== id) this.setRowHighlighted(id, false);
10125
10362
  });
@@ -10139,11 +10376,16 @@ var Vela = (function (exports) {
10139
10376
  e.preventDefault();
10140
10377
  this.onRemove?.(id);
10141
10378
  });
10379
+ el.addEventListener("contextmenu", (e) => {
10380
+ e.preventDefault();
10381
+ e.stopPropagation();
10382
+ this.openRowMenu(id, e.clientX, e.clientY);
10383
+ });
10142
10384
  const statusEl = document.createElement("span");
10143
10385
  statusEl.style.cssText = "display:none;box-sizing:border-box;flex:none;";
10144
- el.appendChild(statusEl);
10145
10386
  const titleWrap = document.createElement("span");
10146
10387
  titleWrap.style.cssText = "white-space:nowrap;";
10388
+ titleWrap.addEventListener("mouseenter", () => this.setRowHighlighted(id, true));
10147
10389
  const titleEl = document.createElement("span");
10148
10390
  titleEl.textContent = title;
10149
10391
  titleEl.style.cssText = "font-weight:600;";
@@ -10155,6 +10397,11 @@ var Vela = (function (exports) {
10155
10397
  titleWrap.appendChild(beta);
10156
10398
  }
10157
10399
  el.appendChild(titleWrap);
10400
+ const valuesEl = document.createElement("span");
10401
+ valuesEl.style.cssText = `display:none;align-items:center;gap:5px;margin-left:${LEGEND_TITLE_VALUES_GAP_PX}px;white-space:nowrap;font-variant-numeric:tabular-nums;`;
10402
+ el.appendChild(valuesEl);
10403
+ const controlsEl = document.createElement("span");
10404
+ controlsEl.style.cssText = `display:none;align-items:center;gap:${LEGEND_ACTION_GAP_PX}px;flex:none;margin-left:${LEGEND_ACTION_GAP_PX}px;`;
10158
10405
  let eyeEl = null;
10159
10406
  if (this.onToggleVisible) {
10160
10407
  const eye = document.createElement("button");
@@ -10163,16 +10410,14 @@ var Vela = (function (exports) {
10163
10410
  this.tip(this.rowTips, id, eye, () => this.rows.get(id)?.hidden ? "Show" : "Hide");
10164
10411
  eye.innerHTML = EYE_SVG;
10165
10412
  eye.className = "vela-ind-ctl";
10166
- eye.style.cssText = "cursor:pointer;display:none;align-items:center;background:transparent;border:none;line-height:0;padding:0 1px;";
10413
+ eye.style.cssText = LEGEND_CTL_CSS;
10167
10414
  eye.addEventListener("click", () => {
10168
10415
  const row = this.rows.get(id);
10169
10416
  this.onToggleVisible?.(id, Boolean(row?.hidden));
10170
10417
  });
10171
- el.appendChild(eye);
10418
+ controlsEl.appendChild(eye);
10172
10419
  eyeEl = eye;
10173
10420
  }
10174
- const controlsEl = document.createElement("span");
10175
- controlsEl.style.cssText = "display:none;align-items:center;gap:6px;";
10176
10421
  if (inputs.length > 0) {
10177
10422
  const gear = document.createElement("button");
10178
10423
  gear.type = "button";
@@ -10180,7 +10425,7 @@ var Vela = (function (exports) {
10180
10425
  this.tip(this.rowTips, id, gear, "Settings");
10181
10426
  gear.innerHTML = GEAR_SVG;
10182
10427
  gear.className = "vela-ind-ctl";
10183
- gear.style.cssText = "cursor:pointer;display:inline-flex;align-items:center;background:transparent;border:none;line-height:0;padding:0 1px;";
10428
+ gear.style.cssText = LEGEND_CTL_CSS;
10184
10429
  gear.addEventListener("click", () => this.openDialog(id));
10185
10430
  controlsEl.appendChild(gear);
10186
10431
  }
@@ -10191,7 +10436,7 @@ var Vela = (function (exports) {
10191
10436
  this.tip(this.rowTips, id, mv, "Move to pane");
10192
10437
  mv.innerHTML = iconAt("move", LEGEND_ICON_PX);
10193
10438
  mv.className = "vela-ind-ctl";
10194
- mv.style.cssText = "cursor:pointer;display:inline-flex;align-items:center;background:transparent;border:none;line-height:0;padding:0 1px;";
10439
+ mv.style.cssText = LEGEND_CTL_CSS;
10195
10440
  mv.addEventListener("click", (e) => {
10196
10441
  e.stopPropagation();
10197
10442
  this.openMoveMenu(id, mv);
@@ -10208,12 +10453,13 @@ var Vela = (function (exports) {
10208
10453
  this.tip(this.rowTips, id, close, "Remove indicator");
10209
10454
  close.innerHTML = CLOSE_SVG;
10210
10455
  close.className = "vela-ind-close";
10211
- close.style.cssText = "cursor:pointer;display:inline-flex;align-items:center;background:transparent;border:none;color:var(--vela-fg-muted);line-height:0;padding:0 1px;";
10456
+ close.style.cssText = LEGEND_CTL_CSS;
10212
10457
  close.addEventListener("click", () => this.onRemove?.(id));
10213
10458
  controlsEl.appendChild(close);
10214
10459
  el.appendChild(controlsEl);
10460
+ el.appendChild(statusEl);
10215
10461
  this.attach(this.legendFor(paneId), el, !!opts.native);
10216
- this.rows.set(id, { id, title, inputs, values: { ...values }, el, titleEl, statusEl, paneId, hidden: false, eyeEl, controlsEl, extrasEl, native: !!opts.native });
10462
+ this.rows.set(id, { id, title, settingsTitle, inputs, values: { ...values }, el, titleEl, statusEl, valuesEl, plotValues: [], plotValuesKey: "", showValues: null, highlighted: false, paneId, hidden: false, eyeEl, controlsEl, extrasEl, native: !!opts.native });
10217
10463
  this.syncFoldToggle();
10218
10464
  }
10219
10465
  /** Place a row in its pane's legend — native rows PREPEND (pinned to the top), Pine rows append. */
@@ -10227,24 +10473,31 @@ var Vela = (function (exports) {
10227
10473
  if (row) row.values = { ...row.values, ...values };
10228
10474
  }
10229
10475
  /**
10230
- * Reflect an indicator's live status in its legend row: `'loading'` shows a spinner (a fetch is
10231
- * in flight), `'live'` a pulsing dot (live-updating), `'idle'` nothing. Rendered left of the title.
10476
+ * Reflect an indicator's live status in its legend row: `'loading'` shows three pulsing
10477
+ * dots (a fetch is in flight the same load affordance as the chart's own bar-load dots,
10478
+ * at legend scale), `'live'` a pulsing dot, `'idle'` nothing. Rendered at the row's right end.
10232
10479
  */
10233
10480
  setStatus(id, status) {
10234
10481
  const row = this.rows.get(id);
10235
10482
  if (!row) return;
10236
10483
  const el = row.statusEl;
10484
+ el.replaceChildren();
10237
10485
  if (status === "idle") {
10238
- el.style.display = "none";
10239
- el.style.animation = "none";
10486
+ el.style.cssText = "display:none;box-sizing:border-box;flex:none;";
10240
10487
  return;
10241
10488
  }
10242
- this.ensureStatusKeyframes();
10243
10489
  if (status === "loading") {
10244
- el.style.cssText = `display:inline-block;box-sizing:border-box;flex:none;width:11px;height:11px;border-radius:50%;border:2px solid var(--vela-border-strong);border-top-color:var(--vela-fg-bright);animation:vela-ind-spin .7s linear infinite;`;
10245
- } else {
10246
- el.style.cssText = `display:inline-block;box-sizing:border-box;flex:none;width:8px;height:8px;border-radius:50%;background:${this.theme.upColor};animation:vela-ind-pulse 1.2s ease-in-out infinite;`;
10490
+ el.style.cssText = "display:inline-flex;align-items:center;gap:3px;box-sizing:border-box;flex:none;";
10491
+ for (let i = 0; i < 3; i += 1) {
10492
+ const dot = document.createElement("span");
10493
+ dot.style.cssText = "width:4px;height:4px;border-radius:50%;background:currentColor;opacity:0.15;flex:none;";
10494
+ dot.animate?.([{ opacity: 0.12 }, { opacity: 0.55 }], { duration: 800, iterations: Infinity, direction: "alternate", easing: "ease-in-out", delay: -i * 260 });
10495
+ el.appendChild(dot);
10496
+ }
10497
+ return;
10247
10498
  }
10499
+ this.ensureStatusKeyframes();
10500
+ el.style.cssText = `display:inline-block;box-sizing:border-box;flex:none;width:8px;height:8px;border-radius:50%;background:${this.theme.upColor};animation:vela-ind-pulse 1.2s ease-in-out infinite;`;
10248
10501
  }
10249
10502
  /** Inject the status keyframes once (idempotent). */
10250
10503
  ensureStatusKeyframes() {
@@ -10263,8 +10516,8 @@ var Vela = (function (exports) {
10263
10516
  if (row.eyeEl) {
10264
10517
  row.eyeEl.innerHTML = visible ? EYE_SVG : EYE_OFF_SVG;
10265
10518
  row.eyeEl.setAttribute("aria-label", visible ? "Hide" : "Show");
10266
- row.eyeEl.style.display = !visible || row.controlsEl.style.display !== "none" ? "inline-flex" : "none";
10267
10519
  }
10520
+ this.syncRowActions(row);
10268
10521
  }
10269
10522
  /**
10270
10523
  * Select a legend row (outlining it) and clear any previous selection, so at most one
@@ -10277,17 +10530,36 @@ var Vela = (function (exports) {
10277
10530
  this.setRowHighlighted(id, true);
10278
10531
  }
10279
10532
  /**
10280
- * Show or hide a row's outline and eye/gear/✕ controls together — driven by both hover and
10281
- * selection, so an idle (unhovered, unselected) row shows just its title. Exception: a hidden
10282
- * indicator keeps its eye visible even when idle, so it can be un-hidden without hovering.
10533
+ * Show or hide a row's outline and eye/gear/✕ controls together — driven by title
10534
+ * hover and selection (plot values do not open the chip). An idle unselected row
10535
+ * shows just its title (+ values). Exception: a hidden indicator keeps its eye
10536
+ * visible even when idle, so it can be un-hidden without hovering.
10283
10537
  */
10284
10538
  setRowHighlighted(id, highlighted) {
10285
10539
  const row = this.rows.get(id);
10286
10540
  if (!row) return;
10541
+ row.highlighted = highlighted;
10542
+ this.renderRowValues(row);
10287
10543
  row.el.style.boxShadow = highlighted ? `inset 0 0 0 1px ${this.neutralBorder()}` : "none";
10288
10544
  row.el.style.background = highlighted ? this.theme.background : this.idleRowFill();
10289
- row.controlsEl.style.display = highlighted ? "inline-flex" : "none";
10290
- if (row.eyeEl) row.eyeEl.style.display = highlighted || row.hidden ? "inline-flex" : "none";
10545
+ this.syncRowActions(row);
10546
+ }
10547
+ /**
10548
+ * Reveal the action cluster (or just the eye for a hidden indicator). Non-eye
10549
+ * buttons only appear while highlighted; the eye keeps its inline-flex from
10550
+ * construction and is shown/hidden with the cluster container.
10551
+ */
10552
+ syncRowActions(row) {
10553
+ const open = row.highlighted;
10554
+ row.controlsEl.style.display = open || row.hidden ? "inline-flex" : "none";
10555
+ for (const child of Array.from(row.controlsEl.children)) {
10556
+ if (!(child instanceof HTMLElement) || child === row.eyeEl) continue;
10557
+ if (child === row.extrasEl) {
10558
+ child.style.display = open ? "contents" : "none";
10559
+ continue;
10560
+ }
10561
+ child.style.display = open ? "inline-flex" : "none";
10562
+ }
10291
10563
  }
10292
10564
  /** Drop the current selection outline, if any. */
10293
10565
  clearSelection() {
@@ -10315,6 +10587,7 @@ var Vela = (function (exports) {
10315
10587
  destroy() {
10316
10588
  this.closeDialog();
10317
10589
  this.closeMoveMenu();
10590
+ this.closeRowMenu();
10318
10591
  for (const id of [...this.rowTips.keys()]) this.disposeTips(this.rowTips, id);
10319
10592
  for (const id of [...this.extrasTips.keys()]) this.disposeTips(this.extrasTips, id);
10320
10593
  for (const lg of this.legends.values()) lg.remove();
@@ -10370,6 +10643,7 @@ var Vela = (function (exports) {
10370
10643
  const card = document.createElement("div");
10371
10644
  card.className = "vela-ind-dialog";
10372
10645
  card.style.cssText = `display:flex;flex-direction:column;width:fit-content;min-width:min(360px,90%);max-width:min(640px,94%);max-height:82%;background:${t.background};border:1px solid ${border};border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow-dialog);color:${fg};color-scheme:${scheme};font:13px ${font};overflow:hidden;`;
10646
+ if (this.mobileLayout) card.style.cssText += "width:100%;min-width:0;max-width:none;height:100%;max-height:none;border:none;border-radius:0;";
10373
10647
  applyChromeTokens(card, t);
10374
10648
  card.addEventListener("keydown", (e) => {
10375
10649
  if (e.key !== "Escape") e.stopPropagation();
@@ -10377,7 +10651,7 @@ var Vela = (function (exports) {
10377
10651
  const header = document.createElement("div");
10378
10652
  header.style.cssText = "display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 20px 12px;flex:0 0 auto;";
10379
10653
  const hTitle = document.createElement("span");
10380
- hTitle.textContent = row.title;
10654
+ hTitle.textContent = row.settingsTitle;
10381
10655
  hTitle.style.cssText = "font-weight:600;font-size:16px;line-height:1.3;";
10382
10656
  const closeBtn = document.createElement("button");
10383
10657
  closeBtn.type = "button";
@@ -10389,7 +10663,7 @@ var Vela = (function (exports) {
10389
10663
  closeBtn.addEventListener("click", () => this.closeDialog());
10390
10664
  header.append(hTitle, closeBtn);
10391
10665
  card.appendChild(header);
10392
- makeDialogDraggable(card, header, { closeSelector: "button" });
10666
+ if (!this.mobileLayout) makeDialogDraggable(card, header, { closeSelector: "button" });
10393
10667
  const tabs = document.createElement("div");
10394
10668
  tabs.style.cssText = `display:flex;gap:16px;padding:0 20px;border-bottom:1px solid ${border};flex:0 0 auto;`;
10395
10669
  const tab = document.createElement("div");
@@ -10409,7 +10683,7 @@ var Vela = (function (exports) {
10409
10683
  section.appendChild(gh);
10410
10684
  }
10411
10685
  const grid = document.createElement("div");
10412
- grid.style.cssText = "display:grid;grid-template-columns:minmax(140px,auto) auto auto 1fr;align-items:center;column-gap:12px;row-gap:22px;";
10686
+ grid.style.cssText = this.mobileLayout ? "display:grid;grid-template-columns:minmax(0,1fr) auto auto max-content;align-items:center;column-gap:12px;row-gap:22px;" : "display:grid;grid-template-columns:minmax(140px,auto) auto auto 1fr;align-items:center;column-gap:12px;row-gap:22px;";
10413
10687
  for (const inputRow of group.rows) this.buildInputRow(grid, inputRow, row);
10414
10688
  section.appendChild(grid);
10415
10689
  body.appendChild(section);
@@ -10858,10 +11132,14 @@ var Vela = (function (exports) {
10858
11132
  var CHECK_SVG = iconAt("check", 12);
10859
11133
  var SELECT_CHEVRON_SVG = iconAt("chevron-down", 16);
10860
11134
  var DIALOG_STYLE_ID = "vela-ind-dialog-styles";
11135
+ var DIALOG_STYLE_REV = "10";
10861
11136
  function ensureDialogStyles() {
10862
- if (typeof document === "undefined" || document.getElementById(DIALOG_STYLE_ID)) return;
10863
- const s = document.createElement("style");
11137
+ if (typeof document === "undefined") return;
11138
+ const existing = document.getElementById(DIALOG_STYLE_ID);
11139
+ if (existing?.dataset.rev === DIALOG_STYLE_REV) return;
11140
+ const s = existing ?? document.createElement("style");
10864
11141
  s.id = DIALOG_STYLE_ID;
11142
+ s.dataset.rev = DIALOG_STYLE_REV;
10865
11143
  s.textContent = `
10866
11144
  .vela-ind-dialog input[type=color]{-webkit-appearance:none;appearance:none;}
10867
11145
  .vela-ind-dialog input[type=color]::-webkit-color-swatch-wrapper{padding:0;}
@@ -10875,19 +11153,19 @@ var Vela = (function (exports) {
10875
11153
  .vela-ind-dialog ::-webkit-scrollbar-track{background:transparent;}
10876
11154
  .vela-ind-hint{background:var(--vela-hover);color:var(--vela-fg-muted);transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease;}
10877
11155
  .vela-ind-hint:hover{background:var(--vela-active);color:var(--vela-fg-bright);}
10878
- .vela-ind-ctl{color:var(--vela-fg-muted);transition:color var(--vela-dur-fast) ease;}
10879
- .vela-ind-ctl:hover{color:var(--vela-fg-bright);}
10880
- .vela-ind-close{transition:color var(--vela-dur-fast) ease;}
10881
- .vela-ind-close:hover{color:var(--vela-danger) !important;}
10882
- .vela-ind-fold{color:var(--vela-fg-muted);transition:color var(--vela-dur-fast) ease,border-color var(--vela-dur-fast) ease;}
10883
- .vela-ind-fold:hover{color:var(--vela-fg-bright);border-color:var(--vela-border-strong);}
11156
+ .vela-ind-ctl,.vela-ind-close{background-color:transparent;color:inherit;transition:color var(--vela-dur-fast) ease,background-color var(--vela-dur-fast) ease;}
11157
+ .vela-ind-ctl svg,.vela-ind-close svg{width:${LEGEND_ICON_PX}px;height:${LEGEND_ICON_PX}px;display:block;flex:none;stroke-width:1;}
11158
+ .vela-ind-ctl:hover{background-color:var(--vela-hover-strong);}
11159
+ .vela-ind-close:hover{color:var(--vela-danger) !important;background-color:var(--vela-hover-strong);}
11160
+ .vela-ind-fold{transition:border-color var(--vela-dur-fast) ease,opacity var(--vela-dur-fast) ease;}
11161
+ .vela-ind-fold:hover{border-color:var(--vela-border-strong);opacity:0.9;}
10884
11162
  .vela-ind-menuitem{background:transparent;transition:background var(--vela-dur-fast) ease;}
10885
11163
  .vela-ind-menuitem:hover{background:var(--vela-hover-strong);}
10886
11164
  .vela-ind-btn{cursor:pointer;padding:7px 14px;border-radius:var(--vela-radius-md);border:1px solid transparent;background:transparent;color:var(--vela-fg-muted);font-weight:600;font-size:13px;font-family:inherit;transition:background var(--vela-dur-fast) ease,color var(--vela-dur-fast) ease,opacity var(--vela-dur-fast) ease;}
10887
11165
  .vela-ind-btn:hover{background:var(--vela-hover);color:var(--vela-fg-bright);}
10888
11166
  .vela-ind-btn-primary{padding:7px 16px;border-color:var(--vela-selected-bg);background:var(--vela-selected-bg);color:var(--vela-selected-fg);}
10889
11167
  .vela-ind-btn-primary:hover{background:var(--vela-selected-bg);color:var(--vela-selected-fg);opacity:0.85;}`;
10890
- document.head.appendChild(s);
11168
+ if (!existing) document.head.appendChild(s);
10891
11169
  }
10892
11170
  var TIMEFRAME_OPTIONS = [
10893
11171
  { value: "", label: "Chart" },
@@ -11580,14 +11858,7 @@ var Vela = (function (exports) {
11580
11858
  const defaults2 = {};
11581
11859
  const addRows = (rows) => {
11582
11860
  for (const r of rows ?? []) {
11583
- if (r.kind === "heading" || r.kind === "header") continue;
11584
- if (r.kind === "range") {
11585
- defaults2[r.minKey] = r.defval;
11586
- defaults2[r.maxKey] = r.defval;
11587
- continue;
11588
- }
11589
- defaults2[r.key] = r.defval;
11590
- if (r.kind === "toggle") for (const c of r.colors ?? []) defaults2[c.key] = c.defval;
11861
+ for (const k of settingsRowValueKeys(r)) defaults2[k.key] = k.defval;
11591
11862
  }
11592
11863
  };
11593
11864
  for (const inst of section.instances ?? []) {
@@ -13731,6 +14002,11 @@ void main() {
13731
14002
  var FLING_MIN_SPEED = 0.04;
13732
14003
  var FLING_STALE_MS = 60;
13733
14004
  var DRAG_SLOP = 2;
14005
+ var LONG_PRESS_MS = 350;
14006
+ var TOUCH_SLOP = 8;
14007
+ var TOUCH_TAP_SLOP = 14;
14008
+ var DOUBLE_TAP_MS = 350;
14009
+ var DOUBLE_TAP_SLOP = 30;
13734
14010
  var TIME_SCALE_K = 4e-3;
13735
14011
  var WHEEL_ZOOM_K = 25e-4;
13736
14012
  function wheelZoomAnchor(coords, cursorX, rightEdge) {
@@ -13751,6 +14027,12 @@ void main() {
13751
14027
  function effectiveSnapMode(momentaryOverride, sticky) {
13752
14028
  return momentaryOverride ? "strong" : sticky;
13753
14029
  }
14030
+ function pinchBarSpacing(startBarSpacing, startDist, dist) {
14031
+ return clampBarSpacing(startBarSpacing * (dist / Math.max(1, startDist)));
14032
+ }
14033
+ function pinchPinnedRightOffset(anchorLogical, barCount, width, x, pxPerBar) {
14034
+ return anchorLogical - (barCount - 1) + (width - x) / pxPerBar;
14035
+ }
13754
14036
  var InputController = class {
13755
14037
  constructor(deps) {
13756
14038
  this.deps = deps;
@@ -13784,6 +14066,23 @@ void main() {
13784
14066
  // press/release re-shape the drawings preview with the pointer stationary.
13785
14067
  this.cursorX = NaN;
13786
14068
  this.cursorY = NaN;
14069
+ // ── touch state ──
14070
+ /** Live touch contacts (local coords) — two entries drive a pinch; extras are ignored. */
14071
+ this.touches = /* @__PURE__ */ new Map();
14072
+ this.lpTimer = null;
14073
+ this.pinchStartDist = 1;
14074
+ this.pinchStartBarSpacing = 0;
14075
+ this.pinchAnchorLogical = 0;
14076
+ // Last clean touch tap (for double-tap pairing). Time 0 = no pending first tap.
14077
+ this.lastTapT = 0;
14078
+ this.lastTapX = 0;
14079
+ this.lastTapY = 0;
14080
+ this.onTouchContextMenu = (e) => {
14081
+ if (this.touches.size === 0) return;
14082
+ if (!(e.target instanceof Node) || !this.el?.contains(e.target)) return;
14083
+ e.preventDefault();
14084
+ e.stopImmediatePropagation();
14085
+ };
13787
14086
  this.onMiddleGuard = (e) => {
13788
14087
  if (e.button === 1 && this.middleDeleted) e.preventDefault();
13789
14088
  };
@@ -13805,6 +14104,15 @@ void main() {
13805
14104
  }
13806
14105
  if (e.button !== 0) return;
13807
14106
  const { x, y } = this.local(e);
14107
+ if (e.pointerType === "touch") {
14108
+ if (this.touches.size === 1 && this.dragging && (this.region === "data" || this.region === "crosshair")) {
14109
+ this.touches.set(e.pointerId, { x, y });
14110
+ this.beginPinch(e);
14111
+ return;
14112
+ }
14113
+ if (this.touches.size >= 1) return;
14114
+ this.touches.set(e.pointerId, { x, y });
14115
+ }
13808
14116
  this.deps.drawingsClearTransient?.();
13809
14117
  this.dragging = true;
13810
14118
  this.moved = false;
@@ -13830,6 +14138,9 @@ void main() {
13830
14138
  if (this.region === "price") this.deps.beginPriceScale(x, y);
13831
14139
  else if (this.region === "separator") this.deps.beginPaneResize(y);
13832
14140
  else if (this.region === "data") this.verticalPan = this.deps.beginPricePan(y);
14141
+ if (e.pointerType === "touch" && (this.region === "data" || this.region === "price" || this.region === "time")) {
14142
+ this.startLongPress(x, y, this.region);
14143
+ }
13833
14144
  this.lastX = x;
13834
14145
  this.lastT = e.timeStamp;
13835
14146
  this.vx = 0;
@@ -13839,28 +14150,42 @@ void main() {
13839
14150
  const { x, y } = this.local(e);
13840
14151
  this.cursorX = x;
13841
14152
  this.cursorY = y;
14153
+ if (e.pointerType === "touch" && this.touches.has(e.pointerId)) this.touches.set(e.pointerId, { x, y });
14154
+ if (this.dragging && this.region === "pinch") {
14155
+ this.applyPinch();
14156
+ return;
14157
+ }
14158
+ if (this.dragging && this.region === "crosshair") {
14159
+ this.deps.onPointerMove(x, y);
14160
+ return;
14161
+ }
14162
+ if (this.dragging && this.region === "axis-sheet") {
14163
+ return;
14164
+ }
14165
+ if (this.lpTimer !== null && Math.hypot(x - this.startX, y - this.startY) > TOUCH_SLOP) this.cancelLongPress();
14166
+ const slop = e.pointerType === "touch" ? TOUCH_SLOP : DRAG_SLOP;
13842
14167
  if (this.dragging) {
13843
14168
  if (this.region === "price") {
13844
- if (Math.abs(y - this.startY) > DRAG_SLOP) this.moved = true;
14169
+ if (Math.abs(y - this.startY) > slop) this.moved = true;
13845
14170
  this.deps.priceScaleBy(y - this.startY);
13846
14171
  } else if (this.region === "separator") {
13847
- if (Math.abs(y - this.startY) > DRAG_SLOP) this.moved = true;
14172
+ if (Math.abs(y - this.startY) > slop) this.moved = true;
13848
14173
  this.deps.paneResizeBy(y - this.startY);
13849
14174
  } else if (this.region === "time") {
13850
- if (Math.abs(x - this.startX) > DRAG_SLOP) this.moved = true;
14175
+ if (Math.abs(x - this.startX) > slop) this.moved = true;
13851
14176
  const barSpacing = clampBarSpacing(this.startBarSpacing * Math.exp((this.startX - x) * TIME_SCALE_K));
13852
14177
  this.deps.apply({ barSpacing, rightOffset: this.startRightOffset });
13853
14178
  } else if (this.region === "drawing") {
13854
- if (Math.abs(x - this.startX) > DRAG_SLOP || Math.abs(y - this.startY) > DRAG_SLOP) this.moved = true;
14179
+ if (Math.abs(x - this.startX) > slop || Math.abs(y - this.startY) > slop) this.moved = true;
13855
14180
  this.deps.drawingsPointerMove?.(x, y, this.snapMode(e), e.shiftKey);
13856
14181
  } else {
13857
14182
  const coords = this.deps.getCoords();
13858
14183
  const vp = coords.getViewport();
13859
14184
  const dx = x - this.startX;
13860
- if (Math.abs(dx) > DRAG_SLOP) this.moved = true;
14185
+ if (Math.abs(dx) > slop) this.moved = true;
13861
14186
  this.deps.apply({ barSpacing: vp.barSpacing, rightOffset: this.startRightOffset - dx / coords.pxPerBar() });
13862
14187
  if (this.verticalPan) {
13863
- if (Math.abs(y - this.startY) > DRAG_SLOP) this.moved = true;
14188
+ if (Math.abs(y - this.startY) > slop) this.moved = true;
13864
14189
  this.deps.pricePanBy(y - this.startY);
13865
14190
  }
13866
14191
  const dt = e.timeStamp - this.lastT;
@@ -13877,14 +14202,44 @@ void main() {
13877
14202
  this.el.style.cursor = drawCursor ?? (r === "price" ? "ns-resize" : r === "time" ? "ew-resize" : r === "separator" ? "row-resize" : "");
13878
14203
  this.deps.drawingsPointerMove?.(x, y, this.snapMode(e), e.shiftKey);
13879
14204
  }
13880
- this.deps.onPointerMove(x, y);
14205
+ if (e.pointerType !== "touch") this.deps.onPointerMove(x, y);
13881
14206
  };
13882
14207
  this.onUp = (e) => {
14208
+ if (e.pointerType === "touch") this.touches.delete(e.pointerId);
14209
+ this.cancelLongPress();
14210
+ if (this.dragging && this.region === "pinch") {
14211
+ if (this.touches.size === 1) {
14212
+ const rest = [...this.touches.values()][0];
14213
+ const vp = this.deps.getCoords().getViewport();
14214
+ this.region = "data";
14215
+ this.verticalPan = false;
14216
+ this.startX = rest.x;
14217
+ this.startY = rest.y;
14218
+ this.startRightOffset = vp.rightOffset;
14219
+ this.startBarSpacing = vp.barSpacing;
14220
+ this.lastX = rest.x;
14221
+ this.lastT = e.timeStamp;
14222
+ this.vx = 0;
14223
+ return;
14224
+ }
14225
+ this.endGesture(e);
14226
+ return;
14227
+ }
14228
+ if (this.dragging && this.region === "crosshair") {
14229
+ this.deps.onPointerMove(null, null);
14230
+ this.endGesture(e);
14231
+ return;
14232
+ }
14233
+ if (this.dragging && this.region === "axis-sheet") {
14234
+ this.endGesture(e);
14235
+ return;
14236
+ }
14237
+ const { x, y } = this.local(e);
14238
+ const wasTouch = e.pointerType === "touch";
14239
+ const tapRelease = this.dragging && !this.moved && (!wasTouch || Math.hypot(x - this.startX, y - this.startY) <= TOUCH_TAP_SLOP);
13883
14240
  if (this.dragging && this.region === "drawing") {
13884
- const { x, y } = this.local(e);
13885
14241
  this.deps.drawingsPointerUp?.(x, y);
13886
- } else if (this.dragging && !this.moved && this.region === "data") {
13887
- const { x, y } = this.local(e);
14242
+ } else if (tapRelease && this.region === "data") {
13888
14243
  this.deps.onClick(x, y);
13889
14244
  } else if (this.dragging && this.region === "data") {
13890
14245
  const stale = e.timeStamp - this.lastT > FLING_STALE_MS;
@@ -13893,11 +14248,20 @@ void main() {
13893
14248
  this.deps.fling(-this.vx / pitch);
13894
14249
  }
13895
14250
  }
13896
- this.dragging = false;
13897
- try {
13898
- this.el?.releasePointerCapture(e.pointerId);
13899
- } catch {
13900
- }
14251
+ const wasTap = wasTouch && tapRelease;
14252
+ this.endGesture(e);
14253
+ if (wasTouch) this.deps.onPointerMove(null, null);
14254
+ if (wasTap) this.registerTap(e.timeStamp, x, y);
14255
+ };
14256
+ /** The browser took the pointer back (system gesture, palm rejection, tab switch):
14257
+ * drop the gesture where it is — no click, no fling, no stuck `dragging`. */
14258
+ this.onCancel = (e) => {
14259
+ if (e.pointerType === "touch") this.touches.delete(e.pointerId);
14260
+ this.cancelLongPress();
14261
+ if (!this.dragging) return;
14262
+ if (this.region === "drawing" && !Number.isNaN(this.cursorX)) this.deps.drawingsPointerUp?.(this.cursorX, this.cursorY);
14263
+ if (this.region === "crosshair" || e.pointerType === "touch") this.deps.onPointerMove(null, null);
14264
+ this.endGesture(e);
13901
14265
  };
13902
14266
  this.onLeave = () => {
13903
14267
  this.cursorX = NaN;
@@ -13906,12 +14270,7 @@ void main() {
13906
14270
  };
13907
14271
  this.onDblClick = (e) => {
13908
14272
  const { x, y } = this.local(e);
13909
- if (this.deps.drawingsDblClick?.(x, y)) return;
13910
- const region = this.regionAt(x, y);
13911
- if (region === "price") this.deps.resetPriceScale(x, y);
13912
- else if (region === "separator") this.deps.resetPaneSize(y);
13913
- else if (region === "time") this.deps.resetView();
13914
- else this.deps.dataDblClick(x, y);
14273
+ this.doubleActivate(x, y);
13915
14274
  };
13916
14275
  this.onWheel = (e) => {
13917
14276
  e.preventDefault();
@@ -13932,10 +14291,17 @@ void main() {
13932
14291
  }
13933
14292
  attach(el) {
13934
14293
  this.el = el;
14294
+ if (el.style !== void 0) {
14295
+ el.style.touchAction = "none";
14296
+ el.style.userSelect = "none";
14297
+ el.style.setProperty("-webkit-user-select", "none");
14298
+ el.style.setProperty("-webkit-touch-callout", "none");
14299
+ }
13935
14300
  el.addEventListener("pointerdown", this.onDown);
13936
14301
  el.addEventListener("pointermove", this.onMove);
13937
14302
  el.addEventListener("pointerup", this.onUp);
13938
14303
  el.addEventListener("pointerleave", this.onLeave);
14304
+ el.addEventListener("pointercancel", this.onCancel);
13939
14305
  el.addEventListener("dblclick", this.onDblClick);
13940
14306
  el.addEventListener("wheel", this.onWheel, { passive: false });
13941
14307
  el.addEventListener("mousedown", this.onMiddleGuard);
@@ -13943,6 +14309,7 @@ void main() {
13943
14309
  const win = el.ownerDocument?.defaultView;
13944
14310
  win?.addEventListener("keydown", this.onModifier);
13945
14311
  win?.addEventListener("keyup", this.onModifier);
14312
+ win?.addEventListener("contextmenu", this.onTouchContextMenu, true);
13946
14313
  }
13947
14314
  detach() {
13948
14315
  const el = this.el;
@@ -13950,14 +14317,18 @@ void main() {
13950
14317
  const win = el.ownerDocument?.defaultView;
13951
14318
  win?.removeEventListener("keydown", this.onModifier);
13952
14319
  win?.removeEventListener("keyup", this.onModifier);
14320
+ win?.removeEventListener("contextmenu", this.onTouchContextMenu, true);
13953
14321
  el.removeEventListener("pointerdown", this.onDown);
13954
14322
  el.removeEventListener("pointermove", this.onMove);
13955
14323
  el.removeEventListener("pointerup", this.onUp);
13956
14324
  el.removeEventListener("pointerleave", this.onLeave);
14325
+ el.removeEventListener("pointercancel", this.onCancel);
13957
14326
  el.removeEventListener("dblclick", this.onDblClick);
13958
14327
  el.removeEventListener("wheel", this.onWheel);
13959
14328
  el.removeEventListener("mousedown", this.onMiddleGuard);
13960
14329
  el.removeEventListener("auxclick", this.onMiddleGuard);
14330
+ this.cancelLongPress();
14331
+ this.touches.clear();
13961
14332
  this.el = null;
13962
14333
  }
13963
14334
  local(e) {
@@ -13981,6 +14352,59 @@ void main() {
13981
14352
  snapMode(e) {
13982
14353
  return effectiveSnapMode(e.ctrlKey || e.metaKey, this.deps.drawingsSnapMode?.() ?? "off");
13983
14354
  }
14355
+ /** Arm the long-press timer for a data-area → crosshair or axis → sheet hold;
14356
+ * movement past TOUCH_SLOP or a second finger cancels it. */
14357
+ startLongPress(x, y, region) {
14358
+ this.cancelLongPress();
14359
+ this.lpTimer = setTimeout(() => {
14360
+ this.lpTimer = null;
14361
+ if (!this.dragging || this.region !== region) return;
14362
+ if (region === "data") {
14363
+ this.region = "crosshair";
14364
+ this.deps.onPointerMove(x, y);
14365
+ return;
14366
+ }
14367
+ this.region = "axis-sheet";
14368
+ this.moved = true;
14369
+ this.deps.onAxisLongPress?.(region, x, y);
14370
+ }, LONG_PRESS_MS);
14371
+ }
14372
+ cancelLongPress() {
14373
+ if (this.lpTimer !== null) clearTimeout(this.lpTimer);
14374
+ this.lpTimer = null;
14375
+ }
14376
+ /** Two fingers down: freeze the view and re-base the gesture as an anchored pinch. */
14377
+ beginPinch(e) {
14378
+ this.cancelLongPress();
14379
+ if (this.region === "crosshair") this.deps.onPointerMove(null, null);
14380
+ const coords = this.deps.getCoords();
14381
+ const vp = coords.getViewport();
14382
+ this.deps.apply(vp);
14383
+ const [a, b] = [...this.touches.values()];
14384
+ this.pinchStartDist = Math.max(1, Math.hypot(a.x - b.x, a.y - b.y));
14385
+ this.pinchStartBarSpacing = vp.barSpacing;
14386
+ this.pinchAnchorLogical = coords.xToLogical((a.x + b.x) / 2);
14387
+ this.region = "pinch";
14388
+ this.dragging = true;
14389
+ this.moved = true;
14390
+ this.vx = 0;
14391
+ this.capture(e.pointerId);
14392
+ }
14393
+ /** Track both fingers: distance ratio zooms, the live midpoint pans (anchor pinned under it). */
14394
+ applyPinch() {
14395
+ const coords = this.deps.getCoords();
14396
+ const pts = [...this.touches.values()];
14397
+ if (pts.length < 2) return;
14398
+ const [a, b] = pts;
14399
+ const barSpacing = pinchBarSpacing(this.pinchStartBarSpacing, this.pinchStartDist, Math.hypot(a.x - b.x, a.y - b.y));
14400
+ const vp = coords.getViewport();
14401
+ const pitchScale = vp.barSpacing > 0 ? coords.pxPerBar() / vp.barSpacing : 1;
14402
+ const midX = (a.x + b.x) / 2;
14403
+ this.deps.apply({
14404
+ barSpacing,
14405
+ rightOffset: pinchPinnedRightOffset(this.pinchAnchorLogical, coords.barCount, coords.width, midX, barSpacing * pitchScale)
14406
+ });
14407
+ }
13984
14408
  /** Capture defensively: a synthetic/already-released pointer can't be captured, and
13985
14409
  * the move/up pair still routes through the element listeners without it. */
13986
14410
  capture(pointerId) {
@@ -13989,6 +14413,35 @@ void main() {
13989
14413
  } catch {
13990
14414
  }
13991
14415
  }
14416
+ /** Pair clean taps into a double-tap — the touch equivalent of dblclick (same
14417
+ * routing: axis taps reset that axis' view, a plot tap toggles pane maximize). */
14418
+ registerTap(t, x, y) {
14419
+ const paired = this.lastTapT > 0 && t - this.lastTapT <= DOUBLE_TAP_MS && Math.hypot(x - this.lastTapX, y - this.lastTapY) <= DOUBLE_TAP_SLOP;
14420
+ if (paired) {
14421
+ this.lastTapT = 0;
14422
+ this.doubleActivate(this.lastTapX, this.lastTapY);
14423
+ return;
14424
+ }
14425
+ this.lastTapT = t;
14426
+ this.lastTapX = x;
14427
+ this.lastTapY = y;
14428
+ }
14429
+ endGesture(e) {
14430
+ this.dragging = false;
14431
+ try {
14432
+ this.el?.releasePointerCapture(e.pointerId);
14433
+ } catch {
14434
+ }
14435
+ }
14436
+ /** Shared double-click / double-tap routing, by the region under the point. */
14437
+ doubleActivate(x, y) {
14438
+ if (this.deps.drawingsDblClick?.(x, y)) return;
14439
+ const region = this.regionAt(x, y);
14440
+ if (region === "price") this.deps.resetPriceScale(x, y);
14441
+ else if (region === "separator") this.deps.resetPaneSize(y);
14442
+ else if (region === "time") this.deps.resetView();
14443
+ else this.deps.dataDblClick(x, y);
14444
+ }
13992
14445
  };
13993
14446
 
13994
14447
  // src/renderers/native/core/KeyboardController.ts
@@ -15802,11 +16255,19 @@ void main() {
15802
16255
  const y = dataH + (fullH - dataH) / 2;
15803
16256
  const tr = coords.visibleTimeRange();
15804
16257
  const offset = tzOffsetMs((tr.from + tr.to) / 2, scene.timezone);
15805
- for (const tick of timeTicks(tr.from, tr.to, 8, offset)) {
15806
- const x = coords.timeToX(tick.time);
15807
- if (x < 20 || x > dataW - 20) continue;
15808
- ctx.fillText(tick.label, x, y);
15809
- }
16258
+ const target = Math.max(3, Math.min(8, Math.floor(dataW / 64)));
16259
+ const ticks = timeTicks(tr.from, tr.to, target, offset).map((tick) => ({ ...tick, x: coords.timeToX(tick.time), half: ctx.measureText(tick.label).width / 2 })).filter((tick) => tick.x >= 20 && tick.x <= dataW - 20);
16260
+ const GAP = 12;
16261
+ const placed = [];
16262
+ const put = (tick) => {
16263
+ const l = tick.x - tick.half;
16264
+ const r = tick.x + tick.half;
16265
+ if (!placed.every((p) => r + GAP <= p.l || l - GAP >= p.r)) return;
16266
+ placed.push({ l, r });
16267
+ ctx.fillText(tick.label, tick.x, y);
16268
+ };
16269
+ for (const tick of ticks) if (tick.major) put(tick);
16270
+ for (const tick of ticks) if (!tick.major) put(tick);
15810
16271
  ctx.textAlign = "start";
15811
16272
  }
15812
16273
  };
@@ -15908,10 +16369,10 @@ void main() {
15908
16369
  }
15909
16370
  /** The synced ghost: a dimmed vertical line at the bar the renderer resolved as
15910
16371
  * CONTAINING the foreign time (+ horizontal line when a comparable price came
15911
- * along), with that bar's time chip in this chart's own timezone. The snap
15912
- * happened upstream (`externalCrossPx`, floor-to-containing-bar) this method
15913
- * only draws. No price chip the ghost answers "when", the local crosshair
15914
- * answers "where". */
16372
+ * along), with that bar's time chip in this chart's own timezone and — when the
16373
+ * level resolved the price chip on the right axis. The snap happened upstream
16374
+ * (`externalCrossPx`, floor-to-containing-bar)this method only draws. Chips
16375
+ * render slightly dimmed so the ghost still reads as foreign. */
15915
16376
  drawExternal(ctx, ext, scene, coords, theme) {
15916
16377
  const cs = scene.style.crosshair;
15917
16378
  const dataW = coords.width;
@@ -15935,7 +16396,20 @@ void main() {
15935
16396
  ctx.setLineDash([]);
15936
16397
  ctx.lineWidth = 1;
15937
16398
  ctx.globalAlpha = 0.8;
15938
- this.chip(ctx, x, dataH + 1, formatStamp(ext.time, scene.timezone), cs.labelBackground ?? theme.borderColor, "center", true, theme.background);
16399
+ const chipBg = cs.labelBackground ?? theme.borderColor;
16400
+ if (ext.y != null && ext.price != null) {
16401
+ let pane;
16402
+ for (const p of scene.panes.values()) {
16403
+ if (ext.y >= p.bounds.top && ext.y <= p.bounds.top + p.bounds.height) {
16404
+ pane = p;
16405
+ break;
16406
+ }
16407
+ }
16408
+ if (pane) {
16409
+ this.chip(ctx, dataW + 1, ext.y, formatAxisValue(pane.scale, pane.bounds.height, ext.price, percentScaleFor(scene, pane), scene.priceMintick, pane.axisFormat), chipBg, "left", false, theme.background);
16410
+ }
16411
+ }
16412
+ this.chip(ctx, x, dataH + 1, formatStamp(ext.time, scene.timezone), chipBg, "center", true, theme.background);
15939
16413
  ctx.globalAlpha = 1;
15940
16414
  }
15941
16415
  /** A soft band + a brighter crisp center line over the hovered separator, so it reads as
@@ -16296,6 +16770,7 @@ void main() {
16296
16770
  swatch.style.background = `linear-gradient(${v}, ${v}), ${CHECKER2}`;
16297
16771
  };
16298
16772
  paint();
16773
+ trigger.addEventListener("vela-sync", paint);
16299
16774
  trigger.addEventListener("click", (e) => {
16300
16775
  e.stopPropagation();
16301
16776
  if (openPopover && openPopover.trigger === trigger) {
@@ -16331,6 +16806,101 @@ void main() {
16331
16806
  closeOpen();
16332
16807
  }
16333
16808
 
16809
+ // src/renderers/native/chrome/WidthField.ts
16810
+ var WIDTH_FIELD_OPTIONS = [1, 2, 3, 4, 5];
16811
+ var STYLE_ID3 = "vela-width-field";
16812
+ function ensureStyles3() {
16813
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID3)) return;
16814
+ const st = document.createElement("style");
16815
+ st.id = STYLE_ID3;
16816
+ st.textContent = `
16817
+ .vela-width-field{height:28px;padding:0 8px;border:1px solid var(--vela-border-strong);border-radius:var(--vela-radius-sm);background:var(--vela-surface-elev);cursor:pointer;display:inline-flex;align-items:center;gap:8px;flex:none;color:var(--vela-fg);font-family:inherit;outline:none;}
16818
+ .vela-width-field:hover{border-color:var(--vela-fg-muted);}
16819
+ .vela-width-field-pop{position:fixed;z-index:6000;background:var(--vela-surface-overlay);border:1px solid var(--vela-border);border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow);padding:4px;display:flex;flex-direction:column;gap:1px;color:var(--vela-fg);}
16820
+ .vela-width-field-item{display:flex;align-items:center;gap:8px;min-width:96px;padding:5px 8px;border:none;border-radius:5px;background:transparent;color:inherit;cursor:pointer;text-align:left;font:inherit;}
16821
+ .vela-width-field-item:hover{background:var(--vela-hover-strong);}
16822
+ .vela-width-field-item[data-active='1']{background:var(--vela-active);}
16823
+ `;
16824
+ document.head.appendChild(st);
16825
+ }
16826
+ function lineGlyph(width) {
16827
+ return `<svg width="22" height="14" viewBox="0 0 22 14" fill="none"><line x1="2" y1="7" x2="20" y2="7" stroke="currentColor" stroke-width="${width}" stroke-linecap="round"/></svg>`;
16828
+ }
16829
+ var CHEVRON = `<svg width="8" height="5" viewBox="0 0 8 5" fill="none"><path d="M1 1l3 3 3-3" stroke="#868a96" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
16830
+ var openPopover2 = null;
16831
+ function closeOpen2() {
16832
+ if (!openPopover2) return;
16833
+ document.removeEventListener("pointerdown", openPopover2.onOutside, true);
16834
+ window.removeEventListener("resize", openPopover2.reflow, true);
16835
+ openPopover2.el.remove();
16836
+ openPopover2 = null;
16837
+ }
16838
+ function place2(pop, trigger) {
16839
+ const r = trigger.getBoundingClientRect();
16840
+ const w = pop.offsetWidth;
16841
+ const h = pop.offsetHeight;
16842
+ let left = r.right - w;
16843
+ let top = r.bottom + 6;
16844
+ if (left < 6) left = 6;
16845
+ if (left + w > window.innerWidth - 6) left = window.innerWidth - w - 6;
16846
+ if (top + h > window.innerHeight - 6) top = r.top - h - 6;
16847
+ if (top < 6) top = 6;
16848
+ pop.style.left = `${Math.round(left)}px`;
16849
+ pop.style.top = `${Math.round(top)}px`;
16850
+ }
16851
+ function widthField(theme, getVal, onVal) {
16852
+ ensureStyles3();
16853
+ const trigger = document.createElement("button");
16854
+ trigger.type = "button";
16855
+ trigger.className = "vela-width-field";
16856
+ const paint = () => {
16857
+ trigger.innerHTML = `<span style="display:flex;">${lineGlyph(getVal())}</span><span style="display:flex;">${CHEVRON}</span>`;
16858
+ };
16859
+ paint();
16860
+ trigger.addEventListener("click", (e) => {
16861
+ e.stopPropagation();
16862
+ if (openPopover2 && openPopover2.trigger === trigger) {
16863
+ closeOpen2();
16864
+ return;
16865
+ }
16866
+ closeOpen2();
16867
+ const pop = document.createElement("div");
16868
+ pop.className = "vela-width-field-pop";
16869
+ applyChromeTokens(pop, theme);
16870
+ pop.style.font = `var(--vela-font-size-md) ${theme.fontFamily}`;
16871
+ pop.addEventListener("pointerdown", (ev) => ev.stopPropagation());
16872
+ for (const w of WIDTH_FIELD_OPTIONS) {
16873
+ const item = document.createElement("button");
16874
+ item.type = "button";
16875
+ item.className = "vela-width-field-item";
16876
+ item.dataset.active = w === getVal() ? "1" : "0";
16877
+ item.innerHTML = `<span style="display:flex;flex:none;">${lineGlyph(w)}</span><span style="flex:1;font-variant-numeric:tabular-nums;">${w}px</span>`;
16878
+ item.addEventListener("click", (ev) => {
16879
+ ev.stopPropagation();
16880
+ closeOpen2();
16881
+ onVal(w);
16882
+ paint();
16883
+ });
16884
+ pop.appendChild(item);
16885
+ }
16886
+ document.body.appendChild(pop);
16887
+ place2(pop, trigger);
16888
+ const onOutside = (ev) => {
16889
+ const t = ev.target;
16890
+ if (pop.contains(t) || trigger.contains(t)) return;
16891
+ closeOpen2();
16892
+ };
16893
+ const reflow = () => place2(pop, trigger);
16894
+ setTimeout(() => document.addEventListener("pointerdown", onOutside, true), 0);
16895
+ window.addEventListener("resize", reflow, true);
16896
+ openPopover2 = { el: pop, trigger, onOutside, reflow };
16897
+ });
16898
+ return trigger;
16899
+ }
16900
+ function closeWidthPopover() {
16901
+ closeOpen2();
16902
+ }
16903
+
16334
16904
  // src/renderers/native/chrome/SettingsDialog.ts
16335
16905
  var BUILTIN_STYLE_LABELS = {
16336
16906
  candles: "Candles",
@@ -16413,6 +16983,30 @@ void main() {
16413
16983
  muted and non-interactive. Applied to each row's children so it survives display:contents;
16414
16984
  !important beats the inline opacity on labels. */
16415
16985
  .vela-sd-soft>*{opacity:0.4 !important;pointer-events:none !important;}
16986
+ /* \u2500\u2500 mobile presentation (.vela-sd-mobile on the scrim; structural sizes are inline in open()) \u2500\u2500
16987
+ The tab rail becomes a burger-opened overlay sidebar; the group TOC becomes a sticky
16988
+ row of horizontally scrollable tabs; the instance strip scrolls instead of wrapping;
16989
+ controls grow to touch size and labels may wrap (the grid gives them a flexible track). */
16990
+ .vela-sd-mobile .vela-sd-burger{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;color:var(--vela-fg);line-height:0;width:36px;height:36px;border-radius:var(--vela-radius-sm);margin-right:2px;}
16991
+ .vela-sd-mobile .vela-sd-burger:active{background:var(--vela-hover);}
16992
+ .vela-sd-mobile .vela-sd-railscrim{position:absolute;inset:0;z-index:2;background:var(--vela-backdrop);display:none;}
16993
+ .vela-sd-mobile .vela-sd-railscrim.open{display:block;}
16994
+ .vela-sd-mobile .vela-sd-rail{position:absolute;left:0;top:0;bottom:0;z-index:3;width:min(240px,80%);box-sizing:border-box;background:var(--vela-surface);border-right:1px solid var(--vela-border);box-shadow:var(--vela-shadow-dialog);transform:translateX(-105%);transition:transform var(--vela-dur-med) var(--vela-ease);}
16995
+ .vela-sd-mobile .vela-sd-rail.open{transform:translateX(0);}
16996
+ .vela-sd-mobile .vela-sd-tab{padding:12px;}
16997
+ .vela-sd-mobile .vela-sd-struct{flex-direction:column;padding-top:8px;}
16998
+ .vela-sd-mobile .vela-sd-toc{position:sticky;top:0;z-index:1;background:var(--vela-surface);flex-direction:row;overflow-x:auto;scrollbar-width:none;min-width:0;width:100%;box-sizing:border-box;gap:4px;padding:2px 0 8px;}
16999
+ .vela-sd-mobile .vela-sd-toc::-webkit-scrollbar{display:none;}
17000
+ .vela-sd-mobile .vela-sd-toc-btn{flex:none;padding:8px 12px;font-size:13px;}
17001
+ .vela-sd-mobile .vela-sd-struct>[data-sd-rows-host]{border-left:none;padding-left:0;width:100%;}
17002
+ .vela-sd-mobile .vela-sd-itabs{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;}
17003
+ .vela-sd-mobile .vela-sd-itabs::-webkit-scrollbar{display:none;}
17004
+ .vela-sd-mobile .vela-sd-itab{height:36px;flex:none;}
17005
+ .vela-sd-mobile .vela-sd-check{width:22px;height:22px;}
17006
+ .vela-sd-mobile .vela-sd-select,.vela-sd-mobile .vela-sd-number{height:34px;}
17007
+ .vela-sd-mobile .vela-sd-close{width:40px;height:40px;}
17008
+ .vela-sd-mobile .vela-sd-btn{height:38px;}
17009
+ .vela-sd-mobile .vela-sd-row span,.vela-sd-mobile .vela-sd-bool span{white-space:normal !important;}
16416
17010
  `;
16417
17011
  document.head.appendChild(st);
16418
17012
  }
@@ -16439,6 +17033,8 @@ void main() {
16439
17033
  this.typeActiveGroup = /* @__PURE__ */ new Map();
16440
17034
  /** The tab currently shown, so a theme change (which rebuilds) lands back on it. */
16441
17035
  this.activeSection = null;
17036
+ /** Mobile chrome: fullscreen card, burger-opened section sidebar, TOC as top tabs. */
17037
+ this.mobileLayout = false;
16442
17038
  if (getComputedStyle(container).position === "static") container.style.position = "relative";
16443
17039
  }
16444
17040
  /** Host-app sections (e.g. the widget's Status line tab) — re-shown on next open. */
@@ -16457,15 +17053,27 @@ void main() {
16457
17053
  }
16458
17054
  setTheme(theme) {
16459
17055
  this.theme = theme;
16460
- if (this.root) {
16461
- const cfg = this.config;
16462
- const oc = this.onChange;
16463
- const oi = this.onImport;
16464
- const orst = this.onReset;
16465
- const section = this.activeSection;
16466
- this.close();
16467
- if (cfg && oc) this.open(cfg, oc, oi ?? void 0, orst ?? void 0, section ?? void 0);
16468
- }
17056
+ this.reopenIfLive();
17057
+ }
17058
+ /** The host shell's chrome size class — mobile presents the dialog fullscreen with
17059
+ * the tab rail behind a burger sidebar and the TOC as top tabs. An open dialog
17060
+ * re-presents in place, on the same tab. */
17061
+ setLayoutMode(mode) {
17062
+ const mobile = mode === "mobile";
17063
+ if (mobile === this.mobileLayout) return;
17064
+ this.mobileLayout = mobile;
17065
+ this.reopenIfLive();
17066
+ }
17067
+ /** Rebuild an open dialog in place (theme swap, layout-mode flip) on the same tab. */
17068
+ reopenIfLive() {
17069
+ if (!this.root) return;
17070
+ const cfg = this.config;
17071
+ const oc = this.onChange;
17072
+ const oi = this.onImport;
17073
+ const orst = this.onReset;
17074
+ const section = this.activeSection;
17075
+ this.close();
17076
+ if (cfg && oc) this.open(cfg, oc, oi ?? void 0, orst ?? void 0, section ?? void 0);
16469
17077
  }
16470
17078
  isOpen() {
16471
17079
  return this.root !== null;
@@ -16487,18 +17095,37 @@ void main() {
16487
17095
  this.onImport = onImport ?? null;
16488
17096
  this.onReset = onReset ?? null;
16489
17097
  ensureControlStyles();
17098
+ const mobile = this.mobileLayout;
16490
17099
  const scrim = document.createElement("div");
16491
- scrim.style.cssText = "position:absolute;inset:0;z-index:21;display:flex;align-items:flex-start;justify-content:center;background:transparent;padding-top:8vh;pointer-events:auto;";
17100
+ scrim.style.cssText = "position:absolute;inset:0;z-index:var(--vela-z-dialog);display:flex;align-items:flex-start;justify-content:center;background:transparent;padding-top:8vh;pointer-events:auto;";
17101
+ if (mobile) {
17102
+ scrim.classList.add("vela-sd-mobile");
17103
+ scrim.style.paddingTop = "0";
17104
+ scrim.style.alignItems = "stretch";
17105
+ }
16492
17106
  scrim.addEventListener("mousedown", (e) => {
16493
17107
  if (e.target === scrim) this.close();
16494
17108
  });
16495
17109
  const dlg = document.createElement("div");
16496
17110
  dlg.style.cssText = `width:fit-content;min-width:min(560px,94vw);max-width:min(720px,94vw);max-height:70vh;display:flex;flex-direction:column;background:${SETTINGS_SURFACE};border:1px solid ${SETTINGS_BORDER};border-radius:var(--vela-radius-lg);box-shadow:var(--vela-shadow-dialog);color:${SETTINGS_TEXT};font:13px var(--vela-font);overflow:hidden;cursor:default;`;
17111
+ if (mobile) dlg.style.cssText += "width:100%;min-width:0;max-width:none;max-height:none;flex:1 1 auto;border:none;border-radius:0;";
16497
17112
  const header = document.createElement("div");
16498
17113
  header.style.cssText = `display:flex;justify-content:space-between;align-items:center;padding:9px 9px 9px 16px;border-bottom:1px solid ${SETTINGS_BORDER};flex:0 0 auto;user-select:none;`;
17114
+ if (mobile) header.style.paddingLeft = "8px";
16499
17115
  const hTitle = document.createElement("span");
16500
17116
  hTitle.textContent = "Chart settings";
16501
17117
  hTitle.style.cssText = "font-size:17px;font-weight:600;letter-spacing:0.2px;";
17118
+ if (mobile) hTitle.style.cssText += "flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";
17119
+ let toggleRail = null;
17120
+ if (mobile) {
17121
+ const burger = document.createElement("button");
17122
+ burger.type = "button";
17123
+ burger.className = "vela-sd-burger";
17124
+ burger.innerHTML = iconAt("burger", 16);
17125
+ burger.title = "Sections";
17126
+ burger.addEventListener("click", () => toggleRail?.());
17127
+ header.append(burger);
17128
+ }
16502
17129
  const closeBtn = document.createElement("button");
16503
17130
  closeBtn.type = "button";
16504
17131
  closeBtn.innerHTML = iconAt("close", 15);
@@ -16506,8 +17133,8 @@ void main() {
16506
17133
  closeBtn.className = "vela-sd-close";
16507
17134
  closeBtn.addEventListener("click", () => this.close());
16508
17135
  header.append(hTitle, closeBtn);
16509
- header.style.cursor = "move";
16510
- {
17136
+ if (!mobile) {
17137
+ header.style.cursor = "move";
16511
17138
  let sx = 0, sy = 0, ox = 0, oy = 0, dragging = false;
16512
17139
  header.addEventListener("pointerdown", (e) => {
16513
17140
  if (e.target?.closest(".vela-sd-close")) return;
@@ -16688,12 +17315,24 @@ void main() {
16688
17315
  renderChartTypeSections("end");
16689
17316
  renderHostSections("end");
16690
17317
  const shell = document.createElement("div");
16691
- shell.style.cssText = "display:flex;min-height:360px;max-height:calc(70vh - 100px);flex:1 1 auto;";
17318
+ shell.style.cssText = mobile ? "display:flex;min-height:0;flex:1 1 auto;position:relative;overflow:hidden;" : "display:flex;min-height:360px;max-height:calc(70vh - 100px);flex:1 1 auto;";
16692
17319
  const rail = document.createElement("div");
16693
- rail.style.cssText = `flex:0 0 170px;display:flex;flex-direction:column;gap:2px;padding:10px 8px;border-right:1px solid ${SETTINGS_BORDER};overflow-y:auto;`;
17320
+ rail.className = "vela-sd-rail";
17321
+ rail.style.cssText = mobile ? "display:flex;flex-direction:column;gap:2px;padding:10px 8px;overflow-y:auto;" : `flex:0 0 170px;display:flex;flex-direction:column;gap:2px;padding:10px 8px;border-right:1px solid ${SETTINGS_BORDER};overflow-y:auto;`;
17322
+ let railScrim = null;
17323
+ if (mobile) {
17324
+ railScrim = document.createElement("div");
17325
+ railScrim.className = "vela-sd-railscrim";
17326
+ railScrim.addEventListener("click", () => toggleRail?.());
17327
+ toggleRail = (open) => {
17328
+ const on = open ?? !rail.classList.contains("open");
17329
+ rail.classList.toggle("open", on);
17330
+ railScrim?.classList.toggle("open", on);
17331
+ };
17332
+ }
16694
17333
  const paneHost = document.createElement("div");
16695
17334
  paneHost.className = "vela-sd-pane";
16696
- paneHost.style.cssText = "flex:1;overflow-y:auto;padding:6px 18px 14px;";
17335
+ paneHost.style.cssText = mobile ? "flex:1;min-width:0;overflow-y:auto;padding:6px 14px calc(14px + env(safe-area-inset-bottom, 0px));" : "flex:1;overflow-y:auto;padding:6px 18px 14px;";
16697
17336
  const panes = [];
16698
17337
  let current = null;
16699
17338
  for (const child of [...body.children]) {
@@ -16728,6 +17367,10 @@ void main() {
16728
17367
  p.tab.classList.toggle("on", i === idx);
16729
17368
  });
16730
17369
  this.activeSection = panes[idx]?.title ?? null;
17370
+ if (mobile) {
17371
+ hTitle.textContent = panes[idx]?.title ?? "Chart settings";
17372
+ toggleRail?.(false);
17373
+ }
16731
17374
  };
16732
17375
  panes.forEach((p, i) => {
16733
17376
  p.tab.addEventListener("click", () => activate(i));
@@ -16735,10 +17378,11 @@ void main() {
16735
17378
  paneHost.appendChild(p.el);
16736
17379
  });
16737
17380
  this.tabs = panes.map((p, i) => ({ title: p.title, show: () => activate(i) }));
16738
- const wanted = section === void 0 ? -1 : panes.findIndex((p) => p.title.toLowerCase() === section.toLowerCase());
17381
+ const wanted = section !== void 0 ? panes.findIndex((p) => p.title.toLowerCase() === section.toLowerCase()) : panes.findIndex((p) => p.style === config.series.style && !p.tab.classList.contains("vela-sd-tab-sub"));
16739
17382
  activate(wanted >= 0 ? wanted : 0);
16740
17383
  this.syncTypeTabs?.(config.series.style);
16741
17384
  shell.append(rail, paneHost);
17385
+ if (railScrim) shell.append(railScrim);
16742
17386
  dlg.appendChild(shell);
16743
17387
  dlg.appendChild(this.footer(config));
16744
17388
  scrim.appendChild(dlg);
@@ -16755,6 +17399,7 @@ void main() {
16755
17399
  }
16756
17400
  close() {
16757
17401
  closeColorPopover();
17402
+ closeWidthPopover();
16758
17403
  this.root?.remove();
16759
17404
  this.root = null;
16760
17405
  this.tabs = [];
@@ -16795,20 +17440,12 @@ void main() {
16795
17440
  body.append(marker);
16796
17441
  const values = config.chartTypes[typeId] ?? {};
16797
17442
  const bag = {};
16798
- const seedKey = (key, want, defval) => {
16799
- const v = values[key];
16800
- bag[key] = typeof v === want ? v : defval;
16801
- };
16802
17443
  const seed = (rows) => {
16803
17444
  for (const r of rows) {
16804
- if (r.kind === "heading" || r.kind === "header") continue;
16805
- if (r.kind === "range") {
16806
- seedKey(r.minKey, "number", r.defval);
16807
- seedKey(r.maxKey, "number", r.defval);
16808
- continue;
17445
+ for (const k of settingsRowValueKeys(r)) {
17446
+ const v = values[k.key];
17447
+ bag[k.key] = typeof v === k.type ? v : k.defval;
16809
17448
  }
16810
- seedKey(r.key, r.kind === "toggle" ? "boolean" : r.kind === "number" ? "number" : "string", r.defval);
16811
- if (r.kind === "toggle") for (const c of r.colors ?? []) seedKey(c.key, "string", c.defval);
16812
17449
  }
16813
17450
  };
16814
17451
  if (section.rows) seed(section.rows);
@@ -16831,7 +17468,8 @@ void main() {
16831
17468
  if (section.instances && section.instances.length > 0) {
16832
17469
  body.append(this.instancesBlock(typeId, section.instances, bag, put, refreshers));
16833
17470
  } else if (section.rows) {
16834
- this.flatTypeRows(section.rows, bag, put, refreshers, body);
17471
+ if (section.layout === "grouped") body.append(this.groupedRows(`${typeId}/rows`, section.rows, bag, put, refreshers));
17472
+ else this.flatTypeRows(section.rows, bag, put, refreshers, body);
16835
17473
  }
16836
17474
  for (const sub of section.subsections ?? []) {
16837
17475
  const subMarker = this.section(sub.title);
@@ -16848,7 +17486,7 @@ void main() {
16848
17486
  flatTypeRows(rows, bag, put, refreshers, body) {
16849
17487
  const entries = [];
16850
17488
  for (const r of rows) {
16851
- const el = r.kind === "heading" || r.kind === "header" ? this.sectionTitle(r.label) : this.typeRow(r, bag, put);
17489
+ const el = r.kind === "heading" || r.kind === "header" ? this.sectionTitle(r.label) : this.typeRow(r, bag, put, refreshers);
16852
17490
  entries.push({ el, when: r.when });
16853
17491
  body.append(el);
16854
17492
  }
@@ -16856,60 +17494,109 @@ void main() {
16856
17494
  for (const e of entries) e.el.classList.toggle("vela-sd-hide", !settingsRowVisible(e.when, bag));
16857
17495
  });
16858
17496
  }
16859
- /** One value row for a chart-type descriptor, writing through `put`. */
16860
- typeRow(r, bag, put) {
16861
- if (r.kind === "toggle") {
16862
- const swatches = (r.colors ?? []).map((c) => {
16863
- const sw = this.swatch(bag[c.key], (v) => put(c.key, v));
16864
- sw.title = c.label;
16865
- return sw;
16866
- });
16867
- return this.toggleRow(r.label, bag[r.key], (v) => put(r.key, v), swatches);
17497
+ /**
17498
+ * One value row for a chart-type descriptor, writing through `put`. EVERY kind is
17499
+ * first reduced to the canonical composite shape ({@link normalizeSettingsRow}) and
17500
+ * rendered by the ONE path: optional leading toggle, then the ordered inline
17501
+ * controls in the control column. A control carrying its own `when` registers a
17502
+ * visibility refresher — it appears and disappears live as the bag changes,
17503
+ * independent of the row's gate — and is exempt from the toggle-off dim (it may
17504
+ * exist FOR the off state).
17505
+ */
17506
+ typeRow(r, bag, put, refreshers) {
17507
+ const n = normalizeSettingsRow(r);
17508
+ const controls = [];
17509
+ for (const c of n.controls) {
17510
+ const el = this.inlineControl(c, bag, put, n.toggle !== void 0);
17511
+ if (c.kind !== "hint") refreshers.push(() => el.dispatchEvent(new Event("vela-sync")));
17512
+ if (c.kind !== "hint" && c.when) {
17513
+ el.dataset.sdSelfGated = "1";
17514
+ const when = c.when;
17515
+ refreshers.push(() => {
17516
+ el.style.display = settingsRowVisible(when, bag) ? "" : "none";
17517
+ });
17518
+ }
17519
+ controls.push(el);
17520
+ }
17521
+ if (n.toggle) {
17522
+ const t = n.toggle;
17523
+ const el = this.toggleRow(n.label, bag[t.key], (v) => put(t.key, v), controls, () => bag[t.key] === true);
17524
+ refreshers.push(() => el.dispatchEvent(new Event("vela-sync")));
17525
+ return el;
16868
17526
  }
16869
- if (r.kind === "number") return this.numberRow(r.label, bag[r.key], r.min ?? 0, r.max ?? 1e6, r.step ?? 1, (v) => put(r.key, v));
16870
- if (r.kind === "color") return this.colorRow(r.label, bag[r.key], (v) => put(r.key, v));
16871
- if (r.kind === "range") return this.rangeRow(r, bag, put);
16872
- return this.selectRowLabeled(r.label, bag[r.key], normalizeSelectOptions(r.options), (v) => put(r.key, v));
17527
+ return this.rowWith(n.label, controls);
16873
17528
  }
16874
17529
  /**
16875
- * A MIN–MAX row: two number inputs on one row (stored under the descriptor's
16876
- * `minKey`/`maxKey`). With a `placeholder`, an input at the DEFAULT value renders
16877
- * empty showing it, and clearing an input stores the default back — the
16878
- * placeholder names the unset state ('Off' for 0-disables bounds).
17530
+ * Build ONE inline control from its descriptor the factory behind the composite
17531
+ * row path. `compact` narrows number inputs on toggle rows (the historical inline
17532
+ * width) while standalone rows keep the full-width input.
16879
17533
  */
16880
- rangeRow(r, bag, put) {
16881
- const { wrap } = this.row(r.label);
16882
- const input = (key, title) => {
16883
- const ni = document.createElement("input");
16884
- ni.type = "number";
16885
- ni.className = "vela-sd-number";
16886
- ni.min = String(r.min ?? 0);
16887
- ni.max = String(r.max ?? 1e6);
16888
- ni.step = String(r.step ?? 1);
16889
- ni.title = title;
16890
- const current = bag[key];
16891
- if (r.placeholder !== void 0) {
16892
- ni.placeholder = r.placeholder;
16893
- if (current !== r.defval) ni.value = String(current);
16894
- } else {
16895
- ni.value = String(current);
17534
+ inlineControl(c, bag, put, compact) {
17535
+ if (c.kind === "hint") {
17536
+ const s = document.createElement("span");
17537
+ s.textContent = c.text;
17538
+ s.style.cssText = "color:var(--vela-fg-muted);";
17539
+ return s;
17540
+ }
17541
+ if (c.kind === "color") {
17542
+ const sw = this.swatch(bag[c.key], (v) => put(c.key, v), () => bag[c.key]);
17543
+ sw.title = c.label;
17544
+ return sw;
17545
+ }
17546
+ if (c.kind === "width") {
17547
+ let cur = typeof bag[c.key] === "number" ? bag[c.key] : c.defval;
17548
+ const wf = widthField(this.theme, () => cur, (v) => {
17549
+ cur = v;
17550
+ put(c.key, v);
17551
+ });
17552
+ wf.title = c.label;
17553
+ return wf;
17554
+ }
17555
+ if (c.kind === "select") {
17556
+ const sel = document.createElement("select");
17557
+ sel.className = "vela-sd-select";
17558
+ sel.style.cssText = "max-width:200px;flex:0 0 auto;";
17559
+ sel.title = c.label;
17560
+ const current2 = typeof bag[c.key] === "string" ? bag[c.key] : c.defval;
17561
+ for (const [val, lbl] of normalizeSelectOptions(c.options)) {
17562
+ const o = document.createElement("option");
17563
+ o.value = val;
17564
+ o.textContent = lbl;
17565
+ if (val === current2) o.selected = true;
17566
+ sel.appendChild(o);
16896
17567
  }
17568
+ sel.addEventListener("change", () => put(c.key, sel.value));
17569
+ sel.addEventListener("vela-sync", () => {
17570
+ sel.value = typeof bag[c.key] === "string" ? bag[c.key] : c.defval;
17571
+ });
17572
+ return sel;
17573
+ }
17574
+ const ni = document.createElement("input");
17575
+ ni.type = "number";
17576
+ ni.className = "vela-sd-number";
17577
+ if (compact) ni.style.width = "56px";
17578
+ if (c.min !== void 0) ni.min = String(c.min);
17579
+ if (c.max !== void 0) ni.max = String(c.max);
17580
+ ni.step = String(c.step ?? 1);
17581
+ ni.title = c.label;
17582
+ const current = typeof bag[c.key] === "number" ? bag[c.key] : c.defval;
17583
+ if (c.placeholder !== void 0) {
17584
+ ni.placeholder = c.placeholder;
17585
+ if (current !== c.defval) ni.value = String(current);
16897
17586
  ni.addEventListener("change", () => {
16898
- const raw = ni.value.trim() === "" ? r.defval : Number(ni.value);
16899
- const v = Number.isFinite(raw) ? Math.min(r.max ?? Infinity, Math.max(r.min ?? -Infinity, raw)) : r.defval;
16900
- ni.value = r.placeholder !== void 0 && v === r.defval ? "" : String(v);
16901
- put(key, v);
17587
+ const raw = ni.value.trim() === "" ? c.defval : Number(ni.value);
17588
+ const v = Number.isFinite(raw) ? Math.min(c.max ?? Infinity, Math.max(c.min ?? -Infinity, raw)) : c.defval;
17589
+ ni.value = v === c.defval ? "" : String(v);
17590
+ put(c.key, v);
16902
17591
  });
16903
- return ni;
16904
- };
16905
- const box = document.createElement("div");
16906
- box.style.cssText = "display:flex;align-items:center;gap:6px;flex:0 0 auto;";
16907
- const dash = document.createElement("span");
16908
- dash.textContent = "\u2013";
16909
- dash.style.cssText = "color:var(--vela-fg-muted);";
16910
- box.append(input(r.minKey, `${r.label} \u2014 min`), dash, input(r.maxKey, `${r.label} \u2014 max`));
16911
- wrap.appendChild(box);
16912
- return wrap;
17592
+ } else {
17593
+ ni.value = String(current);
17594
+ ni.addEventListener("input", () => {
17595
+ const v = Number(ni.value);
17596
+ if (Number.isFinite(v)) put(c.key, v);
17597
+ });
17598
+ }
17599
+ return ni;
16913
17600
  }
16914
17601
  /**
16915
17602
  * The INSTANCE STRIP block: a tab per present instance (label, `×` on the active
@@ -16922,7 +17609,7 @@ void main() {
16922
17609
  const wrap = document.createElement("div");
16923
17610
  const strip = document.createElement("div");
16924
17611
  strip.className = "vela-sd-itabs";
16925
- wrap.append(strip);
17612
+ if (instances.length > 1 || instances[0]?.enableKey !== void 0) wrap.append(strip);
16926
17613
  const contents = instances.map((inst, i) => {
16927
17614
  const content = this.groupedRows(`${typeId}/#${i}`, inst.rows, bag, put, refreshers);
16928
17615
  wrap.append(content);
@@ -17017,8 +17704,8 @@ void main() {
17017
17704
  rowsHost.append(entries[entries.length - 1].el);
17018
17705
  continue;
17019
17706
  }
17020
- const el = this.typeRow(r, bag, put);
17021
- const key = r.kind === "range" ? void 0 : r.key;
17707
+ const el = this.typeRow(r, bag, put, refreshers);
17708
+ const key = r.kind === "row" ? r.toggle?.key : r.kind === "range" ? void 0 : r.key;
17022
17709
  entries.push({ el, when: r.when, group: g, key });
17023
17710
  rowsHost.append(el);
17024
17711
  }
@@ -17084,6 +17771,14 @@ void main() {
17084
17771
  */
17085
17772
  layoutSettingsGrids(pane, measureHost) {
17086
17773
  if (pane.childElementCount === 0) return;
17774
+ if (this.mobileLayout) {
17775
+ const grid2 = document.createElement("div");
17776
+ grid2.style.cssText = "display:grid;grid-template-columns:minmax(0,1fr) max-content;align-items:center;column-gap:12px;row-gap:16px;";
17777
+ while (pane.firstChild) grid2.appendChild(pane.firstChild);
17778
+ pane.appendChild(grid2);
17779
+ this.prepareGridItems(grid2);
17780
+ return;
17781
+ }
17087
17782
  const rows = [...pane.querySelectorAll(".vela-sd-row")];
17088
17783
  const probe2 = document.createElement("div");
17089
17784
  probe2.style.cssText = "position:absolute;left:-9999px;top:0;visibility:hidden;display:flex;flex-direction:column;font:13px var(--vela-font);pointer-events:none;";
@@ -17120,9 +17815,11 @@ void main() {
17120
17815
  }
17121
17816
  }
17122
17817
  /** A bare color swatch input (for toggle-row right groups / swatch pairs). */
17123
- swatch(value, onChange) {
17818
+ /** With `get`, the field reads its value live (and repaints on 'vela-sync')
17819
+ * duplicate-keyed rows stay honest when another row edits the shared key. */
17820
+ swatch(value, onChange, get) {
17124
17821
  let current = value;
17125
- return colorField(this.theme, () => current, (v) => {
17822
+ return colorField(this.theme, () => get ? get() : current, (v) => {
17126
17823
  current = v;
17127
17824
  onChange(v);
17128
17825
  });
@@ -17174,8 +17871,11 @@ void main() {
17174
17871
  }
17175
17872
  /** An enable row: checkbox + label in the label column, dependent controls in the
17176
17873
  * shared control column; the control group dims and ignores input while the toggle
17177
- * is off. With no controls it reads like a plain toggle row (full-width in the grid). */
17178
- toggleRow(label, value, onToggle, controls) {
17874
+ * is off. With no controls it reads like a plain toggle row (full-width in the grid).
17875
+ * With `get`, the row re-reads its state on a 'vela-sync' event — the seam that
17876
+ * keeps DUPLICATE-KEYED rows honest (several `when`-gated rows over one bag key,
17877
+ * only one visible at a time; see `typeRow`). */
17878
+ toggleRow(label, value, onToggle, controls, get) {
17179
17879
  const wrap = document.createElement("div");
17180
17880
  const cb = document.createElement("button");
17181
17881
  cb.type = "button";
@@ -17195,6 +17895,12 @@ void main() {
17195
17895
  wrap.style.cssText = "display:flex;align-items:center;gap:8px;min-height:22px;";
17196
17896
  wrap.append(cb, lbl);
17197
17897
  cb.addEventListener("click", () => onToggle(cbToggle()));
17898
+ if (get) {
17899
+ wrap.addEventListener("vela-sync", () => {
17900
+ checked = get();
17901
+ cb.classList.toggle("on", checked);
17902
+ });
17903
+ }
17198
17904
  return wrap;
17199
17905
  }
17200
17906
  wrap.className = "vela-sd-row";
@@ -17205,8 +17911,11 @@ void main() {
17205
17911
  box.style.cssText = "display:flex;align-items:center;gap:6px;";
17206
17912
  for (const c of controls) box.appendChild(c);
17207
17913
  const syncDim = (on) => {
17208
- box.style.opacity = on ? "1" : "0.4";
17209
- box.style.pointerEvents = on ? "" : "none";
17914
+ for (const c of controls) {
17915
+ if (c.dataset.sdSelfGated === "1") continue;
17916
+ c.style.opacity = on ? "1" : "0.4";
17917
+ c.style.pointerEvents = on ? "" : "none";
17918
+ }
17210
17919
  };
17211
17920
  syncDim(value);
17212
17921
  cb.addEventListener("click", () => {
@@ -17214,6 +17923,13 @@ void main() {
17214
17923
  onToggle(v);
17215
17924
  syncDim(v);
17216
17925
  });
17926
+ if (get) {
17927
+ wrap.addEventListener("vela-sync", () => {
17928
+ checked = get();
17929
+ cb.classList.toggle("on", checked);
17930
+ syncDim(checked);
17931
+ });
17932
+ }
17217
17933
  wrap.append(left, box);
17218
17934
  return wrap;
17219
17935
  }
@@ -17233,96 +17949,6 @@ void main() {
17233
17949
  wrap.appendChild(ni);
17234
17950
  return wrap;
17235
17951
  }
17236
- /** Inline Auto/Manual row (Resolution, Text size): a mode dropdown + a value input greyed out in Auto. */
17237
- autoManualRow(label, isAuto, value, min, max, unit, onMode, onValue) {
17238
- const { wrap } = this.row(label);
17239
- const box = document.createElement("div");
17240
- box.style.cssText = "display:flex;align-items:center;gap:6px;flex:0 0 auto;";
17241
- const sel = document.createElement("select");
17242
- sel.className = "vela-sd-select";
17243
- for (const [val, lbl] of AUTO_MANUAL_OPTS) {
17244
- const o = document.createElement("option");
17245
- o.value = val;
17246
- o.textContent = lbl;
17247
- if (val === "auto" === isAuto) o.selected = true;
17248
- sel.appendChild(o);
17249
- }
17250
- const ni = document.createElement("input");
17251
- ni.type = "number";
17252
- ni.min = String(min);
17253
- ni.max = String(max);
17254
- ni.step = "1";
17255
- ni.value = String(value);
17256
- ni.className = "vela-sd-number";
17257
- const unitLbl = document.createElement("span");
17258
- unitLbl.textContent = unit;
17259
- unitLbl.style.cssText = "opacity:0.6;";
17260
- const syncDisabled = (auto) => {
17261
- ni.disabled = auto;
17262
- ni.style.opacity = auto ? "0.4" : "1";
17263
- };
17264
- syncDisabled(isAuto);
17265
- sel.addEventListener("change", () => {
17266
- const auto = sel.value === "auto";
17267
- onMode(auto);
17268
- syncDisabled(auto);
17269
- });
17270
- ni.addEventListener("input", () => {
17271
- const n = Number(ni.value);
17272
- if (Number.isFinite(n)) onValue(n);
17273
- });
17274
- box.append(sel, ni, unitLbl);
17275
- wrap.appendChild(box);
17276
- return wrap;
17277
- }
17278
- /** A row whose control area holds several inline controls (e.g. show + color + width). */
17279
- inlineRow(label, controls) {
17280
- const { wrap } = this.row(label);
17281
- const box = document.createElement("div");
17282
- box.style.cssText = "display:flex;align-items:center;gap:6px;flex:0 0 auto;";
17283
- for (const c of controls) box.appendChild(c);
17284
- wrap.appendChild(box);
17285
- return wrap;
17286
- }
17287
- /** A small dimmed hint span (e.g. the ≥ / ≤ between filter inputs). */
17288
- hint(text) {
17289
- const s = document.createElement("span");
17290
- s.textContent = text;
17291
- s.style.cssText = "opacity:0.5;font-size:12px;";
17292
- return s;
17293
- }
17294
- /** A bare color input (for inline groups). */
17295
- colorInput(value, onChange) {
17296
- const ci = document.createElement("input");
17297
- ci.type = "color";
17298
- ci.value = toHex6(value);
17299
- ci.style.cssText = "cursor:pointer;width:34px;height:22px;border:none;background:transparent;padding:0;flex:0 0 auto;";
17300
- ci.addEventListener("input", () => onChange(ci.value));
17301
- return ci;
17302
- }
17303
- /** A bare compact number input (for inline groups). */
17304
- numberInput(value, min, max, step, onChange) {
17305
- const ni = document.createElement("input");
17306
- ni.type = "number";
17307
- ni.value = String(value);
17308
- ni.min = String(min);
17309
- ni.max = String(max);
17310
- ni.step = String(step);
17311
- ni.className = "vela-sd-number";
17312
- ni.style.flex = "0 0 auto";
17313
- ni.addEventListener("input", () => {
17314
- const n = Number(ni.value);
17315
- if (Number.isFinite(n)) onChange(n);
17316
- });
17317
- return ni;
17318
- }
17319
- /** A small in-group heading (lighter than a top-level section divider). */
17320
- subheading(text) {
17321
- const el = document.createElement("div");
17322
- el.textContent = text;
17323
- el.style.cssText = "margin-top:4px;font-size:10.5px;font-weight:700;letter-spacing:0.03em;text-transform:uppercase;opacity:0.45;";
17324
- return el;
17325
- }
17326
17952
  /** A dropdown whose option values differ from their display labels. */
17327
17953
  selectRowLabeled(label, value, options, onChange) {
17328
17954
  const { wrap } = this.row(label);
@@ -17368,19 +17994,7 @@ void main() {
17368
17994
  foot.appendChild(resetBtn);
17369
17995
  return foot;
17370
17996
  }
17371
- button(label, onClick) {
17372
- const b = document.createElement("button");
17373
- b.type = "button";
17374
- b.textContent = label;
17375
- b.style.cssText = `cursor:pointer;flex:1 1 auto;${this.ctrlStyle()}padding:5px 8px;font-weight:600;`;
17376
- b.addEventListener("click", onClick);
17377
- return b;
17378
- }
17379
- ctrlStyle() {
17380
- return `background:var(--vela-surface-sunken);border:1px solid ${SETTINGS_BORDER};color:${SETTINGS_TEXT};border-radius:var(--vela-radius-sm);padding:3px 6px;font-size:var(--vela-font-size-md);font-family:inherit;outline:none;`;
17381
- }
17382
17997
  };
17383
- var AUTO_MANUAL_OPTS = [["auto", "Auto"], ["manual", "Manual"]];
17384
17998
  function normalizeSelectOptions(options) {
17385
17999
  return options.map((o) => typeof o === "string" ? [o, o] : o);
17386
18000
  }
@@ -17583,7 +18197,7 @@ void main() {
17583
18197
  return;
17584
18198
  }
17585
18199
  if (d instanceof FixedRangeVolumeProfile) {
17586
- this.paintFixedRangeVp(ctx, d, proj);
18200
+ this.paintFixedRangeVp(ctx, d, proj, theme);
17587
18201
  this.paintLabel(ctx, d, proj, theme);
17588
18202
  return;
17589
18203
  }
@@ -18076,7 +18690,7 @@ void main() {
18076
18690
  /** Paint a fixed-range volume profile: horizontal histogram rows (up/down split) anchored to
18077
18691
  * the left or right of the time span, optional VAH / VAL / POC levels across the range, and
18078
18692
  * optional developing POC / VA polylines. Recomputes from the two anchors on every paint. */
18079
- paintFixedRangeVp(ctx, d, proj) {
18693
+ paintFixedRangeVp(ctx, d, proj, theme) {
18080
18694
  const L = d.layout(proj);
18081
18695
  if (!L) return;
18082
18696
  const s = d.frvp;
@@ -18115,7 +18729,7 @@ void main() {
18115
18729
  };
18116
18730
  hLine(s.showVah, s.vahColor, s.vahStyle, L.vahY);
18117
18731
  hLine(s.showVal, s.valColor, s.valStyle, L.valY);
18118
- hLine(s.showPoc, s.pocColor, s.pocStyle, L.pocY);
18732
+ hLine(s.showPoc, s.pocColor ?? contrastColor(theme.background), s.pocStyle, L.pocY);
18119
18733
  const devW = Math.max(1, w);
18120
18734
  if (s.showDevelopingPoc) {
18121
18735
  this.strokePolyline(ctx, L.developingPoc, {
@@ -18987,7 +19601,11 @@ void main() {
18987
19601
  const last = draft.anchors[draft.anchors.length - 1];
18988
19602
  const lx = last ? proj.xOf(last.time) : NaN;
18989
19603
  const ly = last ? proj.yOf(last.price, draft.paneId) ?? NaN : NaN;
18990
- if (draft.anchors.length < this.state.need && Math.hypot(x - lx, y - ly) > FREEHAND_SAMPLE_PX) {
19604
+ if (Math.hypot(x - lx, y - ly) > FREEHAND_SAMPLE_PX) {
19605
+ if (draft.anchors.length >= this.state.need) {
19606
+ const lastIdx = draft.anchors.length - 1;
19607
+ draft.anchors = draft.anchors.filter((_, i) => i % 2 === 0 || i === lastIdx);
19608
+ }
18991
19609
  draft.anchors.push(proj.pxToPoint(x, y, draft.paneId));
18992
19610
  }
18993
19611
  this.state.cursor = proj.pxToPoint(x, y, draft.paneId);
@@ -19060,11 +19678,11 @@ void main() {
19060
19678
  // src/renderers/native/drawings/DrawingSettingsPopup.ts
19061
19679
  var BTN = 30;
19062
19680
  var ICON = 21;
19063
- var STYLE_ID3 = "vela-drawing-popup-styles";
19064
- function ensureStyles3() {
19065
- if (typeof document === "undefined" || document.getElementById(STYLE_ID3)) return;
19681
+ var STYLE_ID4 = "vela-drawing-popup-styles";
19682
+ function ensureStyles4() {
19683
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID4)) return;
19066
19684
  const s = document.createElement("style");
19067
- s.id = STYLE_ID3;
19685
+ s.id = STYLE_ID4;
19068
19686
  s.textContent = `
19069
19687
  .vela-dpop input[type=color]{-webkit-appearance:none;appearance:none;border:none;padding:0;background:none;cursor:pointer;border-radius:0;}
19070
19688
  .vela-dpop input[type=color]::-webkit-color-swatch-wrapper{padding:0;}
@@ -19083,7 +19701,10 @@ void main() {
19083
19701
  .vela-dpop-btn[data-active='1']{background:var(--vela-active);color:var(--vela-fg-bright);}
19084
19702
  .vela-dpop-item{background:transparent;transition:background var(--vela-dur-fast) ease;}
19085
19703
  .vela-dpop-item:hover{background:var(--vela-hover-strong);}
19086
- .vela-dpop-item[data-active='1']{background:var(--vela-active);}`;
19704
+ .vela-dpop-item[data-active='1']{background:var(--vela-active);}
19705
+ /* A finger needs a wider grab zone than a cursor \u2014 grow the move handle on touch-first
19706
+ devices (the glyph stays centered; only the hit target widens). */
19707
+ @media (pointer: coarse){.vela-dpop-grip{width:${BTN + 14}px !important;}}`;
19087
19708
  document.head.appendChild(s);
19088
19709
  }
19089
19710
  var DrawingSettingsPopup = class {
@@ -19130,7 +19751,7 @@ void main() {
19130
19751
  * `onClose` fires on an outside-click dismissal (not a programmatic close). */
19131
19752
  open(drawing, anchor, actions, onClose) {
19132
19753
  this.close();
19133
- ensureStyles3();
19754
+ ensureStyles4();
19134
19755
  this.onClose = onClose ?? null;
19135
19756
  const t = this.theme;
19136
19757
  const schema = drawing.schema();
@@ -19156,7 +19777,14 @@ void main() {
19156
19777
  bar.appendChild(this.dropdown("Icon size", STAMP_SIZE_OPTIONS, sz, (s) => stampSizeIcon(s), (v) => actions.patch({ size: v }), { label: sizeLabel }));
19157
19778
  }
19158
19779
  if (paths.has("style.lineColor")) bar.appendChild(this.colorButton("Line color", BRUSH_ICON, drawing.style.lineColor || DEFAULT_DRAWING_COLOR, (v) => actions.patch({ "style.lineColor": v })));
19159
- if (paths.has("style.lineWidth")) bar.appendChild(this.dropdown("Line width", [1, 2, 3, 4], drawing.style.lineWidth, (w) => lineIcon(w, "solid"), (v) => actions.patch({ "style.lineWidth": v }), { label: (v) => `${v}px`, labelInTrigger: true }));
19780
+ if (paths.has("style.lineWidth")) {
19781
+ const wf = schema.fields.find((f) => f.path === "style.lineWidth");
19782
+ if (wf?.kind === "number" && (wf.min ?? 1) > 1) {
19783
+ bar.appendChild(this.widthInput("Line width", drawing.style.lineWidth, wf.min ?? 1, wf.max ?? 60, wf.step ?? 1, (v) => actions.patch({ "style.lineWidth": v })));
19784
+ } else {
19785
+ bar.appendChild(this.dropdown("Line width", [1, 2, 3, 4], drawing.style.lineWidth, (w) => lineIcon(w, "solid"), (v) => actions.patch({ "style.lineWidth": v }), { label: (v) => `${v}px`, labelInTrigger: true }));
19786
+ }
19787
+ }
19160
19788
  if (paths.has("style.lineStyle")) bar.appendChild(this.dropdown("Line style", LINE_STYLE_OPTIONS.map((o) => o.value), drawing.style.lineStyle, (s) => lineIcon(2, s), (v) => actions.patch({ "style.lineStyle": v }), { label: styleLabel2 }));
19161
19789
  if (paths.has("style.fillColor")) bar.appendChild(this.colorButton("Fill", BUCKET_ICON, effectiveFillColor(drawing, this.theme) ?? drawing.style.fillColor ?? DEFAULT_DRAWING_COLOR, (v) => actions.patch({ "style.fillColor": v })));
19162
19790
  const isFrvp = paths.has("frvp.rows") && drawing instanceof FixedRangeVolumeProfile;
@@ -19624,14 +20252,15 @@ void main() {
19624
20252
  const chk = document.createElement("input");
19625
20253
  chk.type = "checkbox";
19626
20254
  chk.checked = Boolean(s[showPath]);
19627
- chk.style.cssText = `accent-color:${s[colorPath]};width:15px;height:15px;flex:none;cursor:pointer;`;
20255
+ const current = s[colorPath] ?? contrastColor(t.background);
20256
+ chk.style.cssText = `accent-color:${current};width:15px;height:15px;flex:none;cursor:pointer;`;
19628
20257
  chk.addEventListener("change", () => actions.patch({ [`frvp.${showPath}`]: chk.checked }));
19629
20258
  const lbl = document.createElement("span");
19630
20259
  lbl.textContent = label;
19631
20260
  lbl.style.cssText = "flex:1;min-width:0;opacity:0.9;";
19632
20261
  const col = document.createElement("button");
19633
20262
  col.type = "button";
19634
- let cur = s[colorPath];
20263
+ let cur = current;
19635
20264
  col.style.cssText = `width:18px;height:18px;flex:none;border:1px solid var(--vela-border);border-radius:0;cursor:pointer;background:${cur};padding:0;`;
19636
20265
  col.addEventListener("pointerdown", (e) => e.stopPropagation());
19637
20266
  col.addEventListener("click", (e) => {
@@ -19811,7 +20440,8 @@ void main() {
19811
20440
  dragHandle() {
19812
20441
  const b = document.createElement("button");
19813
20442
  b.type = "button";
19814
- b.style.cssText = `width:${BTN}px;height:${BTN}px;display:flex;align-items:center;justify-content:center;background:transparent;border:none;padding:0;cursor:grab;color:var(--vela-fg-faint);`;
20443
+ b.className = "vela-dpop-grip";
20444
+ b.style.cssText = `width:${BTN}px;height:${BTN}px;display:flex;align-items:center;justify-content:center;background:transparent;border:none;padding:0;cursor:grab;touch-action:none;color:var(--vela-fg-faint);`;
19815
20445
  b.innerHTML = sized(GRIP_ICON);
19816
20446
  b.addEventListener("pointerdown", (e) => {
19817
20447
  const el = this.el;
@@ -19827,6 +20457,10 @@ void main() {
19827
20457
  const origLeft = parseFloat(el.style.left) || 0;
19828
20458
  const origTop = parseFloat(el.style.top) || 0;
19829
20459
  b.style.cursor = "grabbing";
20460
+ try {
20461
+ b.setPointerCapture(e.pointerId);
20462
+ } catch {
20463
+ }
19830
20464
  const move = (ev) => {
19831
20465
  const w = el.offsetWidth;
19832
20466
  const h = el.offsetHeight;
@@ -19839,9 +20473,11 @@ void main() {
19839
20473
  b.style.cursor = "grab";
19840
20474
  window.removeEventListener("pointermove", move);
19841
20475
  window.removeEventListener("pointerup", up);
20476
+ window.removeEventListener("pointercancel", up);
19842
20477
  };
19843
20478
  window.addEventListener("pointermove", move);
19844
20479
  window.addEventListener("pointerup", up);
20480
+ window.addEventListener("pointercancel", up);
19845
20481
  });
19846
20482
  return b;
19847
20483
  }
@@ -19957,6 +20593,39 @@ void main() {
19957
20593
  });
19958
20594
  return b;
19959
20595
  }
20596
+ /** An inline numeric width field for tools whose stroke range outgrows the 1–4px
20597
+ * ladder — the value is clamped to the schema's declared min/max on commit. */
20598
+ widthInput(tip, value, min, max, step, onChange) {
20599
+ const input = document.createElement("input");
20600
+ input.type = "number";
20601
+ input.dataset.tip = tip;
20602
+ input.min = String(min);
20603
+ input.max = String(max);
20604
+ input.step = String(step);
20605
+ input.value = String(value);
20606
+ input.style.cssText = `width:52px;height:${BTN}px;box-sizing:border-box;flex:none;background:transparent;color:inherit;border:1px solid var(--vela-border);border-radius:5px;padding:0 4px;font:12px ${this.theme.fontFamily};font-variant-numeric:tabular-nums;outline:none;`;
20607
+ const commit = () => {
20608
+ const n = parseFloat(input.value);
20609
+ if (!Number.isFinite(n)) {
20610
+ input.value = String(value);
20611
+ return;
20612
+ }
20613
+ const v = Math.min(max, Math.max(min, n));
20614
+ input.value = String(v);
20615
+ value = v;
20616
+ onChange(v);
20617
+ };
20618
+ input.addEventListener("change", commit);
20619
+ input.addEventListener("keydown", (e) => {
20620
+ e.stopPropagation();
20621
+ if (e.key === "Enter") {
20622
+ e.preventDefault();
20623
+ commit();
20624
+ input.blur();
20625
+ }
20626
+ });
20627
+ return input;
20628
+ }
19960
20629
  /** A pick-one dropdown: the trigger shows the current value's glyph (plus an optional inline
19961
20630
  * text label — e.g. `2px` — for controls that would otherwise look alike), and clicking it
19962
20631
  * opens a floating list of every option so a value is one click away (no cycling through). */
@@ -20263,7 +20932,7 @@ void main() {
20263
20932
  this.onCollapse = options.onCollapse ?? (() => {
20264
20933
  });
20265
20934
  this.onDrawingsSync = options.onDrawingsSync ?? null;
20266
- ensureStyles4();
20935
+ ensureStyles5();
20267
20936
  this.root = document.createElement("div");
20268
20937
  this.root.className = "vela-dtb";
20269
20938
  this.styleRoot();
@@ -20746,13 +21415,13 @@ void main() {
20746
21415
  }
20747
21416
  };
20748
21417
  var MAGNET_ID = "__magnet__";
20749
- var STYLE_ID4 = "vela-drawing-toolbar-styles";
20750
- function ensureStyles4() {
21418
+ var STYLE_ID5 = "vela-drawing-toolbar-styles";
21419
+ function ensureStyles5() {
20751
21420
  if (typeof document === "undefined") return;
20752
- let s = document.getElementById(STYLE_ID4);
21421
+ let s = document.getElementById(STYLE_ID5);
20753
21422
  if (!s) {
20754
21423
  s = document.createElement("style");
20755
- s.id = STYLE_ID4;
21424
+ s.id = STYLE_ID5;
20756
21425
  document.head.appendChild(s);
20757
21426
  }
20758
21427
  s.textContent = `
@@ -21034,6 +21703,9 @@ void main() {
21034
21703
  // mirrors showToolbar (drives the gutter reservation)
21035
21704
  this.toolbarCollapsed = false;
21036
21705
  // the bar is a slim expand-strip (narrower gutter)
21706
+ /** Mobile chrome: the docked bar is suppressed (the shell provides its own tool
21707
+ * picker) while `toolbarVisible` keeps the host's INTENT for a later desktop flip. */
21708
+ this.mobileLayout = false;
21037
21709
  /** Self-serve Ctrl+Z / Ctrl+Y as drawing undo/redo. A host that owns a UNIFIED
21038
21710
  * history (drawings + app ops in one timeline) turns this off so the chords
21039
21711
  * bubble to its keymap instead — see the renderer's `historyChords` feature. */
@@ -21092,12 +21764,21 @@ void main() {
21092
21764
  }
21093
21765
  showToolbar(visible) {
21094
21766
  this.toolbarVisible = visible;
21095
- this.toolbar.setVisible(visible);
21767
+ this.toolbar.setVisible(visible && !this.mobileLayout);
21768
+ this.syncToolbarGutter();
21769
+ }
21770
+ /** Mobile suppresses the docked toolbar (hover flyouts don't work with touch; the
21771
+ * shell's own drawer picks tools instead) and releases its gutter; flipping back
21772
+ * to desktop restores whatever `showToolbar` last asked for. */
21773
+ setLayoutMode(mode) {
21774
+ this.mobileLayout = mode === "mobile";
21775
+ this.toolbar.setVisible(this.toolbarVisible && !this.mobileLayout);
21096
21776
  this.syncToolbarGutter();
21097
21777
  }
21098
21778
  /** The gutter follows the bar's current footprint: hidden 0, collapsed a slim strip, else full width. */
21099
21779
  syncToolbarGutter() {
21100
- this.deps.setToolbarGutter(this.toolbarVisible ? this.toolbarCollapsed ? TOOLBAR_COLLAPSED_WIDTH : TOOLBAR_WIDTH : 0);
21780
+ const shown = this.toolbarVisible && !this.mobileLayout;
21781
+ this.deps.setToolbarGutter(shown ? this.toolbarCollapsed ? TOOLBAR_COLLAPSED_WIDTH : TOOLBAR_WIDTH : 0);
21101
21782
  }
21102
21783
  /** Core push: mirror (or clear) another chart's in-progress placement as a ghost. */
21103
21784
  setExternalGhost(doc) {
@@ -21978,7 +22659,7 @@ void main() {
21978
22659
 
21979
22660
  // src/renderers/native/chrome/AttributionMark.ts
21980
22661
  var ATTRIBUTION_URL = "https://luxalgo.com/vela";
21981
- var STYLE_ID5 = "vela-attribution-styles";
22662
+ var STYLE_ID6 = "vela-attribution-styles";
21982
22663
  var CSS = `
21983
22664
  .vela-attribution {
21984
22665
  text-decoration: none;
@@ -22024,12 +22705,28 @@ void main() {
22024
22705
  max-width: 240px;
22025
22706
  opacity: 1;
22026
22707
  transform: translateX(0);
22027
- }`;
22028
- function ensureStyles5(doc) {
22029
- let s = doc.getElementById(STYLE_ID5);
22708
+ }
22709
+ /* Mobile: a hair smaller so the mark doesn't dominate a phone-width plot. Keyed on the
22710
+ renderer's own container attribute (data-vela-layout) AND the shell root's
22711
+ (data-layout): the workspace's single grid-wide mark lives OUTSIDE any renderer
22712
+ container, so only the shell attribute reaches it. */
22713
+ [data-vela-layout='mobile'] .vela-attribution .vela-attr-symbol svg,
22714
+ [data-layout='mobile'] .vela-attribution .vela-attr-symbol svg { height: 22px; }
22715
+ [data-vela-layout='mobile'] .vela-attribution .vela-attr-wordmark,
22716
+ [data-layout='mobile'] .vela-attribution .vela-attr-wordmark {
22717
+ top: 2px;
22718
+ transform: translateX(-6px);
22719
+ }
22720
+ [data-vela-layout='mobile'] .vela-attribution .vela-attr-wordmark svg,
22721
+ [data-layout='mobile'] .vela-attribution .vela-attr-wordmark svg { height: 21px; }
22722
+ [data-vela-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark,
22723
+ [data-layout='mobile'] .vela-attribution:hover .vela-attr-wordmark { transform: translateX(0); }
22724
+ `;
22725
+ function ensureStyles6(doc) {
22726
+ let s = doc.getElementById(STYLE_ID6);
22030
22727
  if (!s) {
22031
22728
  s = doc.createElement("style");
22032
- s.id = STYLE_ID5;
22729
+ s.id = STYLE_ID6;
22033
22730
  doc.head.appendChild(s);
22034
22731
  }
22035
22732
  s.textContent = CSS;
@@ -22058,7 +22755,7 @@ void main() {
22058
22755
  return el;
22059
22756
  }
22060
22757
  function createAttributionMark(doc, background) {
22061
- ensureStyles5(doc);
22758
+ ensureStyles6(doc);
22062
22759
  const a = doc.createElement("a");
22063
22760
  a.className = "vela-attribution";
22064
22761
  a.href = ATTRIBUTION_URL;
@@ -22084,6 +22781,174 @@ void main() {
22084
22781
  return a;
22085
22782
  }
22086
22783
 
22784
+ // src/renderers/shared/dom-raster.ts
22785
+ function hasInk(color) {
22786
+ if (!color || color === "transparent") return false;
22787
+ const m = /rgba?\(\s*[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+\s*,\s*([\d.]+)\s*\)/.exec(color);
22788
+ return m ? parseFloat(m[1]) > 1e-3 : true;
22789
+ }
22790
+ function cornerRadius(cs, w, h) {
22791
+ const raw = cs.borderTopLeftRadius;
22792
+ const v = parseFloat(raw) || 0;
22793
+ const px = raw.endsWith("%") ? v / 100 * Math.min(w, h) : v;
22794
+ return Math.max(0, Math.min(px, Math.min(w, h) / 2));
22795
+ }
22796
+ function tracePath(ctx, x, y, w, h, r) {
22797
+ ctx.beginPath();
22798
+ if (r > 0 && typeof ctx.roundRect === "function") ctx.roundRect(x, y, w, h, r);
22799
+ else ctx.rect(x, y, w, h);
22800
+ }
22801
+ function canDrawUntainted(img) {
22802
+ try {
22803
+ const probe2 = img.ownerDocument.createElement("canvas");
22804
+ probe2.width = 1;
22805
+ probe2.height = 1;
22806
+ const ctx = probe2.getContext("2d");
22807
+ if (!ctx) return false;
22808
+ ctx.drawImage(img, 0, 0, 1, 1);
22809
+ probe2.toDataURL();
22810
+ return true;
22811
+ } catch {
22812
+ return false;
22813
+ }
22814
+ }
22815
+ function rasterizeOverlay(ctx, root, frame) {
22816
+ const win = root.ownerDocument.defaultView;
22817
+ if (!win) return;
22818
+ ctx.save();
22819
+ ctx.scale(frame.dpr, frame.dpr);
22820
+ const drawText = (node, cs, alpha) => {
22821
+ const text = node.textContent?.replace(/\s+/g, " ").trim();
22822
+ if (!text) return;
22823
+ const range = node.ownerDocument.createRange();
22824
+ range.selectNodeContents(node);
22825
+ const r = range.getBoundingClientRect();
22826
+ if (r.width <= 0 || r.height <= 0) return;
22827
+ ctx.globalAlpha = alpha;
22828
+ ctx.fillStyle = cs.color;
22829
+ ctx.font = `${cs.fontStyle} ${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`;
22830
+ ctx.textBaseline = "middle";
22831
+ ctx.textAlign = "left";
22832
+ ctx.fillText(text, r.left - frame.left, r.top - frame.top + r.height / 2);
22833
+ };
22834
+ const drawImg = (img, cs, alpha) => {
22835
+ if (!img.complete || img.naturalWidth <= 0 || !canDrawUntainted(img)) return;
22836
+ const r = img.getBoundingClientRect();
22837
+ if (r.width <= 0 || r.height <= 0) return;
22838
+ const x = r.left - frame.left;
22839
+ const y = r.top - frame.top;
22840
+ ctx.save();
22841
+ ctx.globalAlpha = alpha;
22842
+ tracePath(ctx, x, y, r.width, r.height, cornerRadius(cs, r.width, r.height));
22843
+ ctx.clip();
22844
+ ctx.drawImage(img, x, y, r.width, r.height);
22845
+ ctx.restore();
22846
+ };
22847
+ const drawSvgShapes = (parent, alpha) => {
22848
+ for (const el of parent.children) {
22849
+ if (el.hasAttribute("transform")) continue;
22850
+ const tag = el.tagName.toLowerCase();
22851
+ if (tag === "g") {
22852
+ drawSvgShapes(el, alpha);
22853
+ continue;
22854
+ }
22855
+ const num3 = (name) => parseFloat(el.getAttribute(name) ?? "0") || 0;
22856
+ let path = null;
22857
+ if (tag === "path") {
22858
+ const d = el.getAttribute("d");
22859
+ if (d) path = new Path2D(d);
22860
+ } else if (tag === "circle") {
22861
+ path = new Path2D();
22862
+ path.arc(num3("cx"), num3("cy"), num3("r"), 0, Math.PI * 2);
22863
+ } else if (tag === "ellipse") {
22864
+ path = new Path2D();
22865
+ path.ellipse(num3("cx"), num3("cy"), num3("rx"), num3("ry"), 0, 0, Math.PI * 2);
22866
+ } else if (tag === "rect") {
22867
+ path = new Path2D();
22868
+ path.rect(num3("x"), num3("y"), num3("width"), num3("height"));
22869
+ } else if (tag === "line") {
22870
+ path = new Path2D();
22871
+ path.moveTo(num3("x1"), num3("y1"));
22872
+ path.lineTo(num3("x2"), num3("y2"));
22873
+ } else if (tag === "polyline" || tag === "polygon") {
22874
+ const pts = (el.getAttribute("points") ?? "").trim().split(/[\s,]+/).map(Number);
22875
+ if (pts.length < 4 || pts.some(Number.isNaN)) continue;
22876
+ path = new Path2D();
22877
+ path.moveTo(pts[0], pts[1]);
22878
+ for (let i = 2; i + 1 < pts.length; i += 2) path.lineTo(pts[i], pts[i + 1]);
22879
+ if (tag === "polygon") path.closePath();
22880
+ }
22881
+ if (!path) continue;
22882
+ const cs = win.getComputedStyle(el);
22883
+ if (cs.fill && cs.fill !== "none" && hasInk(cs.fill)) {
22884
+ ctx.globalAlpha = alpha * (parseFloat(cs.fillOpacity) || 1);
22885
+ ctx.fillStyle = cs.fill;
22886
+ ctx.fill(path);
22887
+ }
22888
+ const sw = parseFloat(cs.strokeWidth) || 0;
22889
+ if (cs.stroke && cs.stroke !== "none" && hasInk(cs.stroke) && sw > 0) {
22890
+ ctx.globalAlpha = alpha * (parseFloat(cs.strokeOpacity) || 1);
22891
+ ctx.strokeStyle = cs.stroke;
22892
+ ctx.lineWidth = sw;
22893
+ if (cs.strokeLinecap === "round" || cs.strokeLinecap === "square" || cs.strokeLinecap === "butt") ctx.lineCap = cs.strokeLinecap;
22894
+ if (cs.strokeLinejoin === "round" || cs.strokeLinejoin === "bevel" || cs.strokeLinejoin === "miter") ctx.lineJoin = cs.strokeLinejoin;
22895
+ ctx.stroke(path);
22896
+ }
22897
+ }
22898
+ };
22899
+ const drawSvg = (svg, parentAlpha) => {
22900
+ const r = svg.getBoundingClientRect();
22901
+ if (r.width <= 0 || r.height <= 0) return;
22902
+ const cs = win.getComputedStyle(svg);
22903
+ if (cs.display === "none" || cs.visibility === "hidden") return;
22904
+ const alpha = parentAlpha * (parseFloat(cs.opacity) || 1);
22905
+ if (alpha <= 1e-3) return;
22906
+ const vb = svg.viewBox.baseVal;
22907
+ const vw = vb && vb.width > 0 ? vb.width : r.width;
22908
+ const vh = vb && vb.height > 0 ? vb.height : r.height;
22909
+ ctx.save();
22910
+ ctx.translate(r.left - frame.left, r.top - frame.top);
22911
+ ctx.scale(r.width / vw, r.height / vh);
22912
+ if (vb) ctx.translate(-vb.x, -vb.y);
22913
+ drawSvgShapes(svg, alpha);
22914
+ ctx.restore();
22915
+ };
22916
+ const drawElement = (el, parentAlpha) => {
22917
+ const cs = win.getComputedStyle(el);
22918
+ if (cs.display === "none" || cs.visibility === "hidden") return;
22919
+ const alpha = parentAlpha * (parseFloat(cs.opacity) || 1);
22920
+ if (alpha <= 1e-3) return;
22921
+ const r = el.getBoundingClientRect();
22922
+ if (r.width > 0 && r.height > 0) {
22923
+ const x = r.left - frame.left;
22924
+ const y = r.top - frame.top;
22925
+ const radius = cornerRadius(cs, r.width, r.height);
22926
+ if (hasInk(cs.backgroundColor)) {
22927
+ ctx.globalAlpha = alpha;
22928
+ ctx.fillStyle = cs.backgroundColor;
22929
+ tracePath(ctx, x, y, r.width, r.height, radius);
22930
+ ctx.fill();
22931
+ }
22932
+ const bw = parseFloat(cs.borderTopWidth) || 0;
22933
+ if (bw > 0 && cs.borderTopStyle !== "none" && hasInk(cs.borderTopColor)) {
22934
+ ctx.globalAlpha = alpha;
22935
+ ctx.strokeStyle = cs.borderTopColor;
22936
+ ctx.lineWidth = bw;
22937
+ tracePath(ctx, x + bw / 2, y + bw / 2, r.width - bw, r.height - bw, Math.max(0, radius - bw / 2));
22938
+ ctx.stroke();
22939
+ }
22940
+ }
22941
+ for (const child of el.childNodes) {
22942
+ if (child.nodeType === 3) drawText(child, cs, alpha);
22943
+ else if (child instanceof win.HTMLImageElement) drawImg(child, win.getComputedStyle(child), alpha);
22944
+ else if (child instanceof win.SVGSVGElement) drawSvg(child, alpha);
22945
+ else if (child instanceof win.HTMLElement) drawElement(child, alpha);
22946
+ }
22947
+ };
22948
+ if (root instanceof win.HTMLElement) drawElement(root, 1);
22949
+ ctx.restore();
22950
+ }
22951
+
22087
22952
  // src/renderers/native/vpvr/profile.ts
22088
22953
  function buildVpvrProfile(bars, i0, i1, rowCount, valueAreaFrac) {
22089
22954
  const from = Math.max(0, i0);
@@ -22252,12 +23117,13 @@ void main() {
22252
23117
  var COLLAPSED_PANE_H = 26;
22253
23118
  var TIME_AXIS_H = 22;
22254
23119
  var SCROLL_BTN_SIZE = 26;
23120
+ var SCROLL_BTN_SIZE_TOUCH = 24;
22255
23121
  var SCROLL_BTN_RADIUS = 5;
22256
23122
  var SCROLL_BTN_SHADOW = "0 2px 8px rgba(0,0,0,0.4)";
22257
23123
  var SCROLL_BTN_ICON_PX = 12;
22258
- var SCROLL_BTN_RIGHT_INSET = 25;
23124
+ var SCROLL_BTN_RIGHT_INSET = 12;
22259
23125
  var SCROLL_BTN_RIGHT = RIGHT_AXIS_W + SCROLL_BTN_RIGHT_INSET;
22260
- var SCROLL_BTN_BOTTOM = TIME_AXIS_H + 30;
23126
+ var SCROLL_BTN_BOTTOM = TIME_AXIS_H + 14;
22261
23127
  var SCROLL_BTN_PROXIMITY_PX = 120;
22262
23128
  var MIN_VISIBLE_BARS = 2;
22263
23129
  var ZOOM_OUT_MARGIN_BARS = 6;
@@ -22309,8 +23175,12 @@ void main() {
22309
23175
  this.symbolPicker = null;
22310
23176
  /** Indicator titles (the legend rows) shown — held here so a remount re-applies it. */
22311
23177
  this.indicatorTitlesOn = true;
23178
+ /** Plot values beside the legend titles shown — held here so a remount re-applies it. */
23179
+ this.indicatorValuesOn = true;
22312
23180
  /** Host-contributed legend actions — held here so a rebuild of the legend re-wires them. */
22313
23181
  this.legendActionsProvider = null;
23182
+ /** Host override of the legend's fold toggle — held here so a remount re-applies it. */
23183
+ this.legendOverviewAction = null;
22314
23184
  // ── keyboard navigation / accessibility (item 11) ──
22315
23185
  this.keyboard = null;
22316
23186
  this.keyboardEnabled = true;
@@ -22420,6 +23290,8 @@ void main() {
22420
23290
  // Distance (px) from the plot's right edge — clears the FULL scale gutter, which widens when a
22421
23291
  // pane carries merged (own-scale) columns; the constant only clears a single-column scale.
22422
23292
  this.scrollBtnRightPx = SCROLL_BTN_RIGHT;
23293
+ // ── chrome size class (pushed by the host shell; see IChartRenderer.setLayoutMode) ──
23294
+ this.layoutMode = "desktop";
22423
23295
  this.viewportCbs = /* @__PURE__ */ new Set();
22424
23296
  this.crosshairCbs = /* @__PURE__ */ new Set();
22425
23297
  this.chartTypeSettingsCbs = /* @__PURE__ */ new Set();
@@ -22430,6 +23302,7 @@ void main() {
22430
23302
  this.factoryConfig = null;
22431
23303
  this.hostSettingsSections = [];
22432
23304
  this.clickCbs = /* @__PURE__ */ new Set();
23305
+ this.axisLongPressCbs = /* @__PURE__ */ new Set();
22433
23306
  this.inputChangeCbs = /* @__PURE__ */ new Set();
22434
23307
  this.removeIndicatorCbs = /* @__PURE__ */ new Set();
22435
23308
  this.toggleVisibleCbs = /* @__PURE__ */ new Set();
@@ -22437,7 +23310,7 @@ void main() {
22437
23310
  this.priceStyleCbs = /* @__PURE__ */ new Set();
22438
23311
  this.tableOverlays = /* @__PURE__ */ new Map();
22439
23312
  this.name = "native";
22440
- this.features = ["logScale", "currentPriceLine", "priceLabel", "countdown", "upColor", "downColor", "glow", "animZoom", "animPan", "intro", "zoomAnchor", "axisDrag", "paneResize", "candleZOrder", "candleVisible", "seriesOrder", "highlights", "gridlines", "axisLabels", "scaleMode", "invertScale", "paneScales", "autoScale", "timezone", "keyboard", "historyChords", "priceStyle", "priceBaseline", "baselinePrice", "settings", "attribution", "dialogHost", "tradeMarkers", "indicatorTitles"];
23313
+ this.features = ["logScale", "currentPriceLine", "priceLabel", "countdown", "upColor", "downColor", "glow", "animZoom", "animPan", "intro", "zoomAnchor", "axisDrag", "paneResize", "candleZOrder", "candleVisible", "seriesOrder", "highlights", "gridlines", "axisLabels", "scaleMode", "invertScale", "paneScales", "autoScale", "timezone", "keyboard", "historyChords", "priceStyle", "priceBaseline", "baselinePrice", "settings", "attribution", "dialogHost", "tradeMarkers", "indicatorTitles", "indicatorValues"];
22441
23314
  /** Track cursor proximity to the scroll button on the plot (bubbles from the button too,
22442
23315
  * so moving onto the button doesn't count as leaving). */
22443
23316
  this.onScrollProximityMove = (e) => {
@@ -22610,6 +23483,11 @@ void main() {
22610
23483
  this.inputsUI?.setTitlesVisible(this.indicatorTitlesOn);
22611
23484
  return;
22612
23485
  // own DOM, no repaint needed
23486
+ case "indicatorValues":
23487
+ this.indicatorValuesOn = value !== false;
23488
+ this.inputsUI?.setValuesVisible(this.indicatorValuesOn);
23489
+ return;
23490
+ // own DOM, no repaint needed
22613
23491
  case "attribution":
22614
23492
  this.attributionHtml = typeof value === "string" && value.trim() ? value : null;
22615
23493
  this.attributionEnabled = this.attributionHtml !== null || Boolean(value);
@@ -22698,6 +23576,8 @@ void main() {
22698
23576
  return this.settingsEnabled;
22699
23577
  case "indicatorTitles":
22700
23578
  return this.indicatorTitlesOn;
23579
+ case "indicatorValues":
23580
+ return this.indicatorValuesOn;
22701
23581
  case "attribution":
22702
23582
  return this.attributionHtml ?? this.attributionEnabled;
22703
23583
  case "dialogHost":
@@ -23034,7 +23914,10 @@ void main() {
23034
23914
  /** Port surface: hosts (bottom-bar / chrome buttons) open the same dialog as the
23035
23915
  * in-chart gear — created on demand, independent of the gear feature being enabled. */
23036
23916
  openSettingsDialog(section) {
23037
- if (!this.settingsDialog && this.plot) this.settingsDialog = new SettingsDialog(this.dialogHost ?? this.plot, this.theme);
23917
+ if (!this.settingsDialog && this.plot) {
23918
+ this.settingsDialog = new SettingsDialog(this.dialogHost ?? this.plot, this.theme);
23919
+ this.settingsDialog.setLayoutMode(this.layoutMode);
23920
+ }
23038
23921
  this.toggleSettingsDialog(section);
23039
23922
  }
23040
23923
  /** (Re)aim the dialog's Canvas → Theme row: the current selection reflects the STABLE
@@ -23123,11 +24006,18 @@ void main() {
23123
24006
  this.scrollButton.style.color = this.theme.textColor;
23124
24007
  this.scrollButton.style.borderColor = this.theme.borderColor;
23125
24008
  }
23126
- /** Show the button only when the latest bar is scrolled off the right edge AND the cursor is nearby. */
24009
+ /** Show the button only when the latest bar is scrolled off the right edge. On desktop the
24010
+ * cursor must also be nearby (hover reveal); on mobile — no hovering cursor — the button
24011
+ * appears whenever the latest bars are off-screen and hides again once the view is back
24012
+ * at the right edge. */
23127
24013
  updateScrollToRealtimeButton() {
23128
24014
  const btn = this.scrollButton;
23129
24015
  if (!btn) return;
23130
24016
  const latestOffScreen = this.coords.barCount > 0 && this.coords.getViewport().rightOffset < 0;
24017
+ if (this.layoutMode === "mobile") {
24018
+ btn.style.display = latestOffScreen ? "flex" : "none";
24019
+ return;
24020
+ }
23131
24021
  btn.style.display = latestOffScreen && this.pointerNearScrollBtn ? "flex" : "none";
23132
24022
  }
23133
24023
  /** Glide the view back to the most recent bars, keeping the current zoom (barSpacing). */
@@ -23149,17 +24039,20 @@ void main() {
23149
24039
  this.animator.start();
23150
24040
  }
23151
24041
  /**
23152
- * Export the current chart as a PNG data URL by compositing the geometry (L0)
23153
- * + chrome (L1) + user-drawings (L1.5) canvases onto an offscreen canvas. The
23154
- * background is filled first (the canvas2d data layer is transparent — its bg
23155
- * lives on the wrapper), and a fresh synchronous paint runs first so the WebGL2
23156
- * backend's (non-preserved) drawing buffer is populated before it's read back
23157
- * this tick the same paint also repaints the drawings layers, so they're
23158
- * current (interleaved drawings are already inside the data composite). They're
23159
- * drawn bottom-up in DOM stacking order so the front user drawings (trend lines,
23160
- * boxes, etc.) sit above the Pine drawings on the chrome layer, matching what's
23161
- * on screen. The crosshair (L2) and DOM overlays (tables, legend) are
23162
- * intentionally excluded.
24042
+ * Export the current chart as a PNG data URL by compositing EVERY plot canvas onto
24043
+ * an offscreen canvas, in the same stacking order the DOM shows: plugin layers
24044
+ * below the data, geometry (L0), volume columns (L0.25), the visible-range volume
24045
+ * profile (L0.6), plugin layers above the data, chrome (L1), and user drawings
24046
+ * (L1.5). The background is filled first (the canvas2d data layer is transparent —
24047
+ * its bg lives on the wrapper), and a fresh synchronous paint runs first so the
24048
+ * WebGL2 backend's (non-preserved) drawing buffer is populated before it's read
24049
+ * back this tick the same paint also repaints the drawings layers, so they're
24050
+ * current. DOM chrome joins as a best-effort text/chip raster (see
24051
+ * `rasterizeOverlay`): the per-pane indicator legends, plus any host overlay that
24052
+ * opts in with a `data-vela-screenshot` attribute on the mount container's
24053
+ * subtree (the widget marks its status line, and its symbol watermark with
24054
+ * `"under"` — drawn beneath the canvases, where it sits on screen). Only the
24055
+ * crosshair (L2) is intentionally excluded.
23163
24056
  */
23164
24057
  screenshot() {
23165
24058
  if (!this.dataCanvas) return null;
@@ -23172,9 +24065,25 @@ void main() {
23172
24065
  if (!ctx) return null;
23173
24066
  ctx.fillStyle = this.theme.background;
23174
24067
  ctx.fillRect(0, 0, out.width, out.height);
23175
- ctx.drawImage(this.dataCanvas, 0, 0);
23176
- ctx.drawImage(this.chromeCanvas, 0, 0);
23177
- ctx.drawImage(this.drawingsCanvas, 0, 0);
24068
+ const plotRect = this.plot?.getBoundingClientRect();
24069
+ const frame = plotRect && plotRect.width > 0 ? { left: plotRect.left, top: plotRect.top, dpr: out.width / plotRect.width } : null;
24070
+ const hostMarked = [...this.mountContainer?.querySelectorAll("[data-vela-screenshot]") ?? []];
24071
+ if (frame) {
24072
+ for (const el of hostMarked) {
24073
+ if (el.getAttribute("data-vela-screenshot") === "under") rasterizeOverlay(ctx, el, frame);
24074
+ }
24075
+ }
24076
+ const below = this.extLayers.filter((l) => l.def.placement === "below-data").map((l) => l.canvas);
24077
+ const above = this.extLayers.filter((l) => l.def.placement !== "below-data").map((l) => l.canvas);
24078
+ for (const canvas of [...below, this.dataCanvas, this.volumeCanvas, this.vpvrCanvas, ...above, this.chromeCanvas, this.drawingsCanvas]) {
24079
+ if (canvas && canvas.width > 0 && canvas.height > 0) ctx.drawImage(canvas, 0, 0);
24080
+ }
24081
+ if (frame) {
24082
+ for (const lg of this.plot?.querySelectorAll("[data-vela-pane]") ?? []) rasterizeOverlay(ctx, lg, frame);
24083
+ for (const el of hostMarked) {
24084
+ if (el.getAttribute("data-vela-screenshot") !== "under") rasterizeOverlay(ctx, el, frame);
24085
+ }
24086
+ }
23178
24087
  return out.toDataURL("image/png");
23179
24088
  }
23180
24089
  /**
@@ -23325,6 +24234,9 @@ void main() {
23325
24234
  fling: (v) => this.fling(v),
23326
24235
  onPointerMove: (x, y) => this.handlePointerMove(x, y),
23327
24236
  onClick: (x) => this.handleClick(x),
24237
+ onAxisLongPress: (axis, x, y) => {
24238
+ for (const cb of this.axisLongPressCbs) cb({ axis, x, y });
24239
+ },
23328
24240
  beginPriceScale: (x, y) => this.beginPriceScale(x, y),
23329
24241
  priceScaleBy: (dy) => this.priceScaleBy(dy),
23330
24242
  beginPricePan: (y) => this.beginPricePan(y),
@@ -23371,6 +24283,14 @@ void main() {
23371
24283
  setToolbarGutter: (px) => this.setToolbarGutter(px)
23372
24284
  });
23373
24285
  this.userDrawings.historyChords = this.historyChordsEnabled;
24286
+ if (this.layoutMode === "mobile") {
24287
+ this.mountContainer?.setAttribute("data-vela-layout", this.layoutMode);
24288
+ this.userDrawings.setLayoutMode(this.layoutMode);
24289
+ if (this.scrollButton) {
24290
+ this.scrollButton.style.width = `${SCROLL_BTN_SIZE_TOUCH}px`;
24291
+ this.scrollButton.style.height = `${SCROLL_BTN_SIZE_TOUCH}px`;
24292
+ }
24293
+ }
23374
24294
  this.keyboard = new KeyboardController({
23375
24295
  panByBars: (bars) => this.panByBars(bars),
23376
24296
  zoomByStep: (dir) => this.zoomByStep(dir),
@@ -23383,10 +24303,13 @@ void main() {
23383
24303
  });
23384
24304
  this.setKeyboardEnabled(this.keyboardEnabled);
23385
24305
  this.inputsUI = new InputsUI(this.plot, theme, (paneId) => this.paneBoundsFor(paneId));
24306
+ this.inputsUI.setLayoutMode(this.layoutMode);
23386
24307
  this.inputsUI.setTitlesVisible(this.indicatorTitlesOn);
24308
+ this.inputsUI.setValuesVisible(this.indicatorValuesOn);
23387
24309
  this.inputsUI.setDialogHost(this.dialogHost);
23388
24310
  this.inputsUI.setSymbolPicker(this.symbolPicker);
23389
24311
  this.inputsUI.setLegendActions(this.legendActionsProvider);
24312
+ this.inputsUI.setLegendOverviewAction(this.legendOverviewAction);
23390
24313
  this.inputsUI.setOnChange((c) => {
23391
24314
  for (const cb of this.inputChangeCbs) cb({ indicatorId: c.indicatorId, key: c.key, value: c.value });
23392
24315
  });
@@ -23801,7 +24724,10 @@ void main() {
23801
24724
  this.scene.indicators.set(model.id, model);
23802
24725
  this.refreshAnchorOffset(model);
23803
24726
  this.scene.assignIndicatorZ(model.id);
23804
- this.inputsUI.upsert(model.id, model.title, model.inputs, model.inputValues, model.paneId, { native: !!model.native });
24727
+ this.inputsUI.upsert(model.id, model.shorttitle ?? model.title, model.inputs, model.inputValues, model.paneId, {
24728
+ native: !!model.native,
24729
+ ...model.shorttitle ? { settingsTitle: model.title } : {}
24730
+ });
23805
24731
  this.syncTables(model);
23806
24732
  if (model.native?.type === "volume") {
23807
24733
  this.volumeActive = true;
@@ -23862,6 +24788,13 @@ void main() {
23862
24788
  this.legendActionsProvider = provider;
23863
24789
  this.inputsUI?.setLegendActions(provider);
23864
24790
  }
24791
+ setLegendOverviewAction(action) {
24792
+ this.legendOverviewAction = action;
24793
+ this.inputsUI?.setLegendOverviewAction(action);
24794
+ }
24795
+ openIndicatorSettings(indicatorId) {
24796
+ this.inputsUI?.openSettingsFor(indicatorId);
24797
+ }
23865
24798
  /**
23866
24799
  * Hide/show a mounted indicator. Hiding drops its model from the scene (so every paint path —
23867
24800
  * series, fills, drawings, tables, glow, data window — skips it) while keeping its z key and its
@@ -23915,6 +24848,24 @@ void main() {
23915
24848
  this.removeIndicatorCbs.add(cb);
23916
24849
  return () => this.removeIndicatorCbs.delete(cb);
23917
24850
  }
24851
+ /** Port surface: the host shell's chrome size class. Mobile switches the renderer
24852
+ * chrome to its touch-first presentation — fullscreen dialogs, no docked drawing
24853
+ * toolbar (the shell provides its own picker), the scroll-to-latest button shown
24854
+ * whenever the latest bars are off-screen (touch has no cursor proximity). */
24855
+ setLayoutMode(mode) {
24856
+ if (mode === this.layoutMode) return;
24857
+ this.layoutMode = mode;
24858
+ this.mountContainer?.setAttribute("data-vela-layout", mode);
24859
+ this.userDrawings?.setLayoutMode(mode);
24860
+ this.settingsDialog?.setLayoutMode(mode);
24861
+ this.inputsUI?.setLayoutMode(mode);
24862
+ if (this.scrollButton) {
24863
+ const px = mode === "mobile" ? SCROLL_BTN_SIZE_TOUCH : SCROLL_BTN_SIZE;
24864
+ this.scrollButton.style.width = `${px}px`;
24865
+ this.scrollButton.style.height = `${px}px`;
24866
+ }
24867
+ this.updateScrollToRealtimeButton();
24868
+ }
23918
24869
  setSettingsSections(sections) {
23919
24870
  this.hostSettingsSections = sections;
23920
24871
  this.settingsDialog?.setHostSections(sections);
@@ -23939,6 +24890,10 @@ void main() {
23939
24890
  this.clickCbs.add(cb);
23940
24891
  return () => this.clickCbs.delete(cb);
23941
24892
  }
24893
+ onAxisLongPress(cb) {
24894
+ this.axisLongPressCbs.add(cb);
24895
+ return () => this.axisLongPressCbs.delete(cb);
24896
+ }
23942
24897
  onViewportChange(cb) {
23943
24898
  this.viewportCbs.add(cb);
23944
24899
  return () => this.viewportCbs.delete(cb);
@@ -24080,6 +25035,7 @@ void main() {
24080
25035
  this.skeletonClockMs += dtMs;
24081
25036
  this.paintData();
24082
25037
  this.crosshairLayer.render(this.scene, this.coords, this.theme, this.hoverSeparatorY, this.externalCrossPx());
25038
+ this.updateLegendValues();
24083
25039
  this.emitViewportChange();
24084
25040
  return active;
24085
25041
  }
@@ -24144,7 +25100,7 @@ void main() {
24144
25100
  this.lastPointer = null;
24145
25101
  this.scheduler.invalidate(1 /* Cursor */);
24146
25102
  this.hoverLogical = null;
24147
- const empty = { time: null, price: null, values: /* @__PURE__ */ new Map(), ohlc: null };
25103
+ const empty = { time: null, price: null, paneKind: null, values: /* @__PURE__ */ new Map(), ohlc: null };
24148
25104
  for (const cb of this.crosshairCbs) cb(empty);
24149
25105
  return;
24150
25106
  }
@@ -24156,7 +25112,7 @@ void main() {
24156
25112
  const logical = Math.round(this.coords.xToLogical(x));
24157
25113
  const onBar = logical >= 0 && logical < this.coords.barCount;
24158
25114
  const time = onBar ? this.coords.logicalToTime(logical) : null;
24159
- const pane = this.paneAtY(y);
25115
+ const pane = this.paneNodeAtY(y);
24160
25116
  const price = inData && pane ? this.coords.yToPrice(y, pane.scale, pane.bounds) : null;
24161
25117
  const values = /* @__PURE__ */ new Map();
24162
25118
  if (onBar) {
@@ -24173,7 +25129,7 @@ void main() {
24173
25129
  const bar = onBar ? this.bars[logical] : void 0;
24174
25130
  const ohlc = bar ? { time: bar.time, open: bar.open, high: bar.high, low: bar.low, close: bar.close, volume: bar.volume } : null;
24175
25131
  this.hoverLogical = onBar ? logical : null;
24176
- const event = { time, price, values, ohlc };
25132
+ const event = { time, price, paneKind: inData && pane ? pane.kind : null, values, ohlc };
24177
25133
  for (const cb of this.crosshairCbs) cb(event);
24178
25134
  }
24179
25135
  handleClick(x) {
@@ -24192,6 +25148,20 @@ void main() {
24192
25148
  }
24193
25149
  return null;
24194
25150
  }
25151
+ /** The pane whose bounds sit closest to `y` — the forgiving fallback for points that
25152
+ * fall BETWEEN bounds (separator gaps, the strip under the last pane). */
25153
+ nearestPaneToY(y) {
25154
+ let best = null;
25155
+ let bestDist = Infinity;
25156
+ for (const pane of this.scene.panes.values()) {
25157
+ const d = y < pane.bounds.top ? pane.bounds.top - y : y - (pane.bounds.top + pane.bounds.height);
25158
+ if (d < bestDist) {
25159
+ bestDist = d;
25160
+ best = pane;
25161
+ }
25162
+ }
25163
+ return best;
25164
+ }
24195
25165
  // ── manual vertical scaling (price-axis drag + vertical price pan) ──
24196
25166
  /** The scale window a gesture targets: a pane's master scale, or a merged indicator's
24197
25167
  * own scale column (resolved from the grabbed x). Both share the four scale fields. */
@@ -24254,7 +25224,7 @@ void main() {
24254
25224
  * still fits the view.)
24255
25225
  */
24256
25226
  dataDblClick(_x, y) {
24257
- const pane = this.paneNodeAtY(y);
25227
+ const pane = this.paneNodeAtY(y) ?? this.nearestPaneToY(y);
24258
25228
  if (!pane) return;
24259
25229
  const maximized = this.maximizedPaneId !== pane.id;
24260
25230
  this.maximizedPaneId = maximized ? pane.id : null;
@@ -24495,29 +25465,63 @@ void main() {
24495
25465
  dataWindowGroups(idx, pricePane) {
24496
25466
  const groups = [];
24497
25467
  for (const model of this.scene.indicators.values()) {
24498
- const pane = (model.paneId ? this.scene.panes.get(model.paneId) : null) ?? pricePane;
24499
- const off = this.scene.offsetOf(model.id);
24500
- const rows = [];
24501
- for (const s of model.series) {
24502
- let value;
24503
- let color;
24504
- if (s.kind === "candle" || s.kind === "bar") {
24505
- value = s.bars[idx - off]?.close;
24506
- color = s.style?.up ?? this.theme.upColor;
24507
- } else if (isLineLikeSeries(s)) {
24508
- if (s.visible === false) continue;
24509
- value = s.points[idx - off]?.value;
24510
- color = s.points[idx - off]?.color ?? s.style.color;
24511
- } else {
24512
- continue;
24513
- }
24514
- if (value == null || !Number.isFinite(value)) continue;
24515
- rows.push({ label: s.title || model.title, value: this.dataWindowFmt(value, pane), color });
24516
- }
25468
+ const rows = this.dataWindowRowsFor(model, idx, pricePane);
24517
25469
  if (rows.length) groups.push({ name: model.title, rows });
24518
25470
  }
24519
25471
  return groups;
24520
25472
  }
25473
+ /** One indicator's readout at bar `idx`: a row per drawable plot, formatted on its pane's scale. */
25474
+ dataWindowRowsFor(model, idx, pricePane) {
25475
+ if (model.native?.type === "volume") return this.volumeReadoutRows(model, idx);
25476
+ const pane = (model.paneId ? this.scene.panes.get(model.paneId) : null) ?? pricePane;
25477
+ const off = this.scene.offsetOf(model.id);
25478
+ const rows = [];
25479
+ for (const s of model.series) {
25480
+ let value;
25481
+ let color;
25482
+ if (s.kind === "candle" || s.kind === "bar") {
25483
+ value = s.bars[idx - off]?.close;
25484
+ color = s.style?.up ?? this.theme.upColor;
25485
+ } else if (isLineLikeSeries(s)) {
25486
+ if (s.visible === false) continue;
25487
+ value = s.points[idx - off]?.value;
25488
+ color = s.points[idx - off]?.color ?? s.style.color;
25489
+ } else {
25490
+ continue;
25491
+ }
25492
+ if (value == null || !Number.isFinite(value)) continue;
25493
+ rows.push({ label: s.title || model.title, value: this.dataWindowFmt(value, pane), color });
25494
+ }
25495
+ return rows;
25496
+ }
25497
+ /** The volume indicator's readout: the bar's volume, tinted with the layer's own direction
25498
+ * colors. Hiding volume keeps its model in the scene (only the layer is suppressed — see
25499
+ * `setIndicatorVisible`), so the hidden flag is checked here rather than by model absence. */
25500
+ volumeReadoutRows(model, idx) {
25501
+ if (this.volumeHidden) return [];
25502
+ const bar = this.bars[idx];
25503
+ const vol = bar?.volume;
25504
+ if (bar == null || vol == null || !Number.isFinite(vol)) return [];
25505
+ const cfg = this.scene.volumeLayer;
25506
+ const color = bar.close >= bar.open ? cfg?.upColor ?? this.theme.upColor : cfg?.downColor ?? this.theme.downColor;
25507
+ return [{ label: model.title, value: formatVolume(vol), color }];
25508
+ }
25509
+ /** Refresh the plot values beside every legend title — the same readout the data window
25510
+ * shows (crosshair bar, else the latest bar), pushed per paint. A hidden indicator has
25511
+ * no scene model, so its row is absent from the map and its readout clears. */
25512
+ updateLegendValues() {
25513
+ if (!this.inputsUI) return;
25514
+ const n = this.bars.length;
25515
+ const values = /* @__PURE__ */ new Map();
25516
+ if (n > 0) {
25517
+ const idx = this.hoverLogical != null ? this.hoverLogical : n - 1;
25518
+ const pricePane = this.dataWindowPricePane();
25519
+ for (const model of this.scene.indicators.values()) {
25520
+ values.set(model.id, this.dataWindowRowsFor(model, idx, pricePane).map((r) => ({ value: r.value, color: r.color })));
25521
+ }
25522
+ }
25523
+ this.inputsUI.setPlotValues(values);
25524
+ }
24521
25525
  renderFrame(level) {
24522
25526
  if (this.animator.active) return;
24523
25527
  if (repaintsData(level)) {
@@ -24529,6 +25533,7 @@ void main() {
24529
25533
  }
24530
25534
  this.crosshairLayer.render(this.scene, this.coords, this.theme, this.hoverSeparatorY, this.externalCrossPx());
24531
25535
  if (!repaintsData(level) && this.paintedData) this.repaintCursorLayers();
25536
+ this.updateLegendValues();
24532
25537
  }
24533
25538
  /** Repaint the SDK layers that opted into cursor tracking (their own canvas only). */
24534
25539
  repaintCursorLayers() {
@@ -24677,7 +25682,7 @@ void main() {
24677
25682
  if (!Number.isFinite(y) || y < pricePane.bounds.top || y > pricePane.bounds.top + pricePane.bounds.height) y = null;
24678
25683
  }
24679
25684
  }
24680
- return { x, y, time: this.coords.logicalToTime(logical) };
25685
+ return { x, y, time: this.coords.logicalToTime(logical), price: y != null ? ext.price : null };
24681
25686
  }
24682
25687
  /** Set the sticky magnet mode (called by the drawings toolbar's 3-state button). */
24683
25688
  setSnapMode(mode) {
@@ -25369,7 +26374,8 @@ void main() {
25369
26374
  };
25370
26375
  var vpvrDescriptor = {
25371
26376
  type: "vpvr",
25372
- title: "VPVR",
26377
+ title: "Visible Range Volume Profile",
26378
+ shortTitle: "VRVP",
25373
26379
  paneHint: "price",
25374
26380
  overlay: true,
25375
26381
  inputsSchema: () => [
@@ -27076,6 +28082,7 @@ void main() {
27076
28082
  exports.legendActions = legendActions;
27077
28083
  exports.nativeIndicatorDescriptors = nativeIndicatorDescriptors;
27078
28084
  exports.nativeIndicatorTypes = nativeIndicatorTypes;
28085
+ exports.normalizeSettingsRow = normalizeSettingsRow;
27079
28086
  exports.registerChartType = registerChartType;
27080
28087
  exports.registerDefaultEngine = registerDefaultEngine;
27081
28088
  exports.registerDrawingType = registerDrawingType;
@@ -27091,6 +28098,7 @@ void main() {
27091
28098
  exports.rendererLayers = rendererLayers;
27092
28099
  exports.resolveEngines = resolveEngines;
27093
28100
  exports.resolveTheme = resolveTheme;
28101
+ exports.settingsRowValueKeys = settingsRowValueKeys;
27094
28102
  exports.sharedBarStore = sharedBarStore;
27095
28103
  exports.sidePanels = sidePanels;
27096
28104
  exports.splitColor = splitColor;