@sensiblestats/widget-react 0.140.0 → 0.141.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/dist/index.js CHANGED
@@ -284,6 +284,8 @@ var BUNDLED_EN_GB = {
284
284
  "widget.presets.moreMatches": "More matches",
285
285
  "widget.presets.changeCombo": "Change total or matches",
286
286
  "widget.presets.standoutAsk": "Standout matches today",
287
+ "widget.presets.legFactOver": "Went over in {hits} of the last {games} games",
288
+ "widget.presets.legFactUnder": "Went under in {hits} of the last {games} games",
287
289
  "widget.nba.with": "With",
288
290
  "widget.nba.without": "Without",
289
291
  "widget.nba.line": "Line",
@@ -1121,6 +1123,8 @@ var ROW_LEAVES = {
1121
1123
  v8Hits: (c) => (hits, window2) => c.t("widget.v8Hits", { hits, window: window2 }),
1122
1124
  "presets.comboDisplay": (c) => (legs, total) => c.t("widget.presets.comboDisplay", { legs, total }),
1123
1125
  "presets.comboMessage": (c) => (legs, total) => c.t("widget.presets.comboMessage", { legs, total }),
1126
+ "presets.legFactOver": (c) => (hits, games) => c.t("widget.presets.legFactOver", { hits, games }),
1127
+ "presets.legFactUnder": (c) => (hits, games) => c.t("widget.presets.legFactUnder", { hits, games }),
1124
1128
  "nba.over": (c) => (line) => c.t("widget.nba.over", { line }),
1125
1129
  "nba.under": (c) => (line) => c.t("widget.nba.under", { line }),
1126
1130
  "nba.lastN": (c) => (n) => c.t("widget.nba.lastN", { count: n }),
@@ -1299,7 +1303,7 @@ function parseOddsFormat(value) {
1299
1303
  }
1300
1304
 
1301
1305
  // src/version.generated.ts
1302
- var WIDGET_REACT_VERSION = "0.140.0";
1306
+ var WIDGET_REACT_VERSION = "0.141.0";
1303
1307
 
1304
1308
  // src/config.ts
1305
1309
  function hostTag(cfg) {
@@ -2142,6 +2146,9 @@ function toComboLegVM(leg) {
2142
2146
  const hasStat = !!insightId && !!statText;
2143
2147
  if (price === void 0 || matchOddsId === void 0 || matchId === void 0 || !home || !away || !selectionLabel) return null;
2144
2148
  const line = str(leg.line);
2149
+ const rawFact = leg.fact && typeof leg.fact === "object" ? leg.fact : void 0;
2150
+ const direction2 = leg.direction === "over" || leg.direction === "under" ? leg.direction : void 0;
2151
+ const fact = rawFact && direction2 && Number.isInteger(rawFact.hits) && Number.isInteger(rawFact.games) && Number.isInteger(rawFact.window) && rawFact.games >= 5 && rawFact.hits >= 0 && rawFact.hits <= rawFact.games && rawFact.games <= rawFact.window ? { hits: rawFact.hits, games: rawFact.games, window: rawFact.window, direction: direction2 } : void 0;
2145
2152
  return {
2146
2153
  key: `${matchOddsId}`,
2147
2154
  matchId,
@@ -2162,6 +2169,7 @@ function toComboLegVM(leg) {
2162
2169
  matchOddsId,
2163
2170
  quotedAtUtc: str(leg.quotedAtUtc),
2164
2171
  ...hasStat ? { insightId, statText } : {},
2172
+ ...fact ? { fact } : {},
2165
2173
  pinEnabled: leg.pinEnabled === true
2166
2174
  };
2167
2175
  }
@@ -8352,6 +8360,8 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed })
8352
8360
  const kickoff = leg.kickoffLabel ?? (kickoffFallback ? `${kickoffFallback.dayLabel} ${kickoffFallback.time}` : void 0);
8353
8361
  const selection = addToSlipEnabled ? comboLegToSlipSelection(leg, slip.conversationId) : null;
8354
8362
  const showPin = !!monitor && leg.pinEnabled;
8363
+ const factText = leg.fact ? (leg.fact.direction === "over" ? ui.presets.legFactOver : ui.presets.legFactUnder)(leg.fact.hits, leg.fact.games) : void 0;
8364
+ const line = leg.statText ?? factText;
8355
8365
  return /* @__PURE__ */ jsxs32("li", { className: "ss-w-combo-leg", children: [
8356
8366
  leg.competition || kickoff || showPin ? /* @__PURE__ */ jsxs32("div", { className: "ss-w-combo-leg-meta", children: [
8357
8367
  /* @__PURE__ */ jsx37("span", { className: "ss-w-bi-comp", children: leg.competition ?? "" }),
@@ -8387,7 +8397,7 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor, hold, closed })
8387
8397
  }
8388
8398
  )
8389
8399
  ] }),
8390
- leg.statText ? /* @__PURE__ */ jsx37("p", { className: "ss-w-combo-leg-stat", children: leg.statText }) : null
8400
+ line ? /* @__PURE__ */ jsx37("p", { className: "ss-w-combo-leg-stat", children: line }) : null
8391
8401
  ] });
8392
8402
  }
8393
8403
  function ComboCardView({ vm, ui, slip, monitor }) {
@@ -10852,7 +10862,8 @@ var ChatInput = forwardRef(function ChatInput2({ placeholder, streaming, onSend,
10852
10862
  // src/components/TabBar.tsx
10853
10863
  import { useEffect as useEffect37, useLayoutEffect, useRef as useRef30 } from "react";
10854
10864
  import { jsx as jsx70, jsxs as jsxs64 } from "react/jsx-runtime";
10855
- var TIGHT_LEVELS = [0, 1, 2, 3, 4, 5, 6];
10865
+ var TIGHT_LEVELS = [0, 1, 2, 3, 4, 5, 6, 7];
10866
+ var FOCUS_EDGE = 24;
10856
10867
  function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule, hasBuilder = false, gamesEnabled, clubEnabled }) {
10857
10868
  const tabs = [
10858
10869
  { tab: "chat", label: ui.tabChat, count: 0, dot: monitor.chatDot },
@@ -10885,11 +10896,15 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
10885
10896
  const strip = listRef.current;
10886
10897
  if (!strip) return;
10887
10898
  const measure = () => {
10899
+ strip.removeAttribute("data-scroll");
10888
10900
  for (const tight of TIGHT_LEVELS) {
10889
10901
  if (tight === 0) strip.removeAttribute("data-tight");
10890
10902
  else strip.setAttribute("data-tight", String(tight));
10891
10903
  if (strip.scrollWidth <= strip.clientWidth) return;
10892
10904
  }
10905
+ strip.setAttribute("data-scroll", "");
10906
+ const on = strip.querySelector("[data-on]");
10907
+ if (on) strip.scrollLeft = Math.max(0, on.offsetLeft - 16);
10893
10908
  };
10894
10909
  measure();
10895
10910
  const fonts = typeof document !== "undefined" ? document.fonts : void 0;
@@ -10901,31 +10916,63 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
10901
10916
  fonts?.removeEventListener?.("loadingdone", measure);
10902
10917
  };
10903
10918
  }, [labelSignature]);
10919
+ const pointerDown = useRef30(false);
10920
+ const keepFocusedTabInView = (e) => {
10921
+ const strip = e.currentTarget;
10922
+ const tab = e.target;
10923
+ if (pointerDown.current) {
10924
+ pointerDown.current = false;
10925
+ return;
10926
+ }
10927
+ if (!strip.hasAttribute("data-scroll") || !(tab instanceof HTMLElement) || tab === strip) return;
10928
+ const left = tab.offsetLeft - FOCUS_EDGE;
10929
+ const right = tab.offsetLeft + tab.offsetWidth + FOCUS_EDGE - strip.clientWidth;
10930
+ if (strip.scrollLeft > left) strip.scrollLeft = Math.max(0, left);
10931
+ else if (strip.scrollLeft < right) strip.scrollLeft = right;
10932
+ };
10904
10933
  if (tabs.length < 2) return null;
10905
- return /* @__PURE__ */ jsx70("div", { className: "ss-w-tabs", role: "tablist", ref: listRef, children: tabs.map(({ tab, label, count: count2, dot }) => {
10906
- const active = monitor.activeTab === tab;
10907
- return /* @__PURE__ */ jsxs64(
10908
- "button",
10909
- {
10910
- type: "button",
10911
- role: "tab",
10912
- "aria-selected": active,
10913
- "data-on": active ? "" : void 0,
10914
- "aria-label": tab === "live" && count2 > 0 ? `${label} \xB7 ${ui.liveCountLabel(count2)}` : void 0,
10915
- className: "ss-w-tab",
10916
- onClick: () => {
10917
- if (tab !== monitor.activeTab) track({ name: "tab_change", from: monitor.activeTab, to: tab });
10918
- monitor.setActiveTab(tab);
10919
- },
10920
- children: [
10921
- label,
10922
- count2 > 0 && /* @__PURE__ */ jsx70("span", { className: "ss-w-tab-count", "aria-hidden": tab === "live" ? true : void 0, children: count2 }),
10923
- dot && !active && /* @__PURE__ */ jsx70("span", { className: "ss-w-tab-dot", "aria-hidden": "true" })
10924
- ]
10934
+ return /* @__PURE__ */ jsx70(
10935
+ "div",
10936
+ {
10937
+ className: "ss-w-tabs",
10938
+ role: "tablist",
10939
+ ref: listRef,
10940
+ onFocus: keepFocusedTabInView,
10941
+ onPointerDown: () => {
10942
+ pointerDown.current = true;
10925
10943
  },
10926
- tab
10927
- );
10928
- }) });
10944
+ onClick: () => {
10945
+ pointerDown.current = false;
10946
+ },
10947
+ onPointerCancel: () => {
10948
+ pointerDown.current = false;
10949
+ },
10950
+ children: tabs.map(({ tab, label, count: count2, dot }) => {
10951
+ const active = monitor.activeTab === tab;
10952
+ return /* @__PURE__ */ jsxs64(
10953
+ "button",
10954
+ {
10955
+ type: "button",
10956
+ role: "tab",
10957
+ "aria-selected": active,
10958
+ "data-on": active ? "" : void 0,
10959
+ "aria-label": tab === "live" && count2 > 0 ? `${label} \xB7 ${ui.liveCountLabel(count2)}` : void 0,
10960
+ className: "ss-w-tab",
10961
+ onClick: () => {
10962
+ if (tab !== monitor.activeTab) track({ name: "tab_change", from: monitor.activeTab, to: tab });
10963
+ monitor.setActiveTab(tab);
10964
+ },
10965
+ children: [
10966
+ label,
10967
+ count2 > 0 && /* @__PURE__ */ jsx70("span", { className: "ss-w-tab-count", "aria-hidden": tab === "live" ? true : void 0, children: count2 }),
10968
+ dot && !active && /* @__PURE__ */ jsx70("span", { className: "ss-w-tab-dot", "aria-hidden": "true" })
10969
+ ]
10970
+ },
10971
+ tab
10972
+ );
10973
+ })
10974
+ }
10975
+ );
10929
10976
  }
10930
10977
 
10931
10978
  // src/components/MonitorTabs.tsx
@@ -19671,6 +19718,13 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
19671
19718
  .ss-w-tabs[data-tight="5"] .ss-w-tab { font-size: 11px; }
19672
19719
  .ss-w-tabs[data-tight="6"] .ss-w-tab { font-size: 11px; padding-left: 2px; padding-right: 2px; gap: 3px; letter-spacing: -.01em; }
19673
19720
  .ss-w-tabs[data-tight="6"] .ss-w-tab-count { padding-left: 3px; padding-right: 3px; }
19721
+ .ss-w-tabs[data-tight="7"], .ss-w-tabs[data-scroll] { gap: 0; }
19722
+ .ss-w-tabs[data-tight="7"] .ss-w-tab { font-size: 11px; padding-left: 2px; padding-right: 2px; gap: 3px; letter-spacing: -.01em; }
19723
+ .ss-w-tabs[data-tight="7"] .ss-w-tab-count { background: none; padding: 0; min-width: 0; }
19724
+ .ss-w-tabs[data-scroll] { overflow-x: auto; scrollbar-width: none; scroll-padding-inline: 16px 24px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent); }
19725
+ .ss-w-tabs[data-scroll]::-webkit-scrollbar { display: none; }
19726
+ /* A flex item, not padding: WebKit leaves a flex scroller's end padding out of the scroll range, so the fade would cover the last tab. */
19727
+ .ss-w-tabs[data-scroll]::after { content: ''; flex: 0 0 24px; }
19674
19728
  .ss-w-tab-count { font-size: 10.5px; font-weight: 700; color: var(--ss-w-faint); background: var(--ss-w-bubble); border-radius: 999px; padding: 1px 6px; }
19675
19729
  .ss-w-tab[data-on] .ss-w-tab-count { color: var(--ss-w-accent); }
19676
19730
  /* The dot sits on the tab's corner and takes no width: a poll landing late must not push the last tab out of a strip that already fits to the pixel */