acttrader-charts 1.0.7 → 1.0.8

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/README.md CHANGED
@@ -483,6 +483,7 @@ chart.setDrawingTool(tool: DrawingToolType | null): this
483
483
  ```ts
484
484
  chart.setLevels(levels, labelField, priceField, type): this
485
485
  chart.removeLevelByLabel(label: string): this
486
+ chart.cancelCurrentEdit(): this // cancel the active draft order or in-progress level edit; no-op when nothing is active
486
487
  ```
487
488
 
488
489
  ### Trade Button
package/dist/index.cjs CHANGED
@@ -18776,8 +18776,10 @@ var _ChartEngine = class _ChartEngine {
18776
18776
  return this;
18777
18777
  }
18778
18778
  /**
18779
- * Remove the current draft order preview line without emitting any events.
18779
+ * Remove the current draft order preview line and emit `draftCancelled`.
18780
18780
  * Call when the order panel closes or the user switches to market order type.
18781
+ * To cancel whatever is currently being edited or drafted (draft or existing level),
18782
+ * use `cancelCurrentEdit()` instead.
18781
18783
  */
18782
18784
  clearDraftOrder() {
18783
18785
  this.removeDraftOrder();
@@ -18871,6 +18873,22 @@ var _ChartEngine = class _ChartEngine {
18871
18873
  this.renderTradeLayer();
18872
18874
  return this;
18873
18875
  }
18876
+ /**
18877
+ * Cancel whatever is currently being edited or drafted on the chart.
18878
+ * Handles all three cases without the caller needing to track the active label:
18879
+ * - active limit/stop draft (`draftOrderLabel === selectedTradeLabel`) — emits `draftCancelled`
18880
+ * - active market draft (`draftOrderLabel` set, no `selectedTradeLabel`) — emits `draftCancelled`
18881
+ * - in-progress level edit (`selectedTradeLabel` set with pending changes) — reverts staged changes
18882
+ * No-op when nothing is being edited.
18883
+ */
18884
+ cancelCurrentEdit() {
18885
+ if (this.draftOrderLabel) {
18886
+ this.clearDraftOrder();
18887
+ } else if (this.selectedTradeLabel) {
18888
+ this.revertPendingChanges(this.selectedTradeLabel);
18889
+ }
18890
+ return this;
18891
+ }
18874
18892
  /**
18875
18893
  * Programmatically select (activate) a trade level by its label.
18876
18894
  * Pass `null` to deselect the currently active level.