@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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.60.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Games: send the widget language with game config, result and play requests so server-written game text (quiz questions, grid labels, stat names, hints) arrives in Turkish; Beat the Grid resolves row abbreviations and header icons from stable keys.
8
+ - Updated dependencies
9
+ - @sensiblestats/widget-sdk@0.36.0
10
+
11
+ ## 0.60.4
12
+
13
+ ### Patch Changes
14
+
15
+ - Games: Higher/Lower labels stay on one line (Turkish "Daha fazla" wrapped), and the Beat the Grid board shrinks its rows so the whole grid and the search field fit on screen while the search sheet is open.
16
+
3
17
  ## 0.60.3
4
18
 
5
19
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4704,15 +4704,15 @@ function toSubmitResult(payload) {
4704
4704
  attemptsUsed: payload.attemptsUsed
4705
4705
  };
4706
4706
  }
4707
- function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4707
+ function useGamePlay(conversation, { gameId, gameDay, fixtureId, locale, refresh }) {
4708
4708
  const [result, setResult] = (0, import_react29.useState)(null);
4709
4709
  const [submitting, setSubmitting] = (0, import_react29.useState)(false);
4710
4710
  const [rawStatus, setRawStatus] = (0, import_react29.useState)(null);
4711
4711
  const inFlightRef = (0, import_react29.useRef)(false);
4712
4712
  const convRef = (0, import_react29.useRef)(conversation);
4713
4713
  convRef.current = conversation;
4714
- const optsRef = (0, import_react29.useRef)({ gameId, gameDay, fixtureId, refresh });
4715
- optsRef.current = { gameId, gameDay, fixtureId, refresh };
4714
+ const optsRef = (0, import_react29.useRef)({ gameId, gameDay, fixtureId, locale, refresh });
4715
+ optsRef.current = { gameId, gameDay, fixtureId, locale, refresh };
4716
4716
  const resultRef = (0, import_react29.useRef)(null);
4717
4717
  resultRef.current = result;
4718
4718
  const refetch = (0, import_react29.useCallback)(async () => {
@@ -4720,7 +4720,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4720
4720
  if (!conv) return;
4721
4721
  const opts = optsRef.current;
4722
4722
  try {
4723
- const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay);
4723
+ const payload = await conv.getGameResult(opts.gameId, opts.fixtureId, opts.gameDay, opts.locale);
4724
4724
  if (payload === null) return;
4725
4725
  if (payload.clientStateJson == null && resultRef.current?.clientStateJson != null) {
4726
4726
  setRawStatus(payload.status);
@@ -4738,7 +4738,7 @@ function useGamePlay(conversation, { gameId, gameDay, fixtureId, refresh }) {
4738
4738
  setSubmitting(true);
4739
4739
  try {
4740
4740
  const opts = optsRef.current;
4741
- const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId);
4741
+ const playResult = await conv.postPlay(opts.gameId, answerJson, opts.gameDay, opts.fixtureId, opts.locale);
4742
4742
  if (playResult !== null) {
4743
4743
  const hasFreshState = playResult.clientStateJson != null;
4744
4744
  const isTerminal2 = playResult.alreadyPlayed === true;
@@ -5515,8 +5515,8 @@ function CareerPathGame({
5515
5515
  // src/components/games/BeatTheGridGame.tsx
5516
5516
  var import_react34 = __toESM(require("react"), 1);
5517
5517
  var import_jsx_runtime71 = require("react/jsx-runtime");
5518
- function criterionIconKind(label) {
5519
- const l = label.toLowerCase();
5518
+ function criterionIconKind(label, key) {
5519
+ const l = (key ?? label).toLowerCase();
5520
5520
  if (l.includes("app")) return "calendar";
5521
5521
  if (l.includes("goal")) return "ball";
5522
5522
  if (l.includes("assist")) return "boot";
@@ -5524,8 +5524,10 @@ function criterionIconKind(label) {
5524
5524
  if (l.includes("tackle")) return "shield";
5525
5525
  return "flag";
5526
5526
  }
5527
- function rowAbbrev(label, map) {
5528
- return map[label] ?? label;
5527
+ function rowAbbrev(label, map, key) {
5528
+ const suffix = key?.split(".").pop();
5529
+ const english = suffix ? suffix.charAt(0).toUpperCase() + suffix.slice(1) : label;
5530
+ return map[english] ?? map[label] ?? label;
5529
5531
  }
5530
5532
  function CriterionIcon({ kind }) {
5531
5533
  switch (kind) {
@@ -5692,17 +5694,20 @@ function BeatTheGridGame({
5692
5694
  /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
5693
5695
  "div",
5694
5696
  {
5695
- className: "ss-g-btg-grid",
5696
- style: { gridTemplateColumns: `64px repeat(${cols.length}, minmax(0, 1fr))` },
5697
+ className: activeCell !== null ? "ss-g-btg-grid ss-g-btg-grid--fit" : "ss-g-btg-grid",
5698
+ style: {
5699
+ gridTemplateColumns: `64px repeat(${cols.length}, minmax(0, 1fr))`,
5700
+ gridTemplateRows: `minmax(44px, 60px) repeat(${rows.length}, minmax(44px, 98px))`
5701
+ },
5697
5702
  role: "grid",
5698
5703
  children: [
5699
5704
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "ss-g-btg-corner" }),
5700
- cols.map((col) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "ss-g-btg-colhdr", children: [
5701
- /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CriterionIcon, { kind: criterionIconKind(col) }),
5705
+ cols.map((col, colIdx) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "ss-g-btg-colhdr", children: [
5706
+ /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(CriterionIcon, { kind: criterionIconKind(col, config.colsI18n?.[colIdx]?.key) }),
5702
5707
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: col })
5703
5708
  ] }, col)),
5704
5709
  rows.map((rowLabel, rowIdx) => {
5705
- const abbr = rowAbbrev(rowLabel, s.rowAbbrev);
5710
+ const abbr = rowAbbrev(rowLabel, s.rowAbbrev, config.rowsI18n?.[rowIdx]?.key);
5706
5711
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_react34.default.Fragment, { children: [
5707
5712
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "ss-g-btg-rowhdr", children: abbr === rowLabel ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: rowLabel }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
5708
5713
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { "aria-hidden": "true", children: abbr }),
@@ -6831,7 +6836,7 @@ function GameScreenHost({
6831
6836
  let cancelled = false;
6832
6837
  void (async () => {
6833
6838
  try {
6834
- const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0);
6839
+ const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0, ui.games.lang);
6835
6840
  if (!cancelled && payload?.configJson) {
6836
6841
  setConfigJson(payload.configJson);
6837
6842
  }
@@ -6841,11 +6846,12 @@ function GameScreenHost({
6841
6846
  return () => {
6842
6847
  cancelled = true;
6843
6848
  };
6844
- }, [conversation, gameId, fixtureId, gameDay]);
6849
+ }, [conversation, gameId, fixtureId, gameDay, ui.games.lang]);
6845
6850
  const { result, submitting, submit, hydrate, rawStatus } = useGamePlay(conversation, {
6846
6851
  gameId,
6847
6852
  gameDay,
6848
- fixtureId: fixtureId || void 0
6853
+ fixtureId: fixtureId || void 0,
6854
+ locale: ui.games.lang
6849
6855
  });
6850
6856
  (0, import_react40.useEffect)(() => {
6851
6857
  if (conversation) hydrate();
@@ -8376,8 +8382,10 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8376
8382
  .ss-g-hl-value { font: 800 56px var(--ss-g-font-display); line-height: .95; color: var(--ss-w-accent); margin-top: 6px; }
8377
8383
  .ss-g-hl-stat { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ss-g-muted); }
8378
8384
  .ss-g-hl-btns { display: flex; flex-direction: row; gap: 8px; margin-top: 12px; }
8379
- .ss-g-hl-btns .ss-g-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 8px; }
8380
- .ss-g-hl-btns .ss-g-btn { font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
8385
+ .ss-g-hl-btns .ss-g-btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 6px; gap: 4px; }
8386
+ /* Labels stay on one line: Turkish "DAHA FAZLA" wrapped to two in a ~115px button. */
8387
+ .ss-g-hl-btns .ss-g-btn { font-weight: 800; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
8388
+ .ss-g-hl-btns .ss-g-btn svg { flex: none; }
8381
8389
  .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); }
8382
8390
  /* Clear the VS badge that straddles the seam between the two cards. */
8383
8391
  .ss-g-hl-pair > .ss-g-hl-card:first-child .ss-g-hl-info { padding-bottom: 24px; }
@@ -8516,10 +8524,13 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8516
8524
 
8517
8525
  /* ---- Beat the Grid (u393) ---- */
8518
8526
  .ss-g-btg-grid { display: grid; gap: 6px; }
8519
- .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; }
8527
+ /* While the search sheet is pinned below, the grid shrinks its rows to share the body with it
8528
+ instead of pushing the bottom row under the sheet. */
8529
+ .ss-g-btg-grid--fit { flex: 0 1 auto; min-height: 0; }
8530
+ .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; }
8520
8531
  .ss-g-btg-colhdr svg { color: var(--ss-w-accent); flex: none; }
8521
8532
  .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; }
8522
- .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; }
8533
+ .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; }
8523
8534
  .ss-g-btg-cell:disabled { cursor: default; }
8524
8535
  .ss-g-btg-cell[data-state="active"] { border: 2px solid var(--ss-w-accent); background: var(--ss-g-warm); color: var(--ss-w-accent); }
8525
8536
  .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; }
@@ -8543,6 +8554,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
8543
8554
  .ss-g-btg-sheet .ss-g-search-box { height: 48px; border-radius: 12px; background: var(--ss-g-ground); }
8544
8555
  .ss-g-btg-sheet-empty { font-size: 13px; color: var(--ss-g-muted); }
8545
8556
  .ss-g-btg-sheet .ss-g-opt { background: var(--ss-g-raised); }
8557
+ .ss-g-btg-sheet .ss-g-opts { max-height: 160px; }
8546
8558
  .ss-g-btg-result-name { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
8547
8559
  .ss-g-btg-result-plus { color: var(--ss-w-accent); display: flex; }
8548
8560