@sensiblestats/widget-react 0.154.0 → 0.155.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 +13 -0
- package/README.md +4 -2
- package/dist/index.cjs +51 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -10
- package/dist/index.d.ts +19 -10
- package/dist/index.js +51 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +13 -13
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.155.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Brand colours now come in a light and a dark group. `colors: { light, dark }` replaces the flat `accent`, `cta`, `surface` and `ink` config keys (breaking). Each group takes `accent`, `cta`, `surface` and `ink`. The dark theme reads only `colors.dark`; a dark colour left out shows the built-in dark colour, never the light one. On the script tag, `data-accent`, `data-cta`, `data-surface` and `data-ink` fill the light group and `data-accent-dark`, `data-cta-dark`, `data-surface-dark` and `data-ink-dark` fill the dark group; the mobile fragment uses `accentDark`, `ctaDark`, `surfaceDark` and `inkDark`. Blank values are ignored. Brand colours no longer lock the theme: the visitor's theme choice always wins and Settings always shows the theme row.
|
|
8
|
+
|
|
9
|
+
## 0.154.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [e2b51d5]
|
|
14
|
+
- @sensiblestats/widget-sdk@0.113.0
|
|
15
|
+
|
|
3
16
|
## 0.154.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -57,8 +57,10 @@ Common `config` fields:
|
|
|
57
57
|
over this `defaultLanguage`. `operatorUserId` travels from the browser, so make it a random,
|
|
58
58
|
non-guessable value you map to the user on your side (a UUID works): never an
|
|
59
59
|
account number, email, username or sequential id.
|
|
60
|
-
- White-label branding — `logoUrl`, `headerTitle`, `
|
|
61
|
-
`ink`.
|
|
60
|
+
- White-label branding — `logoUrl`, `headerTitle`, and `colors: { light, dark }`, each group
|
|
61
|
+
taking `accent`, `cta`, `surface` and `ink`. The dark theme reads only `colors.dark`; a dark
|
|
62
|
+
colour left out shows the built-in dark colour, never the light one. Absent → the default
|
|
63
|
+
SensibleStats look.
|
|
62
64
|
- `page` — the page the widget sits on, `{ sport, kind?, matchId?, competitionId? }`, so the
|
|
63
65
|
first greeting can lead with it. Football ids are bare (`'4820113'`); NBA ids are
|
|
64
66
|
`'nba:game:{id}'` or digits. `sport` is `'football'` or `'nba'`; the server answers any other
|
package/dist/index.cjs
CHANGED
|
@@ -1422,9 +1422,19 @@ function parseCustomTotal(text2, format2) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
|
|
1424
1424
|
// src/version.generated.ts
|
|
1425
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1425
|
+
var WIDGET_REACT_VERSION = "0.155.0";
|
|
1426
1426
|
|
|
1427
1427
|
// src/config.ts
|
|
1428
|
+
var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
|
|
1429
|
+
function themeColors(group) {
|
|
1430
|
+
const out = {};
|
|
1431
|
+
if (!group || typeof group !== "object") return out;
|
|
1432
|
+
for (const k of COLOR_KEYS) {
|
|
1433
|
+
const v = group[k];
|
|
1434
|
+
if (typeof v === "string" && v.trim() !== "") out[k] = v.trim();
|
|
1435
|
+
}
|
|
1436
|
+
return out;
|
|
1437
|
+
}
|
|
1428
1438
|
function hostTag(cfg) {
|
|
1429
1439
|
const pick = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
|
|
1430
1440
|
return pick(cfg?.locale) ?? pick(cfg?.userContext?.defaultLanguage);
|
|
@@ -1436,7 +1446,7 @@ function normalizeUi(cfg, loaded) {
|
|
|
1436
1446
|
return {
|
|
1437
1447
|
theme: cfg.theme ?? "auto",
|
|
1438
1448
|
oddsFormat: parseOddsFormat(cfg.oddsFormat) ?? "decimal",
|
|
1439
|
-
|
|
1449
|
+
colors: { light: themeColors(cfg.colors?.light), dark: themeColors(cfg.colors?.dark) },
|
|
1440
1450
|
logoUrl: cfg.logoUrl,
|
|
1441
1451
|
headerTitle: cfg.headerTitle,
|
|
1442
1452
|
locale: loaded.tag,
|
|
@@ -1444,9 +1454,6 @@ function normalizeUi(cfg, loaded) {
|
|
|
1444
1454
|
timeZone,
|
|
1445
1455
|
hostTag: hostTag(cfg),
|
|
1446
1456
|
rawBettingLabels: isBundledFamily(loaded.tag),
|
|
1447
|
-
cta: cfg.cta,
|
|
1448
|
-
surface: cfg.surface,
|
|
1449
|
-
ink: cfg.ink,
|
|
1450
1457
|
pinIcon: cfg.pinIcon ?? "pin",
|
|
1451
1458
|
position: cfg.position ?? "right",
|
|
1452
1459
|
offset: { x: cfg.offset?.x ?? 20, y: cfg.offset?.y ?? 20 },
|
|
@@ -3282,32 +3289,33 @@ function pillFor(accent, panel, theme) {
|
|
|
3282
3289
|
}
|
|
3283
3290
|
return { pill: lightPanel ? "#000000" : "#ffffff", ink };
|
|
3284
3291
|
}
|
|
3292
|
+
var PANEL = { light: LIGHT_PANEL, dark: DARK_PANEL };
|
|
3293
|
+
function brandVars(style, c, theme) {
|
|
3294
|
+
for (const k of ["accent", "cta", "surface", "ink"]) {
|
|
3295
|
+
const v = c[k];
|
|
3296
|
+
if (v) style[`--ss-w-brand-${k}-${theme}`] = v;
|
|
3297
|
+
}
|
|
3298
|
+
if (c.surface && c.ink) {
|
|
3299
|
+
style[`--ss-w-brand-bubble-${theme}`] = `color-mix(in srgb, ${c.ink} 5%, ${c.surface})`;
|
|
3300
|
+
style[`--ss-w-brand-line-${theme}`] = `color-mix(in srgb, ${c.ink} 12%, ${c.surface})`;
|
|
3301
|
+
style[`--ss-w-brand-faint-${theme}`] = `color-mix(in srgb, ${c.ink} 55%, ${c.surface})`;
|
|
3302
|
+
}
|
|
3303
|
+
if (c.accent || c.surface) {
|
|
3304
|
+
const panel = c.surface && rgb(c.surface) ? c.surface : PANEL[theme];
|
|
3305
|
+
const { pill, ink } = pillFor(c.accent, panel, theme);
|
|
3306
|
+
style[`--ss-w-pill-${theme}`] = pill;
|
|
3307
|
+
style[`--ss-w-on-pill-${theme}`] = ink;
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3285
3310
|
function themeAttrs(ui, userTheme) {
|
|
3286
3311
|
const style = {
|
|
3287
3312
|
"--ss-w-offset-x": `${ui.offset.x}px`,
|
|
3288
3313
|
"--ss-w-offset-y": `${ui.offset.y}px`,
|
|
3289
3314
|
"--ss-w-radius": `${ui.radius}px`
|
|
3290
3315
|
};
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
if (ui.ink) style["--ss-w-ink"] = ui.ink;
|
|
3295
|
-
if (ui.surface && ui.ink) {
|
|
3296
|
-
style["--ss-w-bubble"] = "color-mix(in srgb, var(--ss-w-ink) 5%, var(--ss-w-panel))";
|
|
3297
|
-
style["--ss-w-line"] = "color-mix(in srgb, var(--ss-w-ink) 12%, var(--ss-w-panel))";
|
|
3298
|
-
style["--ss-w-faint"] = "color-mix(in srgb, var(--ss-w-ink) 55%, var(--ss-w-panel))";
|
|
3299
|
-
}
|
|
3300
|
-
if (ui.accent || ui.surface) {
|
|
3301
|
-
const surface = ui.surface && rgb(ui.surface) ? ui.surface : void 0;
|
|
3302
|
-
const light = pillFor(ui.accent, surface ?? LIGHT_PANEL, "light");
|
|
3303
|
-
const dark = pillFor(ui.accent, surface ?? DARK_PANEL, "dark");
|
|
3304
|
-
style["--ss-w-pill-light"] = light.pill;
|
|
3305
|
-
style["--ss-w-on-pill-light"] = light.ink;
|
|
3306
|
-
style["--ss-w-pill-dark"] = dark.pill;
|
|
3307
|
-
style["--ss-w-on-pill-dark"] = dark.ink;
|
|
3308
|
-
}
|
|
3309
|
-
const theme = ui.surface || ui.ink ? ui.theme : userTheme ?? ui.theme;
|
|
3310
|
-
return { "data-ss-w-theme": theme, "data-ss-w-pos": ui.position, style };
|
|
3316
|
+
brandVars(style, ui.colors.light, "light");
|
|
3317
|
+
brandVars(style, ui.colors.dark, "dark");
|
|
3318
|
+
return { "data-ss-w-theme": userTheme ?? ui.theme, "data-ss-w-pos": ui.position, style };
|
|
3311
3319
|
}
|
|
3312
3320
|
|
|
3313
3321
|
// src/oddsSettingsContext.ts
|
|
@@ -3371,7 +3379,6 @@ function writeOddsOffered(operatorKey, value) {
|
|
|
3371
3379
|
var OddsSettingsContext = (0, import_react3.createContext)({
|
|
3372
3380
|
oddsFormat: "decimal",
|
|
3373
3381
|
theme: "auto",
|
|
3374
|
-
themeLocked: false,
|
|
3375
3382
|
oddsOffered: true,
|
|
3376
3383
|
setOddsFormat: () => {
|
|
3377
3384
|
},
|
|
@@ -3403,11 +3410,10 @@ function useOddsSettingsState(ui, conversation, operatorKey) {
|
|
|
3403
3410
|
userOddsFormat: stored.oddsFormat,
|
|
3404
3411
|
theme: stored.theme ?? ui.theme,
|
|
3405
3412
|
userTheme: stored.theme,
|
|
3406
|
-
themeLocked: !!(ui.surface || ui.ink),
|
|
3407
3413
|
oddsOffered,
|
|
3408
3414
|
setOddsFormat: (f) => setStored(writeSettings({ oddsFormat: f })),
|
|
3409
3415
|
setTheme: (t) => setStored(writeSettings({ theme: t }))
|
|
3410
|
-
}), [stored, ui.oddsFormat, ui.theme,
|
|
3416
|
+
}), [stored, ui.oddsFormat, ui.theme, oddsOffered]);
|
|
3411
3417
|
}
|
|
3412
3418
|
|
|
3413
3419
|
// src/useChatStream.ts
|
|
@@ -19017,7 +19023,7 @@ function SettingsSheet({ ui, onClose }) {
|
|
|
19017
19023
|
] }),
|
|
19018
19024
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-odds", children: ODDS.map((f) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("button", { type: "button", "aria-pressed": s.oddsFormat === f, onClick: () => s.setOddsFormat(f), children: t[f] }, f)) })
|
|
19019
19025
|
] }),
|
|
19020
|
-
|
|
19026
|
+
/* @__PURE__ */ (0, import_jsx_runtime161.jsxs)("div", { className: "ss-w-set-row", children: [
|
|
19021
19027
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-tool-label", id: "ss-w-set-theme", children: t.themeLabel }),
|
|
19022
19028
|
/* @__PURE__ */ (0, import_jsx_runtime161.jsx)("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-theme", children: THEMES2.map((m) => /* @__PURE__ */ (0, import_jsx_runtime161.jsx)("button", { type: "button", "aria-pressed": s.theme === m, onClick: () => s.setTheme(m), children: t[m] }, m)) })
|
|
19023
19029
|
] })
|
|
@@ -19126,9 +19132,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19126
19132
|
const focusAfterCloseRef = (0, import_react122.useRef)(null);
|
|
19127
19133
|
const [tool, setTool] = (0, import_react122.useState)(null);
|
|
19128
19134
|
const panelRef = (0, import_react122.useRef)(null);
|
|
19129
|
-
const settings = useOddsSettings();
|
|
19130
19135
|
const [settingsOpen, setSettingsOpen] = (0, import_react122.useState)(false);
|
|
19131
|
-
const hasSettings = settings.oddsOffered || !settings.themeLocked;
|
|
19132
19136
|
const openSettings = (0, import_react122.useCallback)(() => {
|
|
19133
19137
|
setTool(null);
|
|
19134
19138
|
setFavouritesOpen?.(false);
|
|
@@ -19195,7 +19199,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19195
19199
|
closeFavourites();
|
|
19196
19200
|
return true;
|
|
19197
19201
|
}
|
|
19198
|
-
if (settingsOpen
|
|
19202
|
+
if (settingsOpen) {
|
|
19199
19203
|
closeSettings();
|
|
19200
19204
|
return true;
|
|
19201
19205
|
}
|
|
@@ -19230,7 +19234,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19230
19234
|
canReset: state.messages.length > 0,
|
|
19231
19235
|
newConversationLabel: ui.newConversation,
|
|
19232
19236
|
moreOptionsLabel: ui.moreOptions,
|
|
19233
|
-
onOpenSettings:
|
|
19237
|
+
onOpenSettings: openSettings,
|
|
19234
19238
|
settingsLabel: ui.settings.title,
|
|
19235
19239
|
onOpenFavourites: favouritesOffered ? openFavourites : void 0,
|
|
19236
19240
|
favouritesLabel: ui.tabFavourites
|
|
@@ -19357,7 +19361,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
|
|
|
19357
19361
|
}
|
|
19358
19362
|
)
|
|
19359
19363
|
] }),
|
|
19360
|
-
settingsOpen
|
|
19364
|
+
settingsOpen ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(SettingsSheet, { ui, onClose: closeSettings }) : null,
|
|
19361
19365
|
favouritesOpen && favourites ? /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(FavouritesSheet, { ui, controller: favourites.controller, sport: favourites.sport, sports: favourites.sports, onSportChange: favourites.onSportChange, onClose: closeFavourites }) : null
|
|
19362
19366
|
] });
|
|
19363
19367
|
}
|
|
@@ -19372,11 +19376,11 @@ function HostEventsProvider({ value, children }) {
|
|
|
19372
19376
|
var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
19373
19377
|
.ss-w-root, .ss-w-root * { box-sizing: border-box; margin: 0; padding: 0; }
|
|
19374
19378
|
.ss-w-root {
|
|
19375
|
-
--ss-w-accent: #17936a;
|
|
19379
|
+
--ss-w-accent: var(--ss-w-brand-accent-light, #17936a);
|
|
19376
19380
|
--ss-w-pill: var(--ss-w-pill-light, color-mix(in srgb, var(--ss-w-accent) 72%, #000)); --ss-w-on-accent: var(--ss-w-on-pill-light, #fff);
|
|
19377
|
-
--ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
|
|
19378
|
-
--ss-w-ink: #14181d; --ss-w-faint: #6b7580; --ss-w-line: #e4e8ec;
|
|
19379
|
-
--ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
|
|
19381
|
+
--ss-w-cta: var(--ss-w-brand-cta-light, #f5a623); --ss-w-cta-ink: #1b1300;
|
|
19382
|
+
--ss-w-ink: var(--ss-w-brand-ink-light, #14181d); --ss-w-faint: var(--ss-w-brand-faint-light, #6b7580); --ss-w-line: var(--ss-w-brand-line-light, #e4e8ec);
|
|
19383
|
+
--ss-w-panel: var(--ss-w-brand-surface-light, #ffffff); --ss-w-bubble: var(--ss-w-brand-bubble-light, #f3f5f7); --ss-w-nav: #0e1622;
|
|
19380
19384
|
--ss-w-pos: #1aa563; --ss-w-neg: #e0524b; --ss-w-warn: #c07a00;
|
|
19381
19385
|
--ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
|
|
19382
19386
|
--ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
|
|
@@ -19386,29 +19390,29 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
19386
19390
|
}
|
|
19387
19391
|
@media (prefers-color-scheme: dark) {
|
|
19388
19392
|
.ss-w-root[data-ss-w-theme="auto"] {
|
|
19389
|
-
--ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
|
|
19393
|
+
--ss-w-accent: var(--ss-w-brand-accent-dark, #37c891); --ss-w-cta: var(--ss-w-brand-cta-dark, #ffb638); --ss-w-cta-ink: #1b1300;
|
|
19390
19394
|
--ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
|
|
19391
|
-
--ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
|
|
19392
|
-
--ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
|
|
19395
|
+
--ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
|
|
19396
|
+
--ss-w-line: var(--ss-w-brand-line-dark, #2a3441); --ss-w-panel: var(--ss-w-brand-surface-dark, #141b24); --ss-w-bubble: var(--ss-w-brand-bubble-dark, #1e2732); --ss-w-nav: #0a0f16;
|
|
19393
19397
|
--ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
|
|
19394
19398
|
--ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
|
|
19395
19399
|
--ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
|
|
19396
19400
|
}
|
|
19397
19401
|
}
|
|
19398
19402
|
.ss-w-root[data-ss-w-theme="dark"] {
|
|
19399
|
-
--ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
|
|
19403
|
+
--ss-w-accent: var(--ss-w-brand-accent-dark, #37c891); --ss-w-cta: var(--ss-w-brand-cta-dark, #ffb638); --ss-w-cta-ink: #1b1300;
|
|
19400
19404
|
--ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
|
|
19401
|
-
--ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
|
|
19402
|
-
--ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
|
|
19405
|
+
--ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
|
|
19406
|
+
--ss-w-line: var(--ss-w-brand-line-dark, #2a3441); --ss-w-panel: var(--ss-w-brand-surface-dark, #141b24); --ss-w-bubble: var(--ss-w-brand-bubble-dark, #1e2732); --ss-w-nav: #0a0f16;
|
|
19403
19407
|
--ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
|
|
19404
19408
|
--ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
|
|
19405
19409
|
--ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
|
|
19406
19410
|
}
|
|
19407
19411
|
.ss-w-root[data-ss-w-theme="light"] {
|
|
19408
|
-
--ss-w-accent: #17936a; --ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
|
|
19412
|
+
--ss-w-accent: var(--ss-w-brand-accent-light, #17936a); --ss-w-cta: var(--ss-w-brand-cta-light, #f5a623); --ss-w-cta-ink: #1b1300;
|
|
19409
19413
|
--ss-w-pill: var(--ss-w-pill-light, color-mix(in srgb, var(--ss-w-accent) 72%, #000)); --ss-w-on-accent: var(--ss-w-on-pill-light, #fff);
|
|
19410
|
-
--ss-w-ink: #14181d; --ss-w-faint: #6b7580;
|
|
19411
|
-
--ss-w-line: #e4e8ec; --ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
|
|
19414
|
+
--ss-w-ink: var(--ss-w-brand-ink-light, #14181d); --ss-w-faint: var(--ss-w-brand-faint-light, #6b7580);
|
|
19415
|
+
--ss-w-line: var(--ss-w-brand-line-light, #e4e8ec); --ss-w-panel: var(--ss-w-brand-surface-light, #ffffff); --ss-w-bubble: var(--ss-w-brand-bubble-light, #f3f5f7); --ss-w-nav: #0e1622;
|
|
19412
19416
|
--ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
|
|
19413
19417
|
--ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
|
|
19414
19418
|
}
|