@arraypress/waveform-sounds 0.2.0 → 0.3.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.
@@ -137,7 +137,7 @@ function formatDuration(seconds) {
137
137
  const s = Number(seconds);
138
138
  if (!Number.isFinite(s) || s < 0) return "";
139
139
  if (s > 0 && s < 0.95) return `${Math.max(0.1, Math.round(s * 10) / 10).toFixed(1)}s`;
140
- const total = Math.round(s);
140
+ const total = s < 1 ? Math.ceil(s) : Math.floor(s);
141
141
  return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`;
142
142
  }
143
143
  function parseDuration(value) {
@@ -377,7 +377,7 @@ function partsOf(menu) {
377
377
  value: menu.querySelector("[data-ws-menu-value]")
378
378
  };
379
379
  }
380
- var focusOwner = (p) => p.search || p.list;
380
+ var focusOwner = (p) => p.search || p.list || p.pop.querySelector("input") || p.pop.querySelector("button");
381
381
  var optionsOf = (p, visibleOnly = false) => [...p.list.querySelectorAll('[role="option"]')].filter((o) => !visibleOnly || !o.hidden);
382
382
  var Menus = class {
383
383
  /**
@@ -409,6 +409,15 @@ var Menus = class {
409
409
  this.open(menu);
410
410
  }
411
411
  }, sig);
412
+ if (!p.list) {
413
+ p.pop.addEventListener("keydown", (e) => {
414
+ if (e.key !== "Escape") return;
415
+ e.preventDefault();
416
+ e.stopPropagation();
417
+ this.close(true);
418
+ }, sig);
419
+ continue;
420
+ }
412
421
  p.list.addEventListener("click", (e) => {
413
422
  const opt = e.target.closest('[role="option"]');
414
423
  if (opt) this._pick(name, opt.dataset.value);
@@ -443,8 +452,8 @@ var Menus = class {
443
452
  }
444
453
  menu.classList.remove("ws-menu--end");
445
454
  if (p.pop.getBoundingClientRect().right > this.container.getBoundingClientRect().right + 1) menu.classList.add("ws-menu--end");
446
- this._activate(menu, p.list.querySelector('[role="option"][aria-selected="true"]'));
447
- focusOwner(p).focus();
455
+ if (p.list) this._activate(menu, p.list.querySelector('[role="option"][aria-selected="true"]'));
456
+ focusOwner(p)?.focus();
448
457
  }
449
458
  /**
450
459
  * Close the open menu, if any.
@@ -472,6 +481,7 @@ var Menus = class {
472
481
  const menu = this.menus[name];
473
482
  if (!menu) return;
474
483
  const p = partsOf(menu);
484
+ if (!p.list) return;
475
485
  let label = null;
476
486
  for (const opt of optionsOf(p)) {
477
487
  const on = opt.dataset.value === String(value ?? "");
@@ -609,6 +619,31 @@ function limitToReveal(limit, pos) {
609
619
  return pos >= limit ? pos + 1 : limit;
610
620
  }
611
621
 
622
+ // src/js/data/bpm.js
623
+ function bpmFilterFromRange(lo, hi, extent) {
624
+ const a = Math.min(lo, hi), b = Math.max(lo, hi);
625
+ return {
626
+ bpmMin: a > extent.min ? String(a) : "",
627
+ bpmMax: b < extent.max ? String(b) : ""
628
+ };
629
+ }
630
+ function bpmRangeFromFilter(filter, extent) {
631
+ const read = (v, fallback) => {
632
+ const n = Number(v);
633
+ return v === "" || v == null || !Number.isFinite(n) ? fallback : Math.min(Math.max(n, extent.min), extent.max);
634
+ };
635
+ const lo = read(filter.bpmMin, extent.min);
636
+ const hi = read(filter.bpmMax, extent.max);
637
+ return lo <= hi ? { lo, hi } : { lo: hi, hi: lo };
638
+ }
639
+ function bpmFraction(value, extent) {
640
+ const span = extent.max - extent.min;
641
+ return span > 0 ? Math.min(Math.max((value - extent.min) / span, 0), 1) : 0;
642
+ }
643
+ function hasBpmFilter(filter) {
644
+ return filter.bpmMin != null && filter.bpmMin !== "" || filter.bpmMax != null && filter.bpmMax !== "";
645
+ }
646
+
612
647
  // src/js/render/strings.js
613
648
  var DEFAULT_STRINGS = {
614
649
  search: "Search sounds",
@@ -624,6 +659,8 @@ var DEFAULT_STRINGS = {
624
659
  bpm: "BPM",
625
660
  bpmMin: "Min BPM",
626
661
  bpmMax: "Max BPM",
662
+ anyBpm: "Any BPM",
663
+ bpmRange: "{min}\u2013{max} BPM",
627
664
  sort: "Sort",
628
665
  sortBy: "Sort by",
629
666
  sortDefault: "Default",
@@ -658,6 +695,11 @@ var SORT_LABEL_KEYS = {
658
695
  function fill(template, vars = {}) {
659
696
  return String(template).replace(/\{(\w+)\}/g, (match, name) => name in vars ? String(vars[name]) : match);
660
697
  }
698
+ function bpmLabel(filter, extent, strings = DEFAULT_STRINGS) {
699
+ if (!hasBpmFilter(filter)) return strings.anyBpm;
700
+ const { lo, hi } = bpmRangeFromFilter(filter, extent);
701
+ return fill(strings.bpmRange, { min: lo, max: hi });
702
+ }
661
703
  function countText(shown, total, strings = DEFAULT_STRINGS) {
662
704
  if (shown !== total) return fill(strings.countFiltered, { count: shown, total });
663
705
  return total === 1 ? strings.countOne : fill(strings.count, { count: total });
@@ -715,7 +757,7 @@ var DEFAULT_OPTIONS = {
715
757
  progressColor: null,
716
758
  barWidth: 2,
717
759
  barGap: 1,
718
- loop: false,
760
+ loop: null,
719
761
  autoAdvance: false,
720
762
  arrowAudition: true,
721
763
  idPrefix: null,
@@ -848,6 +890,9 @@ function toolbarPlan(f, o) {
848
890
  count: !!o.showCount
849
891
  };
850
892
  }
893
+ function loopsByDefault(loop, f) {
894
+ return loop == null ? f.loops > 0 : !!loop;
895
+ }
851
896
  function renderSearch(s) {
852
897
  return h(
853
898
  "label",
@@ -901,15 +946,45 @@ function renderMenu(name, m) {
901
946
  )
902
947
  );
903
948
  }
904
- function renderBpmRange(s, range) {
905
- const field = (attr, label, placeholder) => h("input", { type: "number", inputmode: "numeric", [attr]: true, "aria-label": label, placeholder, min: "0", step: "1" });
949
+ function renderBpmMenu({ id, s, range }) {
950
+ const popId = `${id}-bpm-pop`;
951
+ const handle = (attr, label, value) => h("input", {
952
+ type: "range",
953
+ class: "ws-range-input",
954
+ [attr]: true,
955
+ "aria-label": label,
956
+ min: range.min,
957
+ max: range.max,
958
+ step: "1",
959
+ value
960
+ });
906
961
  return h(
907
- "span",
908
- { class: "ws-bpm-range", role: "group", "aria-label": s.bpm },
909
- field("data-ws-bpm-min", s.bpmMin, range.min),
910
- h("span", { "aria-hidden": "true" }, "\u2013"),
911
- field("data-ws-bpm-max", s.bpmMax, range.max),
912
- h("span", { class: "ws-bpm-unit", "aria-hidden": "true" }, text(s.bpm))
962
+ "div",
963
+ { class: "ws-menu ws-menu--bpm", "data-ws-menu": "bpm" },
964
+ h(
965
+ "button",
966
+ { type: "button", class: "ws-menu-btn", "data-ws-menu-btn": true, "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": popId },
967
+ h("span", { class: "ws-sr" }, text(`${s.bpm}: `)),
968
+ h("span", { class: "ws-menu-value", "data-ws-menu-value": true }, text(bpmLabel({}, range, s))),
969
+ ICONS.chevron
970
+ ),
971
+ h(
972
+ "div",
973
+ { class: "ws-menu-pop ws-bpm-pop", id: popId, role: "dialog", "aria-label": s.bpm, "data-ws-menu-pop": true, hidden: true },
974
+ h(
975
+ "div",
976
+ { class: "ws-bpm-head" },
977
+ h("span", { class: "ws-bpm-readout", "data-ws-bpm-readout": true, "aria-live": "polite" }, text(fill(s.bpmRange, range))),
978
+ h("button", { type: "button", class: "ws-bpm-clear", "data-ws-bpm-clear": true }, text(s.anyBpm))
979
+ ),
980
+ h(
981
+ "div",
982
+ { class: "ws-range", "data-ws-bpm-range": true },
983
+ handle("data-ws-bpm-min", s.bpmMin, range.min),
984
+ handle("data-ws-bpm-max", s.bpmMax, range.max)
985
+ ),
986
+ h("div", { class: "ws-range-ends", "aria-hidden": "true" }, h("span", {}, text(range.min)), h("span", {}, text(range.max)))
987
+ )
913
988
  );
914
989
  }
915
990
  function renderLoopFilter(s) {
@@ -926,8 +1001,8 @@ function renderLoopFilter(s) {
926
1001
  button("one-shot", s.oneShots)
927
1002
  );
928
1003
  }
929
- function renderLoopToggle(s) {
930
- return h("button", { type: "button", class: "ws-loop", "data-ws-loop": true, "aria-pressed": "false" }, ICONS.loop, h("span", {}, text(s.loop)));
1004
+ function renderLoopToggle(s, pressed) {
1005
+ return h("button", { type: "button", class: "ws-loop", "data-ws-loop": true, "aria-pressed": String(pressed) }, ICONS.loop, h("span", {}, text(s.loop)));
931
1006
  }
932
1007
  function renderChip(value, label, count, pressed) {
933
1008
  return h(
@@ -953,7 +1028,7 @@ function renderToolbar(plan, { o, s, f, total, id }) {
953
1028
  placeholder: s.findKey,
954
1029
  options: [{ value: "", label: s.anyKey }, ...f.keys.map((k) => ({ value: k, label: k }))]
955
1030
  }),
956
- plan.bpm && renderBpmRange(s, f.bpm),
1031
+ plan.bpm && renderBpmMenu({ id, s, range: f.bpm }),
957
1032
  plan.loops && renderLoopFilter(s),
958
1033
  plan.sorts.length > 0 && menu("sort", {
959
1034
  label: s.sort,
@@ -961,7 +1036,7 @@ function renderToolbar(plan, { o, s, f, total, id }) {
961
1036
  value: plan.sorts[0],
962
1037
  options: plan.sorts.map((k) => ({ value: k, label: s[SORT_LABEL_KEYS[k]] }))
963
1038
  }),
964
- plan.loop && renderLoopToggle(s)
1039
+ plan.loop && renderLoopToggle(s, loopsByDefault(o.loop, f))
965
1040
  ].filter(Boolean);
966
1041
  const chips = plan.types === "chips" && h(
967
1042
  "div",
@@ -1248,13 +1323,16 @@ var WaveformSounds = class _WaveformSounds {
1248
1323
  this._bind();
1249
1324
  this._observe();
1250
1325
  this._resolveColors();
1326
+ if (!this._loopSet) this.loop = loopsByDefault(this.options.loop, facets(this.sounds));
1251
1327
  this._setLoop(this.loop);
1328
+ this._bpmExtent = facets(this.sounds).bpm;
1252
1329
  this._sorts = availableSorts(this.render.sorts, facets(this.sounds));
1253
1330
  if (!this._sortSet) this.sortBy = this._sorts[0] || "default";
1254
1331
  this._readUrl();
1255
1332
  this._syncControls();
1256
1333
  this._apply({ resort: this.sortBy !== "default" });
1257
1334
  if (this._playerClass()) this._ensureEngine();
1335
+ if (this.render.player === "strip" && this.engine && this.currentIndex == null) this._cueFirst();
1258
1336
  this._emit("ready", { sounds: this.sounds.length });
1259
1337
  this.options.onReady?.(this);
1260
1338
  }
@@ -1280,6 +1358,10 @@ var WaveformSounds = class _WaveformSounds {
1280
1358
  search: q("[data-ws-search]"),
1281
1359
  bpmMin: q("[data-ws-bpm-min]"),
1282
1360
  bpmMax: q("[data-ws-bpm-max]"),
1361
+ bpmRange: q("[data-ws-bpm-range]"),
1362
+ bpmReadout: q("[data-ws-bpm-readout]"),
1363
+ bpmClear: q("[data-ws-bpm-clear]"),
1364
+ bpmLabel: q('[data-ws-menu="bpm"] [data-ws-menu-value]'),
1283
1365
  loop: q("[data-ws-loop]"),
1284
1366
  count: q("[data-ws-count]"),
1285
1367
  empty: q("[data-ws-empty]"),
@@ -1319,12 +1401,20 @@ var WaveformSounds = class _WaveformSounds {
1319
1401
  this.setFilter({ query: "" });
1320
1402
  }
1321
1403
  }, sig);
1322
- const onBpm = () => {
1404
+ const onBpm = (moved) => {
1405
+ const lo = Number($.bpmMin.value), hi = Number($.bpmMax.value);
1406
+ if (lo > hi) moved.value = String(moved === $.bpmMin ? hi : lo);
1407
+ const f = bpmFilterFromRange(Number($.bpmMin.value), Number($.bpmMax.value), this._bpmExtent);
1408
+ this._showBpm(f);
1323
1409
  clearTimeout(bpmTimer);
1324
- bpmTimer = setTimeout(() => this.setFilter({ bpmMin: $.bpmMin?.value ?? "", bpmMax: $.bpmMax?.value ?? "" }), BPM_DELAY);
1410
+ bpmTimer = setTimeout(() => this.setFilter(f), BPM_DELAY);
1325
1411
  };
1326
- $.bpmMin?.addEventListener("input", onBpm, sig);
1327
- $.bpmMax?.addEventListener("input", onBpm, sig);
1412
+ $.bpmMin?.addEventListener("input", () => onBpm($.bpmMin), sig);
1413
+ $.bpmMax?.addEventListener("input", () => onBpm($.bpmMax), sig);
1414
+ $.bpmClear?.addEventListener("click", () => {
1415
+ clearTimeout(bpmTimer);
1416
+ this.setFilter({ bpmMin: "", bpmMax: "" });
1417
+ }, sig);
1328
1418
  this.menus = new Menus(root, {
1329
1419
  signal: this._ctl.signal,
1330
1420
  onPick: (name, value) => name === "sort" ? this.setSort(value) : this.setFilter({ [name]: value })
@@ -1616,11 +1706,32 @@ var WaveformSounds = class _WaveformSounds {
1616
1706
  this.menus?.setValue("type", f.type || "");
1617
1707
  this.menus?.setValue("key", f.key || "");
1618
1708
  this.menus?.setValue("sort", this.sortBy);
1619
- if ($.bpmMin && $.bpmMin.value !== String(f.bpmMin)) $.bpmMin.value = f.bpmMin;
1620
- if ($.bpmMax && $.bpmMax.value !== String(f.bpmMax)) $.bpmMax.value = f.bpmMax;
1709
+ if ($.bpmMin && $.bpmMax && this._bpmExtent) {
1710
+ const { lo, hi } = bpmRangeFromFilter(f, this._bpmExtent);
1711
+ $.bpmMin.value = String(lo);
1712
+ $.bpmMax.value = String(hi);
1713
+ this._showBpm(f);
1714
+ }
1621
1715
  $.chips.forEach((c) => c.setAttribute("aria-pressed", String(c.dataset.wsType === (f.type || ""))));
1622
1716
  $.loopFilter.forEach((b) => b.setAttribute("aria-pressed", String(b.dataset.wsLoopFilter === (f.loop || ""))));
1623
1717
  }
1718
+ /**
1719
+ * Show a BPM filter in its menu: the button label, the panel's readout,
1720
+ * the filled part of the track, and which handle sits on top (the one
1721
+ * that can still move, when they meet).
1722
+ * @private
1723
+ */
1724
+ _showBpm(f) {
1725
+ const $ = this.$, extent = this._bpmExtent;
1726
+ if (!$?.bpmRange || !extent) return;
1727
+ const { lo, hi } = bpmRangeFromFilter(f, extent);
1728
+ if ($.bpmLabel) $.bpmLabel.textContent = bpmLabel(f, extent, this.strings);
1729
+ if ($.bpmReadout) $.bpmReadout.textContent = fill(this.strings.bpmRange, { min: lo, max: hi });
1730
+ $.bpmRange.style.setProperty("--ws-lo", String(bpmFraction(lo, extent)));
1731
+ $.bpmRange.style.setProperty("--ws-hi", String(bpmFraction(hi, extent)));
1732
+ $.bpmRange.classList.toggle("is-min-top", lo >= hi && lo > extent.min);
1733
+ $.bpmRange.classList.toggle("is-active", lo > extent.min || hi < extent.max);
1734
+ }
1624
1735
  /**
1625
1736
  * Lay the rows out for the current filter, sort and page: order, hide,
1626
1737
  * "Show more", the empty state and the count. Then report it.
@@ -1647,6 +1758,7 @@ var WaveformSounds = class _WaveformSounds {
1647
1758
  }
1648
1759
  if ($.empty) $.empty.hidden = shown.length > 0;
1649
1760
  if ($.count) $.count.textContent = countText(shown.length, this.sounds.length, this.strings);
1761
+ if (this._cued && !this.playing) this._cueFirst();
1650
1762
  this._queueUrl();
1651
1763
  this._emit("filter", { visible: shown.length, total: this.sounds.length, filter: { ...this.filter }, sort: this.sortBy });
1652
1764
  this.options.onFilter?.(shown, this);
@@ -1731,6 +1843,7 @@ var WaveformSounds = class _WaveformSounds {
1731
1843
  }
1732
1844
  const index = this._indexOf(target);
1733
1845
  if (index == null) return;
1846
+ this._cued = false;
1734
1847
  const engine = this._ensureEngine();
1735
1848
  if (!engine) return;
1736
1849
  if (index === this.currentIndex && engine.audio?.src) {
@@ -1747,6 +1860,25 @@ var WaveformSounds = class _WaveformSounds {
1747
1860
  const sound = this.sounds[index];
1748
1861
  engine.loadTrack(sound.url, sound.title, sound.type || null, { waveform: enginePeaks(sound, this.render.player), autoplay: true });
1749
1862
  }
1863
+ /**
1864
+ * Strip layout: load the first sound the list shows into the docked
1865
+ * player WITHOUT playing it, so the player shows a title and waveform
1866
+ * (and its play button plays that sound) instead of an empty frame.
1867
+ * Only metadata is fetched — the browser default for any `<audio>`.
1868
+ * The row isn't marked current until it plays.
1869
+ * @private
1870
+ */
1871
+ _cueFirst() {
1872
+ const engine = this.engine;
1873
+ const first = this.visible[0];
1874
+ if (!engine || !first) return;
1875
+ const index = this.sounds.indexOf(first);
1876
+ if (index === this.currentIndex) return;
1877
+ this.currentIndex = index;
1878
+ this.progress = 0;
1879
+ this._cued = true;
1880
+ engine.loadTrack(first.url, first.title, first.type || null, { waveform: enginePeaks(first, "strip"), autoplay: false });
1881
+ }
1750
1882
  /** Pause the current sound. */
1751
1883
  pause() {
1752
1884
  if (this.engine && this.playing) this.engine.pause();
@@ -1779,7 +1911,7 @@ var WaveformSounds = class _WaveformSounds {
1779
1911
  */
1780
1912
  _step(dir) {
1781
1913
  const shown = this.visible;
1782
- const at = this.currentIndex == null ? -1 : shown.indexOf(this.sounds[this.currentIndex]);
1914
+ const at = this.currentIndex == null || this._cued ? -1 : shown.indexOf(this.sounds[this.currentIndex]);
1783
1915
  const target = shown[at + dir];
1784
1916
  if (!target) return false;
1785
1917
  const limit = limitToReveal(this.limit, at + dir);
@@ -1797,6 +1929,7 @@ var WaveformSounds = class _WaveformSounds {
1797
1929
  * @param {boolean} on
1798
1930
  */
1799
1931
  setLoop(on) {
1932
+ this._loopSet = true;
1800
1933
  this.loop = !!on;
1801
1934
  this._setLoop(this.loop);
1802
1935
  }
@@ -1907,6 +2040,7 @@ var WaveformSounds = class _WaveformSounds {
1907
2040
  _setPlaying(on) {
1908
2041
  const changed = this.playing !== on;
1909
2042
  this.playing = on;
2043
+ if (on) this._cued = false;
1910
2044
  const index = this.currentIndex;
1911
2045
  if (index == null) return;
1912
2046
  this._paintRow(index);
@@ -1950,7 +2084,7 @@ var WaveformSounds = class _WaveformSounds {
1950
2084
  }
1951
2085
  /** The sound playing (or paused) now, or null. */
1952
2086
  get current() {
1953
- return this.currentIndex == null ? null : this.sounds[this.currentIndex];
2087
+ return this.currentIndex == null || this._cued ? null : this.sounds[this.currentIndex];
1954
2088
  }
1955
2089
  /**
1956
2090
  * Tear down: listeners, observers, timers and the engine. Markup this
@@ -104,16 +104,6 @@
104
104
  }
105
105
 
106
106
  .ws-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
107
- .ws-bpm-range input {
108
- height: 2.75rem;
109
- border: 1px solid var(--ws-border);
110
- border-radius: var(--ws-control-radius);
111
- background: var(--ws-field);
112
- color: inherit;
113
- font: inherit;
114
- font-size: 0.9em;
115
- }
116
-
117
107
  /* ── Dropdowns (type / key / sort) ──────────────────────────────────── */
118
108
  .ws-menu { position: relative; }
119
109
  .ws-menu-btn {
@@ -185,9 +175,105 @@
185
175
  .ws-menu-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
186
176
  .ws-menu-count { font-family: var(--ws-mono); font-size: 0.85em; color: var(--ws-muted); }
187
177
  .ws-menu-none { margin: 0; padding: 0.6rem; color: var(--ws-muted); font-size: 0.9em; }
188
- .ws-bpm-range { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ws-muted); font-size: 0.9em; }
189
- .ws-bpm-range input { width: 5rem; padding: 0 0.85rem; -moz-appearance: textfield; }
190
- .ws-bpm-range input::-webkit-inner-spin-button { display: none; }
178
+
179
+ /* ── The BPM menu: a panel with a two-handle range ───────────────────── */
180
+ .ws-bpm-pop { width: 17rem; padding: 0.85rem 1rem 0.7rem; }
181
+ .ws-bpm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.6rem; }
182
+ .ws-bpm-readout { font-weight: 600; font-variant-numeric: tabular-nums; }
183
+ .ws-bpm-clear {
184
+ padding: 0;
185
+ border: 0;
186
+ background: none;
187
+ color: var(--ws-muted);
188
+ font: inherit;
189
+ font-size: 0.85em;
190
+ cursor: pointer;
191
+ }
192
+ .ws-bpm-clear:hover { color: inherit; text-decoration: underline; }
193
+
194
+ /* Two native range inputs stacked on one track. The track and the filled
195
+ * span are drawn by the wrapper (--ws-lo / --ws-hi are the handles' 0..1
196
+ * positions, set by the runtime); the inputs contribute only their thumbs.
197
+ * A thumb's centre runs from half a thumb in from each end, hence the
198
+ * calc() on the fill. */
199
+ .ws-range {
200
+ --ws-thumb: 18px;
201
+ --ws-lo: 0;
202
+ --ws-hi: 1;
203
+ position: relative;
204
+ height: 1.75rem;
205
+ }
206
+ .ws-range::before,
207
+ .ws-range::after {
208
+ content: '';
209
+ position: absolute;
210
+ top: 50%;
211
+ height: 4px;
212
+ border-radius: 2px;
213
+ transform: translateY(-50%);
214
+ }
215
+ .ws-range::before { left: 0; right: 0; background: var(--ws-border); }
216
+ .ws-range::after {
217
+ left: calc(var(--ws-thumb) / 2 + var(--ws-lo) * (100% - var(--ws-thumb)));
218
+ right: calc(var(--ws-thumb) / 2 + (1 - var(--ws-hi)) * (100% - var(--ws-thumb)));
219
+ background: var(--ws-accent);
220
+ opacity: 0.35;
221
+ }
222
+ .ws-range.is-active::after { opacity: 1; }
223
+ .ws-range-input {
224
+ position: absolute;
225
+ inset: 0;
226
+ z-index: 1;
227
+ width: 100%;
228
+ height: 100%;
229
+ margin: 0;
230
+ background: none;
231
+ pointer-events: none;
232
+ -webkit-appearance: none;
233
+ appearance: none;
234
+ }
235
+ /* When the handles meet, the lower one goes on top (it's the one that can
236
+ * still move: left). */
237
+ .ws-range.is-min-top [data-ws-bpm-min] { z-index: 2; }
238
+ .ws-range-input::-webkit-slider-runnable-track { height: 100%; background: none; }
239
+ .ws-range-input::-moz-range-track { background: none; }
240
+ .ws-range-input::-webkit-slider-thumb {
241
+ width: var(--ws-thumb);
242
+ height: var(--ws-thumb);
243
+ margin-top: calc((1.75rem - var(--ws-thumb)) / 2);
244
+ border: 2px solid var(--ws-surface, Canvas);
245
+ border-radius: 50%;
246
+ background: var(--ws-accent);
247
+ box-shadow: 0 0 0 1px var(--ws-border);
248
+ cursor: grab;
249
+ pointer-events: auto;
250
+ -webkit-appearance: none;
251
+ appearance: none;
252
+ }
253
+ .ws-range-input::-moz-range-thumb {
254
+ width: var(--ws-thumb);
255
+ height: var(--ws-thumb);
256
+ box-sizing: border-box;
257
+ border: 2px solid var(--ws-surface, Canvas);
258
+ border-radius: 50%;
259
+ background: var(--ws-accent);
260
+ box-shadow: 0 0 0 1px var(--ws-border);
261
+ cursor: grab;
262
+ pointer-events: auto;
263
+ }
264
+ .ws-range-input:active::-webkit-slider-thumb { cursor: grabbing; }
265
+ .ws-range-input:focus-visible { outline: none; }
266
+ .ws-range-input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--ws-accent); }
267
+ .ws-range-input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--ws-accent); }
268
+ .ws-range-ends {
269
+ display: flex;
270
+ justify-content: space-between;
271
+ margin-top: 0.15rem;
272
+ color: var(--ws-muted);
273
+ font-family: var(--ws-mono);
274
+ font-size: 0.75em;
275
+ font-variant-numeric: tabular-nums;
276
+ }
191
277
  .ws-loop {
192
278
  display: inline-flex;
193
279
  align-items: center;
@@ -388,9 +474,11 @@
388
474
  .ws-more { display: block; margin: 1.25rem auto 0; padding: 0.7rem 1.4rem; font-size: 0.92em; }
389
475
  .ws-more:hover, .ws-clear:hover { background: var(--ws-hover); }
390
476
 
391
- /* The strip layout: the engine is a full player docked under the list. */
477
+ /* The strip layout: the engine is a full player docked under the list.
478
+ * It stays in place by default; set --ws-strip-position: sticky to keep it
479
+ * at the bottom of the viewport while a long list scrolls past. */
392
480
  .ws-engine--strip {
393
- position: sticky;
481
+ position: var(--ws-strip-position, static);
394
482
  bottom: 0;
395
483
  margin-top: 1rem;
396
484
  padding: 0.75rem;
@@ -406,7 +494,9 @@
406
494
  @media (pointer: coarse) {
407
495
  .ws-play, .ws-download { width: 2.75rem; height: 2.75rem; }
408
496
  .ws-chip { height: 2.5rem; }
409
- .ws-search-input, .ws-menu-search, .ws-bpm-range input { font-size: 16px; }
497
+ .ws-search-input, .ws-menu-search { font-size: 16px; }
498
+ .ws-range { --ws-thumb: 24px; height: 2.25rem; }
499
+ .ws-range-input::-webkit-slider-thumb { margin-top: calc((2.25rem - var(--ws-thumb)) / 2); }
410
500
  .ws-menu-option { padding: 0.75rem 0.6rem; }
411
501
  }
412
502