acttrader-charts 1.1.2 → 1.2.0-beta.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.
@@ -1,3 +1,50 @@
1
+ /**
2
+ * Definition of a multi-chart layout preset (grid template).
3
+ * Used by the chart-owned LayoutPopover and emitted via the `layoutChange` event.
4
+ * The host project is responsible for actually mounting N panes per `count`.
5
+ */
6
+ interface LayoutPreset {
7
+ id: string;
8
+ count: number;
9
+ cols: string;
10
+ rows: string;
11
+ areas?: string;
12
+ areaOrder?: string[];
13
+ icon: string;
14
+ }
15
+ /** Cross-pane sync toggles emitted alongside layoutChange. */
16
+ interface LayoutSyncState {
17
+ symbol: boolean;
18
+ interval: boolean;
19
+ crosshair: boolean;
20
+ time: boolean;
21
+ dateRange: boolean;
22
+ }
23
+ declare const LAYOUT_PRESETS: LayoutPreset[];
24
+ declare const PRESETS_BY_COUNT: Record<number, LayoutPreset[]>;
25
+ declare const PRESET_COUNTS: number[];
26
+ /**
27
+ * Register a preset that appears alongside the built-ins in `getAllPresets()`
28
+ * and the chart-owned `LayoutPopover`. Re-registering the same id overwrites.
29
+ * Throws when the id collides with a built-in preset.
30
+ */
31
+ declare function registerCustomPreset(preset: LayoutPreset): void;
32
+ /** Remove a previously registered custom preset. No-op for unknown ids. */
33
+ declare function unregisterCustomPreset(id: string): void;
34
+ /** All registered custom presets, in insertion order. */
35
+ declare function getCustomPresets(): LayoutPreset[];
36
+ /** Built-ins followed by registered custom presets. */
37
+ declare function getAllPresets(): LayoutPreset[];
38
+ /**
39
+ * Resolve a preset by id, checking custom presets first, then built-ins. Falls
40
+ * back to the single-pane preset when nothing matches.
41
+ */
42
+ declare function getPreset(id: string): LayoutPreset;
43
+ /** Human-readable label for each preset, useful in status bars / tooltips. */
44
+ declare const PRESET_LABEL: Record<string, string>;
45
+ /** Default sync state — matches the host's current defaults in useChartLayout.ts. */
46
+ declare const DEFAULT_LAYOUT_SYNC: LayoutSyncState;
47
+
1
48
  declare class ScaleManager {
2
49
  private static readonly VERTICAL_PADDING_PX;
3
50
  xToPixel(index: number, viewport: Viewport, chartWidth: number): number;
@@ -37,6 +84,11 @@ interface DrawingToolbarUiConfig {
37
84
  btnGap: number;
38
85
  /** Container width (px) below which LeftBar switches to mobile layout */
39
86
  mobileBreakpoint: number;
87
+ /**
88
+ * Use Lucide-style modern SVG icons for the drawing toolbar categories.
89
+ * Default: `false` (original icons, unchanged for all existing consumers).
90
+ */
91
+ modernIcons?: boolean;
40
92
  }
41
93
  interface TopBarUiConfig {
42
94
  /** Height of the top bar strip */
@@ -354,6 +406,11 @@ interface ChartThemeUi {
354
406
  reconnecting: string;
355
407
  disconnected: string;
356
408
  };
409
+ /**
410
+ * Background color of the scroll-to-latest (➕) button.
411
+ * When omitted the button uses the chart background + axisBorder border (neutral style).
412
+ */
413
+ scrollToEndBtnBg?: string;
357
414
  }
358
415
  /** Colors specific to the drawing toolbar (LeftBar). */
359
416
  interface DrawingToolbarColors {
@@ -546,6 +603,13 @@ interface DataLoaderParams {
546
603
  end: Date;
547
604
  interval: string;
548
605
  }
606
+ /**
607
+ * Params passed to `compareDataLoader`. Mirrors `DataLoaderParams` but also
608
+ * carries the compare symbol so a single loader can serve multiple compares.
609
+ */
610
+ interface CompareDataLoaderParams extends DataLoaderParams {
611
+ symbol: string;
612
+ }
549
613
  /**
550
614
  * Per-theme deep-partial color overrides applied on top of the built-in
551
615
  * dark / light themes. Only the keys you supply are replaced.
@@ -935,6 +999,125 @@ interface ChartConfig {
935
999
  * Default: `false` (bar is hidden).
936
1000
  */
937
1001
  showBottomBar?: boolean;
1002
+ /**
1003
+ * Text-decoration for the clickable symbol name in the top-left OHLCV strip.
1004
+ * Default: `'underline'` (existing behaviour).
1005
+ * - `'underline'` → persistent underline whenever the symbol is clickable
1006
+ * - `'none'` → never underline; click handler still attached
1007
+ * - `'hover'` → no resting underline, but `:hover` / `:focus-visible` reveal one
1008
+ * (preferred for branded designs that still want a link affordance)
1009
+ */
1010
+ symbolNameDecoration?: 'underline' | 'none' | 'hover';
1011
+ /** Called when the user clicks "Add alert" in the trade popover. Omit to hide the alert row. */
1012
+ onAddAlert?: (price: number) => void;
1013
+ /**
1014
+ * Header layout variant. Default `'simple'`.
1015
+ * - `'simple'` — original top-bar with dropdowns + duration buttons
1016
+ * - `'advanced'` — compact toolbar with timeframe pills + Compare/1-Click
1017
+ * - `'compact'` — slim per-pane toolbar (timeframe + series + indicators only),
1018
+ * sized for multi-pane grid cells. Symbol is changed via the
1019
+ * on-canvas OHLC strip label (no symbol button in this variant).
1020
+ *
1021
+ * If both `headerLayout` and the deprecated `features.advancedToolbar` are set,
1022
+ * `headerLayout` wins.
1023
+ */
1024
+ headerLayout?: 'simple' | 'advanced' | 'compact';
1025
+ /**
1026
+ * Hide the chart header entirely (simple TopBar / AdvancedToolbar /
1027
+ * CompactToolbar — whichever `headerLayout` would have rendered).
1028
+ *
1029
+ * Use when the host UI provides its own controls and drives the chart via
1030
+ * `setTimeframe`, `setSeries`, `addIndicatorByName`, `removeIndicator`.
1031
+ *
1032
+ * Independent of `showUI` (which hides ALL UI) and `showBottomBar` /
1033
+ * drawing-tools / OHLC strip flags. Default: `false` (header visible).
1034
+ */
1035
+ hideHeader?: boolean;
1036
+ /**
1037
+ * Show the Layout button and built-in multi-chart layout preset popover.
1038
+ * Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
1039
+ *
1040
+ * The chart owns ONLY the picker UI. Selecting a preset emits a `layoutChange`
1041
+ * event with `{ presetId, preset, sync }`; the host project is responsible for
1042
+ * mounting the actual N-pane grid of ChartEngine instances and applying sync.
1043
+ *
1044
+ * Suppresses the deprecated `onLayoutClick` callback if also provided
1045
+ * (a one-time `console.warn` is logged at init).
1046
+ */
1047
+ enableMultipleLayouts?: boolean;
1048
+ /**
1049
+ * Show the Snapshot button and built-in Download/Copy popover.
1050
+ * Default `false`. Works in both `'simple'` and `'advanced'` header layouts.
1051
+ *
1052
+ * The chart emits a `snapshot` event with `{ dataUrl, action }` BEFORE
1053
+ * attempting the native browser action — mobile wrappers (Android/iOS)
1054
+ * can intercept via the JS bridge to use native APIs (Photos library,
1055
+ * UIPasteboard, ClipboardManager) where browser permissions are restricted.
1056
+ *
1057
+ * Suppresses the deprecated `onScreenshotClick` callback if also provided
1058
+ * (a one-time `console.warn` is logged at init).
1059
+ */
1060
+ enableSnapshot?: boolean;
1061
+ /**
1062
+ * Opt-in feature flags. All flags default to `false` / disabled so existing
1063
+ * consumers are completely unaffected when this field is omitted.
1064
+ */
1065
+ features?: {
1066
+ /**
1067
+ * @deprecated Use top-level `headerLayout: 'advanced'` instead. Will be
1068
+ * removed in a future major version. Currently treated as an alias.
1069
+ */
1070
+ advancedToolbar?: boolean;
1071
+ };
1072
+ /**
1073
+ * Fetches historical OHLC bars for a compare symbol. When provided, the
1074
+ * library owns the Compare flow end-to-end: clicking the Compare button
1075
+ * opens an in-chart picker (reusing `isins`), and this loader is invoked
1076
+ * to populate each chosen compare. It is also re-invoked whenever the
1077
+ * primary symbol's range changes (timeframe switch, primary-symbol switch,
1078
+ * history pan-back, `resetData`) so compares stay aligned.
1079
+ *
1080
+ * No streaming — compares are historical-only in v1.
1081
+ */
1082
+ compareDataLoader?: (params: CompareDataLoaderParams) => Promise<OHLCVBar[]>;
1083
+ /**
1084
+ * Compare symbols to add automatically on chart init. Each one triggers a
1085
+ * `compareDataLoader` call against the initial primary range.
1086
+ */
1087
+ initialCompares?: string[];
1088
+ /**
1089
+ * Maximum number of concurrent compare symbols. Attempting to add beyond
1090
+ * this emits a `compareError` event instead of fetching. Default: `8`.
1091
+ */
1092
+ maxCompares?: number;
1093
+ /**
1094
+ * @deprecated With `enableMultipleLayouts: true`, the chart owns the popover
1095
+ * and emits a `layoutChange` event. Listen to that event instead.
1096
+ * Still honored when `enableMultipleLayouts` is omitted/false.
1097
+ */
1098
+ onLayoutClick?: () => void;
1099
+ /**
1100
+ * Called when the user toggles the 1-Click Trade button. Receives the new
1101
+ * active state as a boolean. The button is rendered in whichever toolbar is
1102
+ * active (default `TopBar` or `AdvancedToolbar`).
1103
+ *
1104
+ * **When omitted, the 1-Click Trade button is hidden** — callback presence
1105
+ * gates the button's visibility, matching the pattern used by
1106
+ * `onLayoutClick` / `onScreenshotClick`.
1107
+ */
1108
+ onOneClickTradeToggle?: (active: boolean) => void;
1109
+ /**
1110
+ * @deprecated Renamed to `onOneClickTradeToggle` for clarity. Will be
1111
+ * removed in a future major version. If both are provided,
1112
+ * `onOneClickTradeToggle` wins and a console warning is emitted.
1113
+ */
1114
+ onOneClickToggle?: (active: boolean) => void;
1115
+ /**
1116
+ * @deprecated With `enableSnapshot: true`, the chart owns the popover and
1117
+ * emits a `snapshot` event. Listen to that event instead.
1118
+ * Still honored when `enableSnapshot` is omitted/false.
1119
+ */
1120
+ onScreenshotClick?: () => void;
938
1121
  /**
939
1122
  * @deprecated DraftOrderQtyInput has been removed. This option is a no-op.
940
1123
  * Accepted for backward compatibility only.
@@ -1045,6 +1228,13 @@ interface IWebSocketAdapter {
1045
1228
  }
1046
1229
  type IndicatorParams = Record<string, number | string>;
1047
1230
  interface ActiveIndicatorState {
1231
+ /**
1232
+ * Unique per-instance identifier (e.g. "EMA#3"). Distinguishes multiple
1233
+ * active instances of the same indicator type. All per-instance state and
1234
+ * UI (results cache, sub-pane overlays, scale factors, pills) is keyed by
1235
+ * this, not by `shortName` — so e.g. EMA-20, EMA-50 and EMA-200 can coexist.
1236
+ */
1237
+ instanceId: string;
1048
1238
  indicator: IIndicator;
1049
1239
  shortName: string;
1050
1240
  currentParams: IndicatorParams;
@@ -1067,6 +1257,12 @@ interface IndicatorStateEntry {
1067
1257
  shortName: string;
1068
1258
  params: IndicatorParams;
1069
1259
  visible?: boolean;
1260
+ /**
1261
+ * Per-instance id captured at serialization time. Optional for backward
1262
+ * compatibility — configs saved before multi-instance support omit it, and
1263
+ * `setState` mints a fresh id when it's absent.
1264
+ */
1265
+ instanceId?: string;
1070
1266
  }
1071
1267
  /** Color overrides for the chart canvas elements (background, grid, candles, etc.). */
1072
1268
  interface CanvasColorSettings {
@@ -1126,6 +1322,11 @@ interface ChartState {
1126
1322
  factor: number;
1127
1323
  panOffset: number;
1128
1324
  };
1325
+ /**
1326
+ * Active compare symbols at snapshot time. The library will re-add each
1327
+ * one (in order) via `compareDataLoader` when this state is restored.
1328
+ */
1329
+ compares?: string[];
1129
1330
  }
1130
1331
  interface CrosshairPosition {
1131
1332
  x: number;
@@ -1135,7 +1336,12 @@ interface CrosshairPosition {
1135
1336
  bar: OHLCVBar | null;
1136
1337
  }
1137
1338
  type ChartEventMap = {
1138
- crosshair: CrosshairPosition;
1339
+ /**
1340
+ * Crosshair position changed. Payload is `null` when the crosshair leaves
1341
+ * the chart area or is otherwise cleared — listeners that mirror crosshair
1342
+ * across multiple panes use `null` to clear the mirrored crosshair.
1343
+ */
1344
+ crosshair: CrosshairPosition | null;
1139
1345
  click: CrosshairPosition;
1140
1346
  zoom: {
1141
1347
  viewport: Viewport;
@@ -1327,6 +1533,60 @@ type ChartEventMap = {
1327
1533
  bracketOrderLabel?: string;
1328
1534
  }>;
1329
1535
  };
1536
+ /**
1537
+ * Emitted when the user picks a preset in the multi-layout popover or toggles
1538
+ * a sync option. Fires only when `enableMultipleLayouts: true`. The host
1539
+ * project listens to this event to mount/teardown N panes accordingly.
1540
+ */
1541
+ layoutChange: {
1542
+ presetId: string;
1543
+ preset: LayoutPreset;
1544
+ sync: LayoutSyncState;
1545
+ };
1546
+ /**
1547
+ * Emitted when the user picks Download or Copy from the snapshot popover.
1548
+ * Fires only when `enableSnapshot: true`. The chart attempts the native
1549
+ * browser action immediately after emitting; mobile wrappers can intercept
1550
+ * via the JS bridge to short-circuit and use platform APIs.
1551
+ */
1552
+ snapshot: {
1553
+ /** Full PNG data URL of the composited chart canvas. */
1554
+ dataUrl: string;
1555
+ action: 'download' | 'copy';
1556
+ };
1557
+ /** Emitted after a compare symbol has been added and its bars resolved. */
1558
+ compareAdded: {
1559
+ symbol: string;
1560
+ color: string;
1561
+ };
1562
+ /** Emitted when a compare symbol is removed (×, `removeCompare`, or `clearCompares`). */
1563
+ compareRemoved: {
1564
+ symbol: string;
1565
+ };
1566
+ /**
1567
+ * Emitted when adding a compare or fetching its bars fails — e.g. no
1568
+ * `compareDataLoader` configured, loader rejected, or `maxCompares` reached.
1569
+ */
1570
+ compareError: {
1571
+ symbol: string;
1572
+ message: string;
1573
+ };
1574
+ /**
1575
+ * Emitted after an indicator instance is added. `instanceId` uniquely
1576
+ * identifies the instance (e.g. "EMA#3") so callers can later remove that
1577
+ * specific instance via `removeIndicator(instanceId)` — important now that
1578
+ * multiple instances of the same `shortName` can coexist.
1579
+ */
1580
+ indicatorAdded: {
1581
+ instanceId: string;
1582
+ shortName: string;
1583
+ params: IndicatorParams;
1584
+ };
1585
+ /** Emitted after an indicator instance is removed (pill ×, settings dialog, or `removeIndicator`). */
1586
+ indicatorRemoved: {
1587
+ instanceId: string;
1588
+ shortName: string;
1589
+ };
1330
1590
  };
1331
1591
  /** Distinguishes level types: historical trade, open position, or pending order. */
1332
1592
  type TradeLevelType = 'trade' | 'position' | 'pending';
@@ -1518,4 +1778,4 @@ declare class MACD implements IIndicator {
1518
1778
  render(ctx: CanvasRenderingContext2D, results: IndicatorResult[], scale: ScaleManager, viewport: Viewport, paneHeight: number, rangeOverride?: PriceRange): void;
1519
1779
  }
1520
1780
 
1521
- export { type IndicatorOverlayColors as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type DrawingToolType as D, DEFAULT_DRAWING_TOOLBAR_CONFIG as E, DEFAULT_INDICATOR_OVERLAY_CONFIG as F, DEFAULT_LABELS as G, DEFAULT_PRICE_AXIS_CONFIG as H, type IIndicator as I, DEFAULT_TIME_AXIS_CONFIG as J, DEFAULT_TOP_BAR_CONFIG as K, DEFAULT_TRADE_BUTTON_CONFIG as L, DEFAULT_UI_CONFIG as M, type DataLoaderParams as N, type OHLCVBar as O, type PriceRange as P, type DeepPartial$1 as Q, type DeepPartialChartTheme as R, type SeriesType as S, type Timeframe as T, type DialogLabels as U, type Viewport as V, type DrawingToolbarColors as W, type DrawingToolbarLabels as X, type DrawingToolbarUiConfig as Y, type Duration as Z, EMA as _, type ChartEventMap as a, type IndicatorOverlayUiConfig as a0, type IndicatorParams as a1, type IndicatorResult as a2, type IndicatorStateEntry as a3, LIGHT_THEME as a4, MACD as a5, type OhlcLabels as a6, type OrderSubmit as a7, type Padding as a8, type PendingOrderLevel as a9, type PositionLevel as aa, type PositionRenderStyle as ab, type PriceAxisUiConfig as ac, RSI as ad, SMA as ae, type Theme as af, type ThemeOverrides as ag, type TimeAxisUiConfig as ah, type TopBarColors as ai, type TopBarLabels as aj, type TopBarUiConfig as ak, type TradeButtonUiConfig as al, type TradeDisplayFilter as am, type TradeLabels as an, type TradeLevel as ao, type TradeLevelColors as ap, type TradePanelColors as aq, type UiConfig as ar, deepMergeTheme as as, resolveCssVarsInTheme as at, resolveLabels as au, resolveUiConfig as av, type PriceSource as aw, type ChartState as b, type IDrawing as c, type IWebSocketAdapter as d, type TradeLevelType as e, type AnyLevel as f, type DrawingPoint as g, ScaleManager as h, type DrawingHandle as i, type ChartTheme as j, type SerializedDrawing as k, type Tick as l, type StreamStatus as m, type ActiveIndicatorState as n, type BottomBarColors as o, type BottomBarLabels as p, type BottomBarUiConfig as q, type CanvasColorSettings as r, type ChartLabels as s, type ChartMiscLabels as t, type ChartThemeUi as u, type CrosshairPosition as v, type CrosshairUiConfig as w, DARK_THEME as x, DEFAULT_BOTTOM_BAR_CONFIG as y, DEFAULT_CROSSHAIR_CONFIG as z };
1781
+ export { type DrawingToolbarUiConfig as $, type AnyDrawingStyle as A, BollingerBands as B, type ChartConfig as C, type DrawingToolType as D, DEFAULT_CROSSHAIR_CONFIG as E, DEFAULT_DRAWING_TOOLBAR_CONFIG as F, DEFAULT_INDICATOR_OVERLAY_CONFIG as G, DEFAULT_LABELS as H, type IIndicator as I, DEFAULT_LAYOUT_SYNC as J, DEFAULT_PRICE_AXIS_CONFIG as K, type LayoutSyncState as L, DEFAULT_TIME_AXIS_CONFIG as M, DEFAULT_TOP_BAR_CONFIG as N, type OHLCVBar as O, type PriceRange as P, DEFAULT_TRADE_BUTTON_CONFIG as Q, DEFAULT_UI_CONFIG as R, type SeriesType as S, type Timeframe as T, type DataLoaderParams as U, type Viewport as V, type DeepPartial$1 as W, type DeepPartialChartTheme as X, type DialogLabels as Y, type DrawingToolbarColors as Z, type DrawingToolbarLabels as _, type IndicatorParams as a, type Duration as a0, EMA as a1, type IndicatorOverlayColors as a2, type IndicatorOverlayUiConfig as a3, type IndicatorResult as a4, type IndicatorStateEntry as a5, LAYOUT_PRESETS as a6, LIGHT_THEME as a7, type LayoutPreset as a8, MACD as a9, getAllPresets as aA, getCustomPresets as aB, getPreset as aC, registerCustomPreset as aD, resolveCssVarsInTheme as aE, resolveLabels as aF, resolveUiConfig as aG, unregisterCustomPreset as aH, type PriceSource as aI, type OhlcLabels as aa, type OrderSubmit as ab, PRESETS_BY_COUNT as ac, PRESET_COUNTS as ad, PRESET_LABEL as ae, type Padding as af, type PendingOrderLevel as ag, type PositionLevel as ah, type PositionRenderStyle as ai, type PriceAxisUiConfig as aj, RSI as ak, SMA as al, type Theme as am, type ThemeOverrides as an, type TimeAxisUiConfig as ao, type TopBarColors as ap, type TopBarLabels as aq, type TopBarUiConfig as ar, type TradeButtonUiConfig as as, type TradeDisplayFilter as at, type TradeLabels as au, type TradeLevel as av, type TradeLevelColors as aw, type TradePanelColors as ax, type UiConfig as ay, deepMergeTheme as az, type ChartEventMap as b, type ChartState as c, type IDrawing as d, type IWebSocketAdapter as e, type TradeLevelType as f, type ChartTheme as g, type AnyLevel as h, type DrawingPoint as i, ScaleManager as j, type DrawingHandle as k, type SerializedDrawing as l, type Tick as m, type StreamStatus as n, type ActiveIndicatorState as o, type BottomBarColors as p, type BottomBarLabels as q, type BottomBarUiConfig as r, type CanvasColorSettings as s, type ChartLabels as t, type ChartMiscLabels as u, type ChartThemeUi as v, type CrosshairPosition as w, type CrosshairUiConfig as x, DARK_THEME as y, DEFAULT_BOTTOM_BAR_CONFIG as z };