@sensiblestats/widget-react 0.60.4 → 0.60.6
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 +14 -0
- package/dist/index.cjs +35 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/dist/styles.css +11 -0
- package/package.json +2 -2
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;
|
|
@@ -4810,6 +4810,9 @@ function nationalityFlag(nationality) {
|
|
|
4810
4810
|
const key = nationality.trim().toLowerCase();
|
|
4811
4811
|
return FLAGS[key] ?? nationality.slice(0, 3).toUpperCase();
|
|
4812
4812
|
}
|
|
4813
|
+
function isNationCode(flag) {
|
|
4814
|
+
return /^[A-Z]{1,3}$/.test(flag);
|
|
4815
|
+
}
|
|
4813
4816
|
|
|
4814
4817
|
// src/components/games/PlayerAvatar.tsx
|
|
4815
4818
|
import { useState as useState24 } from "react";
|
|
@@ -5478,8 +5481,8 @@ function CareerPathGame({
|
|
|
5478
5481
|
// src/components/games/BeatTheGridGame.tsx
|
|
5479
5482
|
import React, { useEffect as useEffect14, useId as useId4, useRef as useRef12, useState as useState28 } from "react";
|
|
5480
5483
|
import { Fragment as Fragment14, jsx as jsx71, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
5481
|
-
function criterionIconKind(label) {
|
|
5482
|
-
const l = label.toLowerCase();
|
|
5484
|
+
function criterionIconKind(label, key) {
|
|
5485
|
+
const l = (key ?? label).toLowerCase();
|
|
5483
5486
|
if (l.includes("app")) return "calendar";
|
|
5484
5487
|
if (l.includes("goal")) return "ball";
|
|
5485
5488
|
if (l.includes("assist")) return "boot";
|
|
@@ -5487,8 +5490,10 @@ function criterionIconKind(label) {
|
|
|
5487
5490
|
if (l.includes("tackle")) return "shield";
|
|
5488
5491
|
return "flag";
|
|
5489
5492
|
}
|
|
5490
|
-
function rowAbbrev(label, map) {
|
|
5491
|
-
|
|
5493
|
+
function rowAbbrev(label, map, key) {
|
|
5494
|
+
const suffix = key?.split(".").pop();
|
|
5495
|
+
const english = suffix ? suffix.charAt(0).toUpperCase() + suffix.slice(1) : label;
|
|
5496
|
+
return map[english] ?? map[label] ?? label;
|
|
5492
5497
|
}
|
|
5493
5498
|
function CriterionIcon({ kind }) {
|
|
5494
5499
|
switch (kind) {
|
|
@@ -5663,12 +5668,12 @@ function BeatTheGridGame({
|
|
|
5663
5668
|
role: "grid",
|
|
5664
5669
|
children: [
|
|
5665
5670
|
/* @__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) }),
|
|
5671
|
+
cols.map((col, colIdx) => /* @__PURE__ */ jsxs59("div", { className: "ss-g-btg-colhdr", children: [
|
|
5672
|
+
/* @__PURE__ */ jsx71(CriterionIcon, { kind: criterionIconKind(col, config.colsI18n?.[colIdx]?.key) }),
|
|
5668
5673
|
/* @__PURE__ */ jsx71("span", { children: col })
|
|
5669
5674
|
] }, col)),
|
|
5670
5675
|
rows.map((rowLabel, rowIdx) => {
|
|
5671
|
-
const abbr = rowAbbrev(rowLabel, s.rowAbbrev);
|
|
5676
|
+
const abbr = rowAbbrev(rowLabel, s.rowAbbrev, config.rowsI18n?.[rowIdx]?.key);
|
|
5672
5677
|
return /* @__PURE__ */ jsxs59(React.Fragment, { children: [
|
|
5673
5678
|
/* @__PURE__ */ jsx71("div", { className: "ss-g-btg-rowhdr", children: abbr === rowLabel ? /* @__PURE__ */ jsx71("span", { children: rowLabel }) : /* @__PURE__ */ jsxs59(Fragment14, { children: [
|
|
5674
5679
|
/* @__PURE__ */ jsx71("span", { "aria-hidden": "true", children: abbr }),
|
|
@@ -5877,15 +5882,17 @@ function GuessTheXiGame({
|
|
|
5877
5882
|
/* @__PURE__ */ jsx73("div", { className: "ss-g-gxi-rows", children: rows.map((row, r) => /* @__PURE__ */ jsx73("div", { className: "ss-g-gxi-row", children: row.map((pos, c) => {
|
|
5878
5883
|
const posLabel = pos.slot ? posBySlot.get(pos.slot) ?? "" : "";
|
|
5879
5884
|
const name = pos.slot ? nameBySlot.get(pos.slot) : void 0;
|
|
5885
|
+
const flag = nationalityFlag(pos.nationality);
|
|
5880
5886
|
return /* @__PURE__ */ jsxs61("div", { className: "ss-g-gxi-node", "data-revealed": name ? "true" : void 0, children: [
|
|
5881
5887
|
/* @__PURE__ */ jsx73(
|
|
5882
5888
|
"span",
|
|
5883
5889
|
{
|
|
5884
5890
|
className: "ss-g-gxi-disc",
|
|
5891
|
+
"data-code": isNationCode(flag) ? "true" : void 0,
|
|
5885
5892
|
role: "img",
|
|
5886
5893
|
title: pos.nationality,
|
|
5887
5894
|
"aria-label": `${posLabel ? posLabel + " \u2014 " : ""}${pos.nationality}${name ? " \u2014 " + name : ""}`,
|
|
5888
|
-
children:
|
|
5895
|
+
children: flag
|
|
5889
5896
|
}
|
|
5890
5897
|
),
|
|
5891
5898
|
name ? /* @__PURE__ */ jsx73("span", { className: "ss-g-gxi-pos ss-g-gxi-pos--name", children: splitName(name).last }) : posLabel && /* @__PURE__ */ jsx73("span", { className: "ss-g-gxi-pos", children: posLabel })
|
|
@@ -6797,7 +6804,7 @@ function GameScreenHost({
|
|
|
6797
6804
|
let cancelled = false;
|
|
6798
6805
|
void (async () => {
|
|
6799
6806
|
try {
|
|
6800
|
-
const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0);
|
|
6807
|
+
const payload = await conversation.getGameConfig(gameId, fixtureId, gameDay || void 0, ui.games.lang);
|
|
6801
6808
|
if (!cancelled && payload?.configJson) {
|
|
6802
6809
|
setConfigJson(payload.configJson);
|
|
6803
6810
|
}
|
|
@@ -6807,11 +6814,12 @@ function GameScreenHost({
|
|
|
6807
6814
|
return () => {
|
|
6808
6815
|
cancelled = true;
|
|
6809
6816
|
};
|
|
6810
|
-
}, [conversation, gameId, fixtureId, gameDay]);
|
|
6817
|
+
}, [conversation, gameId, fixtureId, gameDay, ui.games.lang]);
|
|
6811
6818
|
const { result, submitting, submit, hydrate, rawStatus } = useGamePlay(conversation, {
|
|
6812
6819
|
gameId,
|
|
6813
6820
|
gameDay,
|
|
6814
|
-
fixtureId: fixtureId || void 0
|
|
6821
|
+
fixtureId: fixtureId || void 0,
|
|
6822
|
+
locale: ui.games.lang
|
|
6815
6823
|
});
|
|
6816
6824
|
useEffect15(() => {
|
|
6817
6825
|
if (conversation) hydrate();
|
|
@@ -8346,6 +8354,16 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
8346
8354
|
/* Labels stay on one line: Turkish "DAHA FAZLA" wrapped to two in a ~115px button. */
|
|
8347
8355
|
.ss-g-hl-btns .ss-g-btn { font-weight: 800; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
|
|
8348
8356
|
.ss-g-hl-btns .ss-g-btn svg { flex: none; }
|
|
8357
|
+
/* Phone-width cards: the info column is ~230px, too narrow for "DAHA FAZLA" + icon side by side.
|
|
8358
|
+
Drop the icons and tighten the type first; stack the buttons only when even that cannot fit. */
|
|
8359
|
+
.ss-g-hl-info { container: hlinfo / inline-size; }
|
|
8360
|
+
@container hlinfo (max-width: 280px) {
|
|
8361
|
+
.ss-g-hl-btns .ss-g-btn svg { display: none; }
|
|
8362
|
+
.ss-g-hl-btns .ss-g-btn { font-size: 12px; letter-spacing: 0; padding: 0 4px; }
|
|
8363
|
+
}
|
|
8364
|
+
@container hlinfo (max-width: 180px) {
|
|
8365
|
+
.ss-g-hl-btns { flex-direction: column; }
|
|
8366
|
+
}
|
|
8349
8367
|
.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); }
|
|
8350
8368
|
/* Clear the VS badge that straddles the seam between the two cards. */
|
|
8351
8369
|
.ss-g-hl-pair > .ss-g-hl-card:first-child .ss-g-hl-info { padding-bottom: 24px; }
|
|
@@ -8382,6 +8400,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
8382
8400
|
.ss-g-gxi-node { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; max-width: 72px; }
|
|
8383
8401
|
.ss-g-gxi-disc { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--ss-g-pitch-chip); border: 2px solid var(--ss-g-pitch-ink); font-size: 22px; line-height: 1; }
|
|
8384
8402
|
.ss-g-gxi-node[data-revealed] .ss-g-gxi-disc { border-color: var(--ss-w-accent); }
|
|
8403
|
+
.ss-g-gxi-disc[data-code] { font-family: var(--ss-g-font-body); font-size: 11px; font-weight: 800; letter-spacing: .02em; color: var(--ss-g-pitch-ink); }
|
|
8385
8404
|
.ss-g-gxi-pos { max-width: 100%; padding: 1px 6px; border-radius: 4px; background: var(--ss-g-pitch-chip); color: var(--ss-g-pitch-ink); font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
8386
8405
|
.ss-g-gxi-pos--name { color: var(--ss-w-accent); text-transform: uppercase; }
|
|
8387
8406
|
.ss-g-gxi-wrong { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|