@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/dist/index.js CHANGED
@@ -143,7 +143,9 @@ var STRINGS = {
143
143
  matchesLabel: "Matches",
144
144
  fewerMatches: "Fewer matches",
145
145
  moreMatches: "More matches",
146
- changeNumber: (value) => `${value}, tap to change`,
146
+ maxPriceName: "Max price",
147
+ minPriceName: "Lowest price",
148
+ notToday: " \xB7 not today",
147
149
  changeCombo: "Change total or matches"
148
150
  },
149
151
  games: {
@@ -472,7 +474,9 @@ var STRINGS = {
472
474
  matchesLabel: "Ma\xE7 say\u0131s\u0131",
473
475
  fewerMatches: "Daha az ma\xE7",
474
476
  moreMatches: "Daha fazla ma\xE7",
475
- changeNumber: (value) => `${value}, de\u011Fi\u015Ftirmek i\xE7in dokun`,
477
+ maxPriceName: "En y\xFCksek oran",
478
+ minPriceName: "En d\xFC\u015F\xFCk oran",
479
+ notToday: " \xB7 bug\xFCn yok",
476
480
  changeCombo: "Toplam\u0131 veya ma\xE7lar\u0131 de\u011Fi\u015Ftir"
477
481
  },
478
482
  games: {
@@ -2845,11 +2849,6 @@ function comboLegChoices(grid) {
2845
2849
  for (let n = MIN_COMBO_LEGS; n <= max; n++) out.push(n);
2846
2850
  return out;
2847
2851
  }
2848
- function cycle(values, current) {
2849
- if (values.length === 0) return current;
2850
- const i = values.findIndex((v) => samePrice(v, current));
2851
- return values[(i + 1) % values.length] ?? current;
2852
- }
2853
2852
  function startValue(values, preferred) {
2854
2853
  return values.find((v) => samePrice(v, preferred)) ?? values[0] ?? preferred;
2855
2854
  }
@@ -8677,8 +8676,15 @@ function fillTemplate(template, slots) {
8677
8676
  return /* @__PURE__ */ jsx90(Fragment20, { children: key !== void 0 && key in slots ? slots[key] : part }, i);
8678
8677
  });
8679
8678
  }
8680
- function NumberButton({ value, label, onCycle }) {
8681
- return /* @__PURE__ */ jsx90("button", { type: "button", className: "ss-w-tool-num", "aria-label": label, onClick: onCycle, children: value });
8679
+ function NumberSelect({ current, choices: choices2, label, notToday, lockEmpty = true, onChoose }) {
8680
+ const selected = Math.max(0, choices2.findIndex((c) => c.text === current));
8681
+ return /* @__PURE__ */ jsxs75("span", { className: "ss-w-tool-num", children: [
8682
+ /* @__PURE__ */ jsx90("span", { className: "ss-w-tool-num-size", "aria-hidden": "true", children: current }),
8683
+ /* @__PURE__ */ jsx90("select", { className: "ss-w-tool-num-select", "aria-label": label, value: String(selected), onChange: (e) => {
8684
+ const c = choices2[Number(e.target.value)];
8685
+ if (c) onChoose(c.value);
8686
+ }, children: choices2.map((c, i) => /* @__PURE__ */ jsx90("option", { value: String(i), disabled: lockEmpty && !c.available && i !== selected, children: c.available ? c.text : `${c.text}${notToday}` }, i)) })
8687
+ ] });
8682
8688
  }
8683
8689
  function SendButton({ label, display, disabled, onClick }) {
8684
8690
  return /* @__PURE__ */ jsx90("button", { type: "button", className: "ss-w-tool-send", "aria-label": `${label}: ${display}`, disabled, onClick, children: label });
@@ -8725,33 +8731,33 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8725
8731
  const minCell = findSingles(grid.singlesFrom, minPrice, count);
8726
8732
  const comboCell = findCombo(grid, total, legs);
8727
8733
  const announce = (display, available) => setAnnouncement(available ? display : `${display}. ${strings.unavailable}`);
8728
- const nextMax = () => {
8729
- const v = cycle(limits, maxPrice);
8734
+ const chooseMax = (v) => {
8730
8735
  setMaxPrice(v);
8731
8736
  announce(strings.maxPriceDisplay(count, v), !!findSingles(grid.singles, v, count));
8732
8737
  };
8733
- const nextMin = () => {
8734
- const v = cycle(floors, minPrice);
8738
+ const chooseMin = (v) => {
8735
8739
  setMinPrice(v);
8736
8740
  announce(strings.minPriceDisplay(count, v), !!findSingles(grid.singlesFrom, v, count));
8737
8741
  };
8738
- const nextLegs = () => {
8739
- const v = cycle(legChoices, legs);
8742
+ const chooseLegs = (v) => {
8740
8743
  setLegs(v);
8741
8744
  announce(strings.comboDisplay(v, total), !!findCombo(grid, total, v));
8742
8745
  };
8743
- const nextTotal = () => {
8744
- const v = cycle(totals, total);
8746
+ const chooseTotal = (v) => {
8745
8747
  const l = legsForTotal(grid, v, legs);
8746
8748
  setTotal(v);
8747
8749
  setLegs(l);
8748
8750
  announce(strings.comboDisplay(l, v), !!findCombo(grid, v, l));
8749
8751
  };
8752
+ const maxChoices = limits.map((v) => ({ value: v, text: v.toFixed(2), available: !!findSingles(grid.singles, v, count) }));
8753
+ const minChoices = floors.map((v) => ({ value: v, text: v.toFixed(2), available: !!findSingles(grid.singlesFrom, v, count) }));
8754
+ const totalChoices = totals.map((v) => ({ value: v, text: v.toFixed(1), available: legChoices.some((n) => !!findCombo(grid, v, n)) }));
8755
+ const legChoicesList = legChoices.map((n) => ({ value: n, text: String(n), available: !!findCombo(grid, total, n) }));
8750
8756
  return /* @__PURE__ */ jsxs75(PresetToolModal, { title: strings.setNumbers, closeLabel: strings.close, onClose, children: [
8751
8757
  /* @__PURE__ */ jsxs75("section", { className: "ss-w-tool-row", children: [
8752
8758
  /* @__PURE__ */ jsx90("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.maxPriceRow, {
8753
8759
  count: String(count),
8754
- price: /* @__PURE__ */ jsx90(NumberButton, { value: maxPrice.toFixed(2), label: strings.changeNumber(maxPrice.toFixed(2)), onCycle: nextMax })
8760
+ price: /* @__PURE__ */ jsx90(NumberSelect, { current: maxPrice.toFixed(2), choices: maxChoices, label: strings.maxPriceName, notToday: strings.notToday, onChoose: chooseMax })
8755
8761
  }) }),
8756
8762
  maxCell ? /* @__PURE__ */ jsx90(PickList, { picks: maxCell.picks, formatKickoff }) : /* @__PURE__ */ jsx90(Unavailable, { text: strings.unavailable }),
8757
8763
  /* @__PURE__ */ jsx90(SendButton, { label: strings.send, display: strings.maxPriceDisplay(count, maxPrice), disabled: !maxCell || streaming, onClick: () => {
@@ -8761,7 +8767,7 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8761
8767
  /* @__PURE__ */ jsxs75("section", { className: "ss-w-tool-row", children: [
8762
8768
  /* @__PURE__ */ jsx90("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.minPriceRow, {
8763
8769
  count: String(count),
8764
- price: /* @__PURE__ */ jsx90(NumberButton, { value: minPrice.toFixed(2), label: strings.changeNumber(minPrice.toFixed(2)), onCycle: nextMin })
8770
+ price: /* @__PURE__ */ jsx90(NumberSelect, { current: minPrice.toFixed(2), choices: minChoices, label: strings.minPriceName, notToday: strings.notToday, onChoose: chooseMin })
8765
8771
  }) }),
8766
8772
  minCell ? /* @__PURE__ */ jsx90(PickList, { picks: minCell.picks, formatKickoff }) : /* @__PURE__ */ jsx90(Unavailable, { text: strings.unavailable }),
8767
8773
  /* @__PURE__ */ jsx90(SendButton, { label: strings.send, display: strings.minPriceDisplay(count, minPrice), disabled: !minCell || streaming, onClick: () => {
@@ -8770,8 +8776,8 @@ function SetNumbersTool({ grid, strings, streaming, formatKickoff, onSend, onClo
8770
8776
  ] }),
8771
8777
  /* @__PURE__ */ jsxs75("section", { className: "ss-w-tool-row", children: [
8772
8778
  /* @__PURE__ */ jsx90("p", { className: "ss-w-tool-ask", children: fillTemplate(strings.comboRow, {
8773
- legs: /* @__PURE__ */ jsx90(NumberButton, { value: String(legs), label: strings.changeNumber(String(legs)), onCycle: nextLegs }),
8774
- total: /* @__PURE__ */ jsx90(NumberButton, { value: total.toFixed(1), label: strings.changeNumber(total.toFixed(1)), onCycle: nextTotal })
8779
+ legs: /* @__PURE__ */ jsx90(NumberSelect, { current: String(legs), choices: legChoicesList, label: strings.matchesLabel, notToday: strings.notToday, lockEmpty: false, onChoose: chooseLegs }),
8780
+ total: /* @__PURE__ */ jsx90(NumberSelect, { current: total.toFixed(1), choices: totalChoices, label: strings.totalLabel, notToday: strings.notToday, onChoose: chooseTotal })
8775
8781
  }) }),
8776
8782
  comboCell ? /* @__PURE__ */ jsx90(ComboPreview, { cell: comboCell, formatKickoff }) : /* @__PURE__ */ jsx90(Unavailable, { text: strings.unavailable }),
8777
8783
  /* @__PURE__ */ jsx90(SendButton, { label: strings.send, display: strings.comboDisplay(legs, total), disabled: !comboCell || streaming, onClick: () => {
@@ -9543,7 +9549,13 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
9543
9549
  .ss-w-tool-foot { flex: none; padding: 10px 14px 12px; border-top: 1px solid var(--ss-w-line); }
9544
9550
  .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; }
9545
9551
  .ss-w-tool-ask { font-size: 14px; font-weight: 650; line-height: 1.7; color: var(--ss-w-ink); overflow-wrap: anywhere; }
9546
- .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; }
9552
+ .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); }
9553
+ .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; }
9554
+ .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; }
9555
+ .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; }
9556
+ .ss-w-tool-num-select:focus-visible { outline: 2px solid var(--ss-w-accent); outline-offset: 2px; }
9557
+ .ss-w-tool-num-select option { font-weight: 600; color: var(--ss-w-ink); background: var(--ss-w-panel); }
9558
+ .ss-w-tool-num-select option:disabled { color: var(--ss-w-faint); }
9547
9559
  .ss-w-tool-picks { list-style: none; display: flex; flex-direction: column; gap: 4px; }
9548
9560
  .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; }
9549
9561
  .ss-w-tool-pick-match { grid-column: 1; font-weight: 650; color: var(--ss-w-ink); overflow-wrap: anywhere; }