@sensiblestats/widget-react 0.126.0 → 0.127.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 +11 -0
- package/dist/index.cjs +94 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +94 -6
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -594,6 +594,16 @@ var BUNDLED_EN_GB = {
|
|
|
594
594
|
"one": "{count} day rest",
|
|
595
595
|
"other": "{count} days rest"
|
|
596
596
|
},
|
|
597
|
+
"widget.nba.vsAvg": {
|
|
598
|
+
"one": "Avg vs {team}, {count} game",
|
|
599
|
+
"other": "Avg vs {team}, {count} games"
|
|
600
|
+
},
|
|
601
|
+
"widget.nba.othersAvg": {
|
|
602
|
+
"one": "Avg vs others, {count} game",
|
|
603
|
+
"other": "Avg vs others, {count} games"
|
|
604
|
+
},
|
|
605
|
+
"widget.nba.vsWindow": "Regular season, {season} to now",
|
|
606
|
+
"widget.nba.vsKey": "Filled bar: went over the line. Empty bar: did not. Dashed line: the main line.",
|
|
597
607
|
"widget.nba.allowsToPosition": "{team} allows {value} {stat} per game to {position} (league average {avg})",
|
|
598
608
|
"widget.nba.hitsOf": "{hits} of {total}",
|
|
599
609
|
"widget.nba.morePlayers": "+{count} more players",
|
|
@@ -1054,6 +1064,9 @@ var ROW_LEAVES = {
|
|
|
1054
1064
|
"nba.outChip": (c) => (status2, time) => time ? c.t("widget.nba.outChip", { status: status2, time }) : status2,
|
|
1055
1065
|
"nba.quoted": (c) => (time) => c.t("widget.nba.quoted", { time }),
|
|
1056
1066
|
"nba.avgLast": (c) => (n) => c.t("widget.nba.avgLast", { count: n }),
|
|
1067
|
+
"nba.vsAvg": (c) => (n, team) => c.t("widget.nba.vsAvg", { count: n, team }),
|
|
1068
|
+
"nba.othersAvg": (c) => (n) => c.t("widget.nba.othersAvg", { count: n }),
|
|
1069
|
+
"nba.vsWindow": (c) => (season) => c.t("widget.nba.vsWindow", { season }),
|
|
1057
1070
|
"nba.minutesLast": (c) => (n) => c.t("widget.nba.minutesLast", { count: n }),
|
|
1058
1071
|
"nba.mainLine": (c) => (line) => c.t("widget.nba.mainLine", { line }),
|
|
1059
1072
|
"nba.mainPrice": (c) => (over, under) => c.t("widget.nba.mainPrice", { over, under }),
|
|
@@ -1206,7 +1219,7 @@ function parseOddsFormat(value) {
|
|
|
1206
1219
|
}
|
|
1207
1220
|
|
|
1208
1221
|
// src/version.generated.ts
|
|
1209
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1222
|
+
var WIDGET_REACT_VERSION = "0.127.0";
|
|
1210
1223
|
|
|
1211
1224
|
// src/config.ts
|
|
1212
1225
|
function hostTag(cfg) {
|
|
@@ -2082,7 +2095,7 @@ function validMatchupTeam(t) {
|
|
|
2082
2095
|
return isObj(t) && typeof t.name === "string" && typeof t.abbr === "string" && isNum(t.pace) && isNum(t.offRating) && isNum(t.defRating) && isNum(t.n) && isNum(t.teamsRanked) && numOrNull(t.daysRest) && numOrNull(t.paceRank) && numOrNull(t.offRatingRank) && numOrNull(t.defRatingRank);
|
|
2083
2096
|
}
|
|
2084
2097
|
function validMatchupPosition(p) {
|
|
2085
|
-
return isObj(p) && typeof p.defendingTeamAbbr === "string" && typeof p.position === "string" && typeof p.stat === "string" && isNum(p.allowedPerGame) && isNum(p.leagueAvg) && isNum(p.rank) && isNum(p.teamsRanked) && isNum(p.n);
|
|
2098
|
+
return isObj(p) && typeof p.defendingTeamAbbr === "string" && typeof p.position === "string" && typeof p.stat === "string" && isNum(p.allowedPerGame) && isNum(p.leagueAvg) && isNum(p.rank) && isNum(p.teamsRanked) && isNum(p.n) && strOrNull(p.playerName) && strOrNull(p.mainLine) && strOrNull(p.overSelectionKey) && strOrNull(p.underSelectionKey);
|
|
2086
2099
|
}
|
|
2087
2100
|
function sanitizeMatchup(m) {
|
|
2088
2101
|
if (!m || !Array.isArray(m.teams) || m.teams.length !== 2 || !m.teams.every(validMatchupTeam)) return null;
|
|
@@ -2116,6 +2129,8 @@ function nbaEvidence(insight) {
|
|
|
2116
2129
|
return validQuarterLadder(insight.quarterLadder) ? { kind: "quarter_ladder", quarterLadder: insight.quarterLadder } : null;
|
|
2117
2130
|
case "settle_recap":
|
|
2118
2131
|
return validSettleRecap(insight.settleRecap) ? { kind: "settle_recap", settleRecap: insight.settleRecap } : null;
|
|
2132
|
+
case "vs_opponent":
|
|
2133
|
+
return validVsOpponent(insight.vsOpponent) ? { kind: "vs_opponent", vsOpponent: insight.vsOpponent } : null;
|
|
2119
2134
|
default:
|
|
2120
2135
|
return null;
|
|
2121
2136
|
}
|
|
@@ -2124,7 +2139,7 @@ function toNbaInsightVM(insight) {
|
|
|
2124
2139
|
const evidence = nbaEvidence(insight);
|
|
2125
2140
|
if (!evidence || typeof insight.title !== "string" || typeof insight.text !== "string") return null;
|
|
2126
2141
|
const selections = {};
|
|
2127
|
-
for (const s of insight.selections ?? []) if (typeof s?.key === "string") selections[s.key] = s;
|
|
2142
|
+
for (const s of insight.selections ?? []) if (typeof s?.key === "string" && typeof s.priceFormats?.decimal === "string") selections[s.key] = s;
|
|
2128
2143
|
return {
|
|
2129
2144
|
id: insight.insightId,
|
|
2130
2145
|
matchId: insight.matchId,
|
|
@@ -2187,6 +2202,13 @@ function nbaCoHitLegs(vm, conversationId) {
|
|
|
2187
2202
|
}
|
|
2188
2203
|
var isStr = (v) => typeof v === "string";
|
|
2189
2204
|
var strOrNull = (v) => v === null || v === void 0 || typeof v === "string";
|
|
2205
|
+
var VS_RESULTS = ["over", "under", "push"];
|
|
2206
|
+
function validVsOpponent(v) {
|
|
2207
|
+
if (!v || !isStr(v.playerName) || !isStr(v.stat) || !isStr(v.opponentName) || !isStr(v.mainLine) || !isStr(v.fromSeason)) return false;
|
|
2208
|
+
if (!isNum(v.vsAverage) || !isNum(v.othersAverage) || !isNum(v.meetingsN) || !isNum(v.othersN)) return false;
|
|
2209
|
+
if (!strOrNull(v.overSelectionKey) || !strOrNull(v.underSelectionKey) || !v.overSelectionKey && !v.underSelectionKey) return false;
|
|
2210
|
+
return Array.isArray(v.meetings) && v.meetings.length > 0 && v.meetings.every((m) => isObj(m) && isStr(m.date) && isNum(m.value) && VS_RESULTS.includes(m.result));
|
|
2211
|
+
}
|
|
2190
2212
|
var isList = (v, each) => Array.isArray(v) && v.every((item) => isObj(item) && each(item));
|
|
2191
2213
|
function validNflEvidence(kind, e) {
|
|
2192
2214
|
switch (kind) {
|
|
@@ -7851,6 +7873,11 @@ function dayMonth(iso, ui, month = "short") {
|
|
|
7851
7873
|
if (Number.isNaN(d.getTime())) return iso;
|
|
7852
7874
|
return formatDate(d, ui.locale, { day: "numeric", month, timeZone: "UTC" });
|
|
7853
7875
|
}
|
|
7876
|
+
function dayMonthYear(iso, ui) {
|
|
7877
|
+
const d = new Date(iso);
|
|
7878
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
7879
|
+
return formatDate(d, ui.locale, { day: "numeric", month: "short", year: "2-digit", timeZone: "UTC" });
|
|
7880
|
+
}
|
|
7854
7881
|
var oneDecimal = (n, ui) => formatNumber(n, ui.locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 });
|
|
7855
7882
|
var byDate = (games) => [...games].sort((a, b) => a.date < b.date ? -1 : a.date > b.date ? 1 : 0);
|
|
7856
7883
|
var canAdd = (vm, key, slip) => takesSport(slip, "basketball") && toNbaSlipSelection(vm, key, slip.conversationId) !== null;
|
|
@@ -7968,10 +7995,58 @@ function Ladder({ vm, ld, ui, slip }) {
|
|
|
7968
7995
|
] })
|
|
7969
7996
|
] }, `${st.stat}:${si}`)) });
|
|
7970
7997
|
}
|
|
7998
|
+
function PricePair({ vm, ui, slip, over, under, line }) {
|
|
7999
|
+
const nba = ui.nba;
|
|
8000
|
+
const lineLabel = line === null ? null : nba.lineText(line);
|
|
8001
|
+
const sides = [
|
|
8002
|
+
{ key: over, label: lineLabel === null ? nba.overShort : nba.over(lineLabel) },
|
|
8003
|
+
{ key: under, label: lineLabel === null ? nba.underShort : nba.under(lineLabel) }
|
|
8004
|
+
].filter((side) => side.key && vm.selections[side.key]);
|
|
8005
|
+
if (sides.length === 0) return null;
|
|
8006
|
+
return /* @__PURE__ */ jsx36("div", { className: "ss-w-nba-pair", children: sides.map((side) => /* @__PURE__ */ jsx36("span", { className: "ss-w-nba-pcell", children: /* @__PURE__ */ jsx36(NbaPrice, { vm, ui, slip, selectionKey: side.key, label: side.label }) }, side.key)) });
|
|
8007
|
+
}
|
|
8008
|
+
function VsOpponent({ vm, vo, ui, slip }) {
|
|
8009
|
+
const nba = ui.nba;
|
|
8010
|
+
const meetings = byDate(vo.meetings);
|
|
8011
|
+
const line = parseLine(vo.mainLine);
|
|
8012
|
+
const top = Math.max(Number.isFinite(line) ? line : 0, ...meetings.map((m) => m.value), 1);
|
|
8013
|
+
const pct = (v) => `${Math.max(0, Math.min(100, v / top * 100))}%`;
|
|
8014
|
+
return /* @__PURE__ */ jsxs32(Fragment6, { children: [
|
|
8015
|
+
/* @__PURE__ */ jsx36("div", { className: "ss-w-nba-games", children: meetings.map((m, i) => /* @__PURE__ */ jsxs32("div", { className: "ss-w-nba-game", children: [
|
|
8016
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-gv", children: m.value }),
|
|
8017
|
+
/* @__PURE__ */ jsxs32("span", { className: "ss-w-nba-track", children: [
|
|
8018
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-bar", "data-hit": m.result === "over" || void 0, style: { height: pct(m.value) } }),
|
|
8019
|
+
Number.isFinite(line) ? /* @__PURE__ */ jsx36("span", { className: "ss-w-nba-mark", style: { bottom: pct(line) } }) : null
|
|
8020
|
+
] }),
|
|
8021
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-gd", children: dayMonthYear(m.date, ui) })
|
|
8022
|
+
] }, `${m.date}:${i}`)) }),
|
|
8023
|
+
/* @__PURE__ */ jsxs32("div", { className: "ss-w-nba-vs ss-w-nba-figs", children: [
|
|
8024
|
+
/* @__PURE__ */ jsxs32("span", { className: "ss-w-nba-fig", children: [
|
|
8025
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-figl", children: nba.vsAvg(vo.meetingsN, vo.opponentName) }),
|
|
8026
|
+
/* @__PURE__ */ jsx36("b", { children: oneDecimal(vo.vsAverage, ui) })
|
|
8027
|
+
] }),
|
|
8028
|
+
/* @__PURE__ */ jsxs32("span", { className: "ss-w-nba-fig", children: [
|
|
8029
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-figl", children: nba.othersAvg(vo.othersN) }),
|
|
8030
|
+
/* @__PURE__ */ jsx36("b", { children: oneDecimal(vo.othersAverage, ui) })
|
|
8031
|
+
] })
|
|
8032
|
+
] }),
|
|
8033
|
+
/* @__PURE__ */ jsx36(PricePair, { vm, ui, slip, over: vo.overSelectionKey, under: vo.underSelectionKey, line: vo.mainLine }),
|
|
8034
|
+
/* @__PURE__ */ jsxs32("p", { className: "ss-w-nba-note", children: [
|
|
8035
|
+
nba.vsWindow(vo.fromSeason),
|
|
8036
|
+
vo.smallSample ? /* @__PURE__ */ jsxs32(Fragment6, { children: [
|
|
8037
|
+
" ",
|
|
8038
|
+
/* @__PURE__ */ jsx36(SmallSample, { ui })
|
|
8039
|
+
] }) : null
|
|
8040
|
+
] })
|
|
8041
|
+
] });
|
|
8042
|
+
}
|
|
7971
8043
|
function SmallSample({ ui }) {
|
|
7972
8044
|
return /* @__PURE__ */ jsx36("span", { className: "ss-w-nba-small", children: ui.nba.smallSample });
|
|
7973
8045
|
}
|
|
7974
|
-
function
|
|
8046
|
+
function matchupPriced(vm, pos) {
|
|
8047
|
+
return !!pos && !!pos.playerName && [pos.overSelectionKey, pos.underSelectionKey].some((k) => !!k && !!vm.selections[k]);
|
|
8048
|
+
}
|
|
8049
|
+
function NbaMatchupBody({ vm, mu, ui, slip }) {
|
|
7975
8050
|
const nba = ui.nba;
|
|
7976
8051
|
const metrics = [
|
|
7977
8052
|
{ label: nba.matchupPace, value: (t) => t.pace, rank: (t) => t.paceRank },
|
|
@@ -8011,6 +8086,10 @@ function NbaMatchupBody({ mu, ui }) {
|
|
|
8011
8086
|
" ",
|
|
8012
8087
|
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-note", children: nba.rankOf(pos.rank, pos.teamsRanked) }),
|
|
8013
8088
|
pos.smallSample ? /* @__PURE__ */ jsx36(SmallSample, { ui }) : null
|
|
8089
|
+
] }) : null,
|
|
8090
|
+
matchupPriced(vm, pos) ? /* @__PURE__ */ jsxs32("div", { className: "ss-w-nba-mu-price", children: [
|
|
8091
|
+
/* @__PURE__ */ jsx36("span", { className: "ss-w-nba-who", children: pos.playerName }),
|
|
8092
|
+
/* @__PURE__ */ jsx36(PricePair, { vm, ui, slip, over: pos.overSelectionKey, under: pos.underSelectionKey, line: pos.mainLine })
|
|
8014
8093
|
] }) : null
|
|
8015
8094
|
] });
|
|
8016
8095
|
}
|
|
@@ -8267,8 +8346,12 @@ function NbaCard({ vm, ui, slip, monitor }) {
|
|
|
8267
8346
|
foot = [nba.lineMoveKey];
|
|
8268
8347
|
break;
|
|
8269
8348
|
case "matchup":
|
|
8270
|
-
body = /* @__PURE__ */ jsx36(NbaMatchupBody, { mu: ev.matchup, ui });
|
|
8271
|
-
foot = [];
|
|
8349
|
+
body = /* @__PURE__ */ jsx36(NbaMatchupBody, { vm, mu: ev.matchup, ui, slip });
|
|
8350
|
+
foot = matchupPriced(vm, ev.matchup.position) ? [nba.operatorPrice] : [];
|
|
8351
|
+
break;
|
|
8352
|
+
case "vs_opponent":
|
|
8353
|
+
body = /* @__PURE__ */ jsx36(VsOpponent, { vm, vo: ev.vsOpponent, ui, slip });
|
|
8354
|
+
foot = [...[ev.vsOpponent.overSelectionKey, ev.vsOpponent.underSelectionKey].some((k) => !!k && !!vm.selections[k]) ? [nba.operatorPrice] : [], nba.vsKey];
|
|
8272
8355
|
break;
|
|
8273
8356
|
case "quarter_ladder":
|
|
8274
8357
|
body = /* @__PURE__ */ jsx36(NbaQuarterLadderBody, { vm, ql: ev.quarterLadder, ui, slip });
|
|
@@ -17798,6 +17881,11 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
17798
17881
|
.ss-w-nba-mu-pos { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ss-w-ink); }
|
|
17799
17882
|
.ss-w-nba-small { display: inline-block; font-size: 10px; font-weight: 600; line-height: 1.3; color: var(--ss-w-warn); border: 1px solid var(--ss-w-warn); border-radius: 999px; padding: 0 6px; white-space: nowrap; }
|
|
17800
17883
|
.ss-w-nba-mu-pos .ss-w-nba-small { margin-left: 6px; }
|
|
17884
|
+
.ss-w-nba-vs, .ss-w-nba-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
|
|
17885
|
+
.ss-w-nba-vs > *, .ss-w-nba-mu-price > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
17886
|
+
.ss-w-nba-vs .ss-w-nba-figl { white-space: normal; overflow-wrap: anywhere; }
|
|
17887
|
+
.ss-w-nba-pair .ss-w-nba-pcell { justify-content: flex-start; }
|
|
17888
|
+
.ss-w-nba-mu-price { display: grid; gap: 4px; margin-top: 6px; }
|
|
17801
17889
|
.ss-w-nba-sr-player { display: flex; flex-direction: column; gap: 6px; }
|
|
17802
17890
|
.ss-w-nba-sr{grid-template-columns:minmax(0,1fr) 44px 44px 54px;align-items:center}
|
|
17803
17891
|
.ss-w-nba-sr-line { display: contents; }
|