@sensiblestats/widget-react 0.32.0 → 0.32.1

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,11 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+
3
9
  ## 0.32.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -449,11 +449,15 @@ function toChipVM(intent) {
449
449
  function chipFromText(text) {
450
450
  return { text };
451
451
  }
452
+ function joinSelection(label, line) {
453
+ if (label && line && label.includes(line)) return label;
454
+ return [label, line].filter(Boolean).join(" ") || void 0;
455
+ }
452
456
  function toInsightVM(insight) {
453
457
  const market = str(insight.marketLabel) ?? str(insight.marketDeveloperName) ?? "";
454
458
  const selectionLabel = str(insight.selectionLabel);
455
459
  const selectionLine = str(insight.line);
456
- const selection = (selectionLabel && selectionLine && selectionLabel.includes(selectionLine) ? selectionLabel : [selectionLabel, selectionLine].filter(Boolean).join(" ")) || void 0;
460
+ const selection = joinSelection(selectionLabel, selectionLine);
457
461
  const value = insight.odds?.value;
458
462
  const odds = typeof value === "number" && Number.isFinite(value) ? value.toFixed(2) : void 0;
459
463
  const oddsValue = insight.odds?.value;
@@ -516,7 +520,7 @@ function toSlipSelection(vm, conversationId) {
516
520
  function toMarketOddsVM(card) {
517
521
  const rows = Array.isArray(card.rows) ? card.rows : [];
518
522
  const toRow = (r, i) => {
519
- const selection = [str(r.selectionLabel), str(r.line)].filter(Boolean).join(" ");
523
+ const selection = joinSelection(str(r.selectionLabel), str(r.line)) ?? "";
520
524
  const price = typeof r.price === "number" && Number.isFinite(r.price) ? r.price : void 0;
521
525
  const previous = typeof r.previousPrice === "number" && Number.isFinite(r.previousPrice) ? r.previousPrice : void 0;
522
526
  const direction = r.movementDirection === "shortened" || r.movementDirection === "drifted" ? r.movementDirection : void 0;
@@ -575,7 +579,7 @@ function toOddsMovementVM(card) {
575
579
  const current = asNumber(card.currentPrice);
576
580
  const home = str(card.homeTeamName);
577
581
  const away = str(card.awayTeamName);
578
- const selection = [str(card.selectionLabel), str(card.line)].filter(Boolean).join(" ");
582
+ const selection = joinSelection(str(card.selectionLabel), str(card.line)) ?? "";
579
583
  const bookmakerId = typeof card.bookmakerId === "number" ? card.bookmakerId : "";
580
584
  return {
581
585
  id: `${typeof card.matchId === "number" ? card.matchId : 0}:${str(card.marketDeveloperName) ?? ""}:${selection}:${bookmakerId}`,