@sensiblestats/widget-react 0.124.3 → 0.125.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,11 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.125.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Tennis favourites in the sport switcher: the Favourites search asks for tournaments and players (not teams), result rows and the cap notice say tournament and player, saved tournaments show under their own heading, and a tennis player shows the country code instead of "No current team". New tennis words in en, it, es, pt and tr.
8
+
3
9
  ## 0.124.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -862,7 +862,13 @@ var BUNDLED_EN_GB = {
862
862
  "widget.tennis.movedSince": "Moved since {date}",
863
863
  "widget.tennis.unchangedSince": "Unchanged since {date}",
864
864
  "widget.tennis.updated": "updated {time}",
865
- "widget.tennis.vs": "vs"
865
+ "widget.tennis.vs": "vs",
866
+ "widget.tennis.favKindPlayer": "player",
867
+ "widget.tennis.favKindTournament": "tournament",
868
+ "widget.tennis.favPlayers": "Tennis players",
869
+ "widget.tennis.favTournaments": "Tennis tournaments",
870
+ "widget.tennis.favSearchPlaceholder": "Search a player or tournament",
871
+ "widget.tennis.favEmpty": "Tap a player or tournament and this page builds around it."
866
872
  };
867
873
 
868
874
  // src/strings/fill.ts
@@ -1217,7 +1223,7 @@ function parseOddsFormat(value) {
1217
1223
  }
1218
1224
 
1219
1225
  // src/version.generated.ts
1220
- var WIDGET_REACT_VERSION = "0.124.3";
1226
+ var WIDGET_REACT_VERSION = "0.125.0";
1221
1227
 
1222
1228
  // src/config.ts
1223
1229
  function hostTag(cfg) {
@@ -6531,11 +6537,23 @@ function FavouritesInvite({ ui, onOpen }) {
6531
6537
 
6532
6538
  // src/components/dashboard/v8/useFollow.ts
6533
6539
  var import_react36 = require("react");
6540
+
6541
+ // src/favouriteKinds.ts
6542
+ function favouriteKinds(sport) {
6543
+ if (sport === "football") return ["competition", "team", "player"];
6544
+ if (sport === "tennis") return ["competition", "player"];
6545
+ return ["team", "player"];
6546
+ }
6547
+ var hasCompetitions = (sport) => favouriteKinds(sport).includes("competition");
6548
+ var hasTeams = (sport) => favouriteKinds(sport).includes("team");
6549
+ function favouriteKindLabel(ui, sport, kind) {
6550
+ if (sport === "tennis") return kind === "competition" ? ui.tennis.favKindTournament : ui.tennis.favKindPlayer;
6551
+ return kind === "competition" ? ui.favKindLeague : kind === "team" ? ui.favKindTeam : ui.favKindPlayer;
6552
+ }
6553
+
6554
+ // src/components/dashboard/v8/useFollow.ts
6534
6555
  var isFavouriteKind = (kind) => kind === "team" || kind === "player" || kind === "competition";
6535
6556
  var keyOf2 = (sport, t) => `${sport}:${t.kind}:${t.id}`;
6536
- function kindLabel(kind, ui) {
6537
- return kind === "competition" ? ui.favKindLeague : kind === "player" ? ui.favKindPlayer : ui.favKindTeam;
6538
- }
6539
6557
  function useFollow(controller, ui, holds, sport) {
6540
6558
  const [notice, setNotice] = (0, import_react36.useState)(null);
6541
6559
  const isOpen = (t) => isFavouriteKind(t.kind) && !holds.followed.has(keyOf2(sport, t)) && !controller.isStarred(t.kind, t.id);
@@ -6544,7 +6562,7 @@ function useFollow(controller, ui, holds, sport) {
6544
6562
  setNotice(null);
6545
6563
  const outcome = await controller.toggle(t.kind, t.id);
6546
6564
  if (outcome === "starred") holds.follow(keyOf2(sport, t));
6547
- else if (outcome === "at_cap") setNotice(ui.favAtCap(kindLabel(t.kind, ui)));
6565
+ else if (outcome === "at_cap") setNotice(ui.favAtCap(favouriteKindLabel(ui, sport, t.kind)));
6548
6566
  else if (outcome === "failed" || outcome === "unstarred") setNotice(ui.favError);
6549
6567
  };
6550
6568
  return { isOpen, follow, ready: controller.status === "ready", notice };
@@ -6558,7 +6576,7 @@ function FollowSuggestions({ chips, ui, controller, holds, sport }) {
6558
6576
  if (open.length === 0) return null;
6559
6577
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "ss-w-v8-sec ss-w-v8-pick", children: [
6560
6578
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("b", { className: "ss-w-v8-pick-title", children: ui.v8FollowWho }),
6561
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "ss-w-v8-pick-line", children: ui.favEmpty }),
6579
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "ss-w-v8-pick-line", children: sport === "tennis" ? ui.tennis.favEmpty : ui.favEmpty }),
6562
6580
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "ss-w-v8-chips", children: open.map((chip) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", className: "ss-w-v8-chip ss-w-v8-star", "aria-label": ui.favStar(chip.label), disabled: !ready, onClick: () => {
6563
6581
  void follow(chip);
6564
6582
  }, children: [
@@ -9668,7 +9686,7 @@ function FanDashboardCard({ card, onTap, ui, goalEvents }) {
9668
9686
 
9669
9687
  // src/components/ChatMessage.tsx
9670
9688
  var import_jsx_runtime63 = require("react/jsx-runtime");
9671
- function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor }) {
9689
+ function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor, onGreetingSport }) {
9672
9690
  const [sport, setSport] = (0, import_react57.useState)(null);
9673
9691
  if (message.role === "user") {
9674
9692
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "ss-w-msg ss-w-user", "data-msg-id": message.id, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "ss-w-bubble", children: message.text }) });
@@ -9682,7 +9700,10 @@ function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor }) {
9682
9700
  const actions = setChips ? setChips.map((c) => toActionVM({ ...c })) : message.actions;
9683
9701
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "ss-w-msg ss-w-bot", "data-msg-id": message.id, children: [
9684
9702
  message.text && !message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Markdown, { text: message.text }) : null,
9685
- message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(GreetingDashboard, { dashboard: message.greetingDashboard, dashboards: message.greetingDashboards, defaultSport: message.defaultSport, onTap, onSportChange: setSport, ui, slip, onAct }) : null,
9703
+ message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(GreetingDashboard, { dashboard: message.greetingDashboard, dashboards: message.greetingDashboards, defaultSport: message.defaultSport, onTap, onSportChange: (s) => {
9704
+ setSport(s);
9705
+ onGreetingSport?.(s);
9706
+ }, ui, slip, onAct }) : null,
9686
9707
  message.clubFanDashboard ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ClubFanDashboard, { dashboard: message.clubFanDashboard, onTap: onFanDashboardTap, ui }) : null,
9687
9708
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(EntityCardList, { cards: message.cards, disabled, showLessLabel: ui.showLess, showMoreLabel: ui.showMore }),
9688
9709
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(BettingInsightList, { insights: message.insights, ui, slip, monitor }),
@@ -9716,7 +9737,7 @@ function turnAnchor(messages) {
9716
9737
  const prev = messages[messages.length - 2];
9717
9738
  return { turnId: last.id, anchorId: prev && prev.role === "user" ? prev.id : last.id };
9718
9739
  }
9719
- function MessageList({ controller, ui, slip, onDashboardTap, monitor }) {
9740
+ function MessageList({ controller, ui, slip, onDashboardTap, monitor, onGreetingSport }) {
9720
9741
  const { state, send } = controller;
9721
9742
  const { oddsFormat } = useOddsSettings();
9722
9743
  const listRef = (0, import_react58.useRef)(null);
@@ -9762,7 +9783,8 @@ function MessageList({ controller, ui, slip, onDashboardTap, monitor }) {
9762
9783
  },
9763
9784
  ui,
9764
9785
  slip,
9765
- monitor
9786
+ monitor,
9787
+ onGreetingSport
9766
9788
  },
9767
9789
  m.id
9768
9790
  )),
@@ -15701,8 +15723,9 @@ function FavCrest({ entity: entity2, sport }) {
15701
15723
  const url = sport === "football" && entity2.kind !== "player" ? entity2.imageUrl : void 0;
15702
15724
  return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Crest, { url, name: entity2.name, kind: entity2.kind === "competition" ? "comp" : "team" });
15703
15725
  }
15704
- function PlayerTeam({ entity: entity2, ui }) {
15726
+ function PlayerTeam({ entity: entity2, ui, sport }) {
15705
15727
  if (entity2.kind !== "player") return null;
15728
+ if (sport === "tennis") return entity2.teamName ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "ss-w-fav-sub", children: entity2.teamName }) : null;
15706
15729
  return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "ss-w-fav-sub", children: entity2.teamName || ui.favNoTeam });
15707
15730
  }
15708
15731
  function Chip2({ entity: entity2, sport, ui, busy, onRemove }) {
@@ -15710,7 +15733,7 @@ function Chip2({ entity: entity2, sport, ui, busy, onRemove }) {
15710
15733
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(FavCrest, { entity: entity2, sport }),
15711
15734
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "ss-w-fav-name", children: [
15712
15735
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "ss-w-fav-title", children: entity2.name }),
15713
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(PlayerTeam, { entity: entity2, ui })
15736
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(PlayerTeam, { entity: entity2, ui, sport })
15714
15737
  ] }),
15715
15738
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("button", { type: "button", className: "ss-w-fav-x", "aria-label": ui.favRemove(entity2.name), disabled: busy, onClick: onRemove, children: "\xD7" })
15716
15739
  ] });
@@ -15756,17 +15779,17 @@ function FavouriteChips({ controller, ui, sport, sportLabel: sportLabel2, onNoti
15756
15779
  else onNotice(null);
15757
15780
  };
15758
15781
  return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
15759
- total === 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { className: "ss-w-fav-empty", children: ui.favEmpty }) : null,
15760
- sport === "football" ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: ui.favLeagues, entities: data.competitions, sport, ui, controller, onNotice }) : null,
15761
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: ui.favTeams, entities: data.teams, sport, ui, controller, onNotice }),
15762
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: ui.favPlayers, entities: data.players, sport, ui, controller, onNotice }),
15782
+ total === 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("p", { className: "ss-w-fav-empty", children: sport === "tennis" ? ui.tennis.favEmpty : ui.favEmpty }) : null,
15783
+ hasCompetitions(sport) ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: sport === "tennis" ? ui.tennis.favTournaments : ui.favLeagues, entities: data.competitions, sport, ui, controller, onNotice }) : null,
15784
+ hasTeams(sport) ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: ui.favTeams, entities: data.teams, sport, ui, controller, onNotice }) : null,
15785
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Group, { title: sport === "tennis" ? ui.tennis.favPlayers : ui.favPlayers, entities: data.players, sport, ui, controller, onNotice }),
15763
15786
  data.suggestions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("section", { className: "ss-w-fav-group", children: [
15764
15787
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("h3", { className: "ss-w-fav-h", children: ui.favFromActivity }),
15765
15788
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("ul", { className: "ss-w-fav-chips", children: data.suggestions.map((e) => /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("li", { className: "ss-w-fav-chip ss-w-fav-chip--suggest", children: [
15766
15789
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(FavCrest, { entity: e, sport }),
15767
15790
  /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("span", { className: "ss-w-fav-name", children: [
15768
15791
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { className: "ss-w-fav-title", children: e.name }),
15769
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(PlayerTeam, { entity: e, ui })
15792
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(PlayerTeam, { entity: e, ui, sport })
15770
15793
  ] }),
15771
15794
  /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
15772
15795
  "button",
@@ -15812,7 +15835,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15812
15835
  setAnswer(null);
15813
15836
  if (trimmed.length < MIN_LETTERS) return;
15814
15837
  let cancelled = false;
15815
- const kinds = sport === "football" ? ["competition", "team", "player"] : ["team", "player"];
15838
+ const kinds = favouriteKinds(sport);
15816
15839
  const timer = setTimeout(() => {
15817
15840
  void Promise.all(kinds.map((k) => controllerRef.current.search(trimmed, k))).then((lists) => {
15818
15841
  if (cancelled) return;
@@ -15824,6 +15847,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15824
15847
  clearTimeout(timer);
15825
15848
  };
15826
15849
  }, [trimmed, sport, queryKey]);
15850
+ const placeholder = sport === "tennis" ? ui.tennis.favSearchPlaceholder : ui.favSearchPlaceholder;
15827
15851
  return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "ss-w-fav-search", children: [
15828
15852
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
15829
15853
  "input",
@@ -15832,8 +15856,8 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15832
15856
  className: "ss-w-fav-input",
15833
15857
  value: query,
15834
15858
  maxLength: MAX_LENGTH,
15835
- placeholder: ui.favSearchPlaceholder,
15836
- "aria-label": ui.favSearchPlaceholder,
15859
+ placeholder,
15860
+ "aria-label": placeholder,
15837
15861
  autoComplete: "off",
15838
15862
  onChange: (e) => setQuery(e.target.value)
15839
15863
  }
@@ -15846,7 +15870,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15846
15870
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(FavCrest, { entity: e, sport }),
15847
15871
  /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("span", { className: "ss-w-fav-name", children: [
15848
15872
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "ss-w-fav-title", children: e.name }),
15849
- e.kind === "player" ? /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(PlayerTeam, { entity: e, ui }) : /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "ss-w-fav-kind", children: e.kind === "competition" ? ui.favKindLeague : ui.favKindTeam })
15873
+ e.kind === "player" ? /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(PlayerTeam, { entity: e, ui, sport }) : /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("span", { className: "ss-w-fav-kind", children: favouriteKindLabel(ui, sport, e.kind) })
15850
15874
  ] }),
15851
15875
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
15852
15876
  "button",
@@ -15880,8 +15904,7 @@ function FavouritesPanel({ controller, ui, sport, sports, onSportChange }) {
15880
15904
  setNotice(null);
15881
15905
  }, [sport]);
15882
15906
  const sportLabel2 = sports.find((s) => s.sport === sport)?.label ?? sportLabel(ui, sport);
15883
- const kindLabel2 = (kind) => kind === "competition" ? ui.favKindLeague : kind === "team" ? ui.favKindTeam : ui.favKindPlayer;
15884
- const noticeText = notice === null ? null : notice.type === "cap" ? ui.favAtCap(kindLabel2(notice.kind)) : ui.favError;
15907
+ const noticeText = notice === null ? null : notice.type === "cap" ? ui.favAtCap(favouriteKindLabel(ui, sport, notice.kind)) : ui.favError;
15885
15908
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "ss-w-mon-list ss-w-fav", children: [
15886
15909
  sports.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("div", { className: "ss-w-dash-sports", role: "group", "aria-label": ui.sportGroupLabel, children: sports.map((s) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
15887
15910
  "button",
@@ -16981,7 +17004,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
16981
17004
  }
16982
17005
  ),
16983
17006
  /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)("div", { className: "ss-w-chat-layer", style: onChatTab ? void 0 : HIDDEN_LAYER_STYLE, children: [
16984
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(PresetToolsContext.Provider, { value: toolsValue, children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(MessageList, { controller, ui, slip, onDashboardTap, monitor }) }),
17007
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(PresetToolsContext.Provider, { value: toolsValue, children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(MessageList, { controller, ui, slip, onDashboardTap, monitor, onGreetingSport: favourites?.onSportChange }) }),
16985
17008
  tool && presetGrid && onChatTab && !paused ? /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(BuildComboTool, { grid: presetGrid, strings: ui.presets, streaming: state.isStreaming, formatKickoff, initialTotal: tool.total, initialLegs: tool.legs, onSend: sendAsk, onClose: closeTool }) : null
16986
17009
  ] }),
16987
17010
  monitor && discovery && schedule && monitor.activeTab === "live" && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(