@pipsend/charts 1.2.0 → 1.2.2

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/dist/typings.d.ts CHANGED
@@ -162,7 +162,7 @@ export declare class CircleTool extends DrawingToolBase {
162
162
  remove(): void;
163
163
  }
164
164
  /**
165
- * Draggable Price Line - Línea de precio que se puede arrastrar con el mouse
165
+ * Draggable Price Line - Línea de precio que se puede arrastrar y/o hacer click
166
166
  */
167
167
  export declare class DraggablePriceLine {
168
168
  private _chart;
@@ -174,9 +174,15 @@ export declare class DraggablePriceLine {
174
174
  private _unsubscribeHandlers;
175
175
  private _isHovering;
176
176
  private _originalColor;
177
+ private _mouseDownPos;
178
+ private _mouseDownOnLine;
177
179
  constructor(chart: IChartApi, series: ISeriesApi<SeriesType>, options: DraggablePriceLineOptions);
180
+ /**
181
+ * Resolve the effective title: formatTitle(price) wins over the static title.
182
+ */
183
+ private _resolveTitle;
178
184
  private _createPriceLine;
179
- private _setupDragHandlers;
185
+ private _setupInteractionHandlers;
180
186
  private _getPriceFromY;
181
187
  /**
182
188
  * Verifica si el mouse está EN la línea (no cerca, sino exactamente sobre ella)
@@ -195,15 +201,21 @@ export declare class DraggablePriceLine {
195
201
  private _setHoverState;
196
202
  private _updatePrice;
197
203
  /**
198
- * Update the price line options
204
+ * Update the price line options. Any subset of options can be passed.
205
+ * Title is recomputed from `formatTitle` if available, otherwise from `title`.
199
206
  */
200
207
  applyOptions(options: Partial<DraggablePriceLineOptions>): void;
208
+ /**
209
+ * Set the title directly. Use this for updates that don't depend on the
210
+ * line's price (e.g. live PnL on a fixed entry line). Bypasses formatTitle.
211
+ */
212
+ setTitle(text: string): void;
201
213
  /**
202
214
  * Get current price
203
215
  */
204
216
  getPrice(): number;
205
217
  /**
206
- * Set price programmatically
218
+ * Set price programmatically. Triggers formatTitle if configured.
207
219
  */
208
220
  setPrice(price: number): void;
209
221
  /**
@@ -2477,6 +2489,23 @@ export interface DraggablePriceLineOptions {
2477
2489
  onDragStart?: (price: number) => void;
2478
2490
  onDragMove?: (price: number) => void;
2479
2491
  onDragEnd?: (price: number) => void;
2492
+ /**
2493
+ * Fires when the user clicks the line without dragging it.
2494
+ * Triggered on mouseup if the mouse moved less than CLICK_TOLERANCE_PX
2495
+ * from the initial mousedown position. Works regardless of `draggable`.
2496
+ */
2497
+ onClick?: (price: number) => void;
2498
+ /**
2499
+ * If provided, the line's title is computed from the current price using
2500
+ * this formatter. Invoked automatically:
2501
+ * - At construction (initial title).
2502
+ * - On every internal price change (drag move, programmatic `setPrice`).
2503
+ * Use this for live PnL previews on draggable SL/TP lines.
2504
+ *
2505
+ * For title updates that are independent of price (e.g. ticking PnL on a
2506
+ * fixed entry line), use `setTitle(text)` instead.
2507
+ */
2508
+ formatTitle?: (price: number) => string;
2480
2509
  }
2481
2510
  /**
2482
2511
  * Context passed to drawing tools
@@ -5957,6 +5986,13 @@ export interface TradingLineOptions {
5957
5986
  onDragStart?: (price: number) => void;
5958
5987
  onDragMove?: (price: number) => void;
5959
5988
  onDragEnd?: (price: number) => void;
5989
+ /** Fires on a click that didn't drag (works for non-draggable lines too). */
5990
+ onClick?: (price: number) => void;
5991
+ /**
5992
+ * Dynamic title computed from the line's current price. Overrides `title`
5993
+ * during drag and on `setPrice()` calls. See `DraggablePriceLineOptions.formatTitle`.
5994
+ */
5995
+ formatTitle?: (price: number) => string;
5960
5996
  }
5961
5997
  /**
5962
5998
  * Representa una posición de trading con punto de entrada y salida opcional
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
- "version": "1.2.0",
2
+ "private": false,
3
+ "version": "1.2.2",
3
4
  "name": "@pipsend/charts",
4
5
  "author": "Pipsend",
5
6
  "license": "SEE LICENSE IN LICENSE",
@@ -53,7 +54,88 @@
53
54
  "bollinger-bands",
54
55
  "financial-analysis"
55
56
  ],
57
+ "engines": {
58
+ "node": ">=22.3"
59
+ },
56
60
  "dependencies": {
57
61
  "fancy-canvas": "2.1.0"
62
+ },
63
+ "devDependencies": {
64
+ "@juggle/resize-observer": "3.4.0",
65
+ "@rollup/plugin-node-resolve": "16.0.1",
66
+ "@rollup/plugin-replace": "6.0.2",
67
+ "@rollup/plugin-terser": "0.4.4",
68
+ "@size-limit/file": "11.2.0",
69
+ "@size-limit/webpack": "11.2.0",
70
+ "@types/chai": "5.2.1",
71
+ "@types/express": "5.0.1",
72
+ "@types/glob": "8.1.0",
73
+ "@types/node": "22",
74
+ "@types/pixelmatch": "5.2.6",
75
+ "@types/pngjs": "6.0.5",
76
+ "@typescript-eslint/eslint-plugin": "7.18.0",
77
+ "@typescript-eslint/eslint-plugin-tslint": "7.0.2",
78
+ "@typescript-eslint/parser": "7.18.0",
79
+ "ajv": "7.2.4",
80
+ "bytes": "3.1.2",
81
+ "chai": "5.2.0",
82
+ "chai-exclude": "3.0.1",
83
+ "cross-env": "7.0.3",
84
+ "dts-bundle-generator": "9.5.1",
85
+ "eslint": "8",
86
+ "eslint-formatter-unix": "8.40.0",
87
+ "eslint-plugin-deprecation": "3.0.0",
88
+ "eslint-plugin-import": "2.31.0",
89
+ "eslint-plugin-unicorn": "56.0.1",
90
+ "esno": "4.8.0",
91
+ "glob": "11.0.1",
92
+ "markdown-it": "14.1.0",
93
+ "markdown-it-anchor": "9.2.0",
94
+ "markdownlint-cli": "0.44.0",
95
+ "npm-run-all": "4.1.5",
96
+ "rimraf": "6.0.1",
97
+ "rollup": "4.40.0",
98
+ "size-limit": "11.2.0",
99
+ "ts-node": "10.9.2",
100
+ "ts-patch": "3.3.0",
101
+ "ts-transformer-properties-rename": "0.17.0",
102
+ "ts-transformer-strip-const-enums": "2.0.0",
103
+ "tslib": "2.8.1",
104
+ "tslint": "6.1.3",
105
+ "tslint-eslint-rules": "5.4.0",
106
+ "tslint-microsoft-contrib": "6.2.0",
107
+ "tsx": "4.19.3",
108
+ "typescript": "5.5.4",
109
+ "yargs": "17.7.2"
110
+ },
111
+ "scripts": {
112
+ "prepare": "node scripts/githooks/install.js || true",
113
+ "clean": "rimraf lib/ dist/",
114
+ "bundle-dts": "dts-bundle-generator --config dts-config.json",
115
+ "tsc": "tspc -p tsconfig.prod.json",
116
+ "tsc-watch": "npm run tsc -- --watch --preserveWatchOutput",
117
+ "tsc-verify": "node -e \"const fs=require('fs');const p='website/scripts/generate-versions-dts.js'; if(fs.existsSync(p)){require('child_process').execSync('node '+p,{stdio:'inherit'});} else {console.warn('[tsc-verify] skip: '+p+' not found');}\" && tsc -b tsconfig.composite.json",
118
+ "lint": "npm-run-all -p lint:**",
119
+ "lint:eslint": "eslint --format=unix ./",
120
+ "lint:md": "markdownlint -i \"**/node_modules/**\" -i \"**/website/docs/api/**\" -i \"**/website/versioned_docs/**/api/**\" -i \"**/*.mdx\" \"**/*.md\"",
121
+ "check-dts-docs": "npm-run-all -p check-dts-docs-duplicates check-dts-docs-eslint",
122
+ "check-dts-docs-duplicates": "node ./scripts/check-typings-for-duplicates.js ./dist/typings.d.ts",
123
+ "check-dts-docs-eslint": "eslint --format=unix ./dist/typings.d.ts --no-ignore",
124
+ "check-markdown-links": "node scripts/check-markdown-links.js",
125
+ "rollup": "rollup -c rollup.config.js",
126
+ "rollup-watch": "npm run rollup -- --watch",
127
+ "build": "npm-run-all tsc rollup bundle-dts",
128
+ "build:watch": "npm-run-all tsc -p tsc-watch rollup-watch",
129
+ "build:prod": "cross-env NODE_ENV=production npm run build",
130
+ "build:release": "cross-env BUILD_TAG=release npm run build:prod",
131
+ "prepare-release": "npm-run-all clean build:release && npm run prepare-package-json-for-release",
132
+ "prepare-package-json-for-release": "node ./scripts/clean-package-json.js",
133
+ "size-limit": "size-limit",
134
+ "verify": "npm-run-all clean -p build:prod check-markdown-links -p lint check-dts-docs tsc-verify test size-limit -p type-tests",
135
+ "test": "esno --import ./tests/unittests/setup.units.mjs --test './tests/unittests/**/*.spec.ts'",
136
+ "type-tests": "tsc -b ./src/tsconfig.composite.json && tsc -p ./tests/type-checks/tsconfig.composite.json --noEmit",
137
+ "e2e:coverage": "esno ./tests/e2e/coverage/runner.ts ./dist/pipsend-charts.standalone.development.js",
138
+ "e2e:interactions": "esno ./tests/e2e/interactions/runner.ts ./dist/pipsend-charts.standalone.development.js",
139
+ "e2e:memleaks": "esno ./tests/e2e/memleaks/runner.ts ./dist/pipsend-charts.standalone.development.js"
58
140
  }
59
141
  }