@sensiblestats/widget-react 0.70.1 → 0.72.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 +29 -0
- package/dist/index.cjs +44 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1102,7 +1102,8 @@ function toComboLegVM(leg) {
|
|
|
1102
1102
|
const insight = leg.insight && typeof leg.insight === "object" ? leg.insight : void 0;
|
|
1103
1103
|
const insightId = str(insight?.insightId);
|
|
1104
1104
|
const statText = str(insight?.text);
|
|
1105
|
-
|
|
1105
|
+
const hasStat = !!insightId && !!statText;
|
|
1106
|
+
if (price === void 0 || matchOddsId === void 0 || matchId === void 0 || !home || !away || !selectionLabel) return null;
|
|
1106
1107
|
const line = str(leg.line);
|
|
1107
1108
|
return {
|
|
1108
1109
|
key: `${matchOddsId}`,
|
|
@@ -1123,8 +1124,8 @@ function toComboLegVM(leg) {
|
|
|
1123
1124
|
oddsDecimal: price,
|
|
1124
1125
|
matchOddsId,
|
|
1125
1126
|
quotedAtUtc: str(leg.quotedAtUtc),
|
|
1126
|
-
insightId,
|
|
1127
|
-
|
|
1127
|
+
...hasStat ? { insightId, statText } : {},
|
|
1128
|
+
pinEnabled: leg.pinEnabled === true
|
|
1128
1129
|
};
|
|
1129
1130
|
}
|
|
1130
1131
|
function toComboCardVM(card) {
|
|
@@ -1151,9 +1152,9 @@ function comboLegToSlipSelection(leg, conversationId) {
|
|
|
1151
1152
|
const selection = {
|
|
1152
1153
|
matchOddsId: leg.matchOddsId,
|
|
1153
1154
|
matchId: leg.matchId,
|
|
1154
|
-
oddsDecimal: leg.oddsDecimal
|
|
1155
|
-
insightId: leg.insightId
|
|
1155
|
+
oddsDecimal: leg.oddsDecimal
|
|
1156
1156
|
};
|
|
1157
|
+
if (leg.insightId !== void 0) selection.insightId = leg.insightId;
|
|
1157
1158
|
if (leg.quotedAtUtc !== void 0) selection.quotedAtUtc = leg.quotedAtUtc;
|
|
1158
1159
|
if (conversationId !== void 0) selection.conversationId = conversationId;
|
|
1159
1160
|
return selection;
|
|
@@ -1372,7 +1373,7 @@ function ChatHeader({
|
|
|
1372
1373
|
import { useEffect as useEffect7, useRef as useRef4 } from "react";
|
|
1373
1374
|
|
|
1374
1375
|
// src/presets.ts
|
|
1375
|
-
var CLIENT_CAPABILITIES = ["price_presets"];
|
|
1376
|
+
var CLIENT_CAPABILITIES = ["price_presets", "price_presets_open"];
|
|
1376
1377
|
var PRICE_TILE_PREFIX = "goal-preset-";
|
|
1377
1378
|
function isPriceTile(tile) {
|
|
1378
1379
|
const id = tile.signal?.entityId;
|
|
@@ -2045,16 +2046,20 @@ function usePresetTools() {
|
|
|
2045
2046
|
|
|
2046
2047
|
// src/components/ComboCardList.tsx
|
|
2047
2048
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2048
|
-
function ComboLegRow({ leg, addToSlipEnabled, ui, slip }) {
|
|
2049
|
+
function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor }) {
|
|
2049
2050
|
const kickoffFallback = !leg.kickoffLabel && leg.kickoffUtc && ui?.bettingKickoff ? ui.bettingKickoff(leg.kickoffUtc) : void 0;
|
|
2050
2051
|
const kickoff = leg.kickoffLabel ?? (kickoffFallback ? `${kickoffFallback.dayLabel} ${kickoffFallback.time}` : void 0);
|
|
2051
2052
|
const selection = addToSlipEnabled ? comboLegToSlipSelection(leg, slip.conversationId) : null;
|
|
2053
|
+
const showPin = !!monitor && leg.pinEnabled && !!ui;
|
|
2052
2054
|
return /* @__PURE__ */ jsxs9("li", { className: "ss-w-combo-leg", children: [
|
|
2053
|
-
leg.competition || kickoff ? /* @__PURE__ */ jsxs9("div", { className: "ss-w-combo-leg-meta", children: [
|
|
2055
|
+
leg.competition || kickoff || showPin ? /* @__PURE__ */ jsxs9("div", { className: "ss-w-combo-leg-meta", children: [
|
|
2054
2056
|
/* @__PURE__ */ jsx14("span", { className: "ss-w-bi-comp", children: leg.competition ?? "" }),
|
|
2055
|
-
|
|
2057
|
+
/* @__PURE__ */ jsxs9("span", { className: "ss-w-bi-meta-right", children: [
|
|
2058
|
+
kickoff ? /* @__PURE__ */ jsx14("span", { className: "ss-w-bi-kick", children: kickoff }) : null,
|
|
2059
|
+
showPin && ui ? /* @__PURE__ */ jsx14(PinToggle, { ui, monitor, pin: { kind: "match", matchId: leg.matchId } }) : null
|
|
2060
|
+
] })
|
|
2056
2061
|
] }) : null,
|
|
2057
|
-
/* @__PURE__ */ jsxs9(
|
|
2062
|
+
/* @__PURE__ */ jsxs9("div", { className: "ss-w-bi-fixture-line", children: [
|
|
2058
2063
|
/* @__PURE__ */ jsx14(Crest2, { kind: "team", url: leg.homeCrest, name: leg.homeTeamName }),
|
|
2059
2064
|
/* @__PURE__ */ jsx14("span", { className: "ss-w-bi-team", children: leg.homeTeamName }),
|
|
2060
2065
|
/* @__PURE__ */ jsx14("span", { className: "ss-w-bi-vs", "aria-hidden": "true", children: "vs" }),
|
|
@@ -2081,22 +2086,22 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip }) {
|
|
|
2081
2086
|
}
|
|
2082
2087
|
)
|
|
2083
2088
|
] }),
|
|
2084
|
-
/* @__PURE__ */ jsx14("p", { className: "ss-w-combo-leg-stat", children: leg.statText })
|
|
2089
|
+
leg.statText ? /* @__PURE__ */ jsx14("p", { className: "ss-w-combo-leg-stat", children: leg.statText }) : null
|
|
2085
2090
|
] });
|
|
2086
2091
|
}
|
|
2087
|
-
function ComboCardView({ vm, ui, slip }) {
|
|
2092
|
+
function ComboCardView({ vm, ui, slip, monitor }) {
|
|
2088
2093
|
const tools = usePresetTools();
|
|
2089
2094
|
const { target, legCount } = vm;
|
|
2090
2095
|
return /* @__PURE__ */ jsxs9("div", { className: "ss-w-combo", children: [
|
|
2091
|
-
/* @__PURE__ */ jsx14("ol", { className: "ss-w-combo-legs", role: "list", children: vm.legs.map((leg) => /* @__PURE__ */ jsx14(ComboLegRow, { leg, addToSlipEnabled: vm.addToSlipEnabled, ui, slip }, leg.key)) }),
|
|
2096
|
+
/* @__PURE__ */ jsx14("ol", { className: "ss-w-combo-legs", role: "list", children: vm.legs.map((leg) => /* @__PURE__ */ jsx14(ComboLegRow, { leg, addToSlipEnabled: vm.addToSlipEnabled, ui, slip, monitor }, leg.key)) }),
|
|
2092
2097
|
/* @__PURE__ */ jsx14("div", { className: "ss-w-combo-math", children: vm.multiplication }),
|
|
2093
2098
|
vm.replacedNote ? /* @__PURE__ */ jsx14("p", { className: "ss-w-combo-note", children: vm.replacedNote }) : null,
|
|
2094
2099
|
tools && target !== void 0 && legCount !== void 0 ? /* @__PURE__ */ jsx14("button", { type: "button", className: "ss-w-combo-change", onClick: () => tools.openBuilder(target, legCount), children: tools.changeLabel }) : null
|
|
2095
2100
|
] });
|
|
2096
2101
|
}
|
|
2097
|
-
function ComboCardList({ cards, ui, slip }) {
|
|
2102
|
+
function ComboCardList({ cards, ui, slip, monitor }) {
|
|
2098
2103
|
if (!cards || cards.length === 0) return null;
|
|
2099
|
-
return /* @__PURE__ */ jsx14("div", { className: "ss-w-combos", children: cards.map((vm) => /* @__PURE__ */ jsx14(ComboCardView, { vm, ui, slip }, vm.id)) });
|
|
2104
|
+
return /* @__PURE__ */ jsx14("div", { className: "ss-w-combos", children: cards.map((vm) => /* @__PURE__ */ jsx14(ComboCardView, { vm, ui, slip, monitor }, vm.id)) });
|
|
2100
2105
|
}
|
|
2101
2106
|
|
|
2102
2107
|
// src/components/MarketOddsCardList.tsx
|
|
@@ -3359,7 +3364,7 @@ function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor }) {
|
|
|
3359
3364
|
message.clubFanDashboard ? /* @__PURE__ */ jsx43(ClubFanDashboard, { dashboard: message.clubFanDashboard, onTap: onFanDashboardTap, ui }) : null,
|
|
3360
3365
|
/* @__PURE__ */ jsx43(EntityCardList, { cards: message.cards, disabled, showLessLabel: ui?.showLess, showMoreLabel: ui?.showMore }),
|
|
3361
3366
|
/* @__PURE__ */ jsx43(BettingInsightList, { insights: message.insights, ui, slip, monitor }),
|
|
3362
|
-
/* @__PURE__ */ jsx43(ComboCardList, { cards: message.comboCards ?? [], ui, slip }),
|
|
3367
|
+
/* @__PURE__ */ jsx43(ComboCardList, { cards: message.comboCards ?? [], ui, slip, monitor }),
|
|
3363
3368
|
compact ? /* @__PURE__ */ jsx43(CompactOddsList, { list: compact, ui, slip, monitor }) : /* @__PURE__ */ jsx43(MarketOddsCardList, { cards: message.marketOdds, ui, slip, monitor }),
|
|
3364
3369
|
/* @__PURE__ */ jsx43(OddsMovementCardList, { cards: message.oddsMovement, ui, monitor }),
|
|
3365
3370
|
/* @__PURE__ */ jsx43(ActionButtons, { actions: message.actions, loading: false, disabled, onAct })
|
|
@@ -7061,6 +7066,20 @@ function findCombo(grid, total, legs) {
|
|
|
7061
7066
|
const whole = !!combo && typeof combo.multiplication === "string" && combo.multiplication !== "" && Array.isArray(combo.legs) && combo.legs.length === legs && combo.legs.every(drawable);
|
|
7062
7067
|
return cell && whole ? cell : null;
|
|
7063
7068
|
}
|
|
7069
|
+
function legsForTotal(grid, total, legs) {
|
|
7070
|
+
if (findCombo(grid, total, legs)) return legs;
|
|
7071
|
+
let best = legs;
|
|
7072
|
+
let bestGap = Infinity;
|
|
7073
|
+
for (const n of comboLegChoices(grid)) {
|
|
7074
|
+
if (!findCombo(grid, total, n)) continue;
|
|
7075
|
+
const gap = Math.abs(n - legs);
|
|
7076
|
+
if (gap < bestGap) {
|
|
7077
|
+
best = n;
|
|
7078
|
+
bestGap = gap;
|
|
7079
|
+
}
|
|
7080
|
+
}
|
|
7081
|
+
return best;
|
|
7082
|
+
}
|
|
7064
7083
|
function idsOf(picks) {
|
|
7065
7084
|
return { matchOddsIds: picks.map((p) => p.matchOddsId), matchIds: picks.map((p) => p.matchId) };
|
|
7066
7085
|
}
|
|
@@ -7204,8 +7223,10 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
|
|
|
7204
7223
|
};
|
|
7205
7224
|
const nextTotal = () => {
|
|
7206
7225
|
const v = cycle(totals, total);
|
|
7226
|
+
const l = legsForTotal(grid, v, legs);
|
|
7207
7227
|
setTotal(v);
|
|
7208
|
-
|
|
7228
|
+
setLegs(l);
|
|
7229
|
+
announce(strings.comboDisplay(l, v), !!findCombo(grid, v, l));
|
|
7209
7230
|
};
|
|
7210
7231
|
return /* @__PURE__ */ jsxs73(PresetToolModal, { title: strings.setNumbers, closeLabel: strings.close, onClose, children: [
|
|
7211
7232
|
/* @__PURE__ */ jsxs73("section", { className: "ss-w-tool-row", children: [
|
|
@@ -7245,7 +7266,10 @@ function BuildComboTool({ grid, strings, streaming, formatKickoff, initialTotal,
|
|
|
7245
7266
|
const totals = comboTotals(grid);
|
|
7246
7267
|
const legChoices = comboLegChoices(grid);
|
|
7247
7268
|
const [total, setTotal] = useState33(() => initialTotal !== void 0 ? nearest(totals, initialTotal) : startValue(totals, START.comboTotal));
|
|
7248
|
-
const [legs, setLegs] = useState33(() =>
|
|
7269
|
+
const [legs, setLegs] = useState33(() => {
|
|
7270
|
+
const start = initialLegs !== void 0 ? clampLegs(legChoices, initialLegs) : startValue(legChoices, START.comboLegs);
|
|
7271
|
+
return initialTotal !== void 0 ? legsForTotal(grid, nearest(totals, initialTotal), start) : start;
|
|
7272
|
+
});
|
|
7249
7273
|
const [announcement, setAnnouncement] = useState33("");
|
|
7250
7274
|
const cell = findCombo(grid, total, legs);
|
|
7251
7275
|
const minLegs = legChoices[0] ?? legs;
|
|
@@ -7263,7 +7287,7 @@ function BuildComboTool({ grid, strings, streaming, formatKickoff, initialTotal,
|
|
|
7263
7287
|
return /* @__PURE__ */ jsxs73(PresetToolModal, { title: strings.buildCombo, closeLabel: strings.close, onClose, footer, children: [
|
|
7264
7288
|
/* @__PURE__ */ jsxs73("div", { className: "ss-w-tool-section", role: "group", "aria-label": strings.totalLabel, children: [
|
|
7265
7289
|
/* @__PURE__ */ jsx89("span", { className: "ss-w-tool-label", "aria-hidden": "true", children: strings.totalLabel }),
|
|
7266
|
-
/* @__PURE__ */ jsx89("div", { className: "ss-w-tool-chips", children: totals.map((t) => /* @__PURE__ */ jsx89("button", { type: "button", className: "ss-w-tool-chip", "aria-pressed": samePrice(t, total), onClick: () => choose(t, legs), children: t.toFixed(1) }, t)) })
|
|
7290
|
+
/* @__PURE__ */ jsx89("div", { className: "ss-w-tool-chips", children: totals.map((t) => /* @__PURE__ */ jsx89("button", { type: "button", className: "ss-w-tool-chip", "aria-pressed": samePrice(t, total), onClick: () => choose(t, samePrice(t, total) ? legs : legsForTotal(grid, t, legs)), children: t.toFixed(1) }, t)) })
|
|
7267
7291
|
] }),
|
|
7268
7292
|
/* @__PURE__ */ jsxs73("div", { className: "ss-w-tool-section", role: "group", "aria-label": strings.matchesLabel, children: [
|
|
7269
7293
|
/* @__PURE__ */ jsx89("span", { className: "ss-w-tool-label", "aria-hidden": "true", children: strings.matchesLabel }),
|
|
@@ -10867,7 +10891,7 @@ function StatsWidget(props) {
|
|
|
10867
10891
|
const gamesResult = useGames(built?.conversation ?? null, { activeTab: monitor.activeTab });
|
|
10868
10892
|
const leaderboardResult = useLeaderboard(built?.conversation ?? null, { activeTab: monitor.activeTab });
|
|
10869
10893
|
const getPricePresets = useCallback14(
|
|
10870
|
-
(locale2) => built ? built.conversation.getPricePresets(locale2) : Promise.resolve(null),
|
|
10894
|
+
(locale2) => built ? built.conversation.getPricePresets(locale2, { pool: "open" }) : Promise.resolve(null),
|
|
10871
10895
|
[built]
|
|
10872
10896
|
);
|
|
10873
10897
|
const presetGrid = usePresetGrid({ getPricePresets, isOpen: controller.state.isOpen, locale: ui.presets.lang });
|