@forgecharts/sdk 1.5.24 → 1.5.26

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/internal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TextStyle, Application, Container, Graphics, Text, FillGradient, CanvasTextMetrics } from 'pixi.js';
2
- import { forwardRef, useRef, useState, useImperativeHandle, useEffect, useCallback, createContext, useMemo, useContext } from 'react';
2
+ import { forwardRef, useRef, useState, useEffect, useImperativeHandle, useCallback, createContext, useMemo, useContext } from 'react';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import ReactDOM from 'react-dom';
5
5
 
@@ -7941,9 +7941,6 @@ var PixiTradingRenderer = class {
7941
7941
  } else {
7942
7942
  this._lineGfx.moveTo(0, y).lineTo(plotWidth, y).stroke({ color, width: lineCrisp.width, alpha });
7943
7943
  }
7944
- if (isDraggableRole(order.role)) {
7945
- this._drawDragHandle(plotWidth - 26, y, color, alpha);
7946
- }
7947
7944
  const boxY = y - LINE_H / 2;
7948
7945
  const roleStr = orderRoleLabel(order.role);
7949
7946
  const text = roleStr ? `${roleStr} ${order.qty}` : `${order.side.toUpperCase()} ${order.qty}`;
@@ -7952,6 +7949,9 @@ var PixiTradingRenderer = class {
7952
7949
  const pillX = Math.max(0, plotWidth - LABEL_GAP - pillW);
7953
7950
  this._boxGfx.roundRect(pillX, boxY, pillW, LINE_H, PILL_R).fill({ color, alpha });
7954
7951
  labelIdx = this._drawLabel(text, pillX + pillW / 2, y, labelIdx, labelStyle, true);
7952
+ if (isDraggableRole(order.role)) {
7953
+ this._drawPillDragArrows(pillX + pillW / 2, boxY, color, alpha);
7954
+ }
7955
7955
  this._boxGfx.rect(plotWidth, boxY, psWidth, LINE_H).fill({ color, alpha });
7956
7956
  labelIdx = this._drawLabel(order.price.toFixed(2), plotWidth + 4, y, labelIdx, labelStyle);
7957
7957
  if (isDraggableRole(order.role)) {
@@ -8083,12 +8083,19 @@ var PixiTradingRenderer = class {
8083
8083
  * with an up and a down chevron, centred on the line. Signals "drag me
8084
8084
  * vertically" the way TradingView's order-line handles do.
8085
8085
  */
8086
- _drawDragHandle(x, y, color, alpha) {
8087
- const s = 4;
8088
- const gap = 3;
8089
- this._boxGfx.roundRect(x - 8, y - 13, 16, 26, 4).fill({ color, alpha: alpha * 0.18 });
8090
- this._boxGfx.poly([x, y - gap - 2 * s, x + s, y - gap, x - s, y - gap]).fill({ color, alpha });
8091
- this._boxGfx.poly([x, y + gap + 2 * s, x + s, y + gap, x - s, y + gap]).fill({ color, alpha });
8086
+ /**
8087
+ * Up/down chevrons hugging a label pill, marking it draggable.
8088
+ *
8089
+ * Anchored to the pill rather than a fixed x so the affordance stays with
8090
+ * the label wherever it is laid out.
8091
+ */
8092
+ _drawPillDragArrows(cx, boxY, color, alpha) {
8093
+ const s = 3.5;
8094
+ const gap = 2;
8095
+ const upBase = boxY - gap;
8096
+ this._boxGfx.poly([cx, upBase - s * 1.6, cx + s, upBase, cx - s, upBase]).fill({ color, alpha: alpha * 0.9 });
8097
+ const downBase = boxY + LINE_H + gap;
8098
+ this._boxGfx.poly([cx, downBase + s * 1.6, cx + s, downBase, cx - s, downBase]).fill({ color, alpha: alpha * 0.9 });
8092
8099
  }
8093
8100
  /** Draws or reuses a label at the given position and returns the next label index. */
8094
8101
  _drawLabel(text, x, y, labelIdx, style, centered) {
@@ -23078,6 +23085,19 @@ var ChartCanvas = forwardRef(
23078
23085
  );
23079
23086
  const drawOverlayRef = useRef(null);
23080
23087
  const [priceFraction, setPriceFraction] = useState(priceFractionProp ?? 0.6);
23088
+ const [effectiveTheme, setEffectiveTheme] = useState(theme);
23089
+ useEffect(() => {
23090
+ setEffectiveTheme(theme);
23091
+ }, [theme]);
23092
+ useEffect(() => {
23093
+ const chart = chartRef.current;
23094
+ if (!chart) return;
23095
+ const onThemeChanged = ({ theme: t }) => setEffectiveTheme(t);
23096
+ chart.on("themeChanged", onThemeChanged);
23097
+ return () => {
23098
+ chart.off?.("themeChanged", onThemeChanged);
23099
+ };
23100
+ }, [dataBlocked]);
23081
23101
  const selectPointerToolRef = useRef(() => {
23082
23102
  });
23083
23103
  useImperativeHandle(ref, () => ({
@@ -24200,29 +24220,41 @@ var ChartCanvas = forwardRef(
24200
24220
  },
24201
24221
  children: [
24202
24222
  /* @__PURE__ */ jsx(
24203
- "a",
24223
+ "div",
24204
24224
  {
24205
- href: "https://forgecharts.com",
24206
- target: "_blank",
24207
- rel: "noopener noreferrer",
24208
24225
  style: {
24209
24226
  position: "absolute",
24210
24227
  bottom: 38,
24211
24228
  left: 6,
24212
24229
  zIndex: 5,
24213
- lineHeight: 0
24230
+ display: "flex",
24231
+ flexDirection: "column",
24232
+ alignItems: "flex-start",
24233
+ gap: 1,
24234
+ // Never intercept clicks meant for the chart; the logo re-enables
24235
+ // pointer events on itself below.
24236
+ pointerEvents: "none"
24214
24237
  },
24215
24238
  children: /* @__PURE__ */ jsx(
24216
- "img",
24239
+ "a",
24217
24240
  {
24218
- src: theme === "light" ? logo_light_default : logo_dark_default,
24219
- alt: "ForgeCharts",
24220
- style: {
24221
- height: 48,
24222
- width: "auto",
24223
- opacity: 0.55,
24224
- userSelect: "none"
24225
- }
24241
+ href: "https://forgecharts.com",
24242
+ target: "_blank",
24243
+ rel: "noopener noreferrer",
24244
+ style: { lineHeight: 0, pointerEvents: "auto" },
24245
+ children: /* @__PURE__ */ jsx(
24246
+ "img",
24247
+ {
24248
+ src: effectiveTheme === "light" ? logo_light_default : logo_dark_default,
24249
+ alt: "ForgeCharts",
24250
+ style: {
24251
+ height: 48,
24252
+ width: "auto",
24253
+ opacity: 0.55,
24254
+ userSelect: "none"
24255
+ }
24256
+ }
24257
+ )
24226
24258
  }
24227
24259
  )
24228
24260
  }