hyperprop-charting-library 0.1.125 → 0.1.127

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.
@@ -303,15 +303,38 @@ var getIndicatorSourceValue = (point, source) => {
303
303
  var clampIndicatorLength = (value, fallback) => {
304
304
  return Math.max(1, Math.round(Number(value) || fallback));
305
305
  };
306
- var isFullyWhiteColor = (value) => {
307
- if (!value) return false;
306
+ var parseColorToRgb = (value) => {
307
+ if (!value) return null;
308
308
  const normalized = value.trim().toLowerCase();
309
- if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
310
- const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
311
- return rgb !== null;
309
+ if (normalized === "white") return { r: 255, g: 255, b: 255 };
310
+ if (normalized === "black") return { r: 0, g: 0, b: 0 };
311
+ const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
312
+ if (hex3) {
313
+ return {
314
+ r: parseInt(hex3[1] + hex3[1], 16),
315
+ g: parseInt(hex3[2] + hex3[2], 16),
316
+ b: parseInt(hex3[3] + hex3[3], 16)
317
+ };
318
+ }
319
+ const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
320
+ if (hex) {
321
+ return {
322
+ r: parseInt(hex[1], 16),
323
+ g: parseInt(hex[2], 16),
324
+ b: parseInt(hex[3], 16)
325
+ };
326
+ }
327
+ const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
328
+ if (rgb) {
329
+ return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
330
+ }
331
+ return null;
312
332
  };
313
333
  var labelTextColorOn = (background, textColor) => {
314
- return isFullyWhiteColor(background) ? "#000000" : textColor;
334
+ const rgb = parseColorToRgb(background);
335
+ if (!rgb) return textColor;
336
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
337
+ return luminance >= 0.62 ? "#000000" : textColor;
315
338
  };
316
339
  var computeSmaSeries = (data, length, source) => {
317
340
  const result = new Array(data.length).fill(null);
@@ -5705,6 +5728,9 @@ function createChart(element, options = {}) {
5705
5728
  return;
5706
5729
  }
5707
5730
  const point = getCanvasPoint(event);
5731
+ if (getCrosshairPriceActionRegion(point.x, point.y) || getOrderActionRegion(point.x, point.y)) {
5732
+ return;
5733
+ }
5708
5734
  const region = getHitRegion(point.x, point.y);
5709
5735
  if (region === "outside") {
5710
5736
  return;
@@ -277,15 +277,38 @@ var getIndicatorSourceValue = (point, source) => {
277
277
  var clampIndicatorLength = (value, fallback) => {
278
278
  return Math.max(1, Math.round(Number(value) || fallback));
279
279
  };
280
- var isFullyWhiteColor = (value) => {
281
- if (!value) return false;
280
+ var parseColorToRgb = (value) => {
281
+ if (!value) return null;
282
282
  const normalized = value.trim().toLowerCase();
283
- if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
284
- const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
285
- return rgb !== null;
283
+ if (normalized === "white") return { r: 255, g: 255, b: 255 };
284
+ if (normalized === "black") return { r: 0, g: 0, b: 0 };
285
+ const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
286
+ if (hex3) {
287
+ return {
288
+ r: parseInt(hex3[1] + hex3[1], 16),
289
+ g: parseInt(hex3[2] + hex3[2], 16),
290
+ b: parseInt(hex3[3] + hex3[3], 16)
291
+ };
292
+ }
293
+ const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
294
+ if (hex) {
295
+ return {
296
+ r: parseInt(hex[1], 16),
297
+ g: parseInt(hex[2], 16),
298
+ b: parseInt(hex[3], 16)
299
+ };
300
+ }
301
+ const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
302
+ if (rgb) {
303
+ return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
304
+ }
305
+ return null;
286
306
  };
287
307
  var labelTextColorOn = (background, textColor) => {
288
- return isFullyWhiteColor(background) ? "#000000" : textColor;
308
+ const rgb = parseColorToRgb(background);
309
+ if (!rgb) return textColor;
310
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
311
+ return luminance >= 0.62 ? "#000000" : textColor;
289
312
  };
290
313
  var computeSmaSeries = (data, length, source) => {
291
314
  const result = new Array(data.length).fill(null);
@@ -5679,6 +5702,9 @@ function createChart(element, options = {}) {
5679
5702
  return;
5680
5703
  }
5681
5704
  const point = getCanvasPoint(event);
5705
+ if (getCrosshairPriceActionRegion(point.x, point.y) || getOrderActionRegion(point.x, point.y)) {
5706
+ return;
5707
+ }
5682
5708
  const region = getHitRegion(point.x, point.y);
5683
5709
  if (region === "outside") {
5684
5710
  return;
package/dist/index.cjs CHANGED
@@ -303,15 +303,38 @@ var getIndicatorSourceValue = (point, source) => {
303
303
  var clampIndicatorLength = (value, fallback) => {
304
304
  return Math.max(1, Math.round(Number(value) || fallback));
305
305
  };
306
- var isFullyWhiteColor = (value) => {
307
- if (!value) return false;
306
+ var parseColorToRgb = (value) => {
307
+ if (!value) return null;
308
308
  const normalized = value.trim().toLowerCase();
309
- if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
310
- const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
311
- return rgb !== null;
309
+ if (normalized === "white") return { r: 255, g: 255, b: 255 };
310
+ if (normalized === "black") return { r: 0, g: 0, b: 0 };
311
+ const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
312
+ if (hex3) {
313
+ return {
314
+ r: parseInt(hex3[1] + hex3[1], 16),
315
+ g: parseInt(hex3[2] + hex3[2], 16),
316
+ b: parseInt(hex3[3] + hex3[3], 16)
317
+ };
318
+ }
319
+ const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
320
+ if (hex) {
321
+ return {
322
+ r: parseInt(hex[1], 16),
323
+ g: parseInt(hex[2], 16),
324
+ b: parseInt(hex[3], 16)
325
+ };
326
+ }
327
+ const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
328
+ if (rgb) {
329
+ return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
330
+ }
331
+ return null;
312
332
  };
313
333
  var labelTextColorOn = (background, textColor) => {
314
- return isFullyWhiteColor(background) ? "#000000" : textColor;
334
+ const rgb = parseColorToRgb(background);
335
+ if (!rgb) return textColor;
336
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
337
+ return luminance >= 0.62 ? "#000000" : textColor;
315
338
  };
316
339
  var computeSmaSeries = (data, length, source) => {
317
340
  const result = new Array(data.length).fill(null);
@@ -5705,6 +5728,9 @@ function createChart(element, options = {}) {
5705
5728
  return;
5706
5729
  }
5707
5730
  const point = getCanvasPoint(event);
5731
+ if (getCrosshairPriceActionRegion(point.x, point.y) || getOrderActionRegion(point.x, point.y)) {
5732
+ return;
5733
+ }
5708
5734
  const region = getHitRegion(point.x, point.y);
5709
5735
  if (region === "outside") {
5710
5736
  return;
package/dist/index.js CHANGED
@@ -277,15 +277,38 @@ var getIndicatorSourceValue = (point, source) => {
277
277
  var clampIndicatorLength = (value, fallback) => {
278
278
  return Math.max(1, Math.round(Number(value) || fallback));
279
279
  };
280
- var isFullyWhiteColor = (value) => {
281
- if (!value) return false;
280
+ var parseColorToRgb = (value) => {
281
+ if (!value) return null;
282
282
  const normalized = value.trim().toLowerCase();
283
- if (normalized === "white" || normalized === "#fff" || normalized === "#ffffff") return true;
284
- const rgb = /^rgba?\(\s*255\s*,\s*255\s*,\s*255\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
285
- return rgb !== null;
283
+ if (normalized === "white") return { r: 255, g: 255, b: 255 };
284
+ if (normalized === "black") return { r: 0, g: 0, b: 0 };
285
+ const hex3 = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(normalized);
286
+ if (hex3) {
287
+ return {
288
+ r: parseInt(hex3[1] + hex3[1], 16),
289
+ g: parseInt(hex3[2] + hex3[2], 16),
290
+ b: parseInt(hex3[3] + hex3[3], 16)
291
+ };
292
+ }
293
+ const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/.exec(normalized);
294
+ if (hex) {
295
+ return {
296
+ r: parseInt(hex[1], 16),
297
+ g: parseInt(hex[2], 16),
298
+ b: parseInt(hex[3], 16)
299
+ };
300
+ }
301
+ const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/.exec(normalized);
302
+ if (rgb) {
303
+ return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]) };
304
+ }
305
+ return null;
286
306
  };
287
307
  var labelTextColorOn = (background, textColor) => {
288
- return isFullyWhiteColor(background) ? "#000000" : textColor;
308
+ const rgb = parseColorToRgb(background);
309
+ if (!rgb) return textColor;
310
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
311
+ return luminance >= 0.62 ? "#000000" : textColor;
289
312
  };
290
313
  var computeSmaSeries = (data, length, source) => {
291
314
  const result = new Array(data.length).fill(null);
@@ -5679,6 +5702,9 @@ function createChart(element, options = {}) {
5679
5702
  return;
5680
5703
  }
5681
5704
  const point = getCanvasPoint(event);
5705
+ if (getCrosshairPriceActionRegion(point.x, point.y) || getOrderActionRegion(point.x, point.y)) {
5706
+ return;
5707
+ }
5682
5708
  const region = getHitRegion(point.x, point.y);
5683
5709
  if (region === "outside") {
5684
5710
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperprop-charting-library",
3
- "version": "0.1.125",
3
+ "version": "0.1.127",
4
4
  "description": "Lightweight TypeScript charting core",
5
5
  "type": "module",
6
6
  "main": "./dist/hyperprop-charting-library.cjs",