@pipsend/charts 1.2.0 → 1.2.1

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,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v1.2.0
3
+ * Pipsend Charts v1.2.1
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -17443,8 +17443,9 @@
17443
17443
  indicator.setVolumeData(volumeMap);
17444
17444
  }
17445
17445
 
17446
+ const CLICK_TOLERANCE_PX = 4;
17446
17447
  /**
17447
- * Draggable Price Line - Línea de precio que se puede arrastrar con el mouse
17448
+ * Draggable Price Line - Línea de precio que se puede arrastrar y/o hacer click
17448
17449
  */
17449
17450
  class DraggablePriceLine {
17450
17451
  constructor(chart, series, options) {
@@ -17454,6 +17455,8 @@
17454
17455
  this._private__unsubscribeHandlers = [];
17455
17456
  this._private__isHovering = false;
17456
17457
  this._private__originalColor = '';
17458
+ this._private__mouseDownPos = null;
17459
+ this._private__mouseDownOnLine = false;
17457
17460
  this._private__chart = chart;
17458
17461
  this._private__series = series;
17459
17462
  this._private__options = {
@@ -17464,8 +17467,9 @@
17464
17467
  ...options,
17465
17468
  };
17466
17469
  this._private__createPriceLine();
17467
- if (this._private__options.draggable) {
17468
- this._private__setupDragHandlers();
17470
+ // Set up handlers if line is interactive (draggable or clickable)
17471
+ if (this._private__options.draggable || this._private__options.onClick) {
17472
+ this._private__setupInteractionHandlers();
17469
17473
  }
17470
17474
  }
17471
17475
  _private__createPriceLine() {
@@ -17479,26 +17483,33 @@
17479
17483
  title: this._private__options.title || '',
17480
17484
  });
17481
17485
  }
17482
- _private__setupDragHandlers() {
17486
+ _private__setupInteractionHandlers() {
17483
17487
  const chartElement = this._private__chart.chartElement?.() || document.querySelector('.tv-lightweight-charts');
17484
17488
  if (!chartElement)
17485
17489
  return;
17486
17490
  this._private__container = chartElement;
17487
17491
  const handleMouseDown = (e) => {
17488
- // Solo permitir drag desde el área del gráfico (no desde el price axis)
17492
+ // Solo permitir interacción desde el área del gráfico (no desde el price axis)
17489
17493
  if (!this._private__isInChartArea(e)) {
17490
17494
  return;
17491
17495
  }
17492
17496
  const price = this._private__getPriceFromY(e.clientY);
17493
- if (this._private__isOnLine(e, price)) {
17497
+ if (!this._private__isOnLine(e, price)) {
17498
+ return;
17499
+ }
17500
+ // Track press for click vs drag detection
17501
+ this._private__mouseDownPos = { _internal_x: e.clientX, _internal_y: e.clientY };
17502
+ this._private__mouseDownOnLine = true;
17503
+ // Only start drag if line is draggable
17504
+ if (this._private__options.draggable) {
17494
17505
  this._private__isDragging = true;
17495
17506
  this._private__container.style.cursor = 'ns-resize';
17496
17507
  if (this._private__options.onDragStart) {
17497
17508
  this._private__options.onDragStart(this._private__options.price);
17498
17509
  }
17499
- e.preventDefault();
17500
- e.stopPropagation();
17501
17510
  }
17511
+ e.preventDefault();
17512
+ e.stopPropagation();
17502
17513
  };
17503
17514
  const handleMouseMove = (e) => {
17504
17515
  if (this._private__isDragging) {
@@ -17519,7 +17530,7 @@
17519
17530
  }
17520
17531
  const price = this._private__getPriceFromY(e.clientY);
17521
17532
  if (this._private__isOnLine(e, price)) {
17522
- this._private__container.style.cursor = 'ns-resize';
17533
+ this._private__container.style.cursor = this._private__options.draggable ? 'ns-resize' : 'pointer';
17523
17534
  this._private__setHoverState(true);
17524
17535
  }
17525
17536
  else {
@@ -17529,13 +17540,40 @@
17529
17540
  }
17530
17541
  };
17531
17542
  const handleMouseUp = (e) => {
17532
- if (this._private__isDragging) {
17533
- this._private__isDragging = false;
17543
+ const wasDragging = this._private__isDragging;
17544
+ const downOnLine = this._private__mouseDownOnLine;
17545
+ const downPos = this._private__mouseDownPos;
17546
+ // Reset state regardless of outcome
17547
+ this._private__isDragging = false;
17548
+ this._private__mouseDownOnLine = false;
17549
+ this._private__mouseDownPos = null;
17550
+ if (wasDragging) {
17551
+ // Drag-end path
17534
17552
  this._private__container.style.cursor = 'default';
17535
17553
  this._private__setHoverState(false);
17536
- if (this._private__options.onDragEnd) {
17554
+ const movedFromDown = downPos &&
17555
+ (Math.abs(e.clientX - downPos._internal_x) > CLICK_TOLERANCE_PX ||
17556
+ Math.abs(e.clientY - downPos._internal_y) > CLICK_TOLERANCE_PX);
17557
+ // If barely moved, treat as click instead of drag
17558
+ if (!movedFromDown && this._private__options.onClick) {
17559
+ this._private__options.onClick(this._private__options.price);
17560
+ }
17561
+ else if (this._private__options.onDragEnd) {
17537
17562
  this._private__options.onDragEnd(this._private__options.price);
17538
17563
  }
17564
+ return;
17565
+ }
17566
+ // Pure click path (non-draggable line or draggable that didn't start drag)
17567
+ if (downOnLine && downPos && this._private__options.onClick) {
17568
+ const moved = Math.abs(e.clientX - downPos._internal_x) > CLICK_TOLERANCE_PX ||
17569
+ Math.abs(e.clientY - downPos._internal_y) > CLICK_TOLERANCE_PX;
17570
+ if (!moved) {
17571
+ // Confirm release was still on the line area
17572
+ const price = this._private__getPriceFromY(e.clientY);
17573
+ if (this._private__isOnLine(e, price)) {
17574
+ this._private__options.onClick(this._private__options.price);
17575
+ }
17576
+ }
17539
17577
  }
17540
17578
  };
17541
17579
  const handleMouseLeave = (e) => {
@@ -17549,6 +17587,8 @@
17549
17587
  else {
17550
17588
  this._private__setHoverState(false);
17551
17589
  }
17590
+ this._private__mouseDownOnLine = false;
17591
+ this._private__mouseDownPos = null;
17552
17592
  };
17553
17593
  this._private__container.addEventListener('mousedown', handleMouseDown);
17554
17594
  this._private__container.addEventListener('mousemove', handleMouseMove);
@@ -17793,6 +17833,7 @@
17793
17833
  onDragStart: options.onDragStart,
17794
17834
  onDragMove: options.onDragMove,
17795
17835
  onDragEnd: options.onDragEnd,
17836
+ onClick: options.onClick,
17796
17837
  };
17797
17838
  return new DraggablePriceLine(chart, series, lineOptions);
17798
17839
  }
@@ -24863,7 +24904,7 @@
24863
24904
  * Returns the current version as a string. For example `'1.0.0'`.
24864
24905
  */
24865
24906
  function version() {
24866
- return "1.2.0";
24907
+ return "1.2.1";
24867
24908
  }
24868
24909
 
24869
24910
  var PipsendChartsModule = /*#__PURE__*/Object.freeze({
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @license
3
- * Pipsend Charts v1.2.0
3
+ * Pipsend Charts v1.2.1
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -17440,8 +17440,9 @@ function setVolumeProfileData(indicator, data) {
17440
17440
  indicator.setVolumeData(volumeMap);
17441
17441
  }
17442
17442
 
17443
+ const CLICK_TOLERANCE_PX = 4;
17443
17444
  /**
17444
- * Draggable Price Line - Línea de precio que se puede arrastrar con el mouse
17445
+ * Draggable Price Line - Línea de precio que se puede arrastrar y/o hacer click
17445
17446
  */
17446
17447
  class DraggablePriceLine {
17447
17448
  constructor(chart, series, options) {
@@ -17451,6 +17452,8 @@ class DraggablePriceLine {
17451
17452
  this._private__unsubscribeHandlers = [];
17452
17453
  this._private__isHovering = false;
17453
17454
  this._private__originalColor = '';
17455
+ this._private__mouseDownPos = null;
17456
+ this._private__mouseDownOnLine = false;
17454
17457
  this._private__chart = chart;
17455
17458
  this._private__series = series;
17456
17459
  this._private__options = {
@@ -17461,8 +17464,9 @@ class DraggablePriceLine {
17461
17464
  ...options,
17462
17465
  };
17463
17466
  this._private__createPriceLine();
17464
- if (this._private__options.draggable) {
17465
- this._private__setupDragHandlers();
17467
+ // Set up handlers if line is interactive (draggable or clickable)
17468
+ if (this._private__options.draggable || this._private__options.onClick) {
17469
+ this._private__setupInteractionHandlers();
17466
17470
  }
17467
17471
  }
17468
17472
  _private__createPriceLine() {
@@ -17476,26 +17480,33 @@ class DraggablePriceLine {
17476
17480
  title: this._private__options.title || '',
17477
17481
  });
17478
17482
  }
17479
- _private__setupDragHandlers() {
17483
+ _private__setupInteractionHandlers() {
17480
17484
  const chartElement = this._private__chart.chartElement?.() || document.querySelector('.tv-lightweight-charts');
17481
17485
  if (!chartElement)
17482
17486
  return;
17483
17487
  this._private__container = chartElement;
17484
17488
  const handleMouseDown = (e) => {
17485
- // Solo permitir drag desde el área del gráfico (no desde el price axis)
17489
+ // Solo permitir interacción desde el área del gráfico (no desde el price axis)
17486
17490
  if (!this._private__isInChartArea(e)) {
17487
17491
  return;
17488
17492
  }
17489
17493
  const price = this._private__getPriceFromY(e.clientY);
17490
- if (this._private__isOnLine(e, price)) {
17494
+ if (!this._private__isOnLine(e, price)) {
17495
+ return;
17496
+ }
17497
+ // Track press for click vs drag detection
17498
+ this._private__mouseDownPos = { _internal_x: e.clientX, _internal_y: e.clientY };
17499
+ this._private__mouseDownOnLine = true;
17500
+ // Only start drag if line is draggable
17501
+ if (this._private__options.draggable) {
17491
17502
  this._private__isDragging = true;
17492
17503
  this._private__container.style.cursor = 'ns-resize';
17493
17504
  if (this._private__options.onDragStart) {
17494
17505
  this._private__options.onDragStart(this._private__options.price);
17495
17506
  }
17496
- e.preventDefault();
17497
- e.stopPropagation();
17498
17507
  }
17508
+ e.preventDefault();
17509
+ e.stopPropagation();
17499
17510
  };
17500
17511
  const handleMouseMove = (e) => {
17501
17512
  if (this._private__isDragging) {
@@ -17516,7 +17527,7 @@ class DraggablePriceLine {
17516
17527
  }
17517
17528
  const price = this._private__getPriceFromY(e.clientY);
17518
17529
  if (this._private__isOnLine(e, price)) {
17519
- this._private__container.style.cursor = 'ns-resize';
17530
+ this._private__container.style.cursor = this._private__options.draggable ? 'ns-resize' : 'pointer';
17520
17531
  this._private__setHoverState(true);
17521
17532
  }
17522
17533
  else {
@@ -17526,13 +17537,40 @@ class DraggablePriceLine {
17526
17537
  }
17527
17538
  };
17528
17539
  const handleMouseUp = (e) => {
17529
- if (this._private__isDragging) {
17530
- this._private__isDragging = false;
17540
+ const wasDragging = this._private__isDragging;
17541
+ const downOnLine = this._private__mouseDownOnLine;
17542
+ const downPos = this._private__mouseDownPos;
17543
+ // Reset state regardless of outcome
17544
+ this._private__isDragging = false;
17545
+ this._private__mouseDownOnLine = false;
17546
+ this._private__mouseDownPos = null;
17547
+ if (wasDragging) {
17548
+ // Drag-end path
17531
17549
  this._private__container.style.cursor = 'default';
17532
17550
  this._private__setHoverState(false);
17533
- if (this._private__options.onDragEnd) {
17551
+ const movedFromDown = downPos &&
17552
+ (Math.abs(e.clientX - downPos._internal_x) > CLICK_TOLERANCE_PX ||
17553
+ Math.abs(e.clientY - downPos._internal_y) > CLICK_TOLERANCE_PX);
17554
+ // If barely moved, treat as click instead of drag
17555
+ if (!movedFromDown && this._private__options.onClick) {
17556
+ this._private__options.onClick(this._private__options.price);
17557
+ }
17558
+ else if (this._private__options.onDragEnd) {
17534
17559
  this._private__options.onDragEnd(this._private__options.price);
17535
17560
  }
17561
+ return;
17562
+ }
17563
+ // Pure click path (non-draggable line or draggable that didn't start drag)
17564
+ if (downOnLine && downPos && this._private__options.onClick) {
17565
+ const moved = Math.abs(e.clientX - downPos._internal_x) > CLICK_TOLERANCE_PX ||
17566
+ Math.abs(e.clientY - downPos._internal_y) > CLICK_TOLERANCE_PX;
17567
+ if (!moved) {
17568
+ // Confirm release was still on the line area
17569
+ const price = this._private__getPriceFromY(e.clientY);
17570
+ if (this._private__isOnLine(e, price)) {
17571
+ this._private__options.onClick(this._private__options.price);
17572
+ }
17573
+ }
17536
17574
  }
17537
17575
  };
17538
17576
  const handleMouseLeave = (e) => {
@@ -17546,6 +17584,8 @@ class DraggablePriceLine {
17546
17584
  else {
17547
17585
  this._private__setHoverState(false);
17548
17586
  }
17587
+ this._private__mouseDownOnLine = false;
17588
+ this._private__mouseDownPos = null;
17549
17589
  };
17550
17590
  this._private__container.addEventListener('mousedown', handleMouseDown);
17551
17591
  this._private__container.addEventListener('mousemove', handleMouseMove);
@@ -17790,6 +17830,7 @@ function createTradingLine(series, chart, options) {
17790
17830
  onDragStart: options.onDragStart,
17791
17831
  onDragMove: options.onDragMove,
17792
17832
  onDragEnd: options.onDragEnd,
17833
+ onClick: options.onClick,
17793
17834
  };
17794
17835
  return new DraggablePriceLine(chart, series, lineOptions);
17795
17836
  }
@@ -24860,7 +24901,7 @@ const customSeriesDefaultOptions = {
24860
24901
  * Returns the current version as a string. For example `'1.0.0'`.
24861
24902
  */
24862
24903
  function version() {
24863
- return "1.2.0";
24904
+ return "1.2.1";
24864
24905
  }
24865
24906
 
24866
24907
  export { areaSeries as AreaSeries, ArrowTool, barSeries as BarSeries, baselineSeries as BaselineSeries, BrushTool, candlestickSeries as CandlestickSeries, CircleTool, ColorType, CrosshairMode, DEFAULT_SESSIONS, DraggablePriceLine, DrawingToolsManager, EXTENDED_FIBONACCI_RATIOS, FibonacciCalculator, FibonacciExtensionTool, FibonacciFanTool, FibonacciTool, GanttTool, histogramSeries as HistogramSeries, HorizontalLineTool, InteractiveLineManager, LastPriceAnimationMode, lineSeries as LineSeries, LineStyle, LineType, MismatchDirection, PositionCalculator, PositionMarkersManager, PositionTool, PriceLineSource, PriceScaleMode, RectangleTool, RulerCalculator, RulerTool, STANDARD_FIBONACCI_RATIOS, TextTool, TickMarkType, TrackingModeExitMode, TradingSessionsIndicator, TrendLineTool, VerticalLineTool, VolumeProfileIndicator, applyATR, applyBollingerBands, applyEMA, applyMACD, applyOBV, applyRSI, applySMA, applyStochastic, applyVolume, applyWMA, calculatePipConfig, createArrowTool, createBrushTool, createChart, createChartEx, createCircleTool, createFibonacciExtensionTool, createFibonacciFanTool, createFibonacciTool, createGanttTool, createHorizontalLineTool, createImageWatermark, createInteractiveLineManager, createOptionsChart, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, isBusinessDay, isUTCTimestamp, setOBVVolumeData, setVolumeData, setVolumeProfileData, version };