@sensiblestats/widget-react 0.32.0 → 0.33.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.33.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Live monitor's momentum block gets a localized "Momentum" title with the home/away pressure split (styled like the card's other stat rows), and its end-of-series marker is now an HTML overlay dot instead of an SVG `<circle>` -- the wave's `preserveAspectRatio="none"` scaling was stretching the circle into a squashed, half-clipped oval. `LiveMonitorMatch` gains an additive `momentumHomePct` field.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @sensiblestats/widget-sdk@0.29.0
13
+
14
+ ## 0.32.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Fix market-odds and odds-movement rows doubling the line for localized selections that already embed it (e.g. TR "2.5 Üst" rendering as "2.5 Üst 2.5"). Extracts the dedupe guard already used by betting-insight cards into a shared helper so all three selection/line join sites stay in sync.
19
+
3
20
  ## 0.32.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -119,7 +119,8 @@ var STRINGS = {
119
119
  suspendedLabel: "Suspended",
120
120
  fullTimeLabel: "Full time",
121
121
  inSlipLabel: "In slip",
122
- oddsUnavailable: "Odds unavailable right now"
122
+ oddsUnavailable: "Odds unavailable right now",
123
+ momentumLabel: "Momentum"
123
124
  },
124
125
  tr: {
125
126
  launcherLabel: "SensibleStats ile sohbet et",
@@ -187,7 +188,8 @@ var STRINGS = {
187
188
  suspendedLabel: "Ask\u0131da",
188
189
  fullTimeLabel: "Ma\xE7 sonu",
189
190
  inSlipLabel: "Kuponda",
190
- oddsUnavailable: "Oranlar \u015Fu anda kullan\u0131lam\u0131yor"
191
+ oddsUnavailable: "Oranlar \u015Fu anda kullan\u0131lam\u0131yor",
192
+ momentumLabel: "Momentum"
191
193
  }
192
194
  };
193
195
  function resolveLocaleStrings(locale) {
@@ -268,7 +270,8 @@ function normalizeUi(cfg) {
268
270
  suspendedLabel: strings.suspendedLabel,
269
271
  fullTimeLabel: strings.fullTimeLabel,
270
272
  inSlipLabel: strings.inSlipLabel,
271
- oddsUnavailable: strings.oddsUnavailable
273
+ oddsUnavailable: strings.oddsUnavailable,
274
+ momentumLabel: strings.momentumLabel
272
275
  };
273
276
  }
274
277
  function toClientOptions(cfg) {
@@ -449,11 +452,15 @@ function toChipVM(intent) {
449
452
  function chipFromText(text) {
450
453
  return { text };
451
454
  }
455
+ function joinSelection(label, line) {
456
+ if (label && line && label.includes(line)) return label;
457
+ return [label, line].filter(Boolean).join(" ") || void 0;
458
+ }
452
459
  function toInsightVM(insight) {
453
460
  const market = str(insight.marketLabel) ?? str(insight.marketDeveloperName) ?? "";
454
461
  const selectionLabel = str(insight.selectionLabel);
455
462
  const selectionLine = str(insight.line);
456
- const selection = (selectionLabel && selectionLine && selectionLabel.includes(selectionLine) ? selectionLabel : [selectionLabel, selectionLine].filter(Boolean).join(" ")) || void 0;
463
+ const selection = joinSelection(selectionLabel, selectionLine);
457
464
  const value = insight.odds?.value;
458
465
  const odds = typeof value === "number" && Number.isFinite(value) ? value.toFixed(2) : void 0;
459
466
  const oddsValue = insight.odds?.value;
@@ -516,7 +523,7 @@ function toSlipSelection(vm, conversationId) {
516
523
  function toMarketOddsVM(card) {
517
524
  const rows = Array.isArray(card.rows) ? card.rows : [];
518
525
  const toRow = (r, i) => {
519
- const selection = [str(r.selectionLabel), str(r.line)].filter(Boolean).join(" ");
526
+ const selection = joinSelection(str(r.selectionLabel), str(r.line)) ?? "";
520
527
  const price = typeof r.price === "number" && Number.isFinite(r.price) ? r.price : void 0;
521
528
  const previous = typeof r.previousPrice === "number" && Number.isFinite(r.previousPrice) ? r.previousPrice : void 0;
522
529
  const direction = r.movementDirection === "shortened" || r.movementDirection === "drifted" ? r.movementDirection : void 0;
@@ -575,7 +582,7 @@ function toOddsMovementVM(card) {
575
582
  const current = asNumber(card.currentPrice);
576
583
  const home = str(card.homeTeamName);
577
584
  const away = str(card.awayTeamName);
578
- const selection = [str(card.selectionLabel), str(card.line)].filter(Boolean).join(" ");
585
+ const selection = joinSelection(str(card.selectionLabel), str(card.line)) ?? "";
579
586
  const bookmakerId = typeof card.bookmakerId === "number" ? card.bookmakerId : "";
580
587
  return {
581
588
  id: `${typeof card.matchId === "number" ? card.matchId : 0}:${str(card.marketDeveloperName) ?? ""}:${selection}:${bookmakerId}`,
@@ -2507,7 +2514,8 @@ function buildPaths(points) {
2507
2514
  const area = `M0,${BASELINE} L${linePts.join(" L")} L${WIDTH},${BASELINE} Z`;
2508
2515
  const line = `M${linePts.join(" L")}`;
2509
2516
  const lastValue = points[lastIndex]?.value ?? 0;
2510
- return { area, line, lastX: px(lastIndex).toFixed(1), lastY: py(lastValue).toFixed(1) };
2517
+ const lastLeftPct = lastIndex === 0 ? 0 : 100;
2518
+ return { area, line, lastLeftPct, lastTopPx: py(lastValue) };
2511
2519
  }
2512
2520
  function MomentumWave({
2513
2521
  points,
@@ -2515,7 +2523,7 @@ function MomentumWave({
2515
2523
  clubIsHome
2516
2524
  }) {
2517
2525
  if (points.length === 0) return null;
2518
- const { area, line, lastX, lastY } = buildPaths(points);
2526
+ const { area, line, lastLeftPct, lastTopPx } = buildPaths(points);
2519
2527
  const clipId = (0, import_react17.useId)();
2520
2528
  const topClipId = `${clipId}-top`;
2521
2529
  const bottomClipId = `${clipId}-bottom`;
@@ -2523,27 +2531,36 @@ function MomentumWave({
2523
2531
  const bottomClass = clubIsHome ? "ss-w-fandash-live-mom-away" : "ss-w-fandash-live-mom-home";
2524
2532
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "ss-w-fandash-live-mom", children: [
2525
2533
  caption ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "ss-w-fandash-live-mom-caption", children: caption }) : null,
2526
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2527
- "svg",
2528
- {
2529
- className: "ss-w-fandash-live-mom-svg",
2530
- viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
2531
- preserveAspectRatio: "none",
2532
- role: "img",
2533
- "aria-label": caption ?? "Momentum",
2534
- children: [
2535
- /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("defs", { children: [
2536
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("clipPath", { id: topClipId, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("rect", { x: 0, y: 0, width: WIDTH, height: BASELINE }) }),
2537
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("clipPath", { id: bottomClipId, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("rect", { x: 0, y: BASELINE, width: WIDTH, height: HEIGHT - BASELINE }) })
2538
- ] }),
2539
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: area, className: topClass, clipPath: `url(#${topClipId})` }),
2540
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: area, className: bottomClass, clipPath: `url(#${bottomClipId})` }),
2541
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("line", { x1: 0, y1: BASELINE, x2: WIDTH, y2: BASELINE, className: "ss-w-fandash-live-mom-base" }),
2542
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: line, className: "ss-w-fandash-live-mom-line", vectorEffect: "non-scaling-stroke" }),
2543
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("circle", { cx: lastX, cy: lastY, r: 3.2, className: "ss-w-fandash-live-mom-now", vectorEffect: "non-scaling-stroke" })
2544
- ]
2545
- }
2546
- )
2534
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "ss-w-fandash-live-mom-plot", children: [
2535
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
2536
+ "svg",
2537
+ {
2538
+ className: "ss-w-fandash-live-mom-svg",
2539
+ viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
2540
+ preserveAspectRatio: "none",
2541
+ role: "img",
2542
+ "aria-label": caption ?? "Momentum",
2543
+ children: [
2544
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("defs", { children: [
2545
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("clipPath", { id: topClipId, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("rect", { x: 0, y: 0, width: WIDTH, height: BASELINE }) }),
2546
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("clipPath", { id: bottomClipId, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("rect", { x: 0, y: BASELINE, width: WIDTH, height: HEIGHT - BASELINE }) })
2547
+ ] }),
2548
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: area, className: topClass, clipPath: `url(#${topClipId})` }),
2549
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: area, className: bottomClass, clipPath: `url(#${bottomClipId})` }),
2550
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("line", { x1: 0, y1: BASELINE, x2: WIDTH, y2: BASELINE, className: "ss-w-fandash-live-mom-base" }),
2551
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: line, className: "ss-w-fandash-live-mom-line", vectorEffect: "non-scaling-stroke" })
2552
+ ]
2553
+ }
2554
+ ),
2555
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2556
+ "span",
2557
+ {
2558
+ className: "ss-w-fandash-live-mom-now",
2559
+ style: { left: `clamp(4px, ${lastLeftPct}%, calc(100% - 4px))`, top: `${lastTopPx}px` },
2560
+ "aria-hidden": "true"
2561
+ }
2562
+ )
2563
+ ] })
2547
2564
  ] });
2548
2565
  }
2549
2566
 
@@ -2913,7 +2930,14 @@ function MonitorMatchCard({ match, promotedPins, monitor, ui, slip }) {
2913
2930
  ] }, row.label);
2914
2931
  }) }),
2915
2932
  match.status === "stale" && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "ss-w-mon-asof", children: ui.asOf(formatTime(match.asOfUtc)) }),
2916
- match.momentum.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(MomentumWave, { points: match.momentum, clubIsHome: true }),
2933
+ match.momentum.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "ss-w-mon-mom", children: [
2934
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "ss-w-mon-stat-row", children: [
2935
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "ss-w-mon-stat-v ss-w-mon-stat-v--home", children: typeof match.momentumHomePct === "number" ? `${match.momentumHomePct}%` : "" }),
2936
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "ss-w-mon-stat-l", children: ui.momentumLabel }),
2937
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "ss-w-mon-stat-v ss-w-mon-stat-v--away", children: typeof match.momentumHomePct === "number" ? `${100 - match.momentumHomePct}%` : "" })
2938
+ ] }),
2939
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(MomentumWave, { points: match.momentum, clubIsHome: true })
2940
+ ] }),
2917
2941
  match.mainMarket && match.phase !== "fullTime" && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(MarketOddsCardList, { cards: [toMarketOddsVM(match.mainMarket)], ui, slip }),
2918
2942
  match.phase === "fullTime" && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "ss-w-mon-grace", children: ui.graceNote })
2919
2943
  ] });
@@ -3718,7 +3742,15 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
3718
3742
  .ss-w-fandash-live-mom-away { fill: var(--ss-w-away); fill-opacity: .85; }
3719
3743
  .ss-w-fandash-live-mom-line { fill: none; stroke: color-mix(in srgb, var(--ss-w-ink) 55%, transparent); stroke-width: 1.5; }
3720
3744
  .ss-w-fandash-live-mom-base { stroke: var(--ss-w-line); stroke-width: 1; stroke-dasharray: 3 3; }
3721
- .ss-w-fandash-live-mom-now { fill: var(--ss-w-panel); stroke: var(--ss-w-ink); stroke-width: 1.5; }
3745
+ .ss-w-fandash-live-mom-plot { position: relative; }
3746
+ .ss-w-fandash-live-mom-now {
3747
+ position: absolute; width: 7px; height: 7px; border-radius: 50%;
3748
+ transform: translate(-50%, -50%);
3749
+ background: var(--ss-w-panel); border: 1.5px solid var(--ss-w-ink);
3750
+ pointer-events: none;
3751
+ }
3752
+ .ss-w-mon-mom { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--ss-w-line); }
3753
+ .ss-w-mon-mom .ss-w-fandash-live-mom { margin-top: 6px; padding-top: 0; border-top: none; }
3722
3754
 
3723
3755
  .ss-w-fandash-live-legend { display: flex; gap: 14px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--ss-w-line); font-size: 11px; color: var(--ss-w-faint); }
3724
3756
  .ss-w-fandash-live-legend-item { display: inline-flex; align-items: center; gap: 6px; }