@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.127.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c1cd84b: NBA vs-opponent card and a priced matchup position row.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [c1cd84b]
|
|
12
|
+
- @sensiblestats/widget-sdk@0.91.0
|
|
13
|
+
|
|
3
14
|
## 0.126.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -632,6 +632,16 @@ var BUNDLED_EN_GB = {
|
|
|
632
632
|
"one": "{count} day rest",
|
|
633
633
|
"other": "{count} days rest"
|
|
634
634
|
},
|
|
635
|
+
"widget.nba.vsAvg": {
|
|
636
|
+
"one": "Avg vs {team}, {count} game",
|
|
637
|
+
"other": "Avg vs {team}, {count} games"
|
|
638
|
+
},
|
|
639
|
+
"widget.nba.othersAvg": {
|
|
640
|
+
"one": "Avg vs others, {count} game",
|
|
641
|
+
"other": "Avg vs others, {count} games"
|
|
642
|
+
},
|
|
643
|
+
"widget.nba.vsWindow": "Regular season, {season} to now",
|
|
644
|
+
"widget.nba.vsKey": "Filled bar: went over the line. Empty bar: did not. Dashed line: the main line.",
|
|
635
645
|
"widget.nba.allowsToPosition": "{team} allows {value} {stat} per game to {position} (league average {avg})",
|
|
636
646
|
"widget.nba.hitsOf": "{hits} of {total}",
|
|
637
647
|
"widget.nba.morePlayers": "+{count} more players",
|
|
@@ -1092,6 +1102,9 @@ var ROW_LEAVES = {
|
|
|
1092
1102
|
"nba.outChip": (c) => (status2, time) => time ? c.t("widget.nba.outChip", { status: status2, time }) : status2,
|
|
1093
1103
|
"nba.quoted": (c) => (time) => c.t("widget.nba.quoted", { time }),
|
|
1094
1104
|
"nba.avgLast": (c) => (n) => c.t("widget.nba.avgLast", { count: n }),
|
|
1105
|
+
"nba.vsAvg": (c) => (n, team) => c.t("widget.nba.vsAvg", { count: n, team }),
|
|
1106
|
+
"nba.othersAvg": (c) => (n) => c.t("widget.nba.othersAvg", { count: n }),
|
|
1107
|
+
"nba.vsWindow": (c) => (season) => c.t("widget.nba.vsWindow", { season }),
|
|
1095
1108
|
"nba.minutesLast": (c) => (n) => c.t("widget.nba.minutesLast", { count: n }),
|
|
1096
1109
|
"nba.mainLine": (c) => (line) => c.t("widget.nba.mainLine", { line }),
|
|
1097
1110
|
"nba.mainPrice": (c) => (over, under) => c.t("widget.nba.mainPrice", { over, under }),
|
|
@@ -1244,7 +1257,7 @@ function parseOddsFormat(value) {
|
|
|
1244
1257
|
}
|
|
1245
1258
|
|
|
1246
1259
|
// src/version.generated.ts
|
|
1247
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1260
|
+
var WIDGET_REACT_VERSION = "0.127.0";
|
|
1248
1261
|
|
|
1249
1262
|
// src/config.ts
|
|
1250
1263
|
function hostTag(cfg) {
|
|
@@ -2120,7 +2133,7 @@ function validMatchupTeam(t) {
|
|
|
2120
2133
|
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);
|
|
2121
2134
|
}
|
|
2122
2135
|
function validMatchupPosition(p) {
|
|
2123
|
-
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);
|
|
2136
|
+
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);
|
|
2124
2137
|
}
|
|
2125
2138
|
function sanitizeMatchup(m) {
|
|
2126
2139
|
if (!m || !Array.isArray(m.teams) || m.teams.length !== 2 || !m.teams.every(validMatchupTeam)) return null;
|
|
@@ -2154,6 +2167,8 @@ function nbaEvidence(insight) {
|
|
|
2154
2167
|
return validQuarterLadder(insight.quarterLadder) ? { kind: "quarter_ladder", quarterLadder: insight.quarterLadder } : null;
|
|
2155
2168
|
case "settle_recap":
|
|
2156
2169
|
return validSettleRecap(insight.settleRecap) ? { kind: "settle_recap", settleRecap: insight.settleRecap } : null;
|
|
2170
|
+
case "vs_opponent":
|
|
2171
|
+
return validVsOpponent(insight.vsOpponent) ? { kind: "vs_opponent", vsOpponent: insight.vsOpponent } : null;
|
|
2157
2172
|
default:
|
|
2158
2173
|
return null;
|
|
2159
2174
|
}
|
|
@@ -2162,7 +2177,7 @@ function toNbaInsightVM(insight) {
|
|
|
2162
2177
|
const evidence = nbaEvidence(insight);
|
|
2163
2178
|
if (!evidence || typeof insight.title !== "string" || typeof insight.text !== "string") return null;
|
|
2164
2179
|
const selections = {};
|
|
2165
|
-
for (const s of insight.selections ?? []) if (typeof s?.key === "string") selections[s.key] = s;
|
|
2180
|
+
for (const s of insight.selections ?? []) if (typeof s?.key === "string" && typeof s.priceFormats?.decimal === "string") selections[s.key] = s;
|
|
2166
2181
|
return {
|
|
2167
2182
|
id: insight.insightId,
|
|
2168
2183
|
matchId: insight.matchId,
|
|
@@ -2225,6 +2240,13 @@ function nbaCoHitLegs(vm, conversationId) {
|
|
|
2225
2240
|
}
|
|
2226
2241
|
var isStr = (v) => typeof v === "string";
|
|
2227
2242
|
var strOrNull = (v) => v === null || v === void 0 || typeof v === "string";
|
|
2243
|
+
var VS_RESULTS = ["over", "under", "push"];
|
|
2244
|
+
function validVsOpponent(v) {
|
|
2245
|
+
if (!v || !isStr(v.playerName) || !isStr(v.stat) || !isStr(v.opponentName) || !isStr(v.mainLine) || !isStr(v.fromSeason)) return false;
|
|
2246
|
+
if (!isNum(v.vsAverage) || !isNum(v.othersAverage) || !isNum(v.meetingsN) || !isNum(v.othersN)) return false;
|
|
2247
|
+
if (!strOrNull(v.overSelectionKey) || !strOrNull(v.underSelectionKey) || !v.overSelectionKey && !v.underSelectionKey) return false;
|
|
2248
|
+
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));
|
|
2249
|
+
}
|
|
2228
2250
|
var isList = (v, each) => Array.isArray(v) && v.every((item) => isObj(item) && each(item));
|
|
2229
2251
|
function validNflEvidence(kind, e) {
|
|
2230
2252
|
switch (kind) {
|
|
@@ -7889,6 +7911,11 @@ function dayMonth(iso, ui, month = "short") {
|
|
|
7889
7911
|
if (Number.isNaN(d.getTime())) return iso;
|
|
7890
7912
|
return formatDate(d, ui.locale, { day: "numeric", month, timeZone: "UTC" });
|
|
7891
7913
|
}
|
|
7914
|
+
function dayMonthYear(iso, ui) {
|
|
7915
|
+
const d = new Date(iso);
|
|
7916
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
7917
|
+
return formatDate(d, ui.locale, { day: "numeric", month: "short", year: "2-digit", timeZone: "UTC" });
|
|
7918
|
+
}
|
|
7892
7919
|
var oneDecimal = (n, ui) => formatNumber(n, ui.locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 });
|
|
7893
7920
|
var byDate = (games) => [...games].sort((a, b) => a.date < b.date ? -1 : a.date > b.date ? 1 : 0);
|
|
7894
7921
|
var canAdd = (vm, key, slip) => takesSport(slip, "basketball") && toNbaSlipSelection(vm, key, slip.conversationId) !== null;
|
|
@@ -8006,10 +8033,58 @@ function Ladder({ vm, ld, ui, slip }) {
|
|
|
8006
8033
|
] })
|
|
8007
8034
|
] }, `${st.stat}:${si}`)) });
|
|
8008
8035
|
}
|
|
8036
|
+
function PricePair({ vm, ui, slip, over, under, line }) {
|
|
8037
|
+
const nba = ui.nba;
|
|
8038
|
+
const lineLabel = line === null ? null : nba.lineText(line);
|
|
8039
|
+
const sides = [
|
|
8040
|
+
{ key: over, label: lineLabel === null ? nba.overShort : nba.over(lineLabel) },
|
|
8041
|
+
{ key: under, label: lineLabel === null ? nba.underShort : nba.under(lineLabel) }
|
|
8042
|
+
].filter((side) => side.key && vm.selections[side.key]);
|
|
8043
|
+
if (sides.length === 0) return null;
|
|
8044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "ss-w-nba-pair", children: sides.map((side) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-pcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(NbaPrice, { vm, ui, slip, selectionKey: side.key, label: side.label }) }, side.key)) });
|
|
8045
|
+
}
|
|
8046
|
+
function VsOpponent({ vm, vo, ui, slip }) {
|
|
8047
|
+
const nba = ui.nba;
|
|
8048
|
+
const meetings = byDate(vo.meetings);
|
|
8049
|
+
const line = parseLine(vo.mainLine);
|
|
8050
|
+
const top = Math.max(Number.isFinite(line) ? line : 0, ...meetings.map((m) => m.value), 1);
|
|
8051
|
+
const pct = (v) => `${Math.max(0, Math.min(100, v / top * 100))}%`;
|
|
8052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
8053
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "ss-w-nba-games", children: meetings.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "ss-w-nba-game", children: [
|
|
8054
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-gv", children: m.value }),
|
|
8055
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "ss-w-nba-track", children: [
|
|
8056
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-bar", "data-hit": m.result === "over" || void 0, style: { height: pct(m.value) } }),
|
|
8057
|
+
Number.isFinite(line) ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-mark", style: { bottom: pct(line) } }) : null
|
|
8058
|
+
] }),
|
|
8059
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-gd", children: dayMonthYear(m.date, ui) })
|
|
8060
|
+
] }, `${m.date}:${i}`)) }),
|
|
8061
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "ss-w-nba-vs ss-w-nba-figs", children: [
|
|
8062
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "ss-w-nba-fig", children: [
|
|
8063
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-figl", children: nba.vsAvg(vo.meetingsN, vo.opponentName) }),
|
|
8064
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("b", { children: oneDecimal(vo.vsAverage, ui) })
|
|
8065
|
+
] }),
|
|
8066
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "ss-w-nba-fig", children: [
|
|
8067
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-figl", children: nba.othersAvg(vo.othersN) }),
|
|
8068
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("b", { children: oneDecimal(vo.othersAverage, ui) })
|
|
8069
|
+
] })
|
|
8070
|
+
] }),
|
|
8071
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PricePair, { vm, ui, slip, over: vo.overSelectionKey, under: vo.underSelectionKey, line: vo.mainLine }),
|
|
8072
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "ss-w-nba-note", children: [
|
|
8073
|
+
nba.vsWindow(vo.fromSeason),
|
|
8074
|
+
vo.smallSample ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
8075
|
+
" ",
|
|
8076
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SmallSample, { ui })
|
|
8077
|
+
] }) : null
|
|
8078
|
+
] })
|
|
8079
|
+
] });
|
|
8080
|
+
}
|
|
8009
8081
|
function SmallSample({ ui }) {
|
|
8010
8082
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-small", children: ui.nba.smallSample });
|
|
8011
8083
|
}
|
|
8012
|
-
function
|
|
8084
|
+
function matchupPriced(vm, pos) {
|
|
8085
|
+
return !!pos && !!pos.playerName && [pos.overSelectionKey, pos.underSelectionKey].some((k) => !!k && !!vm.selections[k]);
|
|
8086
|
+
}
|
|
8087
|
+
function NbaMatchupBody({ vm, mu, ui, slip }) {
|
|
8013
8088
|
const nba = ui.nba;
|
|
8014
8089
|
const metrics = [
|
|
8015
8090
|
{ label: nba.matchupPace, value: (t) => t.pace, rank: (t) => t.paceRank },
|
|
@@ -8049,6 +8124,10 @@ function NbaMatchupBody({ mu, ui }) {
|
|
|
8049
8124
|
" ",
|
|
8050
8125
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-note", children: nba.rankOf(pos.rank, pos.teamsRanked) }),
|
|
8051
8126
|
pos.smallSample ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SmallSample, { ui }) : null
|
|
8127
|
+
] }) : null,
|
|
8128
|
+
matchupPriced(vm, pos) ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "ss-w-nba-mu-price", children: [
|
|
8129
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "ss-w-nba-who", children: pos.playerName }),
|
|
8130
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(PricePair, { vm, ui, slip, over: pos.overSelectionKey, under: pos.underSelectionKey, line: pos.mainLine })
|
|
8052
8131
|
] }) : null
|
|
8053
8132
|
] });
|
|
8054
8133
|
}
|
|
@@ -8305,8 +8384,12 @@ function NbaCard({ vm, ui, slip, monitor }) {
|
|
|
8305
8384
|
foot = [nba.lineMoveKey];
|
|
8306
8385
|
break;
|
|
8307
8386
|
case "matchup":
|
|
8308
|
-
body = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(NbaMatchupBody, { mu: ev.matchup, ui });
|
|
8309
|
-
foot = [];
|
|
8387
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(NbaMatchupBody, { vm, mu: ev.matchup, ui, slip });
|
|
8388
|
+
foot = matchupPriced(vm, ev.matchup.position) ? [nba.operatorPrice] : [];
|
|
8389
|
+
break;
|
|
8390
|
+
case "vs_opponent":
|
|
8391
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(VsOpponent, { vm, vo: ev.vsOpponent, ui, slip });
|
|
8392
|
+
foot = [...[ev.vsOpponent.overSelectionKey, ev.vsOpponent.underSelectionKey].some((k) => !!k && !!vm.selections[k]) ? [nba.operatorPrice] : [], nba.vsKey];
|
|
8310
8393
|
break;
|
|
8311
8394
|
case "quarter_ladder":
|
|
8312
8395
|
body = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(NbaQuarterLadderBody, { vm, ql: ev.quarterLadder, ui, slip });
|
|
@@ -17836,6 +17919,11 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
17836
17919
|
.ss-w-nba-mu-pos { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ss-w-ink); }
|
|
17837
17920
|
.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; }
|
|
17838
17921
|
.ss-w-nba-mu-pos .ss-w-nba-small { margin-left: 6px; }
|
|
17922
|
+
.ss-w-nba-vs, .ss-w-nba-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
|
|
17923
|
+
.ss-w-nba-vs > *, .ss-w-nba-mu-price > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
17924
|
+
.ss-w-nba-vs .ss-w-nba-figl { white-space: normal; overflow-wrap: anywhere; }
|
|
17925
|
+
.ss-w-nba-pair .ss-w-nba-pcell { justify-content: flex-start; }
|
|
17926
|
+
.ss-w-nba-mu-price { display: grid; gap: 4px; margin-top: 6px; }
|
|
17839
17927
|
.ss-w-nba-sr-player { display: flex; flex-direction: column; gap: 6px; }
|
|
17840
17928
|
.ss-w-nba-sr{grid-template-columns:minmax(0,1fr) 44px 44px 54px;align-items:center}
|
|
17841
17929
|
.ss-w-nba-sr-line { display: contents; }
|