@sensiblestats/widget-react 0.128.0 → 0.128.1

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
@@ -1219,7 +1219,7 @@ function parseOddsFormat(value) {
1219
1219
  }
1220
1220
 
1221
1221
  // src/version.generated.ts
1222
- var WIDGET_REACT_VERSION = "0.128.0";
1222
+ var WIDGET_REACT_VERSION = "0.128.1";
1223
1223
 
1224
1224
  // src/config.ts
1225
1225
  function hostTag(cfg) {
@@ -8729,6 +8729,7 @@ var SCATTER_VIEW = { w: 400, h: 250, pad: { l: 34, r: 12, t: 12, b: 30 } };
8729
8729
  var FORM_VIEW = { w: 400, h: 170, pad: { l: 28, r: 8, t: 14, b: 40 } };
8730
8730
  var PATH_VIEW = { w: 400, h: 165, pad: { l: 8, r: 8, t: 18, b: 22 } };
8731
8731
  var ROUND_STEPS = 11;
8732
+ var MIN_SPAN_STEPS = 3;
8732
8733
  var MAX_BAR_W = 28;
8733
8734
  var BAR_GAP = 4;
8734
8735
  var MAX_TICKS = 6;
@@ -8774,26 +8775,71 @@ function formBars(e) {
8774
8775
  });
8775
8776
  return { bars, tourY: y(e.tourServePct) };
8776
8777
  }
8777
- function pathBars(e) {
8778
+ var GLYPH_W = 4.6;
8779
+ var FORM_GLYPH_W = 5.1;
8780
+ var FORM_LABEL_GAP = 10;
8781
+ var GUTTER_PAD = 6;
8782
+ var ROUND_LABEL_FONT = 9;
8783
+ var ROUND_LABEL_MIN_GAP = ROUND_LABEL_FONT * 1.4;
8784
+ function fitLabel(text2, width, glyph = GLYPH_W) {
8785
+ const max = Math.max(Math.floor((width - 1) / glyph), 2);
8786
+ return text2.length <= max ? text2 : `${text2.slice(0, max - 1)}\u2026`;
8787
+ }
8788
+ function formLabelWidth(slot) {
8789
+ return Math.max(slot * 2 - FORM_LABEL_GAP, 0);
8790
+ }
8791
+ function roundSpan(e) {
8792
+ const known = e.events.filter((ev) => ev.roundIndex >= 0).map((ev) => clampTo(ev.roundIndex, 0, ROUND_STEPS - 1));
8793
+ const lo = Math.min(ROUND_STEPS - MIN_SPAN_STEPS, ...known);
8794
+ return { lo, span: ROUND_STEPS - lo };
8795
+ }
8796
+ function pathRounds(e) {
8797
+ const { h, pad: pad2 } = PATH_VIEW;
8798
+ const base = h - pad2.b;
8799
+ const plotH = h - pad2.t - pad2.b;
8800
+ const { lo, span } = roundSpan(e);
8801
+ const seen = /* @__PURE__ */ new Map();
8802
+ for (const ev of e.events) {
8803
+ if (ev.roundIndex < 0) continue;
8804
+ const idx = clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8805
+ const short = typeof ev.roundShort === "string" ? ev.roundShort : "";
8806
+ if (short !== "" && !seen.has(idx)) seen.set(idx, short);
8807
+ }
8808
+ const kept = [];
8809
+ for (const [roundIndex, label] of [...seen.entries()].sort((a, b) => b[0] - a[0])) {
8810
+ const y = round22(base - (roundIndex - lo + 1) / span * plotH);
8811
+ const last = kept[kept.length - 1];
8812
+ if (last === void 0 || y - last.y >= ROUND_LABEL_MIN_GAP) kept.push({ roundIndex, label, y });
8813
+ }
8814
+ return kept.reverse();
8815
+ }
8816
+ function pathGutter(e) {
8817
+ const rounds = pathRounds(e);
8818
+ if (rounds.length === 0) return PATH_VIEW.pad.l;
8819
+ const longest = Math.max(...rounds.map((r) => r.label.length));
8820
+ return Math.max(PATH_VIEW.pad.l, Math.ceil(longest * GLYPH_W) + GUTTER_PAD + 4);
8821
+ }
8822
+ function pathBars(e, left = PATH_VIEW.pad.l) {
8778
8823
  const { w, h, pad: pad2 } = PATH_VIEW;
8779
8824
  const n = e.events.length;
8780
- const plotW = w - pad2.l - pad2.r;
8825
+ const plotW = w - left - pad2.r;
8781
8826
  const plotH = h - pad2.t - pad2.b;
8782
8827
  const base = h - pad2.b;
8783
8828
  const slot = plotW / Math.max(n, 1);
8784
8829
  const bw = Math.max(1, Math.min(MAX_BAR_W, slot - BAR_GAP));
8785
- const heightOf = (steps) => Math.min(steps, ROUND_STEPS) / ROUND_STEPS * plotH;
8830
+ const { lo, span } = roundSpan(e);
8831
+ const heightOf = (steps) => Math.min(steps, span) / span * plotH;
8786
8832
  return e.events.map((ev, i) => {
8787
- const idx = clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8788
- const bh = heightOf(idx + 1);
8833
+ const idx = ev.roundIndex < 0 ? lo : clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8834
+ const bh = heightOf(idx - lo + 1);
8789
8835
  return {
8790
- x: round22(pad2.l + slot * i + (slot - bw) / 2),
8836
+ x: round22(left + slot * i + (slot - bw) / 2),
8791
8837
  w: round22(bw),
8792
8838
  h: round22(bh),
8793
8839
  y: round22(base - bh),
8794
8840
  surface: ev.surface ?? null,
8795
8841
  title: ev.title,
8796
- capY: ev.laterRoundsMissing ? round22(base - heightOf(idx + 2)) : null
8842
+ capY: ev.laterRoundsMissing ? round22(base - heightOf(idx - lo + 2)) : null
8797
8843
  };
8798
8844
  });
8799
8845
  }
@@ -8806,12 +8852,7 @@ function labelSide(p, view) {
8806
8852
  import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs34 } from "react/jsx-runtime";
8807
8853
  var SURFACES = /* @__PURE__ */ new Set(["hard", "clay", "grass"]);
8808
8854
  var surfaceOf = (code) => code && SURFACES.has(code) ? code : "other";
8809
- var GLYPH_W = 4.6;
8810
8855
  var pct = (v, ui, digits = 1) => formatNumber(v / 100, ui.locale, { style: "percent", minimumFractionDigits: digits, maximumFractionDigits: digits });
8811
- function fitLabel(text2, slot) {
8812
- const max = Math.max(Math.floor((slot - 1) / GLYPH_W), 2);
8813
- return text2.length <= max ? text2 : `${text2.slice(0, max - 1)}\u2026`;
8814
- }
8815
8856
  function Country({ code }) {
8816
8857
  return code ? /* @__PURE__ */ jsx38("span", { className: "ss-w-tni-cc", children: code }) : null;
8817
8858
  }
@@ -8917,7 +8958,7 @@ function ServeFormCard({ vm, e, ui }) {
8917
8958
  return /* @__PURE__ */ jsxs34("g", { children: [
8918
8959
  /* @__PURE__ */ jsx38("rect", { className: `ss-w-tni-fbar ss-w-tni-fbar-${b.won ? "w" : "l"}`, x: b.x, y: b.y, width: b.w, height: b.h, rx: 2, children: /* @__PURE__ */ jsx38("title", { children: `${m.opponent} \xB7 ${resultLabel2} \xB7 ${pct(m.servePct, ui)}` }) }),
8919
8960
  /* @__PURE__ */ jsx38("text", { className: `ss-w-tni-xl ss-w-tni-xl-${b.won ? "w" : "l"}`, x: cx, y: base + 11, textAnchor: "middle", children: resultLabel2 }),
8920
- /* @__PURE__ */ jsx38("text", { className: "ss-w-tni-xl", x: cx, y: base + (i % 2 === 0 ? 22 : 32), textAnchor: "middle", children: fitLabel(m.opponent, slot * 2 - 2) })
8961
+ /* @__PURE__ */ jsx38("text", { className: "ss-w-tni-xl", x: cx, y: base + (i % 2 === 0 ? 22 : 32), textAnchor: "middle", children: fitLabel(m.opponent, formLabelWidth(slot), FORM_GLYPH_W) })
8921
8962
  ] }, m.matchId);
8922
8963
  }),
8923
8964
  /* @__PURE__ */ jsx38("line", { className: "ss-w-tni-tour", x1: pad2.l, x2: w - pad2.r, y1: tourY, y2: tourY }),
@@ -8931,21 +8972,26 @@ function ServeFormCard({ vm, e, ui }) {
8931
8972
  }
8932
8973
  function SeasonPathCard({ vm, e, ui }) {
8933
8974
  const { w, h, pad: pad2 } = PATH_VIEW;
8934
- const bars = pathBars(e);
8975
+ const left = pathGutter(e);
8976
+ const bars = pathBars(e, left);
8977
+ const rounds = pathRounds(e);
8935
8978
  const base = h - pad2.b;
8936
- const slot = (w - pad2.l - pad2.r) / Math.max(e.events.length, 1);
8937
- const labelled = slot >= 22;
8979
+ const labelled = (w - pad2.l - pad2.r) / Math.max(e.events.length, 1) >= 22;
8938
8980
  const NAME_ROOM = 46;
8981
+ const namesShown = labelled && e.events.some((ev) => ev.name);
8939
8982
  const hasTitle = e.events.some((ev) => ev.title);
8940
8983
  const hasCap = e.events.some((ev) => ev.laterRoundsMissing);
8941
8984
  const aliveChip = e.aliveLabel ? e.events.some((ev) => ev.alive) : false;
8942
8985
  return /* @__PURE__ */ jsxs34(Fragment8, { children: [
8943
- /* @__PURE__ */ jsxs34("svg", { className: "ss-w-tni-svg", viewBox: `0 0 ${w} ${h + NAME_ROOM}`, width: "100%", role: "img", "aria-label": summaryOf(vm, ui), children: [
8944
- /* @__PURE__ */ jsx38("line", { className: "ss-w-tni-grid", x1: pad2.l, x2: w - pad2.r, y1: base, y2: base }),
8986
+ /* @__PURE__ */ jsxs34("svg", { className: "ss-w-tni-svg", viewBox: `0 0 ${w} ${h + (namesShown ? NAME_ROOM : -14)}`, width: "100%", role: "img", "aria-label": summaryOf(vm, ui), children: [
8987
+ rounds.map((r) => /* @__PURE__ */ jsxs34("g", { children: [
8988
+ /* @__PURE__ */ jsx38("line", { className: "ss-w-tni-grid ss-w-tni-rline", x1: left, x2: w - pad2.r, y1: r.y, y2: r.y }),
8989
+ /* @__PURE__ */ jsx38("text", { className: "ss-w-tni-tick", x: left - 4, y: r.y + 3, textAnchor: "end", children: r.label })
8990
+ ] }, `r${r.roundIndex}`)),
8991
+ /* @__PURE__ */ jsx38("line", { className: "ss-w-tni-grid", x1: left, x2: w - pad2.r, y1: base, y2: base }),
8945
8992
  bars.map((b, i) => {
8946
8993
  const ev = e.events[i];
8947
8994
  const surface = surfaceOf(b.surface);
8948
- const short = typeof ev.roundShort === "string" && ev.roundShort !== "" ? ev.roundShort : null;
8949
8995
  return /* @__PURE__ */ jsxs34("g", { children: [
8950
8996
  /* @__PURE__ */ jsx38(
8951
8997
  "rect",
@@ -8963,7 +9009,6 @@ function SeasonPathCard({ vm, e, ui }) {
8963
9009
  ),
8964
9010
  b.capY !== null ? /* @__PURE__ */ jsx38("rect", { className: "ss-w-tni-cap", x: b.x, y: b.capY, width: b.w, height: b.y - b.capY, rx: Math.min(2, b.w / 2), children: /* @__PURE__ */ jsx38("title", { children: e.laterRoundsMissingLabel }) }) : null,
8965
9011
  b.title ? /* @__PURE__ */ jsx38("path", { className: "ss-w-tni-titlemark", d: `M${b.x + b.w / 2} ${b.y - 9} l3.5 6 h-7 z`, children: /* @__PURE__ */ jsx38("title", { children: e.titleMark }) }) : null,
8966
- labelled && short && short.length * GLYPH_W <= slot - 1 ? /* @__PURE__ */ jsx38("text", { className: "ss-w-tni-xl", x: b.x + b.w / 2, y: base + 12, textAnchor: "middle", children: short }) : null,
8967
9012
  labelled && ev.name ? /* @__PURE__ */ jsx38("text", { className: "ss-w-tni-xl ss-w-tni-xl-name", transform: `translate(${b.x + b.w / 2 + 3} ${base + 19}) rotate(90)`, children: fitLabel(ev.name, NAME_ROOM * 1.1) }) : null
8968
9013
  ] }, `${ev.tournamentId}:${i}`);
8969
9014
  })
@@ -20470,6 +20515,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
20470
20515
  .ss-w-root[data-ss-w-theme="dark"] .ss-w-tni { --ss-w-tni-hard: #5b83c8; --ss-w-tni-clay: #e0835a; --ss-w-tni-grass: #5cc069; --ss-w-tni-other: #8b95a1; }
20471
20516
  .ss-w-tni-svg { display: block; width: 100%; height: auto; max-width: 100%; overflow: hidden; font-variant-numeric: tabular-nums; }
20472
20517
  .ss-w-tni-grid { stroke: var(--ss-w-line); stroke-width: 1; }
20518
+ .ss-w-tni-rline { stroke-dasharray: 2 3; opacity: 0.6; }
20473
20519
  .ss-w-tni-tick { font-size: 9px; fill: var(--ss-w-faint); }
20474
20520
  .ss-w-tni-axis { font-size: 9.5px; fill: var(--ss-w-faint); }
20475
20521
  .ss-w-tni-dot { fill: var(--ss-w-ink); opacity: 0.35; }