@sensiblestats/widget-react 0.60.4 → 0.60.5

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/dist/index.js CHANGED
@@ -4667,15 +4667,15 @@ function toSubmitResult(payload) {
4667
4667
  attemptsUsed: payload.attemptsUsed
4668
4668
  };
4669
4669
  }
4670
- function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4670
+ function useGamePlay(conversation, { gameId, gameDay, fixtureId, locale, refresh }) {
4671
4671
  const [result, setResult] = useState23(null);
4672
4672
  const [submitting, setSubmitting] = useState23(false);
4673
4673
  const [rawStatus, setRawStatus] = useState23(null);
4674
4674
  const inFlightRef = useRef11(false);
4675
4675
  const convRef = useRef11(conversation);
4676
4676
  convRef.current = conversation;
4677
- const optsRef = useRef11({ gameId, gameDay, fixtureId, refresh });
4678
- optsRef.current = { gameId, gameDay, fixtureId, refresh };
4677
+ const optsRef = useRef11({ gameId, gameDay, fixtureId, locale, refresh });
4678
+ optsRef.current = { gameId, gameDay, fixtureId, locale, refresh };
4679
4679
  const resultRef = useRef11(null);
4680
4680
  resultRef.current = result;
4681
4681
  const refetch = useCallback8(async () => {
@@ -4683,7 +4683,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4683
4683
  if (!conv) return;
4684
4684
  const opts = optsRef.current;
4685
4685
  try {
4686
- const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay);
4686
+ const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay, opts.locale);
4687
4687
  if (payload === null) return;
4688
4688
  if (payload.clientStateJson == null && resultRef.current?.clientStateJson != null) {
4689
4689
  setRawStatus(payload.status);
@@ -4701,7 +4701,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4701
4701
  setSubmitting(true);
4702
4702
  try {
4703
4703
  const opts = optsRef.current;
4704
- const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId);
4704
+ const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId, opts.locale);
4705
4705
  if (playResult !== null) {
4706
4706
  const hasFreshState = playResult.clientStateJson != null;
4707
4707
  const isTerminal2 = playResult.alreadyPlayed === true;
@@ -5478,8 +5478,8 @@ function CareerPathGame({
5478
5478
  // src/components/games/BeatTheGridGame.tsx
5479
5479
  import React, { useEffect as useEffect14, useId as useId4, useRef as useRef12, useState as useState28 } from "react";
5480
5480
  import { Fragment as Fragment14, jsx as jsx71, jsxs as jsxs59 } from "react/jsx-runtime";
5481
- function criterionIconKind(label) {
5482
- const l = label.toLowerCase();
5481
+ function criterionIconKind(label, key) {
5482
+ const l = (key ?? label).toLowerCase();
5483
5483
  if (l.includes("app")) return "calendar";
5484
5484
  if (l.includes("goal")) return "ball";
5485
5485
  if (l.includes("assist")) return "boot";
@@ -5487,8 +5487,10 @@ function criterionIconKind(label) {
5487
5487
  if (l.includes("tackle")) return "shield";
5488
5488
  return "flag";
5489
5489
  }
5490
- function rowAbbrev(label, map) {
5491
- return map[label] ?? label;
5490
+ function rowAbbrev(label, map, key) {
5491
+ const suffix = key?.split(".").pop();
5492
+ const english = suffix ? suffix.charAt(0).toUpperCase() + suffix.slice(1) : label;
5493
+ return map[english] ?? map[label] ?? label;
5492
5494
  }
5493
5495
  function CriterionIcon({ kind }) {
5494
5496
  switch (kind) {
@@ -5663,12 +5665,12 @@ function BeatTheGridGame({
5663
5665
  role: "grid",
5664
5666
  children: [
5665
5667
  /* @__PURE__ */ jsx71("div", { className: "ss-g-btg-corner" }),
5666
- cols.map((col) => /* @__PURE__ */ jsxs59("div", { className: "ss-g-btg-colhdr", children: [
5667
- /* @__PURE__ */ jsx71(CriterionIcon, { kind: criterionIconKind(col) }),
5668
+ cols.map((col, colIdx) => /* @__PURE__ */ jsxs59("div", { className: "ss-g-btg-colhdr", children: [
5669
+ /* @__PURE__ */ jsx71(CriterionIcon, { kind: criterionIconKind(col, config.colsI18n?.[colIdx]?.key) }),
5668
5670
  /* @__PURE__ */ jsx71("span", { children: col })
5669
5671
  ] }, col)),
5670
5672
  rows.map((rowLabel, rowIdx) => {
5671
- const abbr = rowAbbrev(rowLabel, s.rowAbbrev);
5673
+ const abbr = rowAbbrev(rowLabel, s.rowAbbrev, config.rowsI18n?.[rowIdx]?.key);
5672
5674
  return /* @__PURE__ */ jsxs59(React.Fragment, { children: [
5673
5675
  /* @__PURE__ */ jsx71("div", { className: "ss-g-btg-rowhdr", children: abbr === rowLabel ? /* @__PURE__ */ jsx71("span", { children: rowLabel }) : /* @__PURE__ */ jsxs59(Fragment14, { children: [
5674
5676
  /* @__PURE__ */ jsx71("span", { "aria-hidden": "true", children: abbr }),
@@ -6797,7 +6799,7 @@ function GameScreenHost({
6797
6799
  let cancelled = false;
6798
6800
  void (async () => {
6799
6801
  try {
6800
- const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0);
6802
+ const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0, ui.games.lang);
6801
6803
  if (!cancelled && payload?.configJson) {
6802
6804
  setConfigJson(payload.configJson);
6803
6805
  }
@@ -6807,11 +6809,12 @@ function GameScreenHost({
6807
6809
  return () => {
6808
6810
  cancelled = true;
6809
6811
  };
6810
- }, [conversation, gameId, fixtureId, gameDay]);
6812
+ }, [conversation, gameId, fixtureId, gameDay, ui.games.lang]);
6811
6813
  const { result, submitting, submit, hydrate, rawStatus } = useGamePlay(conversation, {
6812
6814
  gameId,
6813
6815
  gameDay,
6814
- fixtureId: fixtureId || void 0
6816
+ fixtureId: fixtureId || void 0,
6817
+ locale: ui.games.lang
6815
6818
  });
6816
6819
  useEffect15(() => {
6817
6820
  if (conversation) hydrate();