@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/dist/index.js
CHANGED
|
@@ -869,7 +869,7 @@ var BUNDLED_EN_GB = {
|
|
|
869
869
|
};
|
|
870
870
|
|
|
871
871
|
// src/strings/fill.ts
|
|
872
|
-
var pickForm = (row,
|
|
872
|
+
var pickForm = (row, count2, tag2) => row[new Intl.PluralRules(tag2).select(count2)] ?? row.other;
|
|
873
873
|
function fill(template, tokens, tag2) {
|
|
874
874
|
const text2 = typeof template === "string" ? template : pickForm(template, Number(tokens[template.$count ?? "count"]), tag2);
|
|
875
875
|
return text2.replace(/\{(\w+)\}/g, (match, name) => Object.prototype.hasOwnProperty.call(tokens, name) ? String(tokens[name]) : match);
|
|
@@ -1298,7 +1298,7 @@ function parseOddsFormat(value) {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
|
|
1300
1300
|
// src/version.generated.ts
|
|
1301
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1301
|
+
var WIDGET_REACT_VERSION = "0.138.0";
|
|
1302
1302
|
|
|
1303
1303
|
// src/config.ts
|
|
1304
1304
|
function hostTag(cfg) {
|
|
@@ -1863,6 +1863,19 @@ function str(v) {
|
|
|
1863
1863
|
function num(v) {
|
|
1864
1864
|
return typeof v === "number" && Number.isFinite(v) ? String(v) : void 0;
|
|
1865
1865
|
}
|
|
1866
|
+
function count(v) {
|
|
1867
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : void 0;
|
|
1868
|
+
}
|
|
1869
|
+
function readRecord(raw) {
|
|
1870
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
1871
|
+
const r = raw;
|
|
1872
|
+
const wins = count(r.wins);
|
|
1873
|
+
const losses = count(r.losses);
|
|
1874
|
+
if (wins === void 0 || losses === void 0) return void 0;
|
|
1875
|
+
const draws = count(r.draws);
|
|
1876
|
+
const ties = count(r.ties);
|
|
1877
|
+
return { wins, losses, ...draws !== void 0 ? { draws } : {}, ...ties !== void 0 ? { ties } : {} };
|
|
1878
|
+
}
|
|
1866
1879
|
function readStatCells(raw) {
|
|
1867
1880
|
if (!Array.isArray(raw)) return [];
|
|
1868
1881
|
const cells = [];
|
|
@@ -1871,7 +1884,8 @@ function readStatCells(raw) {
|
|
|
1871
1884
|
const value = num(entry.value) ?? str(entry.value);
|
|
1872
1885
|
if (label === void 0 || value === void 0) continue;
|
|
1873
1886
|
const note = str(entry.note);
|
|
1874
|
-
|
|
1887
|
+
const record2 = readRecord(entry.record);
|
|
1888
|
+
cells.push({ label, value, ...note !== void 0 ? { note } : {}, ...entry.muted === true ? { muted: true } : {}, ...record2 ? { record: record2 } : {} });
|
|
1875
1889
|
}
|
|
1876
1890
|
return cells;
|
|
1877
1891
|
}
|
|
@@ -1890,7 +1904,7 @@ function toCardVM(card) {
|
|
|
1890
1904
|
};
|
|
1891
1905
|
}).filter((s) => s !== null) : [];
|
|
1892
1906
|
return {
|
|
1893
|
-
id:
|
|
1907
|
+
id: `${kind}:${card.entityId}`,
|
|
1894
1908
|
kind,
|
|
1895
1909
|
name: card.canonicalName,
|
|
1896
1910
|
image: str(card.imagePath) ?? str(card.imageUrl) ?? str(card.image_url) ?? str(card.logoUrl) ?? str(card.logo),
|
|
@@ -6566,7 +6580,7 @@ function allMarketsCount(vm, monitor) {
|
|
|
6566
6580
|
if (!monitor?.enabled || !vm.pinEnabled || sportOf7(vm.sport) !== void 0) return null;
|
|
6567
6581
|
return vm.marketCount !== void 0 && vm.marketCount >= 2 ? vm.marketCount : null;
|
|
6568
6582
|
}
|
|
6569
|
-
function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
6583
|
+
function AllMarketsButton({ vm, count: count2, monitor, ui, surface }) {
|
|
6570
6584
|
const log = useEventLog();
|
|
6571
6585
|
const [toast, setToast] = useState24(null);
|
|
6572
6586
|
const dismiss = useCallback18(() => setToast(null), []);
|
|
@@ -6583,9 +6597,9 @@ function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
|
6583
6597
|
outcome: surface === "card" ? "all_markets_card" : "all_markets_list"
|
|
6584
6598
|
});
|
|
6585
6599
|
};
|
|
6586
|
-
const label = vm.homeTeamName && vm.awayTeamName ? ui.allMarketsAria(
|
|
6600
|
+
const label = vm.homeTeamName && vm.awayTeamName ? ui.allMarketsAria(count2, vm.homeTeamName, vm.awayTeamName) : void 0;
|
|
6587
6601
|
return /* @__PURE__ */ jsxs10("span", { className: surface === "card" ? "ss-w-allmk-wrap" : "ss-w-allmk-wrap ss-w-allmk-wrap--chip", children: [
|
|
6588
|
-
/* @__PURE__ */ jsxs10("button", { type: "button", className: surface === "card" ? "ss-w-allmk" : "ss-w-allmk ss-w-allmk--chip", "aria-label": label ?? ui.allMarkets(
|
|
6602
|
+
/* @__PURE__ */ jsxs10("button", { type: "button", className: surface === "card" ? "ss-w-allmk" : "ss-w-allmk ss-w-allmk--chip", "aria-label": label ?? ui.allMarkets(count2), onClick, children: [
|
|
6589
6603
|
/* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6590
6604
|
/* @__PURE__ */ jsx12("rect", { x: "3", y: "5", width: "5", height: "5", rx: "1.2" }),
|
|
6591
6605
|
/* @__PURE__ */ jsx12("rect", { x: "9.5", y: "5", width: "5", height: "5", rx: "1.2" }),
|
|
@@ -6594,7 +6608,7 @@ function AllMarketsButton({ vm, count, monitor, ui, surface }) {
|
|
|
6594
6608
|
/* @__PURE__ */ jsx12("rect", { x: "9.5", y: "14", width: "5", height: "5", rx: "1.2" }),
|
|
6595
6609
|
/* @__PURE__ */ jsx12("rect", { x: "16", y: "14", width: "5", height: "5", rx: "1.2" })
|
|
6596
6610
|
] }),
|
|
6597
|
-
surface === "card" ? ui.allMarkets(
|
|
6611
|
+
surface === "card" ? ui.allMarkets(count2) : count2
|
|
6598
6612
|
] }),
|
|
6599
6613
|
/* @__PURE__ */ jsx12(Toast, { toast, onDismiss: dismiss })
|
|
6600
6614
|
] });
|
|
@@ -7936,6 +7950,13 @@ function cellClass(s) {
|
|
|
7936
7950
|
return s.muted ? "ss-w-ecard-cell ss-w-ecard-cell--muted" : "ss-w-ecard-cell";
|
|
7937
7951
|
}
|
|
7938
7952
|
function StatCellView({ s }) {
|
|
7953
|
+
if (s.record) {
|
|
7954
|
+
return /* @__PURE__ */ jsxs29("div", { className: cellClass(s), children: [
|
|
7955
|
+
/* @__PURE__ */ jsx33("span", { className: "ss-w-ecard-cval", children: /* @__PURE__ */ jsx33(FormBar, { w: s.record.wins, d: s.record.draws ?? s.record.ties ?? 0, l: s.record.losses }) }),
|
|
7956
|
+
/* @__PURE__ */ jsx33("span", { className: "ss-w-ecard-clabel", children: `${s.label} ${s.value}` }),
|
|
7957
|
+
s.note ? /* @__PURE__ */ jsx33("span", { className: "ss-w-ecard-note", children: s.note }) : null
|
|
7958
|
+
] });
|
|
7959
|
+
}
|
|
7939
7960
|
const m = RECORD_RE.exec(s.value);
|
|
7940
7961
|
if (m) {
|
|
7941
7962
|
return /* @__PURE__ */ jsxs29("div", { className: cellClass(s), children: [
|
|
@@ -7996,7 +8017,7 @@ function ScopeTabs({ scopes, active, onSelect }) {
|
|
|
7996
8017
|
onClick: () => onSelect(i),
|
|
7997
8018
|
children: s.image ? /* @__PURE__ */ jsx33(Crest2, { image: s.image }) : s.label
|
|
7998
8019
|
},
|
|
7999
|
-
String(s.competitionId
|
|
8020
|
+
s.competitionId == null ? `i${i}` : String(s.competitionId)
|
|
8000
8021
|
)) });
|
|
8001
8022
|
}
|
|
8002
8023
|
function EntityCardItem({ c }) {
|
|
@@ -9541,7 +9562,7 @@ function Cell({ row, cell: cell2, ui, slip }) {
|
|
|
9541
9562
|
function Row({ row, columns, ui, slip, monitor, rowRef }) {
|
|
9542
9563
|
const vm = row.card;
|
|
9543
9564
|
useNextKickoffRender(isNfl(vm.sport) ? [vm.kickoffUtc] : []);
|
|
9544
|
-
const
|
|
9565
|
+
const count2 = allMarketsCount(vm, monitor);
|
|
9545
9566
|
const nflPin = sportOf10(vm.sport) === "americanfootball" && !vm.isLive;
|
|
9546
9567
|
const kickoffFallback = vm.kickoffUtc ? ui.bettingKickoff(vm.kickoffUtc) : void 0;
|
|
9547
9568
|
const when = vm.isLive ? ui.liveLabel : vm.kickoffLabel ?? (kickoffFallback ? `${kickoffFallback.dayLabel} ${kickoffFallback.time}` : void 0);
|
|
@@ -9560,7 +9581,7 @@ function Row({ row, columns, ui, slip, monitor, rowRef }) {
|
|
|
9560
9581
|
/* @__PURE__ */ jsx40("span", { className: "ss-w-mol-cells", style: { gridTemplateColumns: `repeat(${row.cells.length || columns}, minmax(0, 1fr))` }, children: row.cells.map((cell2) => /* @__PURE__ */ jsx40(Cell, { row, cell: cell2, ui, slip }, cell2.row.key)) }),
|
|
9561
9582
|
/* @__PURE__ */ jsxs36("span", { className: vm.isLive ? "ss-w-mol-side ss-w-mol-side--live" : "ss-w-mol-side", children: [
|
|
9562
9583
|
when ? /* @__PURE__ */ jsx40("span", { className: "ss-w-mol-when", children: when }) : null,
|
|
9563
|
-
|
|
9584
|
+
count2 !== null && monitor && ui ? /* @__PURE__ */ jsx40(AllMarketsButton, { vm, count: count2, monitor, ui, surface: "list" }) : monitor && (vm.pinEnabled && vm.isLive || nflPin) && mayPinOrSlip5(vm.sport) ? /* @__PURE__ */ jsx40(PinToggle, { ui, monitor, pin: { kind: "match", matchId: vm.matchId, sport: slipSportOf6(vm.sport) } }) : null
|
|
9564
9585
|
] })
|
|
9565
9586
|
] });
|
|
9566
9587
|
}
|
|
@@ -10757,7 +10778,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10757
10778
|
};
|
|
10758
10779
|
}, [labelSignature]);
|
|
10759
10780
|
if (tabs.length < 2) return null;
|
|
10760
|
-
return /* @__PURE__ */ jsx69("div", { className: "ss-w-tabs", role: "tablist", ref: listRef, children: tabs.map(({ tab, label, count, dot }) => {
|
|
10781
|
+
return /* @__PURE__ */ jsx69("div", { className: "ss-w-tabs", role: "tablist", ref: listRef, children: tabs.map(({ tab, label, count: count2, dot }) => {
|
|
10761
10782
|
const active = monitor.activeTab === tab;
|
|
10762
10783
|
return /* @__PURE__ */ jsxs64(
|
|
10763
10784
|
"button",
|
|
@@ -10766,7 +10787,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10766
10787
|
role: "tab",
|
|
10767
10788
|
"aria-selected": active,
|
|
10768
10789
|
"data-on": active ? "" : void 0,
|
|
10769
|
-
"aria-label": tab === "live" &&
|
|
10790
|
+
"aria-label": tab === "live" && count2 > 0 ? `${label} \xB7 ${ui.liveCountLabel(count2)}` : void 0,
|
|
10770
10791
|
className: "ss-w-tab",
|
|
10771
10792
|
onClick: () => {
|
|
10772
10793
|
if (tab !== monitor.activeTab) track({ name: "tab_change", from: monitor.activeTab, to: tab });
|
|
@@ -10774,7 +10795,7 @@ function TabBar({ monitor, ui, matchCount, trendsCount, liveCount, hasSchedule,
|
|
|
10774
10795
|
},
|
|
10775
10796
|
children: [
|
|
10776
10797
|
label,
|
|
10777
|
-
|
|
10798
|
+
count2 > 0 && /* @__PURE__ */ jsx69("span", { className: "ss-w-tab-count", "aria-hidden": tab === "live" ? true : void 0, children: count2 }),
|
|
10778
10799
|
dot && !active && /* @__PURE__ */ jsx69("span", { className: "ss-w-tab-dot", "aria-hidden": "true" })
|
|
10779
10800
|
]
|
|
10780
10801
|
},
|
|
@@ -11817,7 +11838,7 @@ var nflDescriptor = (ui) => ({
|
|
|
11817
11838
|
statShort: (stat) => stat.shortLabel,
|
|
11818
11839
|
mainStat: (p) => STAT_ORDER2.map((k) => p.stats.find((s) => s.stat === k)).find((s) => s != null && hasMainLine(s)),
|
|
11819
11840
|
bars: (stat) => [...stat.games ?? []].reverse().map((g) => ({ label: g.opponent, away: !g.isHome, value: g.value })),
|
|
11820
|
-
barsTitle: (
|
|
11841
|
+
barsTitle: (count2) => count2 === 1 ? ui.nfl.propsLastOne : fillNfl(ui.nfl.propsLastN, { n: count2 }),
|
|
11821
11842
|
showHits: true,
|
|
11822
11843
|
live: (stat, player) => {
|
|
11823
11844
|
const now = LIVE_VALUE2[stat.stat];
|
|
@@ -15911,10 +15932,10 @@ function formationSlots(formation) {
|
|
|
15911
15932
|
const lines = [1, ...outfield];
|
|
15912
15933
|
const template = FORMATION_POSITIONS[used];
|
|
15913
15934
|
const slots = [];
|
|
15914
|
-
lines.forEach((
|
|
15935
|
+
lines.forEach((count2, li) => {
|
|
15915
15936
|
const top = 88 - li * (77 / (lines.length - 1));
|
|
15916
|
-
for (let ci = 0; ci <
|
|
15917
|
-
const left =
|
|
15937
|
+
for (let ci = 0; ci < count2; ci++) {
|
|
15938
|
+
const left = count2 === 1 ? 50 : 12 + ci * (76 / (count2 - 1));
|
|
15918
15939
|
slots.push({ index: slots.length, label: template?.[li]?.[ci] ?? lineFallback(li, lines.length), left, top });
|
|
15919
15940
|
}
|
|
15920
15941
|
});
|