@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/dist/index.js CHANGED
@@ -1383,9 +1383,19 @@ function parseCustomTotal(text2, format2) {
1383
1383
  }
1384
1384
 
1385
1385
  // src/version.generated.ts
1386
- var WIDGET_REACT_VERSION = "0.154.0";
1386
+ var WIDGET_REACT_VERSION = "0.155.0";
1387
1387
 
1388
1388
  // src/config.ts
1389
+ var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
1390
+ function themeColors(group) {
1391
+ const out = {};
1392
+ if (!group || typeof group !== "object") return out;
1393
+ for (const k of COLOR_KEYS) {
1394
+ const v = group[k];
1395
+ if (typeof v === "string" && v.trim() !== "") out[k] = v.trim();
1396
+ }
1397
+ return out;
1398
+ }
1389
1399
  function hostTag(cfg) {
1390
1400
  const pick = (v) => typeof v === "string" && v.trim() !== "" ? v.trim() : void 0;
1391
1401
  return pick(cfg?.locale) ?? pick(cfg?.userContext?.defaultLanguage);
@@ -1397,7 +1407,7 @@ function normalizeUi(cfg, loaded) {
1397
1407
  return {
1398
1408
  theme: cfg.theme ?? "auto",
1399
1409
  oddsFormat: parseOddsFormat(cfg.oddsFormat) ?? "decimal",
1400
- accent: cfg.accent,
1410
+ colors: { light: themeColors(cfg.colors?.light), dark: themeColors(cfg.colors?.dark) },
1401
1411
  logoUrl: cfg.logoUrl,
1402
1412
  headerTitle: cfg.headerTitle,
1403
1413
  locale: loaded.tag,
@@ -1405,9 +1415,6 @@ function normalizeUi(cfg, loaded) {
1405
1415
  timeZone,
1406
1416
  hostTag: hostTag(cfg),
1407
1417
  rawBettingLabels: isBundledFamily(loaded.tag),
1408
- cta: cfg.cta,
1409
- surface: cfg.surface,
1410
- ink: cfg.ink,
1411
1418
  pinIcon: cfg.pinIcon ?? "pin",
1412
1419
  position: cfg.position ?? "right",
1413
1420
  offset: { x: cfg.offset?.x ?? 20, y: cfg.offset?.y ?? 20 },
@@ -3243,32 +3250,33 @@ function pillFor(accent, panel, theme) {
3243
3250
  }
3244
3251
  return { pill: lightPanel ? "#000000" : "#ffffff", ink };
3245
3252
  }
3253
+ var PANEL = { light: LIGHT_PANEL, dark: DARK_PANEL };
3254
+ function brandVars(style, c, theme) {
3255
+ for (const k of ["accent", "cta", "surface", "ink"]) {
3256
+ const v = c[k];
3257
+ if (v) style[`--ss-w-brand-${k}-${theme}`] = v;
3258
+ }
3259
+ if (c.surface && c.ink) {
3260
+ style[`--ss-w-brand-bubble-${theme}`] = `color-mix(in srgb, ${c.ink} 5%, ${c.surface})`;
3261
+ style[`--ss-w-brand-line-${theme}`] = `color-mix(in srgb, ${c.ink} 12%, ${c.surface})`;
3262
+ style[`--ss-w-brand-faint-${theme}`] = `color-mix(in srgb, ${c.ink} 55%, ${c.surface})`;
3263
+ }
3264
+ if (c.accent || c.surface) {
3265
+ const panel = c.surface && rgb(c.surface) ? c.surface : PANEL[theme];
3266
+ const { pill, ink } = pillFor(c.accent, panel, theme);
3267
+ style[`--ss-w-pill-${theme}`] = pill;
3268
+ style[`--ss-w-on-pill-${theme}`] = ink;
3269
+ }
3270
+ }
3246
3271
  function themeAttrs(ui, userTheme) {
3247
3272
  const style = {
3248
3273
  "--ss-w-offset-x": `${ui.offset.x}px`,
3249
3274
  "--ss-w-offset-y": `${ui.offset.y}px`,
3250
3275
  "--ss-w-radius": `${ui.radius}px`
3251
3276
  };
3252
- if (ui.accent) style["--ss-w-accent"] = ui.accent;
3253
- if (ui.cta) style["--ss-w-cta"] = ui.cta;
3254
- if (ui.surface) style["--ss-w-panel"] = ui.surface;
3255
- if (ui.ink) style["--ss-w-ink"] = ui.ink;
3256
- if (ui.surface && ui.ink) {
3257
- style["--ss-w-bubble"] = "color-mix(in srgb, var(--ss-w-ink) 5%, var(--ss-w-panel))";
3258
- style["--ss-w-line"] = "color-mix(in srgb, var(--ss-w-ink) 12%, var(--ss-w-panel))";
3259
- style["--ss-w-faint"] = "color-mix(in srgb, var(--ss-w-ink) 55%, var(--ss-w-panel))";
3260
- }
3261
- if (ui.accent || ui.surface) {
3262
- const surface = ui.surface && rgb(ui.surface) ? ui.surface : void 0;
3263
- const light = pillFor(ui.accent, surface ?? LIGHT_PANEL, "light");
3264
- const dark = pillFor(ui.accent, surface ?? DARK_PANEL, "dark");
3265
- style["--ss-w-pill-light"] = light.pill;
3266
- style["--ss-w-on-pill-light"] = light.ink;
3267
- style["--ss-w-pill-dark"] = dark.pill;
3268
- style["--ss-w-on-pill-dark"] = dark.ink;
3269
- }
3270
- const theme = ui.surface || ui.ink ? ui.theme : userTheme ?? ui.theme;
3271
- return { "data-ss-w-theme": theme, "data-ss-w-pos": ui.position, style };
3277
+ brandVars(style, ui.colors.light, "light");
3278
+ brandVars(style, ui.colors.dark, "dark");
3279
+ return { "data-ss-w-theme": userTheme ?? ui.theme, "data-ss-w-pos": ui.position, style };
3272
3280
  }
3273
3281
 
3274
3282
  // src/oddsSettingsContext.ts
@@ -3332,7 +3340,6 @@ function writeOddsOffered(operatorKey, value) {
3332
3340
  var OddsSettingsContext = createContext({
3333
3341
  oddsFormat: "decimal",
3334
3342
  theme: "auto",
3335
- themeLocked: false,
3336
3343
  oddsOffered: true,
3337
3344
  setOddsFormat: () => {
3338
3345
  },
@@ -3364,11 +3371,10 @@ function useOddsSettingsState(ui, conversation, operatorKey) {
3364
3371
  userOddsFormat: stored.oddsFormat,
3365
3372
  theme: stored.theme ?? ui.theme,
3366
3373
  userTheme: stored.theme,
3367
- themeLocked: !!(ui.surface || ui.ink),
3368
3374
  oddsOffered,
3369
3375
  setOddsFormat: (f) => setStored(writeSettings({ oddsFormat: f })),
3370
3376
  setTheme: (t) => setStored(writeSettings({ theme: t }))
3371
- }), [stored, ui.oddsFormat, ui.theme, ui.surface, ui.ink, oddsOffered]);
3377
+ }), [stored, ui.oddsFormat, ui.theme, oddsOffered]);
3372
3378
  }
3373
3379
 
3374
3380
  // src/useChatStream.ts
@@ -18978,7 +18984,7 @@ function SettingsSheet({ ui, onClose }) {
18978
18984
  ] }),
18979
18985
  /* @__PURE__ */ jsx161("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-odds", children: ODDS.map((f) => /* @__PURE__ */ jsx161("button", { type: "button", "aria-pressed": s.oddsFormat === f, onClick: () => s.setOddsFormat(f), children: t[f] }, f)) })
18980
18986
  ] }),
18981
- !s.themeLocked && /* @__PURE__ */ jsxs139("div", { className: "ss-w-set-row", children: [
18987
+ /* @__PURE__ */ jsxs139("div", { className: "ss-w-set-row", children: [
18982
18988
  /* @__PURE__ */ jsx161("div", { className: "ss-w-tool-label", id: "ss-w-set-theme", children: t.themeLabel }),
18983
18989
  /* @__PURE__ */ jsx161("div", { className: "ss-w-set-seg", role: "group", "aria-labelledby": "ss-w-set-theme", children: THEMES2.map((m) => /* @__PURE__ */ jsx161("button", { type: "button", "aria-pressed": s.theme === m, onClick: () => s.setTheme(m), children: t[m] }, m)) })
18984
18990
  ] })
@@ -19087,9 +19093,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
19087
19093
  const focusAfterCloseRef = useRef49(null);
19088
19094
  const [tool, setTool] = useState88(null);
19089
19095
  const panelRef = useRef49(null);
19090
- const settings = useOddsSettings();
19091
19096
  const [settingsOpen, setSettingsOpen] = useState88(false);
19092
- const hasSettings = settings.oddsOffered || !settings.themeLocked;
19093
19097
  const openSettings = useCallback30(() => {
19094
19098
  setTool(null);
19095
19099
  setFavouritesOpen?.(false);
@@ -19156,7 +19160,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
19156
19160
  closeFavourites();
19157
19161
  return true;
19158
19162
  }
19159
- if (settingsOpen && hasSettings) {
19163
+ if (settingsOpen) {
19160
19164
  closeSettings();
19161
19165
  return true;
19162
19166
  }
@@ -19191,7 +19195,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
19191
19195
  canReset: state.messages.length > 0,
19192
19196
  newConversationLabel: ui.newConversation,
19193
19197
  moreOptionsLabel: ui.moreOptions,
19194
- onOpenSettings: hasSettings ? openSettings : void 0,
19198
+ onOpenSettings: openSettings,
19195
19199
  settingsLabel: ui.settings.title,
19196
19200
  onOpenFavourites: favouritesOffered ? openFavourites : void 0,
19197
19201
  favouritesLabel: ui.tabFavourites
@@ -19318,7 +19322,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
19318
19322
  }
19319
19323
  )
19320
19324
  ] }),
19321
- settingsOpen && hasSettings ? /* @__PURE__ */ jsx162(SettingsSheet, { ui, onClose: closeSettings }) : null,
19325
+ settingsOpen ? /* @__PURE__ */ jsx162(SettingsSheet, { ui, onClose: closeSettings }) : null,
19322
19326
  favouritesOpen && favourites ? /* @__PURE__ */ jsx162(FavouritesSheet, { ui, controller: favourites.controller, sport: favourites.sport, sports: favourites.sports, onSportChange: favourites.onSportChange, onClose: closeFavourites }) : null
19323
19327
  ] });
19324
19328
  }
@@ -19333,11 +19337,11 @@ function HostEventsProvider({ value, children }) {
19333
19337
  var WIDGET_CSS = `.ss-w-root { all: revert; }
19334
19338
  .ss-w-root, .ss-w-root * { box-sizing: border-box; margin: 0; padding: 0; }
19335
19339
  .ss-w-root {
19336
- --ss-w-accent: #17936a;
19340
+ --ss-w-accent: var(--ss-w-brand-accent-light, #17936a);
19337
19341
  --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);
19338
- --ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
19339
- --ss-w-ink: #14181d; --ss-w-faint: #6b7580; --ss-w-line: #e4e8ec;
19340
- --ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
19342
+ --ss-w-cta: var(--ss-w-brand-cta-light, #f5a623); --ss-w-cta-ink: #1b1300;
19343
+ --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);
19344
+ --ss-w-panel: var(--ss-w-brand-surface-light, #ffffff); --ss-w-bubble: var(--ss-w-brand-bubble-light, #f3f5f7); --ss-w-nav: #0e1622;
19341
19345
  --ss-w-pos: #1aa563; --ss-w-neg: #e0524b; --ss-w-warn: #c07a00;
19342
19346
  --ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
19343
19347
  --ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
@@ -19347,29 +19351,29 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
19347
19351
  }
19348
19352
  @media (prefers-color-scheme: dark) {
19349
19353
  .ss-w-root[data-ss-w-theme="auto"] {
19350
- --ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
19354
+ --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;
19351
19355
  --ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
19352
- --ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
19353
- --ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
19356
+ --ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
19357
+ --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;
19354
19358
  --ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
19355
19359
  --ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
19356
19360
  --ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
19357
19361
  }
19358
19362
  }
19359
19363
  .ss-w-root[data-ss-w-theme="dark"] {
19360
- --ss-w-accent: #37c891; --ss-w-cta: #ffb638; --ss-w-cta-ink: #1b1300;
19364
+ --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;
19361
19365
  --ss-w-pill: var(--ss-w-pill-dark, var(--ss-w-accent)); --ss-w-on-accent: var(--ss-w-on-pill-dark, #06231a);
19362
- --ss-w-ink: #e8edf2; --ss-w-faint: #8b95a1;
19363
- --ss-w-line: #2a3441; --ss-w-panel: #141b24; --ss-w-bubble: #1e2732; --ss-w-nav: #0a0f16;
19366
+ --ss-w-ink: var(--ss-w-brand-ink-dark, #e8edf2); --ss-w-faint: var(--ss-w-brand-faint-dark, #8b95a1);
19367
+ --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;
19364
19368
  --ss-w-pos: #37c891; --ss-w-neg: #f0655d; --ss-w-warn: #e0a030;
19365
19369
  --ss-w-home: #5b83c8; --ss-w-away: #e8384f; --ss-w-track: #232d3a;
19366
19370
  --ss-w-correct: #37c86b; --ss-w-wrong: #3a3a41;
19367
19371
  }
19368
19372
  .ss-w-root[data-ss-w-theme="light"] {
19369
- --ss-w-accent: #17936a; --ss-w-cta: #f5a623; --ss-w-cta-ink: #1b1300;
19373
+ --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;
19370
19374
  --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);
19371
- --ss-w-ink: #14181d; --ss-w-faint: #6b7580;
19372
- --ss-w-line: #e4e8ec; --ss-w-panel: #ffffff; --ss-w-bubble: #f3f5f7; --ss-w-nav: #0e1622;
19375
+ --ss-w-ink: var(--ss-w-brand-ink-light, #14181d); --ss-w-faint: var(--ss-w-brand-faint-light, #6b7580);
19376
+ --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;
19373
19377
  --ss-w-home: #3a63a8; --ss-w-away: #c8102e; --ss-w-track: #e9edf1;
19374
19378
  --ss-w-correct: #1f9d55; --ss-w-wrong: #b9bbc2;
19375
19379
  }