react-native-vroom-chart 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -187,6 +187,13 @@ type ChartType = 'candles' | 'line';
187
187
  * Defaults to `'ease-in-out'`.
188
188
  */
189
189
  type TransitionEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
190
+ /**
191
+ * How a same-asset interval switch animates. `'transform'` (default) lerps
192
+ * each visible column into its counterpart. `'fade'` fades the old scene out
193
+ * then the new one in — use when the two windows don’t share a 1:1 pairing
194
+ * (e.g. a fixed lookback).
195
+ */
196
+ type IntervalTransition = 'transform' | 'fade';
190
197
  /** Active drawing tool while in `draw` mode. `null` draws nothing. */
191
198
  type DrawTool = null | 'line' | 'box' | 'pencil' | 'path';
192
199
  /** A drawing anchor in data space, so it stays glued to the candles on pan/zoom. */
@@ -200,9 +207,12 @@ type DrawPoint = {
200
207
  type DrawingBase = {
201
208
  /** Stable unique id (the chart generates one for drawings it creates). */
202
209
  id: string;
203
- /** Stroke color (hex string or packed ARGB number). Default solid blue. */
210
+ /**
211
+ * Stroke color (hex string or packed ARGB number). New drawings take
212
+ * `drawingStyle.color` when set; otherwise `#ff2962ff`.
213
+ */
204
214
  color?: VroomColor;
205
- /** Stroke width in px. Default 2. */
215
+ /** Stroke width in px. New drawings take `drawingStyle.width` when set; otherwise 2. */
206
216
  width?: number;
207
217
  /**
208
218
  * Protect the drawing from editing. A locked drawing still renders and can
@@ -295,6 +305,29 @@ type DrawingStyle = {
295
305
  fill?: VroomColor;
296
306
  locked?: boolean;
297
307
  };
308
+ /**
309
+ * Default appearance for drawings the user creates — the live draft and the
310
+ * object handed to `onDrawingComplete`. Paste copies the source drawing's
311
+ * style instead of this default.
312
+ *
313
+ * Omitted fields keep the library defaults: a 2px `#ff2962ff` stroke, and for
314
+ * boxes a 10% tint of the stroke as fill.
315
+ *
316
+ * Prefer 6-digit hex for `color` (`'#00FFFF'`). vroom treats that as opaque,
317
+ * and CSS swatches preview it correctly. 8-digit hex is `#aarrggbb`, not CSS
318
+ * `#rrggbbaa`.
319
+ */
320
+ type DefaultDrawingStyle = {
321
+ /** Stroke color, used for the live draft and stamped onto the committed drawing. */
322
+ color?: VroomColor;
323
+ /** Stroke width in px. Default 2. */
324
+ width?: number;
325
+ /**
326
+ * Box interior fill. Omitted, new boxes keep the default 10% stroke tint.
327
+ * Ignored by line, pencil, and path.
328
+ */
329
+ fill?: VroomColor;
330
+ };
298
331
  /**
299
332
  * Storage adapter for **managed** drawing persistence. Provide it via the
300
333
  * `drawingStore` prop and the chart owns the drawings array itself — loading and
@@ -720,16 +753,23 @@ type VroomChartCoreProps = {
720
753
  chartType?: ChartType;
721
754
  /**
722
755
  * Duration (ms) of the animated transitions: the candle↔line switch when
723
- * `chartType` changes, and the candle reshape when the `candles` array is
756
+ * `chartType` changes, and the interval switch when the `candles` array is
724
757
  * swapped for a different interval of the same asset. Default ~300. `0` snaps
725
- * instantly. Ignored (snaps) when the OS requests reduced motion, which
726
- * instead uses a plain cross-fade.
758
+ * instantly. Ignored (snaps) when the OS requests reduced motion.
727
759
  */
728
760
  transitionMs?: number;
729
761
  /**
730
762
  * Easing curve applied to those transitions. Default `'ease-in-out'`.
731
763
  */
732
764
  transitionEasing?: TransitionEasing;
765
+ /**
766
+ * How a same-asset interval switch animates. `'transform'` (default) lerps
767
+ * each visible column into its counterpart. `'fade'` fades the old scene out
768
+ * then the new one in — use when the two windows don’t share a 1:1 pairing
769
+ * (e.g. a fixed lookback). Same duration/easing as `transitionMs`. Reduced
770
+ * motion still snaps.
771
+ */
772
+ intervalTransition?: IntervalTransition;
733
773
  theme?: VroomTheme;
734
774
  /** RSI indicator (pane below the candles). Omit/disable to hide it. */
735
775
  rsi?: RSIConfig;
@@ -802,6 +842,12 @@ type VroomChartCoreProps = {
802
842
  mode?: ChartMode;
803
843
  /** Active drawing tool while in `draw` mode. Default `null` (draws nothing). */
804
844
  tool?: DrawTool;
845
+ /**
846
+ * Default appearance for drawings the user creates (live draft + the object
847
+ * handed to `onDrawingComplete`). Paste copies the source drawing's style
848
+ * instead of this. Omitted fields keep the library defaults.
849
+ */
850
+ drawingStyle?: DefaultDrawingStyle;
805
851
  /**
806
852
  * Committed drawings to render, anchored to data so they track the candles on
807
853
  * pan/zoom. This is a controlled prop: append the value the chart hands you in
@@ -945,4 +991,4 @@ declare function classifyTransition(prev: Candle[] | null, next: Candle[], serie
945
991
  */
946
992
  declare function timeframeWindow(oldWindow: VisibleRange, oldStepMs: number, oldLastMs: number, newStepMs: number, newLastMs: number): VisibleRange;
947
993
 
948
- export { type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PriceLine, type PriceLinesStyle, type RSIConfig, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };
994
+ export { type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type DefaultDrawingStyle, type IntervalTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PriceLine, type PriceLinesStyle, type RSIConfig, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };
package/lib/index.d.ts CHANGED
@@ -187,6 +187,13 @@ type ChartType = 'candles' | 'line';
187
187
  * Defaults to `'ease-in-out'`.
188
188
  */
189
189
  type TransitionEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
190
+ /**
191
+ * How a same-asset interval switch animates. `'transform'` (default) lerps
192
+ * each visible column into its counterpart. `'fade'` fades the old scene out
193
+ * then the new one in — use when the two windows don’t share a 1:1 pairing
194
+ * (e.g. a fixed lookback).
195
+ */
196
+ type IntervalTransition = 'transform' | 'fade';
190
197
  /** Active drawing tool while in `draw` mode. `null` draws nothing. */
191
198
  type DrawTool = null | 'line' | 'box' | 'pencil' | 'path';
192
199
  /** A drawing anchor in data space, so it stays glued to the candles on pan/zoom. */
@@ -200,9 +207,12 @@ type DrawPoint = {
200
207
  type DrawingBase = {
201
208
  /** Stable unique id (the chart generates one for drawings it creates). */
202
209
  id: string;
203
- /** Stroke color (hex string or packed ARGB number). Default solid blue. */
210
+ /**
211
+ * Stroke color (hex string or packed ARGB number). New drawings take
212
+ * `drawingStyle.color` when set; otherwise `#ff2962ff`.
213
+ */
204
214
  color?: VroomColor;
205
- /** Stroke width in px. Default 2. */
215
+ /** Stroke width in px. New drawings take `drawingStyle.width` when set; otherwise 2. */
206
216
  width?: number;
207
217
  /**
208
218
  * Protect the drawing from editing. A locked drawing still renders and can
@@ -295,6 +305,29 @@ type DrawingStyle = {
295
305
  fill?: VroomColor;
296
306
  locked?: boolean;
297
307
  };
308
+ /**
309
+ * Default appearance for drawings the user creates — the live draft and the
310
+ * object handed to `onDrawingComplete`. Paste copies the source drawing's
311
+ * style instead of this default.
312
+ *
313
+ * Omitted fields keep the library defaults: a 2px `#ff2962ff` stroke, and for
314
+ * boxes a 10% tint of the stroke as fill.
315
+ *
316
+ * Prefer 6-digit hex for `color` (`'#00FFFF'`). vroom treats that as opaque,
317
+ * and CSS swatches preview it correctly. 8-digit hex is `#aarrggbb`, not CSS
318
+ * `#rrggbbaa`.
319
+ */
320
+ type DefaultDrawingStyle = {
321
+ /** Stroke color, used for the live draft and stamped onto the committed drawing. */
322
+ color?: VroomColor;
323
+ /** Stroke width in px. Default 2. */
324
+ width?: number;
325
+ /**
326
+ * Box interior fill. Omitted, new boxes keep the default 10% stroke tint.
327
+ * Ignored by line, pencil, and path.
328
+ */
329
+ fill?: VroomColor;
330
+ };
298
331
  /**
299
332
  * Storage adapter for **managed** drawing persistence. Provide it via the
300
333
  * `drawingStore` prop and the chart owns the drawings array itself — loading and
@@ -720,16 +753,23 @@ type VroomChartCoreProps = {
720
753
  chartType?: ChartType;
721
754
  /**
722
755
  * Duration (ms) of the animated transitions: the candle↔line switch when
723
- * `chartType` changes, and the candle reshape when the `candles` array is
756
+ * `chartType` changes, and the interval switch when the `candles` array is
724
757
  * swapped for a different interval of the same asset. Default ~300. `0` snaps
725
- * instantly. Ignored (snaps) when the OS requests reduced motion, which
726
- * instead uses a plain cross-fade.
758
+ * instantly. Ignored (snaps) when the OS requests reduced motion.
727
759
  */
728
760
  transitionMs?: number;
729
761
  /**
730
762
  * Easing curve applied to those transitions. Default `'ease-in-out'`.
731
763
  */
732
764
  transitionEasing?: TransitionEasing;
765
+ /**
766
+ * How a same-asset interval switch animates. `'transform'` (default) lerps
767
+ * each visible column into its counterpart. `'fade'` fades the old scene out
768
+ * then the new one in — use when the two windows don’t share a 1:1 pairing
769
+ * (e.g. a fixed lookback). Same duration/easing as `transitionMs`. Reduced
770
+ * motion still snaps.
771
+ */
772
+ intervalTransition?: IntervalTransition;
733
773
  theme?: VroomTheme;
734
774
  /** RSI indicator (pane below the candles). Omit/disable to hide it. */
735
775
  rsi?: RSIConfig;
@@ -802,6 +842,12 @@ type VroomChartCoreProps = {
802
842
  mode?: ChartMode;
803
843
  /** Active drawing tool while in `draw` mode. Default `null` (draws nothing). */
804
844
  tool?: DrawTool;
845
+ /**
846
+ * Default appearance for drawings the user creates (live draft + the object
847
+ * handed to `onDrawingComplete`). Paste copies the source drawing's style
848
+ * instead of this. Omitted fields keep the library defaults.
849
+ */
850
+ drawingStyle?: DefaultDrawingStyle;
805
851
  /**
806
852
  * Committed drawings to render, anchored to data so they track the candles on
807
853
  * pan/zoom. This is a controlled prop: append the value the chart hands you in
@@ -945,4 +991,4 @@ declare function classifyTransition(prev: Candle[] | null, next: Candle[], serie
945
991
  */
946
992
  declare function timeframeWindow(oldWindow: VisibleRange, oldStepMs: number, oldLastMs: number, newStepMs: number, newLastMs: number): VisibleRange;
947
993
 
948
- export { type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PriceLine, type PriceLinesStyle, type RSIConfig, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };
994
+ export { type BollingerBandsConfig, type Candle, type ChartType, type CrosshairEvent, type DataTransition, type DefaultDrawingStyle, type IntervalTransition, type MACDConfig, type MAKind, type MASource, type MovingAverageOverlay, type PriceLine, type PriceLinesStyle, type RSIConfig, type TransitionEasing, type VWAPConfig, type VisibleRange, type VolumeConfig, VroomChart, type VroomChartProps, type VroomColor, type VroomTheme, classifyTransition, inferStepMs, timeframeWindow };
package/lib/index.js CHANGED
@@ -384,11 +384,12 @@ function useChartCore(candles, size, visibleRange, defaultCandleWidth, chartType
384
384
  ensureInstalled();
385
385
  handleRef.current = globalThis.VroomChartJSI.create();
386
386
  }
387
- const animRef = (0, import_react.useRef)({ ms: 300, easing: void 0, reduceMotion: false });
387
+ const animRef = (0, import_react.useRef)({ ms: 300, easing: void 0, reduceMotion: false, interval: "transform" });
388
388
  animRef.current = {
389
389
  ms: Math.max(0, transition?.transitionMs ?? 300),
390
390
  easing: transition?.transitionEasing,
391
- reduceMotion: transition?.reduceMotion ?? false
391
+ reduceMotion: transition?.reduceMotion ?? false,
392
+ interval: transition?.intervalTransition === "fade" ? "fade" : "transform"
392
393
  };
393
394
  const onFrameRef = (0, import_react.useRef)(transition?.onFrame);
394
395
  onFrameRef.current = transition?.onFrame;
@@ -461,7 +462,7 @@ function useChartCore(candles, size, visibleRange, defaultCandleWidth, chartType
461
462
  morphing = animRef.current.ms > 0 && !animRef.current.reduceMotion && onFrameRef.current != null;
462
463
  if (morphing) {
463
464
  endIntervalMorph();
464
- h.beginIntervalMorph();
465
+ h.beginIntervalMorph(animRef.current.interval);
465
466
  }
466
467
  } else if (transitionKind === "initial" || transitionKind === "reset") {
467
468
  endIntervalMorph();
@@ -529,6 +530,7 @@ function VroomChart(props) {
529
530
  chartType,
530
531
  transitionMs,
531
532
  transitionEasing,
533
+ intervalTransition,
532
534
  theme,
533
535
  rsi,
534
536
  macd,
@@ -611,7 +613,7 @@ function VroomChart(props) {
611
613
  bollingerBands,
612
614
  volume,
613
615
  priceLinesProp,
614
- { seriesKey, transitionMs, transitionEasing, reduceMotion, onFrame }
616
+ { seriesKey, transitionMs, transitionEasing, intervalTransition, reduceMotion, onFrame }
615
617
  );
616
618
  const crosshairActive = (0, import_react2.useRef)(false);
617
619
  const lastCrosshairTime = (0, import_react2.useRef)(null);