@protobase/ui 0.15.3 → 0.15.4

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.
@@ -5,8 +5,8 @@ import { mapCards } from "./list-displays.js";
5
5
  import { useAdminMeta } from "../meta-gate.js";
6
6
  import { ErrorBanner } from "../error-banner.js";
7
7
  import { Problem } from "../pages/problem.js";
8
- import { RecordCard } from "./record-card.js";
9
8
  import { useDebounced } from "../../lib/use-debounced.js";
9
+ import { RecordCard } from "./record-card.js";
10
10
  import { boundsAround, worldArea } from "../map/map-area.js";
11
11
  import { keptSelection, mapPoints, stepSelection } from "./map-groups.js";
12
12
  import { useMapRecords } from "./use-map-records.js";
@@ -1,13 +1,26 @@
1
1
  import { cn } from "../lib/cn.js";
2
+ import { useDebounced } from "../lib/use-debounced.js";
2
3
  import { barInRange, fraction, moveThumb } from "./range-math.js";
4
+ import { useEffect, useState } from "react";
3
5
  import { jsx, jsxs } from "react/jsx-runtime";
4
6
  import "./range-slider.css";
5
7
  //#region src/filter-panel/range-filter.tsx
8
+ /** How long a thumb rests, mid-drag or between arrow keys, before the list filters on it. */
9
+ const rangeSettleMs = 1e3;
6
10
  const RangeFilter = ({ config, value, onChange }) => {
7
11
  const { min, max, step, histogram, format } = config;
8
- const selected = value ?? [min, max];
12
+ const [draft, setDraft] = useState();
13
+ const selected = draft ?? value ?? [min, max];
9
14
  const peak = Math.max(...histogram);
10
- const commit = (next) => onChange(next[0] === min && next[1] === max ? void 0 : next);
15
+ const commit = () => {
16
+ if (!draft) return;
17
+ setDraft(void 0);
18
+ onChange(draft[0] === min && draft[1] === max ? void 0 : draft);
19
+ };
20
+ const rested = useDebounced(draft, rangeSettleMs);
21
+ useEffect(() => {
22
+ if (rested) commit();
23
+ }, [rested]);
11
24
  return /* @__PURE__ */ jsxs("div", {
12
25
  className: "w-full",
13
26
  children: [
@@ -40,7 +53,10 @@ const RangeFilter = ({ config, value, onChange }) => {
40
53
  max,
41
54
  step,
42
55
  value: selected[thumb],
43
- onChange: (event) => commit(moveThumb(selected, thumb, Number(event.target.value)))
56
+ onChange: (event) => setDraft(moveThumb(selected, thumb, Number(event.target.value))),
57
+ onPointerUp: commit,
58
+ onTouchEnd: commit,
59
+ onBlur: commit
44
60
  }, thumb))
45
61
  }),
46
62
  /* @__PURE__ */ jsxs("div", {
@@ -51,4 +67,4 @@ const RangeFilter = ({ config, value, onChange }) => {
51
67
  });
52
68
  };
53
69
  //#endregion
54
- export { RangeFilter };
70
+ export { RangeFilter, rangeSettleMs };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.15.3";
2
+ var version = "0.15.4";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };