@pipsend/charts 2.2.0 → 2.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 v2.2.0
3
+ * Pipsend Charts v2.2.1
4
4
  * Copyright (c) 2026 Pipsend
5
5
  * Licensed under MIT License
6
6
  * Built on TradingView Lightweight Charts™ (Apache 2.0)
@@ -20012,6 +20012,9 @@ class DrawingToolBase {
20012
20012
  get type() {
20013
20013
  return this._type;
20014
20014
  }
20015
+ isComplete() {
20016
+ return true;
20017
+ }
20015
20018
  /**
20016
20019
  * Lets a tool hand the base its own options object, once, in the constructor.
20017
20020
  *
@@ -20339,6 +20342,7 @@ class TrendLineTool extends DrawingToolBase {
20339
20342
  this._private__dragStartPoint2 = null;
20340
20343
  // Interactive mode
20341
20344
  this._private__isComplete = false;
20345
+ this._private__interactive = null;
20342
20346
  this._private__previewPoint = null;
20343
20347
  this._private__trendOptions = {
20344
20348
  lineColor: '#2962ff',
@@ -20386,7 +20390,7 @@ class TrendLineTool extends DrawingToolBase {
20386
20390
  this._private__isComplete = true;
20387
20391
  }
20388
20392
  });
20389
- // Start the interactive drawing mode
20393
+ this._private__interactive = manager;
20390
20394
  manager._internal_startDrawing();
20391
20395
  }
20392
20396
  _private__createPrimitive() {
@@ -20716,7 +20720,14 @@ class TrendLineTool extends DrawingToolBase {
20716
20720
  _update() {
20717
20721
  this._private__requestUpdate();
20718
20722
  }
20723
+ isComplete() {
20724
+ return this._private__isComplete;
20725
+ }
20719
20726
  remove() {
20727
+ if (this._private__interactive) {
20728
+ this._private__interactive._internal_destroy();
20729
+ this._private__interactive = null;
20730
+ }
20720
20731
  if (this._private__primitive) {
20721
20732
  // Detach from series
20722
20733
  this._series.detachPrimitive(this._private__primitive);
@@ -21623,6 +21634,9 @@ class PolygonTool extends DrawingToolBase {
21623
21634
  points() {
21624
21635
  return this._private__points;
21625
21636
  }
21637
+ isComplete() {
21638
+ return this._private__isComplete;
21639
+ }
21626
21640
  remove() {
21627
21641
  this._private__stopDrawing();
21628
21642
  if (this._private__primitive) {
@@ -22093,6 +22107,9 @@ class ParallelChannelTool extends DrawingToolBase {
22093
22107
  isHovered() {
22094
22108
  return this._private__isHovered;
22095
22109
  }
22110
+ isComplete() {
22111
+ return this._private__isComplete;
22112
+ }
22096
22113
  remove() {
22097
22114
  this._private__stopDrawing();
22098
22115
  if (this._private__primitive) {
@@ -22557,6 +22574,9 @@ class PitchforkTool extends DrawingToolBase {
22557
22574
  isHovered() {
22558
22575
  return this._private__isHovered;
22559
22576
  }
22577
+ isComplete() {
22578
+ return this._private__isComplete;
22579
+ }
22560
22580
  remove() {
22561
22581
  this._private__stopDrawing();
22562
22582
  if (this._private__primitive) {
@@ -23487,6 +23507,9 @@ class FibonacciTool extends DrawingToolBase {
23487
23507
  }
23488
23508
  return false;
23489
23509
  }
23510
+ isComplete() {
23511
+ return this._private__isComplete;
23512
+ }
23490
23513
  remove() {
23491
23514
  if (this._private__primitive) {
23492
23515
  this._series.detachPrimitive(this._private__primitive);
@@ -24377,6 +24400,9 @@ class FibonacciFanTool extends DrawingToolBase {
24377
24400
  _update() {
24378
24401
  this._private__requestUpdate();
24379
24402
  }
24403
+ isComplete() {
24404
+ return !this._private__isDrawing;
24405
+ }
24380
24406
  remove() {
24381
24407
  if (this._private__clickHandler) {
24382
24408
  this._chart.unsubscribeClick(this._private__clickHandler);
@@ -24920,6 +24946,9 @@ class RectangleTool extends DrawingToolBase {
24920
24946
  _update() {
24921
24947
  this._private__requestUpdate();
24922
24948
  }
24949
+ isComplete() {
24950
+ return !this._private__isDrawing;
24951
+ }
24923
24952
  remove() {
24924
24953
  if (this._private__clickHandler) {
24925
24954
  this._chart.unsubscribeClick(this._private__clickHandler);
@@ -25383,6 +25412,9 @@ class CircleTool extends DrawingToolBase {
25383
25412
  _update() {
25384
25413
  this._private__requestUpdate();
25385
25414
  }
25415
+ isComplete() {
25416
+ return !this._private__isDrawing;
25417
+ }
25386
25418
  remove() {
25387
25419
  if (this._private__clickHandler) {
25388
25420
  this._chart.unsubscribeClick(this._private__clickHandler);
@@ -25925,6 +25957,9 @@ class ArrowTool extends DrawingToolBase {
25925
25957
  _update() {
25926
25958
  this._private__requestUpdate();
25927
25959
  }
25960
+ isComplete() {
25961
+ return !this._private__isDrawing;
25962
+ }
25928
25963
  remove() {
25929
25964
  // Clean up click handler
25930
25965
  if (this._private__clickHandler) {
@@ -26491,7 +26526,7 @@ class TextTool extends DrawingToolBase {
26491
26526
  }
26492
26527
  _private__setupClickOutsideHandler() {
26493
26528
  // Set up click handler to finish editing when clicking outside
26494
- this._private__clickOutsideHandler = this._chart.subscribeClick((param) => {
26529
+ const handler = (param) => {
26495
26530
  if (!this._private__isEditing)
26496
26531
  return;
26497
26532
  // Get click coordinates
@@ -26507,7 +26542,9 @@ class TextTool extends DrawingToolBase {
26507
26542
  this.remove();
26508
26543
  }
26509
26544
  }
26510
- });
26545
+ };
26546
+ this._private__clickOutsideHandler = handler;
26547
+ this._chart.subscribeClick(handler);
26511
26548
  }
26512
26549
  _private__createPrimitive() {
26513
26550
  this._private__paneView = this._private__createPaneView();
@@ -28656,6 +28693,9 @@ class DrawingToolsManager {
28656
28693
  this._private__selectionChanged = new Delegate();
28657
28694
  this._private__isDragging = false;
28658
28695
  this._private__draggedToolId = null;
28696
+ this._private__pendingToolIds = new Set();
28697
+ this._private__completionCheck = null;
28698
+ this._private__drawingCompleted = new Delegate();
28659
28699
  this._private__chart = chart;
28660
28700
  this._private__series = series;
28661
28701
  this._private__options = {
@@ -28694,9 +28734,63 @@ class DrawingToolsManager {
28694
28734
  addTool(tool, id) {
28695
28735
  const toolId = id ?? tool.id;
28696
28736
  this._private__tools.set(toolId, tool);
28737
+ if (!tool.isComplete()) {
28738
+ this._private__pendingToolIds.add(toolId);
28739
+ }
28697
28740
  this.recordChange();
28698
28741
  return toolId;
28699
28742
  }
28743
+ hasPendingDrawing() {
28744
+ return this._private__pendingToolIds.size > 0;
28745
+ }
28746
+ /** Removes every tool still waiting for points; returns how many were dropped. */
28747
+ cancelPendingDrawings() {
28748
+ if (this._private__pendingToolIds.size === 0) {
28749
+ return 0;
28750
+ }
28751
+ let cancelled = 0;
28752
+ for (const id of Array.from(this._private__pendingToolIds)) {
28753
+ const tool = this._private__tools.get(id);
28754
+ if (tool) {
28755
+ if (this._private__selectedToolId === id) {
28756
+ this._private__applySelection(null);
28757
+ }
28758
+ tool.remove();
28759
+ this._private__tools.delete(id);
28760
+ cancelled++;
28761
+ }
28762
+ }
28763
+ this._private__pendingToolIds.clear();
28764
+ if (cancelled > 0) {
28765
+ this.recordChange();
28766
+ }
28767
+ return cancelled;
28768
+ }
28769
+ subscribeDrawingCompleted(handler) {
28770
+ this._private__drawingCompleted._internal_subscribe(handler);
28771
+ }
28772
+ unsubscribeDrawingCompleted(handler) {
28773
+ this._private__drawingCompleted._internal_unsubscribe(handler);
28774
+ }
28775
+ _private__scheduleCompletionCheck() {
28776
+ if (this._private__pendingToolIds.size === 0 || this._private__completionCheck !== null) {
28777
+ return;
28778
+ }
28779
+ this._private__completionCheck = setTimeout(() => {
28780
+ this._private__completionCheck = null;
28781
+ for (const id of Array.from(this._private__pendingToolIds)) {
28782
+ const tool = this._private__tools.get(id);
28783
+ if (!tool) {
28784
+ this._private__pendingToolIds.delete(id);
28785
+ continue;
28786
+ }
28787
+ if (tool.isComplete()) {
28788
+ this._private__pendingToolIds.delete(id);
28789
+ this._private__drawingCompleted._internal_fire(id);
28790
+ }
28791
+ }
28792
+ }, 0);
28793
+ }
28700
28794
  /**
28701
28795
  * Remove a tool by ID
28702
28796
  */
@@ -28708,6 +28802,7 @@ class DrawingToolsManager {
28708
28802
  }
28709
28803
  tool.remove();
28710
28804
  this._private__tools.delete(id);
28805
+ this._private__pendingToolIds.delete(id);
28711
28806
  this.recordChange();
28712
28807
  return true;
28713
28808
  }
@@ -28907,6 +29002,7 @@ class DrawingToolsManager {
28907
29002
  this._private__applySelection(null);
28908
29003
  this._private__tools.forEach((tool) => tool.remove());
28909
29004
  this._private__tools.clear();
29005
+ this._private__pendingToolIds.clear();
28910
29006
  this.recordChange();
28911
29007
  }
28912
29008
  /**
@@ -29127,6 +29223,11 @@ class DrawingToolsManager {
29127
29223
  * Destroy the manager and cleanup
29128
29224
  */
29129
29225
  destroy() {
29226
+ if (this._private__completionCheck !== null) {
29227
+ clearTimeout(this._private__completionCheck);
29228
+ this._private__completionCheck = null;
29229
+ }
29230
+ this._private__drawingCompleted._internal_destroy();
29130
29231
  this.clearAll();
29131
29232
  this._private__detachEventHandlers();
29132
29233
  }
@@ -29146,8 +29247,8 @@ class DrawingToolsManager {
29146
29247
  const chartElement = this._private__chart.chartElement();
29147
29248
  if (chartElement) {
29148
29249
  this._private__pointerDownHandler = (event) => this._private__handlePointerDown(event);
29149
- this._private__pointerUpHandler = (event) => this._private__handlePointerUp();
29150
- this._private__pointerCancelHandler = (event) => this._private__handlePointerUp();
29250
+ this._private__pointerUpHandler = (event) => this._private__handlePointerUp(event);
29251
+ this._private__pointerCancelHandler = (event) => this._private__handlePointerUp(event);
29151
29252
  chartElement.addEventListener('pointerdown', this._private__pointerDownHandler);
29152
29253
  chartElement.addEventListener('pointerup', this._private__pointerUpHandler);
29153
29254
  chartElement.addEventListener('pointercancel', this._private__pointerCancelHandler);
@@ -29190,6 +29291,7 @@ class DrawingToolsManager {
29190
29291
  }
29191
29292
  }
29192
29293
  _private__handleClick(param) {
29294
+ this._private__scheduleCompletionCheck();
29193
29295
  if (!param.point) {
29194
29296
  return;
29195
29297
  }
@@ -29269,6 +29371,9 @@ class DrawingToolsManager {
29269
29371
  return null;
29270
29372
  }
29271
29373
  _private__handlePointerDown(event) {
29374
+ if (this._private__isDragging) {
29375
+ return;
29376
+ }
29272
29377
  // Cleared for every press, then raised only if this one grabs a drawing
29273
29378
  setInputClaim(this._private__chart, false);
29274
29379
  const chartElement = this._private__chart.chartElement();
@@ -29311,10 +29416,13 @@ class DrawingToolsManager {
29311
29416
  // mouse events, and those are what drive the crosshair the drag reads.
29312
29417
  this._private__disableChartInteractions();
29313
29418
  }
29314
- _private__handlePointerUp() {
29419
+ _private__handlePointerUp(event) {
29315
29420
  if (!this._private__isDragging || this._private__draggedToolId === null) {
29316
29421
  return;
29317
29422
  }
29423
+ if (event && this._private__pointerId !== null && event.pointerId !== this._private__pointerId) {
29424
+ return;
29425
+ }
29318
29426
  const tool = this._private__tools.get(this._private__draggedToolId);
29319
29427
  if (tool) {
29320
29428
  tool.stopDrag();
@@ -29372,6 +29480,9 @@ class DrawingToolsManager {
29372
29480
  this._private__pointerId = null;
29373
29481
  }
29374
29482
  _private__disableChartInteractions() {
29483
+ if (this._private__interactionsBeforeDrag !== null) {
29484
+ return;
29485
+ }
29375
29486
  const options = this._private__chart.options();
29376
29487
  this._private__interactionsBeforeDrag = {
29377
29488
  _internal_handleScroll: options.handleScroll,
@@ -29396,6 +29507,14 @@ class DrawingToolsManager {
29396
29507
  });
29397
29508
  }
29398
29509
  _private__handleKeyboard(event) {
29510
+ const target = event.target;
29511
+ const typing = !!target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable);
29512
+ if (typing) {
29513
+ return;
29514
+ }
29515
+ if (event.key === 'Enter') {
29516
+ this._private__scheduleCompletionCheck();
29517
+ }
29399
29518
  // Delete or Backspace to remove selected tool
29400
29519
  if (event.key === 'Delete' || event.key === 'Backspace') {
29401
29520
  if (this.deleteSelected()) {
@@ -29416,8 +29535,8 @@ class DrawingToolsManager {
29416
29535
  }
29417
29536
  return;
29418
29537
  }
29419
- // Escape to deselect
29420
29538
  if (event.key === 'Escape') {
29539
+ this.cancelPendingDrawings();
29421
29540
  this._private__handlePointerUp();
29422
29541
  this._private__deselectAll();
29423
29542
  this.stopDrawing();
@@ -29453,7 +29572,7 @@ const customSeriesDefaultOptions = {
29453
29572
  * Returns the current version as a string. For example `'1.0.0'`.
29454
29573
  */
29455
29574
  function version() {
29456
- return "2.2.0";
29575
+ return "2.2.1";
29457
29576
  }
29458
29577
 
29459
29578
  export { areaSeries as AreaSeries, ArrowTool, barSeries as BarSeries, baselineSeries as BaselineSeries, BrushTool, candlestickSeries as CandlestickSeries, CircleTool, ColorType, CrossLineTool, 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, ParallelChannelTool, PitchforkTool, PolygonTool, PositionCalculator, PositionMarkersManager, PositionTool, PriceLineSource, PriceScaleMode, RectangleTool, RulerCalculator, RulerTool, STANDARD_FIBONACCI_RATIOS, TextTool, TickMarkType, TrackingModeExitMode, TradingSessionsIndicator, TrendLineTool, VerticalLineTool, VolumeProfileIndicator, applyADX, applyATR, applyBollingerBands, applyCCI, applyDonchianChannels, applyEMA, applyHeikinAshi, applyIchimoku, applyKeltnerChannels, applyMACD, applyMFI, applyOBV, applyParabolicSAR, applyPivotPoints, applyRSI, applySMA, applyStochastic, applySuperTrend, applyVWAP, applyVolume, applyWMA, applyWilliamsR, calculateHeikinAshi, calculatePipConfig, coordinateFromTime, createArrowTool, createBrushTool, createChart, createChartEx, createCircleTool, createCrossLineTool, createFibonacciExtensionTool, createFibonacciFanTool, createFibonacciTool, createGanttTool, createHorizontalLineTool, createImageWatermark, createInteractiveLineManager, createOptionsChart, createParallelChannelTool, createPitchforkTool, createPolygonTool, createPositionMarkers, createPositionTool, createRectangleTool, createRulerTool, createSeriesMarkers, createTextTool, createTextWatermark, createTradingLine, createTradingSessionsIndicator, createTrendLineTool, createUpDownMarkers, createVerticalLineTool, createVolumeProfileIndicator, createYieldCurveChart, customSeriesDefaultOptions, defaultHorzScaleBehavior, getPipConfig, hideSeriesPaint, isBusinessDay, isUTCTimestamp, setSeriesVolumes, setVolumeProfileData, timeFromCoordinate, version };