@sensiblestats/widget-react 0.60.3 → 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) {
@@ -5655,17 +5657,20 @@ function BeatTheGridGame({
5655
5657
  /* @__PURE__ */ jsxs59(
5656
5658
  "div",
5657
5659
  {
5658
- className: "ss-g-btg-grid",
5659
- style: { gridTemplateColumns: `64px repeat(${cols.length}, minmax(0, 1fr))` },
5660
+ className: activeCell !== null ? "ss-g-btg-grid ss-g-btg-grid--fit" : "ss-g-btg-grid",
5661
+ style: {
5662
+ gridTemplateColumns: `64px repeat(${cols.length}, minmax(0, 1fr))`,
5663
+ gridTemplateRows: `minmax(44px, 60px) repeat(${rows.length}, minmax(44px, 98px))`
5664
+ },
5660
5665
  role: "grid",
5661
5666
  children: [
5662
5667
  /* @__PURE__ */ jsx71("div", { className: "ss-g-btg-corner" }),
5663
- cols.map((col) => /* @__PURE__ */ jsxs59("div", { className: "ss-g-btg-colhdr", children: [
5664
- /* @__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) }),
5665
5670
  /* @__PURE__ */ jsx71("span", { children: col })
5666
5671
  ] }, col)),
5667
5672
  rows.map((rowLabel, rowIdx) => {
5668
- const abbr = rowAbbrev(rowLabel, s.rowAbbrev);
5673
+ const abbr = rowAbbrev(rowLabel, s.rowAbbrev, config.rowsI18n?.[rowIdx]?.key);
5669
5674
  return /* @__PURE__ */ jsxs59(React.Fragment, { children: [
5670
5675
  /* @__PURE__ */ jsx71("div", { className: "ss-g-btg-rowhdr", children: abbr === rowLabel ? /* @__PURE__ */ jsx71("span", { children: rowLabel }) : /* @__PURE__ */ jsxs59(Fragment14, { children: [
5671
5676
  /* @__PURE__ */ jsx71("span", { "aria-hidden": "true", children: abbr }),
@@ -6794,7 +6799,7 @@ function GameScreenHost({
6794
6799
  let cancelled = false;
6795
6800
  void (async () => {
6796
6801
  try {
6797
- const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0);
6802
+ const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0, ui.games.lang);
6798
6803
  if (!cancelled && payload?.configJson) {
6799
6804
  setConfigJson(payload.configJson);
6800
6805
  }
@@ -6804,11 +6809,12 @@ function GameScreenHost({
6804
6809
  return () => {
6805
6810
  cancelled = true;
6806
6811
  };
6807
- }, [conversation, gameId, fixtureId, gameDay]);
6812
+ }, [conversation, gameId, fixtureId, gameDay, ui.games.lang]);
6808
6813
  const { result, submitting, submit, hydrate, rawStatus } = useGamePlay(conversation, {
6809
6814
  gameId,
6810
6815
  gameDay,
6811
- fixtureId: fixtureId || void 0
6816
+ fixtureId: fixtureId || void 0,
6817
+ locale: ui.games.lang
6812
6818
  });
6813
6819
  useEffect15(() => {
6814
6820
  if (conversation) hydrate();
@@ -8339,8 +8345,10 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8339
8345
  .ss-g-hl-value { font: 800 56px var(--ss-g-font-display); line-height: .95; color: var(--ss-w-accent); margin-top: 6px; }
8340
8346
  .ss-g-hl-stat { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ss-g-muted); }
8341
8347
  .ss-g-hl-btns { display: flex; flex-direction: row; gap: 8px; margin-top: 12px; }
8342
- .ss-g-hl-btns .ss-g-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 8px; }
8343
- .ss-g-hl-btns .ss-g-btn { font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
8348
+ .ss-g-hl-btns .ss-g-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 6px; gap: 4px; }
8349
+ /* Labels stay on one line: Turkish "DAHA FAZLA" wrapped to two in a ~115px button. */
8350
+ .ss-g-hl-btns .ss-g-btn { font-weight: 800; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
8351
+ .ss-g-hl-btns .ss-g-btn svg { flex: none; }
8344
8352
  .ss-g-hl-vs { position: relative; z-index: 1; flex: none; align-self: center; width: 44px; height: 44px; margin: -28px 0; border-radius: 50%; display: grid; place-items: center; background: var(--ss-g-ground); border: 2px solid var(--ss-g-line-warm); color: var(--ss-w-accent); font: 800 18px var(--ss-g-font-display); }
8345
8353
  /* Clear the VS badge that straddles the seam between the two cards. */
8346
8354
  .ss-g-hl-pair > .ss-g-hl-card:first-child .ss-g-hl-info { padding-bottom: 24px; }
@@ -8479,10 +8487,13 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8479
8487
 
8480
8488
  /* ---- Beat the Grid (u393) ---- */
8481
8489
  .ss-g-btg-grid { display: grid; gap: 6px; }
8482
- .ss-g-btg-colhdr { height: 60px; border-radius: 12px; background: var(--ss-g-surface); border: 1px solid var(--ss-g-line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 0 4px; font-size: 12px; font-weight: 700; line-height: 1.1; min-width: 0; overflow-wrap: anywhere; }
8490
+ /* While the search sheet is pinned below, the grid shrinks its rows to share the body with it
8491
+ instead of pushing the bottom row under the sheet. */
8492
+ .ss-g-btg-grid--fit { flex: 0 1 auto; min-height: 0; }
8493
+ .ss-g-btg-colhdr { min-height: 0; border-radius: 12px; background: var(--ss-g-surface); border: 1px solid var(--ss-g-line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 0 4px; font-size: 12px; font-weight: 700; line-height: 1.1; min-width: 0; overflow-wrap: anywhere; }
8483
8494
  .ss-g-btg-colhdr svg { color: var(--ss-w-accent); flex: none; }
8484
8495
  .ss-g-btg-rowhdr { border-radius: 12px; background: var(--ss-g-surface); border: 1px solid var(--ss-g-line); display: grid; place-items: center; font-family: var(--ss-g-font-display); font-weight: 800; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; overflow-wrap: anywhere; text-align: center; }
8485
- .ss-g-btg-cell { position: relative; height: 98px; min-width: 0; border-radius: 12px; border: 1.5px dashed var(--ss-g-strong-line); background: transparent; color: var(--ss-g-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; font: inherit; padding: 0; }
8496
+ .ss-g-btg-cell { position: relative; min-height: 0; min-width: 0; border-radius: 12px; border: 1.5px dashed var(--ss-g-strong-line); background: transparent; color: var(--ss-g-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; font: inherit; padding: 0; }
8486
8497
  .ss-g-btg-cell:disabled { cursor: default; }
8487
8498
  .ss-g-btg-cell[data-state="active"] { border: 2px solid var(--ss-w-accent); background: var(--ss-g-warm); color: var(--ss-w-accent); }
8488
8499
  .ss-g-btg-cell[data-state="correct"], .ss-g-btg-cell[data-state="wrong"] { justify-content: flex-end; background: var(--ss-g-surface); border-style: solid; }
@@ -8506,6 +8517,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8506
8517
  .ss-g-btg-sheet .ss-g-search-box { height: 48px; border-radius: 12px; background: var(--ss-g-ground); }
8507
8518
  .ss-g-btg-sheet-empty { font-size: 13px; color: var(--ss-g-muted); }
8508
8519
  .ss-g-btg-sheet .ss-g-opt { background: var(--ss-g-raised); }
8520
+ .ss-g-btg-sheet .ss-g-opts { max-height: 160px; }
8509
8521
  .ss-g-btg-result-name { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
8510
8522
  .ss-g-btg-result-plus { color: var(--ss-w-accent); display: flex; }
8511
8523