@sensiblestats/widget-react 0.137.0 → 0.138.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 +39 -18
- 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 +39 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.138.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Entity cards for NBA and NFL answers, with a win-loss record bar.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @sensiblestats/widget-sdk@0.100.0
|
|
13
|
+
|
|
3
14
|
## 0.137.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -908,7 +908,7 @@ var BUNDLED_EN_GB = {
|
|
|
908
908
|
};
|
|
909
909
|
|
|
910
910
|
// src/strings/fill.ts
|
|
911
|
-
var pickForm = (row,
|
|
911
|
+
var pickForm = (row, count2, tag2) => row[new Intl.PluralRules(tag2).select(count2)] ?? row.other;
|
|
912
912
|
function fill(template, tokens, tag2) {
|
|
913
913
|
const text2 = typeof template === "string" ? template : pickForm(template, Number(tokens[template.$count ?? "count"]), tag2);
|
|
914
914
|
return text2.replace(/\{(\w+)\}/g, (match, name) => Object.prototype.hasOwnProperty.call(tokens, name) ? String(tokens[name]) : match);
|
|
@@ -1337,7 +1337,7 @@ function parseOddsFormat(value) {
|
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
1339
|
// src/version.generated.ts
|
|
1340
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1340
|
+
var WIDGET_REACT_VERSION = "0.138.0";
|
|
1341
1341
|
|
|
1342
1342
|
// src/config.ts
|
|
1343
1343
|
function hostTag(cfg) {
|
|
@@ -1902,6 +1902,19 @@ function str(v) {
|
|
|
1902
1902
|
function num(v) {
|
|
1903
1903
|
return typeof v === "number" && Number.isFinite(v) ? String(v) : void 0;
|
|
1904
1904
|
}
|
|
1905
|
+
function count(v) {
|
|
1906
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : void 0;
|
|
1907
|
+
}
|
|
1908
|
+
function readRecord(raw) {
|
|
1909
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
1910
|
+
const r = raw;
|
|
1911
|
+
const wins = count(r.wins);
|
|
1912
|
+
const losses = count(r.losses);
|
|
1913
|
+
if (wins === void 0 || losses === void 0) return void 0;
|
|
1914
|
+
const draws = count(r.draws);
|
|
1915
|
+
const ties = count(r.ties);
|
|
1916
|
+
return { wins, losses, ...draws !== void 0 ? { draws } : {}, ...ties !== void 0 ? { ties } : {} };
|
|
1917
|
+
}
|
|
1905
1918
|
function readStatCells(raw) {
|
|
1906
1919
|
if (!Array.isArray(raw)) return [];
|
|
1907
1920
|
const cells = [];
|
|
@@ -1910,7 +1923,8 @@ function readStatCells(raw) {
|
|
|
1910
1923
|
const value = num(entry.value) ?? str(entry.value);
|
|
1911
1924
|
if (label === void 0 || value === void 0) continue;
|
|
1912
1925
|
const note = str(entry.note);
|
|
1913
|
-
|
|
1926
|
+
const record2 = readRecord(entry.record);
|
|
1927
|
+
cells.push({ label, value, ...note !== void 0 ? { note } : {}, ...entry.muted === true ? { muted: true } : {}, ...record2 ? { record: record2 } : {} });
|
|
1914
1928
|
}
|
|
1915
1929
|
return cells;
|
|
1916
1930
|
}
|
|
@@ -1929,7 +1943,7 @@ function toCardVM(card) {
|
|
|
1929
1943
|
};
|
|
1930
1944
|
}).filter((s) => s !== null) : [];
|
|
1931
1945
|
return {
|
|
1932
|
-
id:
|
|
1946
|
+
id: `${kind}:${card.entityId}`,
|
|
1933
1947
|
kind,
|
|
1934
1948
|
name: card.canonicalName,
|
|
1935
1949
|
image: str(card.imagePath) ?? str(card.imageUrl) ?? str(card.image_url) ?? str(card.logoUrl) ?? str(card.logo),
|
|
@@ -6605,7 +6619,7 @@ function allMarketsCount(vm, monitor) {
|
|
|
6605
6619
|
if (!monitor?.enabled || !vm.pinEnabled || (0, import_widget_sdk20.sportOf)(vm.sport) !== void 0) return null;
|
|
6606
6620
|
return vm.marketCount !== void 0 && vm.marketCount >= 2 ? vm.marketCount : null;
|
|
6607
6621
|
}
|
|
6608
|
-
function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
6622
|
+
function AllMarketsButton({ vm, count: count2, monitor, ui, surface }) {
|
|
6609
6623
|
const log = useEventLog();
|
|
6610
6624
|
const [toast, setToast] = (0, import_react34.useState)(null);
|
|
6611
6625
|
const dismiss = (0, import_react34.useCallback)(() => setToast(null), []);
|
|
@@ -6622,9 +6636,9 @@ function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
|
6622
6636
|
outcome: surface === "card" ? "all_markets_card" : "all_markets_list"
|
|
6623
6637
|
});
|
|
6624
6638
|
};
|
|
6625
|
-
const label = vm.homeTeamName && vm.awayTeamName ? ui.allMarketsAria(
|
|
6639
|
+
const label = vm.homeTeamName && vm.awayTeamName ? ui.allMarketsAria(count2, vm.homeTeamName, vm.awayTeamName) : void 0;
|
|
6626
6640
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: surface === "card" ? "ss-w-allmk-wrap" : "ss-w-allmk-wrap ss-w-allmk-wrap--chip", children: [
|
|
6627
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: surface === "card" ? "ss-w-allmk" : "ss-w-allmk ss-w-allmk--chip", "aria-label": label ?? ui.allMarkets(
|
|
6641
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", className: surface === "card" ? "ss-w-allmk" : "ss-w-allmk ss-w-allmk--chip", "aria-label": label ?? ui.allMarkets(count2), onClick, children: [
|
|
6628
6642
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6629
6643
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: "3", y: "5", width: "5", height: "5", rx: "1.2" }),
|
|
6630
6644
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: "9.5", y: "5", width: "5", height: "5", rx: "1.2" }),
|
|
@@ -6633,7 +6647,7 @@ function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
|
6633
6647
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: "9.5", y: "14", width: "5", height: "5", rx: "1.2" }),
|
|
6634
6648
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { x: "16", y: "14", width: "5", height: "5", rx: "1.2" })
|
|
6635
6649
|
] }),
|
|
6636
|
-
surface === "card" ? ui.allMarkets(
|
|
6650
|
+
surface === "card" ? ui.allMarkets(count2) : count2
|
|
6637
6651
|
] }),
|
|
6638
6652
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Toast, { toast, onDismiss: dismiss })
|
|
6639
6653
|
] });
|
|
@@ -7975,6 +7989,13 @@ function cellClass(s) {
|
|
|
7975
7989
|
return s.muted ? "ss-w-ecard-cell ss-w-ecard-cell--muted" : "ss-w-ecard-cell";
|
|
7976
7990
|
}
|
|
7977
7991
|
function StatCellView({ s }) {
|
|
7992
|
+
if (s.record) {
|
|
7993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: cellClass(s), children: [
|
|
7994
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ss-w-ecard-cval", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FormBar, { w: s.record.wins, d: s.record.draws ?? s.record.ties ?? 0, l: s.record.losses }) }),
|
|
7995
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ss-w-ecard-clabel", children: `${s.label} ${s.value}` }),
|
|
7996
|
+
s.note ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "ss-w-ecard-note", children: s.note }) : null
|
|
7997
|
+
] });
|
|
7998
|
+
}
|
|
7978
7999
|
const m = RECORD_RE.exec(s.value);
|
|
7979
8000
|
if (m) {
|
|
7980
8001
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: cellClass(s), children: [
|
|
@@ -8035,7 +8056,7 @@ function ScopeTabs({ scopes, active, onSelect }) {
|
|
|
8035
8056
|
onClick: () => onSelect(i),
|
|
8036
8057
|
children: s.image ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Crest2, { image: s.image }) : s.label
|
|
8037
8058
|
},
|
|
8038
|
-
String(s.competitionId
|
|
8059
|
+
s.competitionId == null ? `i${i}` : String(s.competitionId)
|
|
8039
8060
|
)) });
|
|
8040
8061
|
}
|
|
8041
8062
|
function EntityCardItem({ c }) {
|
|
@@ -9580,7 +9601,7 @@ function Cell({ row, cell: cell2, ui, slip }) {
|
|
|
9580
9601
|
function Row({ row, columns, ui, slip, monitor, rowRef }) {
|
|
9581
9602
|
const vm = row.card;
|
|
9582
9603
|
useNextKickoffRender(isNfl(vm.sport) ? [vm.kickoffUtc] : []);
|
|
9583
|
-
const
|
|
9604
|
+
const count2 = allMarketsCount(vm, monitor);
|
|
9584
9605
|
const nflPin = (0, import_widget_sdk23.sportOf)(vm.sport) === "americanfootball" && !vm.isLive;
|
|
9585
9606
|
const kickoffFallback = vm.kickoffUtc ? ui.bettingKickoff(vm.kickoffUtc) : void 0;
|
|
9586
9607
|
const when = vm.isLive ? ui.liveLabel : vm.kickoffLabel ?? (kickoffFallback ? `${kickoffFallback.dayLabel} ${kickoffFallback.time}` : void 0);
|
|
@@ -9599,7 +9620,7 @@ function Row({ row, columns, ui, slip, monitor, rowRef }) {
|
|
|
9599
9620
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "ss-w-mol-cells", style: { gridTemplateColumns: `repeat(${row.cells.length || columns}, minmax(0, 1fr))` }, children: row.cells.map((cell2) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Cell, { row, cell: cell2, ui, slip }, cell2.row.key)) }),
|
|
9600
9621
|
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("span", { className: vm.isLive ? "ss-w-mol-side ss-w-mol-side--live" : "ss-w-mol-side", children: [
|
|
9601
9622
|
when ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "ss-w-mol-when", children: when }) : null,
|
|
9602
|
-
|
|
9623
|
+
count2 !== null && monitor && ui ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AllMarketsButton, { vm, count: count2, monitor, ui, surface: "list" }) : monitor && (vm.pinEnabled && vm.isLive || nflPin) && (0, import_widget_sdk23.mayPinOrSlip)(vm.sport) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(PinToggle, { ui, monitor, pin: { kind: "match", matchId: vm.matchId, sport: (0, import_widget_sdk23.slipSportOf)(vm.sport) } }) : null
|
|
9603
9624
|
] })
|
|
9604
9625
|
] });
|
|
9605
9626
|
}
|
|
@@ -10796,7 +10817,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10796
10817
|
};
|
|
10797
10818
|
}, [labelSignature]);
|
|
10798
10819
|
if (tabs.length < 2) return null;
|
|
10799
|
-
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ss-w-tabs", role: "tablist", ref: listRef, children: tabs.map(({ tab, label, count, dot }) => {
|
|
10820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ss-w-tabs", role: "tablist", ref: listRef, children: tabs.map(({ tab, label, count: count2, dot }) => {
|
|
10800
10821
|
const active = monitor.activeTab === tab;
|
|
10801
10822
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
10802
10823
|
"button",
|
|
@@ -10805,7 +10826,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10805
10826
|
role: "tab",
|
|
10806
10827
|
"aria-selected": active,
|
|
10807
10828
|
"data-on": active ? "" : void 0,
|
|
10808
|
-
"aria-label": tab === "live" &&
|
|
10829
|
+
"aria-label": tab === "live" && count2 > 0 ? `${label} \xB7 ${ui.liveCountLabel(count2)}` : void 0,
|
|
10809
10830
|
className: "ss-w-tab",
|
|
10810
10831
|
onClick: () => {
|
|
10811
10832
|
if (tab !== monitor.activeTab) track({ name: "tab_change", from: monitor.activeTab, to: tab });
|
|
@@ -10813,7 +10834,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10813
10834
|
},
|
|
10814
10835
|
children: [
|
|
10815
10836
|
label,
|
|
10816
|
-
|
|
10837
|
+
count2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ss-w-tab-count", "aria-hidden": tab === "live" ? true : void 0, children: count2 }),
|
|
10817
10838
|
dot && !active && /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ss-w-tab-dot", "aria-hidden": "true" })
|
|
10818
10839
|
]
|
|
10819
10840
|
},
|
|
@@ -11856,7 +11877,7 @@ var nflDescriptor = (ui) => ({
|
|
|
11856
11877
|
statShort: (stat) => stat.shortLabel,
|
|
11857
11878
|
mainStat: (p) => STAT_ORDER2.map((k) => p.stats.find((s) => s.stat === k)).find((s) => s != null && hasMainLine(s)),
|
|
11858
11879
|
bars: (stat) => [...stat.games ?? []].reverse().map((g) => ({ label: g.opponent, away: !g.isHome, value: g.value })),
|
|
11859
|
-
barsTitle: (
|
|
11880
|
+
barsTitle: (count2) => count2 === 1 ? ui.nfl.propsLastOne : fillNfl(ui.nfl.propsLastN, { n: count2 }),
|
|
11860
11881
|
showHits: true,
|
|
11861
11882
|
live: (stat, player) => {
|
|
11862
11883
|
const now = LIVE_VALUE2[stat.stat];
|
|
@@ -15950,10 +15971,10 @@ function formationSlots(formation) {
|
|
|
15950
15971
|
const lines = [1, ...outfield];
|
|
15951
15972
|
const template = FORMATION_POSITIONS[used];
|
|
15952
15973
|
const slots = [];
|
|
15953
|
-
lines.forEach((
|
|
15974
|
+
lines.forEach((count2, li) => {
|
|
15954
15975
|
const top = 88 - li * (77 / (lines.length - 1));
|
|
15955
|
-
for (let ci = 0; ci <
|
|
15956
|
-
const left =
|
|
15976
|
+
for (let ci = 0; ci < count2; ci++) {
|
|
15977
|
+
const left = count2 === 1 ? 50 : 12 + ci * (76 / (count2 - 1));
|
|
15957
15978
|
slots.push({ index: slots.length, label: template?.[li]?.[ci] ?? lineFallback(li, lines.length), left, top });
|
|
15958
15979
|
}
|
|
15959
15980
|
});
|