@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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.128.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Tennis season path: a round reference (gridlines with the payload's short round labels in a left gutter) at any density, and no blank name band when names are not drawn. Serve form: opponent labels on the same row no longer touch.
8
+
3
9
  ## 0.128.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1257,7 +1257,7 @@ function parseOddsFormat(value) {
1257
1257
  }
1258
1258
 
1259
1259
  // src/version.generated.ts
1260
- var WIDGET_REACT_VERSION = "0.128.0";
1260
+ var WIDGET_REACT_VERSION = "0.128.1";
1261
1261
 
1262
1262
  // src/config.ts
1263
1263
  function hostTag(cfg) {
@@ -8767,6 +8767,7 @@ var SCATTER_VIEW = { w: 400, h: 250, pad: { l: 34, r: 12, t: 12, b: 30 } };
8767
8767
  var FORM_VIEW = { w: 400, h: 170, pad: { l: 28, r: 8, t: 14, b: 40 } };
8768
8768
  var PATH_VIEW = { w: 400, h: 165, pad: { l: 8, r: 8, t: 18, b: 22 } };
8769
8769
  var ROUND_STEPS = 11;
8770
+ var MIN_SPAN_STEPS = 3;
8770
8771
  var MAX_BAR_W = 28;
8771
8772
  var BAR_GAP = 4;
8772
8773
  var MAX_TICKS = 6;
@@ -8812,26 +8813,71 @@ function formBars(e) {
8812
8813
  });
8813
8814
  return { bars, tourY: y(e.tourServePct) };
8814
8815
  }
8815
- function pathBars(e) {
8816
+ var GLYPH_W = 4.6;
8817
+ var FORM_GLYPH_W = 5.1;
8818
+ var FORM_LABEL_GAP = 10;
8819
+ var GUTTER_PAD = 6;
8820
+ var ROUND_LABEL_FONT = 9;
8821
+ var ROUND_LABEL_MIN_GAP = ROUND_LABEL_FONT * 1.4;
8822
+ function fitLabel(text2, width, glyph = GLYPH_W) {
8823
+ const max = Math.max(Math.floor((width - 1) / glyph), 2);
8824
+ return text2.length <= max ? text2 : `${text2.slice(0, max - 1)}\u2026`;
8825
+ }
8826
+ function formLabelWidth(slot) {
8827
+ return Math.max(slot * 2 - FORM_LABEL_GAP, 0);
8828
+ }
8829
+ function roundSpan(e) {
8830
+ const known = e.events.filter((ev) => ev.roundIndex >= 0).map((ev) => clampTo(ev.roundIndex, 0, ROUND_STEPS - 1));
8831
+ const lo = Math.min(ROUND_STEPS - MIN_SPAN_STEPS, ...known);
8832
+ return { lo, span: ROUND_STEPS - lo };
8833
+ }
8834
+ function pathRounds(e) {
8835
+ const { h, pad: pad2 } = PATH_VIEW;
8836
+ const base = h - pad2.b;
8837
+ const plotH = h - pad2.t - pad2.b;
8838
+ const { lo, span } = roundSpan(e);
8839
+ const seen = /* @__PURE__ */ new Map();
8840
+ for (const ev of e.events) {
8841
+ if (ev.roundIndex < 0) continue;
8842
+ const idx = clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8843
+ const short = typeof ev.roundShort === "string" ? ev.roundShort : "";
8844
+ if (short !== "" && !seen.has(idx)) seen.set(idx, short);
8845
+ }
8846
+ const kept = [];
8847
+ for (const [roundIndex, label] of [...seen.entries()].sort((a, b) => b[0] - a[0])) {
8848
+ const y = round22(base - (roundIndex - lo + 1) / span * plotH);
8849
+ const last = kept[kept.length - 1];
8850
+ if (last === void 0 || y - last.y >= ROUND_LABEL_MIN_GAP) kept.push({ roundIndex, label, y });
8851
+ }
8852
+ return kept.reverse();
8853
+ }
8854
+ function pathGutter(e) {
8855
+ const rounds = pathRounds(e);
8856
+ if (rounds.length === 0) return PATH_VIEW.pad.l;
8857
+ const longest = Math.max(...rounds.map((r) => r.label.length));
8858
+ return Math.max(PATH_VIEW.pad.l, Math.ceil(longest * GLYPH_W) + GUTTER_PAD + 4);
8859
+ }
8860
+ function pathBars(e, left = PATH_VIEW.pad.l) {
8816
8861
  const { w, h, pad: pad2 } = PATH_VIEW;
8817
8862
  const n = e.events.length;
8818
- const plotW = w - pad2.l - pad2.r;
8863
+ const plotW = w - left - pad2.r;
8819
8864
  const plotH = h - pad2.t - pad2.b;
8820
8865
  const base = h - pad2.b;
8821
8866
  const slot = plotW / Math.max(n, 1);
8822
8867
  const bw = Math.max(1, Math.min(MAX_BAR_W, slot - BAR_GAP));
8823
- const heightOf = (steps) => Math.min(steps, ROUND_STEPS) / ROUND_STEPS * plotH;
8868
+ const { lo, span } = roundSpan(e);
8869
+ const heightOf = (steps) => Math.min(steps, span) / span * plotH;
8824
8870
  return e.events.map((ev, i) => {
8825
- const idx = clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8826
- const bh = heightOf(idx + 1);
8871
+ const idx = ev.roundIndex < 0 ? lo : clampTo(ev.roundIndex, 0, ROUND_STEPS - 1);
8872
+ const bh = heightOf(idx - lo + 1);
8827
8873
  return {
8828
- x: round22(pad2.l + slot * i + (slot - bw) / 2),
8874
+ x: round22(left + slot * i + (slot - bw) / 2),
8829
8875
  w: round22(bw),
8830
8876
  h: round22(bh),
8831
8877
  y: round22(base - bh),
8832
8878
  surface: ev.surface ?? null,
8833
8879
  title: ev.title,
8834
- capY: ev.laterRoundsMissing ? round22(base - heightOf(idx + 2)) : null
8880
+ capY: ev.laterRoundsMissing ? round22(base - heightOf(idx - lo + 2)) : null
8835
8881
  };
8836
8882
  });
8837
8883
  }
@@ -8844,12 +8890,7 @@ function labelSide(p, view) {
8844
8890
  var import_jsx_runtime38 = require("react/jsx-runtime");
8845
8891
  var SURFACES = /* @__PURE__ */ new Set(["hard", "clay", "grass"]);
8846
8892
  var surfaceOf = (code) => code && SURFACES.has(code) ? code : "other";
8847
- var GLYPH_W = 4.6;
8848
8893
  var pct = (v, ui, digits = 1) => formatNumber(v / 100, ui.locale, { style: "percent", minimumFractionDigits: digits, maximumFractionDigits: digits });
8849
- function fitLabel(text2, slot) {
8850
- const max = Math.max(Math.floor((slot - 1) / GLYPH_W), 2);
8851
- return text2.length <= max ? text2 : `${text2.slice(0, max - 1)}\u2026`;
8852
- }
8853
8894
  function Country({ code }) {
8854
8895
  return code ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "ss-w-tni-cc", children: code }) : null;
8855
8896
  }
@@ -8955,7 +8996,7 @@ function ServeFormCard({ vm, e, ui }) {
8955
8996
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("g", { children: [
8956
8997
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("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__ */ (0, import_jsx_runtime38.jsx)("title", { children: `${m.opponent} \xB7 ${resultLabel2} \xB7 ${pct(m.servePct, ui)}` }) }),
8957
8998
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("text", { className: `ss-w-tni-xl ss-w-tni-xl-${b.won ? "w" : "l"}`, x: cx, y: base + 11, textAnchor: "middle", children: resultLabel2 }),
8958
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("text", { className: "ss-w-tni-xl", x: cx, y: base + (i % 2 === 0 ? 22 : 32), textAnchor: "middle", children: fitLabel(m.opponent, slot * 2 - 2) })
8999
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("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) })
8959
9000
  ] }, m.matchId);
8960
9001
  }),
8961
9002
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { className: "ss-w-tni-tour", x1: pad2.l, x2: w - pad2.r, y1: tourY, y2: tourY }),
@@ -8969,21 +9010,26 @@ function ServeFormCard({ vm, e, ui }) {
8969
9010
  }
8970
9011
  function SeasonPathCard({ vm, e, ui }) {
8971
9012
  const { w, h, pad: pad2 } = PATH_VIEW;
8972
- const bars = pathBars(e);
9013
+ const left = pathGutter(e);
9014
+ const bars = pathBars(e, left);
9015
+ const rounds = pathRounds(e);
8973
9016
  const base = h - pad2.b;
8974
- const slot = (w - pad2.l - pad2.r) / Math.max(e.events.length, 1);
8975
- const labelled = slot >= 22;
9017
+ const labelled = (w - pad2.l - pad2.r) / Math.max(e.events.length, 1) >= 22;
8976
9018
  const NAME_ROOM = 46;
9019
+ const namesShown = labelled && e.events.some((ev) => ev.name);
8977
9020
  const hasTitle = e.events.some((ev) => ev.title);
8978
9021
  const hasCap = e.events.some((ev) => ev.laterRoundsMissing);
8979
9022
  const aliveChip = e.aliveLabel ? e.events.some((ev) => ev.alive) : false;
8980
9023
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
8981
- /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("svg", { className: "ss-w-tni-svg", viewBox: `0 0 ${w} ${h + NAME_ROOM}`, width: "100%", role: "img", "aria-label": summaryOf(vm, ui), children: [
8982
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { className: "ss-w-tni-grid", x1: pad2.l, x2: w - pad2.r, y1: base, y2: base }),
9024
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("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: [
9025
+ rounds.map((r) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("g", { children: [
9026
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { className: "ss-w-tni-grid ss-w-tni-rline", x1: left, x2: w - pad2.r, y1: r.y, y2: r.y }),
9027
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("text", { className: "ss-w-tni-tick", x: left - 4, y: r.y + 3, textAnchor: "end", children: r.label })
9028
+ ] }, `r${r.roundIndex}`)),
9029
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("line", { className: "ss-w-tni-grid", x1: left, x2: w - pad2.r, y1: base, y2: base }),
8983
9030
  bars.map((b, i) => {
8984
9031
  const ev = e.events[i];
8985
9032
  const surface = surfaceOf(b.surface);
8986
- const short = typeof ev.roundShort === "string" && ev.roundShort !== "" ? ev.roundShort : null;
8987
9033
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("g", { children: [
8988
9034
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8989
9035
  "rect",
@@ -9001,7 +9047,6 @@ function SeasonPathCard({ vm, e, ui }) {
9001
9047
  ),
9002
9048
  b.capY !== null ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("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__ */ (0, import_jsx_runtime38.jsx)("title", { children: e.laterRoundsMissingLabel }) }) : null,
9003
9049
  b.title ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { className: "ss-w-tni-titlemark", d: `M${b.x + b.w / 2} ${b.y - 9} l3.5 6 h-7 z`, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("title", { children: e.titleMark }) }) : null,
9004
- labelled && short && short.length * GLYPH_W <= slot - 1 ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("text", { className: "ss-w-tni-xl", x: b.x + b.w / 2, y: base + 12, textAnchor: "middle", children: short }) : null,
9005
9050
  labelled && ev.name ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("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
9006
9051
  ] }, `${ev.tournamentId}:${i}`);
9007
9052
  })
@@ -20508,6 +20553,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
20508
20553
  .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; }
20509
20554
  .ss-w-tni-svg { display: block; width: 100%; height: auto; max-width: 100%; overflow: hidden; font-variant-numeric: tabular-nums; }
20510
20555
  .ss-w-tni-grid { stroke: var(--ss-w-line); stroke-width: 1; }
20556
+ .ss-w-tni-rline { stroke-dasharray: 2 3; opacity: 0.6; }
20511
20557
  .ss-w-tni-tick { font-size: 9px; fill: var(--ss-w-faint); }
20512
20558
  .ss-w-tni-axis { font-size: 9.5px; fill: var(--ss-w-faint); }
20513
20559
  .ss-w-tni-dot { fill: var(--ss-w-ink); opacity: 0.35; }