@sensiblestats/widget-react 0.72.1 → 0.72.2

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.72.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 77ecef1: Set the numbers: the numbers inside each sentence are now dropdowns instead of tap-to-cycle boxes, so it is clear they are a choice. Numbers with no picks today are marked "not today". Prices and totals with no picks cannot be chosen. A match count with no picks at the chosen total can be, and the row then says it is not available today.
8
+
3
9
  ## 0.72.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -181,7 +181,9 @@ var STRINGS = {
181
181
  matchesLabel: "Matches",
182
182
  fewerMatches: "Fewer matches",
183
183
  moreMatches: "More matches",
184
- changeNumber: (value) => `${value}, tap to change`,
184
+ maxPriceName: "Max price",
185
+ minPriceName: "Lowest price",
186
+ notToday: " \xB7 not today",
185
187
  changeCombo: "Change total or matches"
186
188
  },
187
189
  games: {
@@ -510,7 +512,9 @@ var STRINGS = {
510
512
  matchesLabel: "Ma\xE7 say\u0131s\u0131",
511
513
  fewerMatches: "Daha az ma\xE7",
512
514
  moreMatches: "Daha fazla ma\xE7",
513
- changeNumber: (value) => `${value}, de\u011Fi\u015Ftirmek i\xE7in dokun`,
515
+ maxPriceName: "En y\xFCksek oran",
516
+ minPriceName: "En d\xFC\u015F\xFCk oran",
517
+ notToday: " \xB7 bug\xFCn yok",
514
518
  changeCombo: "Toplam\u0131 veya ma\xE7lar\u0131 de\u011Fi\u015Ftir"
515
519
  },
516
520
  games: {
@@ -2883,11 +2887,6 @@ function comboLegChoices(grid) {
2883
2887
  for (let n = MIN_COMBO_LEGS; n <= max; n++) out.push(n);
2884
2888
  return out;
2885
2889
  }
2886
- function cycle(values, current) {
2887
- if (values.length === 0) return current;
2888
- const i = values.findIndex((v) => samePrice(v, current));
2889
- return values[(i + 1) % values.length] ?? current;
2890
- }
2891
2890
  function startValue(values, preferred) {
2892
2891
  return values.find((v) => samePrice(v, preferred)) ?? values[0] ?? preferred;
2893
2892
  }
@@ -8715,8 +8714,15 @@ function fillTemplate(template, slots) {
8715
8714
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_react51.Fragment, { children: key !== void 0 && key in slots ? slots[key] : part }, i);
8716
8715
  });
8717
8716
  }
8718
- function NumberButton({ value, label, onCycle }) {
8719
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("button", { type: "button", className: "ss-w-tool-num", "aria-label": label, onClick: onCycle, children: value });
8717
+ function NumberSelect({ current, choices: choices2, label, notToday, lockEmpty = true, onChoose }) {
8718
+ const selected = Math.max(0, choices2.findIndex((c) => c.text === current));
8719
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("span", { className: "ss-w-tool-num", children: [
8720
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("span", { className: "ss-w-tool-num-size", "aria-hidden": "true", children: current }),
8721
+ /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("select", { className: "ss-w-tool-num-select", "aria-label": label, value: String(selected), onChange: (e) => {
8722
+ const c = choices2[Number(e.target.value)];
8723
+ if (c) onChoose(c.value);
8724
+ }, children: choices2.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("option", { value: String(i), disabled: lockEmpty && !c.available && i !== selected, children: c.available ? c.text : `${c.text}${notToday}` }, i)) })
8725
+ ] });
8720
8726
  }
8721
8727
  function SendButton({ label, display, disabled, onClick }) {
8722
8728
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("button", { type: "button", className: "ss-w-tool-send", "aria-label": `${label}: ${display}`, disabled, onClick, children: label });
@@ -8763,33 +8769,33 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8763
8769
  const minCell = findSingles(grid.singlesFrom, minPrice, count);
8764
8770
  const comboCell = findCombo(grid, total, legs);
8765
8771
  const announce = (display, available) => setAnnouncement(available ? display : `${display}. ${strings.unavailable}`);
8766
- const nextMax = () => {
8767
- const v = cycle(limits, maxPrice);
8772
+ const chooseMax = (v) => {
8768
8773
  setMaxPrice(v);
8769
8774
  announce(strings.maxPriceDisplay(count, v), !!findSingles(grid.singles, v, count));
8770
8775
  };
8771
- const nextMin = () => {
8772
- const v = cycle(floors, minPrice);
8776
+ const chooseMin = (v) => {
8773
8777
  setMinPrice(v);
8774
8778
  announce(strings.minPriceDisplay(count, v), !!findSingles(grid.singlesFrom, v, count));
8775
8779
  };
8776
- const nextLegs = () => {
8777
- const v = cycle(legChoices, legs);
8780
+ const chooseLegs = (v) => {
8778
8781
  setLegs(v);
8779
8782
  announce(strings.comboDisplay(v, total), !!findCombo(grid, total, v));
8780
8783
  };
8781
- const nextTotal = () => {
8782
- const v = cycle(totals, total);
8784
+ const chooseTotal = (v) => {
8783
8785
  const l = legsForTotal(grid, v, legs);
8784
8786
  setTotal(v);
8785
8787
  setLegs(l);
8786
8788
  announce(strings.comboDisplay(l, v), !!findCombo(grid, v, l));
8787
8789
  };
8790
+ const maxChoices = limits.map((v) => ({ value: v, text: v.toFixed(2), available: !!findSingles(grid.singles, v, count) }));
8791
+ const minChoices = floors.map((v) => ({ value: v, text: v.toFixed(2), available: !!findSingles(grid.singlesFrom, v, count) }));
8792
+ const totalChoices = totals.map((v) => ({ value: v, text: v.toFixed(1), available: legChoices.some((n) => !!findCombo(grid, v, n)) }));
8793
+ const legChoicesList = legChoices.map((n) => ({ value: n, text: String(n), available: !!findCombo(grid, total, n) }));
8788
8794
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(PresetToolModal, { title: strings.setNumbers, closeLabel: strings.close, onClose, children: [
8789
8795
  /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("section", { className: "ss-w-tool-row", children: [
8790
8796
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.maxPriceRow, {
8791
8797
  count: String(count),
8792
- price: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberButton, { value: maxPrice.toFixed(2), label: strings.changeNumber(maxPrice.toFixed(2)), onCycle: nextMax })
8798
+ price: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberSelect, { current: maxPrice.toFixed(2), choices: maxChoices, label: strings.maxPriceName, notToday: strings.notToday, onChoose: chooseMax })
8793
8799
  }) }),
8794
8800
  maxCell ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(PickList, { picks: maxCell.picks, formatKickoff }) : /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Unavailable, { text: strings.unavailable }),
8795
8801
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SendButton, { label: strings.send, display: strings.maxPriceDisplay(count, maxPrice), disabled: !maxCell || streaming, onClick: () => {
@@ -8799,7 +8805,7 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8799
8805
  /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("section", { className: "ss-w-tool-row", children: [
8800
8806
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.minPriceRow, {
8801
8807
  count: String(count),
8802
- price: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberButton, { value: minPrice.toFixed(2), label: strings.changeNumber(minPrice.toFixed(2)), onCycle: nextMin })
8808
+ price: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberSelect, { current: minPrice.toFixed(2), choices: minChoices, label: strings.minPriceName, notToday: strings.notToday, onChoose: chooseMin })
8803
8809
  }) }),
8804
8810
  minCell ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(PickList, { picks: minCell.picks, formatKickoff }) : /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Unavailable, { text: strings.unavailable }),
8805
8811
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SendButton, { label: strings.send, display: strings.minPriceDisplay(count, minPrice), disabled: !minCell || streaming, onClick: () => {
@@ -8808,8 +8814,8 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8808
8814
  ] }),
8809
8815
  /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("section", { className: "ss-w-tool-row", children: [
8810
8816
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.comboRow, {
8811
- legs: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberButton, { value: String(legs), label: strings.changeNumber(String(legs)), onCycle: nextLegs }),
8812
- total: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberButton, { value: total.toFixed(1), label: strings.changeNumber(total.toFixed(1)), onCycle: nextTotal })
8817
+ legs: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberSelect, { current: String(legs), choices: legChoicesList, label: strings.matchesLabel, notToday: strings.notToday, lockEmpty: false, onChoose: chooseLegs }),
8818
+ total: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(NumberSelect, { current: total.toFixed(1), choices: totalChoices, label: strings.totalLabel, notToday: strings.notToday, onChoose: chooseTotal })
8813
8819
  }) }),
8814
8820
  comboCell ? /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ComboPreview, { cell: comboCell, formatKickoff }) : /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Unavailable, { text: strings.unavailable }),
8815
8821
  /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(SendButton, { label: strings.send, display: strings.comboDisplay(legs, total), disabled: !comboCell || streaming, onClick: () => {
@@ -9581,7 +9587,13 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
9581
9587
  .ss-w-tool-foot { flex: none; padding: 10px 14px 12px; border-top: 1px solid var(--ss-w-line); }
9582
9588
  .ss-w-tool-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 11px; border: 1px solid var(--ss-w-line); border-left: 3px solid var(--ss-w-accent); border-radius: 12px; }
9583
9589
  .ss-w-tool-ask { font-size: 14px; font-weight: 650; line-height: 1.7; color: var(--ss-w-ink); overflow-wrap: anywhere; }
9584
- .ss-w-tool-num { display: inline-block; min-width: 44px; min-height: 32px; margin: 0 2px; padding: 3px 8px; font: inherit; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ss-w-accent); background: color-mix(in srgb, var(--ss-w-accent) 10%, var(--ss-w-panel)); border: 1px dashed color-mix(in srgb, var(--ss-w-accent) 55%, var(--ss-w-line)); border-radius: 8px; cursor: pointer; }
9590
+ .ss-w-tool-num { position: relative; display: inline-block; vertical-align: middle; margin: 0 2px; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ss-w-accent); }
9591
+ .ss-w-tool-num-size { display: block; font-size: max(16px, 1em); user-select: none; -webkit-user-select: none; visibility: hidden; box-sizing: border-box; min-width: 44px; min-height: 32px; padding: 6px 26px 6px 10px; line-height: 1.3; white-space: pre; }
9592
+ .ss-w-tool-num-select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0 22px 0 10px; font: inherit; font-size: max(16px, 1em); font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ss-w-accent); background-color: color-mix(in srgb, var(--ss-w-accent) 10%, var(--ss-w-panel)); border: 1.5px solid color-mix(in srgb, var(--ss-w-accent) 65%, var(--ss-w-line)); border-radius: 8px; cursor: pointer; appearance: none; -webkit-appearance: none; }
9593
+ .ss-w-tool-num::after { content: ""; position: absolute; right: 9px; top: 50%; width: 5px; height: 5px; margin-top: -4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); pointer-events: none; }
9594
+ .ss-w-tool-num-select:focus-visible { outline: 2px solid var(--ss-w-accent); outline-offset: 2px; }
9595
+ .ss-w-tool-num-select option { font-weight: 600; color: var(--ss-w-ink); background: var(--ss-w-panel); }
9596
+ .ss-w-tool-num-select option:disabled { color: var(--ss-w-faint); }
9585
9597
  .ss-w-tool-picks { list-style: none; display: flex; flex-direction: column; gap: 4px; }
9586
9598
  .ss-w-tool-pick { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; padding: 5px 8px; font-size: 12px; line-height: 1.35; background: var(--ss-w-bubble); border-radius: 8px; }
9587
9599
  .ss-w-tool-pick-match { grid-column: 1; font-weight: 650; color: var(--ss-w-ink); overflow-wrap: anywhere; }