@pradeepjadhav/trading-reload-chart 1.0.3 → 1.0.4

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.
@@ -15,7 +15,7 @@ export declare class FibRetracementShape {
15
15
  converter: ShapeCoordinateConverter;
16
16
  config?: FibRetracementConfig;
17
17
  }): void;
18
- static getHandles(shape: FibRetracementShapeData, converter: ShapeCoordinateConverter, config?: FibRetracementConfig): ShapeHandleHitbox[];
18
+ static getHandles(shape: FibRetracementShapeData, converter: ShapeCoordinateConverter): ShapeHandleHitbox[];
19
19
  static hitTest({ point, shape, converter, tolerance, config, }: {
20
20
  point: ShapePoint;
21
21
  shape: FibRetracementShapeData;
@@ -15,7 +15,7 @@ export declare class LineShape {
15
15
  converter: ShapeCoordinateConverter;
16
16
  config?: CommonShapeConfig;
17
17
  }): void;
18
- static getHandles(shape: TrendlineShape, converter: ShapeCoordinateConverter, config?: CommonShapeConfig): ShapeHandleHitbox[];
18
+ static getHandles(shape: TrendlineShape, converter: ShapeCoordinateConverter): ShapeHandleHitbox[];
19
19
  static hitTest({ point, shape, converter, tolerance, }: {
20
20
  point: ShapePoint;
21
21
  shape: TrendlineShape;
@@ -16,7 +16,7 @@ export declare class PathShape {
16
16
  converter: ShapeCoordinateConverter;
17
17
  config?: CommonShapeConfig;
18
18
  }): void;
19
- static getHandles(shape: PathShapeData, converter: ShapeCoordinateConverter, config?: CommonShapeConfig): ShapeHandleHitbox[];
19
+ static getHandles(shape: PathShapeData, converter: ShapeCoordinateConverter): ShapeHandleHitbox[];
20
20
  static hitTest({ point, shape, converter, tolerance, }: {
21
21
  point: ShapePoint;
22
22
  shape: PathShapeData;
@@ -15,7 +15,7 @@ export declare class RectangleShape {
15
15
  converter: ShapeCoordinateConverter;
16
16
  config?: RectangleShapeConfig;
17
17
  }): void;
18
- static getHandles(shape: RectangleShapeData, converter: ShapeCoordinateConverter, config?: RectangleShapeConfig): ShapeHandleHitbox[];
18
+ static getHandles(shape: RectangleShapeData, converter: ShapeCoordinateConverter): ShapeHandleHitbox[];
19
19
  static hitTest({ point, shape, converter, tolerance, }: {
20
20
  point: ShapePoint;
21
21
  shape: RectangleShapeData;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Fixed visual constants for shape drag handles.
3
+ * These are chart-internal rendering properties and are not user-configurable.
4
+ */
5
+ export declare const SHAPE_HANDLE_CONFIG: {
6
+ readonly handleColor: "#0F0F0F";
7
+ readonly handleBorderColor: "#2962FF";
8
+ readonly handleBorderThickness: 1.5;
9
+ readonly handleRadius: 5;
10
+ };
@@ -15,9 +15,12 @@ export declare class ShapesLayer {
15
15
  handleHitboxes: ShapeHandleHitbox[];
16
16
  private draft;
17
17
  private dragState;
18
+ private lastTapTime;
19
+ private lastTapShapeId;
18
20
  private onShapeAdded?;
19
21
  private onShapeModified?;
20
22
  private onShapeSelected?;
23
+ private onShapeDoubleClicked?;
21
24
  private onToolChange?;
22
25
  constructor(options: ShapesLayerOptions);
23
26
  setCandles(candles: Candle[]): void;
@@ -29,9 +32,17 @@ export declare class ShapesLayer {
29
32
  render(): void;
30
33
  handlePointerEvent(event: PointerEvent | MouseEvent): boolean;
31
34
  handleKeyboardEvent(event: KeyboardEvent): boolean;
35
+ private getArrowKeyDelta;
32
36
  private handlePointerDown;
33
37
  private handlePointerMove;
34
38
  private handlePointerUp;
39
+ private handleDoubleClick;
40
+ /**
41
+ * Tracks touch taps and fires `onShapeDoubleClicked` on a double-tap.
42
+ * Only runs for touch pointer events; mouse/stylus use the `dblclick` DOM
43
+ * event path instead to avoid firing twice.
44
+ */
45
+ private checkTouchDoubleTap;
35
46
  private handleContextMenu;
36
47
  private handleToolPointerDown;
37
48
  private handleTwoPointDraft;
@@ -72,10 +72,6 @@ export type ShapeLineStyle = "solid" | "dashed" | "dotted";
72
72
  * lineColor: "#4ade80",
73
73
  * lineOpacity: 1,
74
74
  * lineStyle: "solid",
75
- * handleColor: "#ffffff",
76
- * handleBorderColor: "#111827",
77
- * handleBorderThickness: 1,
78
- * handleRadius: 4,
79
75
  * };
80
76
  * ```
81
77
  */
@@ -86,12 +82,6 @@ export type CommonShapeConfig = {
86
82
  lineStyle: ShapeLineStyle;
87
83
  fillColor?: string;
88
84
  fillOpacity?: number;
89
- handleColor: string;
90
- handleBorderColor: string;
91
- handleBorderThickness: number;
92
- handleRadius: number;
93
- hoverLineWidth?: number;
94
- selectedLineWidth?: number;
95
85
  };
96
86
  export type RectangleShapeConfig = CommonShapeConfig & {
97
87
  textColor: string;
@@ -112,12 +102,6 @@ export type FibRetracementConfig = {
112
102
  levels: FibLevelConfig[];
113
103
  fillColor?: string;
114
104
  fillOpacity?: number;
115
- handleColor: string;
116
- handleBorderColor: string;
117
- handleBorderThickness: number;
118
- handleRadius: number;
119
- hoverLineWidth: number;
120
- selectedLineWidth: number;
121
105
  };
122
106
  export type PositionShapeConfig = {
123
107
  defaultWidthCandles: number;
@@ -135,12 +119,6 @@ export type PositionShapeConfig = {
135
119
  midLineOpacity: number;
136
120
  midLineWidth: number;
137
121
  midLineStyle: ShapeLineStyle;
138
- handleColor: string;
139
- handleBorderColor: string;
140
- handleBorderThickness: number;
141
- handleRadius: number;
142
- hoverLineWidth: number;
143
- selectedLineWidth: number;
144
122
  };
145
123
  /**
146
124
  * Trendline shape defined by two vertices.
@@ -293,12 +271,12 @@ export type Shape = TrendlineShape | RectangleShapeData | PathShapeData | FibRet
293
271
  * @example
294
272
  * ```ts
295
273
  * const config: ShapeConfig = {
296
- * trendline: { lineWidth: 2, lineColor: "#4ade80", lineOpacity: 1, lineStyle: "solid", handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4 },
297
- * rectangle: { lineWidth: 2, lineColor: "#60a5fa", lineOpacity: 1, lineStyle: "solid", handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4, textColor: "#fff", textOpacity: 1, textFontFamily: "Arial", textFontSize: 12 },
298
- * path: { lineWidth: 2, lineColor: "#f59e0b", lineOpacity: 1, lineStyle: "solid", handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4 },
299
- * fibRetracement: { levels: [], handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4, hoverLineWidth: 3, selectedLineWidth: 3 },
300
- * shortPosition: { defaultWidthCandles: 20, defaultStopLossPercent: 0.25, defaultRiskRewardRatio: 2, profitFillColor: "#16a34a", profitFillOpacity: 0.2, lossFillColor: "#dc2626", lossFillOpacity: 0.2, borderColor: "#fff", borderOpacity: 1, borderWidth: 1, borderStyle: "solid", midLineColor: "#fff", midLineOpacity: 0.8, midLineWidth: 1, midLineStyle: "dashed", handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4, hoverLineWidth: 2, selectedLineWidth: 2 },
301
- * longPosition: { defaultWidthCandles: 20, defaultStopLossPercent: 0.25, defaultRiskRewardRatio: 2, profitFillColor: "#16a34a", profitFillOpacity: 0.2, lossFillColor: "#dc2626", lossFillOpacity: 0.2, borderColor: "#fff", borderOpacity: 1, borderWidth: 1, borderStyle: "solid", midLineColor: "#fff", midLineOpacity: 0.8, midLineWidth: 1, midLineStyle: "dashed", handleColor: "#fff", handleBorderColor: "#111827", handleBorderThickness: 1, handleRadius: 4, hoverLineWidth: 2, selectedLineWidth: 2 },
274
+ * trendline: { lineWidth: 2, lineColor: "#4ade80", lineOpacity: 1, lineStyle: "solid" },
275
+ * rectangle: { lineWidth: 2, lineColor: "#60a5fa", lineOpacity: 1, lineStyle: "solid", textColor: "#fff", textOpacity: 1, textFontFamily: "Arial", textFontSize: 12 },
276
+ * path: { lineWidth: 2, lineColor: "#f59e0b", lineOpacity: 1, lineStyle: "solid" },
277
+ * fibRetracement: { levels: [] },
278
+ * shortPosition: { defaultWidthCandles: 20, defaultStopLossPercent: 0.25, defaultRiskRewardRatio: 2, profitFillColor: "#16a34a", profitFillOpacity: 0.2, lossFillColor: "#dc2626", lossFillOpacity: 0.2, borderColor: "#fff", borderOpacity: 1, borderWidth: 1, borderStyle: "solid", midLineColor: "#fff", midLineOpacity: 0.8, midLineWidth: 1, midLineStyle: "dashed" },
279
+ * longPosition: { defaultWidthCandles: 20, defaultStopLossPercent: 0.25, defaultRiskRewardRatio: 2, profitFillColor: "#16a34a", profitFillOpacity: 0.2, lossFillColor: "#dc2626", lossFillOpacity: 0.2, borderColor: "#fff", borderOpacity: 1, borderWidth: 1, borderStyle: "solid", midLineColor: "#fff", midLineOpacity: 0.8, midLineWidth: 1, midLineStyle: "dashed" },
302
280
  * };
303
281
  * ```
304
282
  */
@@ -462,6 +440,7 @@ export type ShapesLayerOptions = {
462
440
  onShapeAdded?: (payload: ShapeAddedPayload) => void;
463
441
  onShapeModified?: (payload: ShapeModifiedPayload) => void;
464
442
  onShapeSelected?: (payload: ShapeSelectedPayload | null) => void;
443
+ onShapeDoubleClicked?: (payload: ShapeSelectedPayload) => void;
465
444
  onToolChange?: (tool: ShapeToolType | null) => void;
466
445
  };
467
446
  export type InternalDragState = {
@@ -20,12 +20,11 @@ export declare class ShortLongPosition {
20
20
  config?: PositionShapeConfig;
21
21
  }): PositionShapeData;
22
22
  static getGeometry(shape: PositionShapeData, converter: ShapeCoordinateConverter): PositionGeometry;
23
- static getHandles(shape: PositionShapeData, converter: ShapeCoordinateConverter, config?: PositionShapeConfig): ShapeHandleHitbox[];
24
- static hitTest({ point, shape, converter, config, }: {
23
+ static getHandles(shape: PositionShapeData, converter: ShapeCoordinateConverter): ShapeHandleHitbox[];
24
+ static hitTest({ point, shape, converter, }: {
25
25
  point: ShapePoint;
26
26
  shape: PositionShapeData;
27
27
  converter: ShapeCoordinateConverter;
28
- config?: PositionShapeConfig;
29
28
  }): boolean;
30
29
  static move(shape: PositionShapeData, delta: ShapeVertex): PositionShapeData;
31
30
  static resize({ shape, handleType, vertex, converter, }: {
@@ -193,6 +193,18 @@ export type ChartControllerProps = {
193
193
  * ```
194
194
  */
195
195
  onShapeSelected?: (payload: ShapeSelectedPayload | null) => void;
196
+ /**
197
+ * Called when the user double-clicks on a shape.
198
+ *
199
+ * Fires with the same payload as {@link onShapeSelected} but only on a
200
+ * double-click gesture. Does not affect shape selection state.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * onShapeDoubleClicked: (payload) => openShapeEditor(payload.shapeId)
205
+ * ```
206
+ */
207
+ onShapeDoubleClicked?: (payload: ShapeSelectedPayload) => void;
196
208
  /**
197
209
  * Called when the chart wants the parent to change the active drawing tool.
198
210
  *