@sensiblestats/widget-react 0.71.0 → 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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.72.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Onboarding presets, stage 3: the open pick pool.
8
+
9
+ - widget-sdk: `ComboLeg.insight` is optional and may be null; `getPricePresets` and
10
+ `Conversation.getPricePresets(locale, { pool })` take `pool: 'open'`.
11
+ - widget-react: a combo leg with no stat is drawn with its price and no stat line, and its slip
12
+ selection carries no `insightId`, instead of the whole card being dropped; every chat request
13
+ declares `price_presets_open`; the preset grid is asked with `pool=open`. Picking a combo total that exists only at another match count moves the match count to the nearest count that has it.
14
+ - widget-embed: rebuilt against the new widget-react and widget-sdk.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @sensiblestats/widget-sdk@0.47.0
20
+
3
21
  ## 0.71.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1140,7 +1140,8 @@ function toComboLegVM(leg) {
1140
1140
  const insight = leg.insight && typeof leg.insight === "object" ? leg.insight : void 0;
1141
1141
  const insightId = str(insight?.insightId);
1142
1142
  const statText = str(insight?.text);
1143
- if (price === void 0 || matchOddsId === void 0 || matchId === void 0 || !home || !away || !selectionLabel || !insightId || !statText) return null;
1143
+ const hasStat = !!insightId && !!statText;
1144
+ if (price === void 0 || matchOddsId === void 0 || matchId === void 0 || !home || !away || !selectionLabel) return null;
1144
1145
  const line = str(leg.line);
1145
1146
  return {
1146
1147
  key: `${matchOddsId}`,
@@ -1161,8 +1162,7 @@ function toComboLegVM(leg) {
1161
1162
  oddsDecimal: price,
1162
1163
  matchOddsId,
1163
1164
  quotedAtUtc: str(leg.quotedAtUtc),
1164
- insightId,
1165
- statText,
1165
+ ...hasStat ? { insightId, statText } : {},
1166
1166
  pinEnabled: leg.pinEnabled === true
1167
1167
  };
1168
1168
  }
@@ -1190,9 +1190,9 @@ function comboLegToSlipSelection(leg, conversationId) {
1190
1190
  const selection = {
1191
1191
  matchOddsId: leg.matchOddsId,
1192
1192
  matchId: leg.matchId,
1193
- oddsDecimal: leg.oddsDecimal,
1194
- insightId: leg.insightId
1193
+ oddsDecimal: leg.oddsDecimal
1195
1194
  };
1195
+ if (leg.insightId !== void 0) selection.insightId = leg.insightId;
1196
1196
  if (leg.quotedAtUtc !== void 0) selection.quotedAtUtc = leg.quotedAtUtc;
1197
1197
  if (conversationId !== void 0) selection.conversationId = conversationId;
1198
1198
  return selection;
@@ -1411,7 +1411,7 @@ function ChatHeader({
1411
1411
  var import_react22 = require("react");
1412
1412
 
1413
1413
  // src/presets.ts
1414
- var CLIENT_CAPABILITIES = ["price_presets"];
1414
+ var CLIENT_CAPABILITIES = ["price_presets", "price_presets_open"];
1415
1415
  var PRICE_TILE_PREFIX = "goal-preset-";
1416
1416
  function isPriceTile(tile) {
1417
1417
  const id = tile.signal?.entityId;
@@ -2124,7 +2124,7 @@ function ComboLegRow({ leg, addToSlipEnabled, ui, slip, monitor }) {
2124
2124
  }
2125
2125
  )
2126
2126
  ] }),
2127
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "ss-w-combo-leg-stat", children: leg.statText })
2127
+ leg.statText ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "ss-w-combo-leg-stat", children: leg.statText }) : null
2128
2128
  ] });
2129
2129
  }
2130
2130
  function ComboCardView({ vm, ui, slip, monitor }) {
@@ -7104,6 +7104,20 @@ function findCombo(grid, total, legs) {
7104
7104
  const whole = !!combo && typeof combo.multiplication === "string" && combo.multiplication !== "" && Array.isArray(combo.legs) && combo.legs.length === legs && combo.legs.every(drawable);
7105
7105
  return cell && whole ? cell : null;
7106
7106
  }
7107
+ function legsForTotal(grid, total, legs) {
7108
+ if (findCombo(grid, total, legs)) return legs;
7109
+ let best = legs;
7110
+ let bestGap = Infinity;
7111
+ for (const n of comboLegChoices(grid)) {
7112
+ if (!findCombo(grid, total, n)) continue;
7113
+ const gap = Math.abs(n - legs);
7114
+ if (gap < bestGap) {
7115
+ best = n;
7116
+ bestGap = gap;
7117
+ }
7118
+ }
7119
+ return best;
7120
+ }
7107
7121
  function idsOf(picks) {
7108
7122
  return { matchOddsIds: picks.map((p) => p.matchOddsId), matchIds: picks.map((p) => p.matchId) };
7109
7123
  }
@@ -7247,8 +7261,10 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
7247
7261
  };
7248
7262
  const nextTotal = () => {
7249
7263
  const v = cycle(totals, total);
7264
+ const l = legsForTotal(grid, v, legs);
7250
7265
  setTotal(v);
7251
- announce(strings.comboDisplay(legs, v), !!findCombo(grid, v, legs));
7266
+ setLegs(l);
7267
+ announce(strings.comboDisplay(l, v), !!findCombo(grid, v, l));
7252
7268
  };
7253
7269
  return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(PresetToolModal, { title: strings.setNumbers, closeLabel: strings.close, onClose, children: [
7254
7270
  /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("section", { className: "ss-w-tool-row", children: [
@@ -7288,7 +7304,10 @@ function BuildComboTool({ grid, strings, streaming, formatKickoff, initialTotal,
7288
7304
  const totals = comboTotals(grid);
7289
7305
  const legChoices = comboLegChoices(grid);
7290
7306
  const [total, setTotal] = (0, import_react41.useState)(() => initialTotal !== void 0 ? nearest(totals, initialTotal) : startValue(totals, START.comboTotal));
7291
- const [legs, setLegs] = (0, import_react41.useState)(() => initialLegs !== void 0 ? clampLegs(legChoices, initialLegs) : startValue(legChoices, START.comboLegs));
7307
+ const [legs, setLegs] = (0, import_react41.useState)(() => {
7308
+ const start = initialLegs !== void 0 ? clampLegs(legChoices, initialLegs) : startValue(legChoices, START.comboLegs);
7309
+ return initialTotal !== void 0 ? legsForTotal(grid, nearest(totals, initialTotal), start) : start;
7310
+ });
7292
7311
  const [announcement, setAnnouncement] = (0, import_react41.useState)("");
7293
7312
  const cell = findCombo(grid, total, legs);
7294
7313
  const minLegs = legChoices[0] ?? legs;
@@ -7306,7 +7325,7 @@ function BuildComboTool({ grid, strings, streaming, formatKickoff, initialTotal,
7306
7325
  return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(PresetToolModal, { title: strings.buildCombo, closeLabel: strings.close, onClose, footer, children: [
7307
7326
  /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "ss-w-tool-section", role: "group", "aria-label": strings.totalLabel, children: [
7308
7327
  /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "ss-w-tool-label", "aria-hidden": "true", children: strings.totalLabel }),
7309
- /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "ss-w-tool-chips", children: totals.map((t) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("button", { type: "button", className: "ss-w-tool-chip", "aria-pressed": samePrice(t, total), onClick: () => choose(t, legs), children: t.toFixed(1) }, t)) })
7328
+ /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "ss-w-tool-chips", children: totals.map((t) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("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)) })
7310
7329
  ] }),
7311
7330
  /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { className: "ss-w-tool-section", role: "group", "aria-label": strings.matchesLabel, children: [
7312
7331
  /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("span", { className: "ss-w-tool-label", "aria-hidden": "true", children: strings.matchesLabel }),
@@ -10910,7 +10929,7 @@ function StatsWidget(props) {
10910
10929
  const gamesResult = useGames(built?.conversation ?? null, { activeTab: monitor.activeTab });
10911
10930
  const leaderboardResult = useLeaderboard(built?.conversation ?? null, { activeTab: monitor.activeTab });
10912
10931
  const getPricePresets = (0, import_react55.useCallback)(
10913
- (locale2) => built ? built.conversation.getPricePresets(locale2) : Promise.resolve(null),
10932
+ (locale2) => built ? built.conversation.getPricePresets(locale2, { pool: "open" }) : Promise.resolve(null),
10914
10933
  [built]
10915
10934
  );
10916
10935
  const presetGrid = usePresetGrid({ getPricePresets, isOpen: controller.state.isOpen, locale: ui.presets.lang });