panelui-native 0.102.0 → 0.102.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.
@@ -13,7 +13,8 @@
13
13
  * short delay and then faster, the way a native stepper does — so walking from
14
14
  * 0 to 200 is a press, not two hundred of them. The repeat reads the live
15
15
  * value from a ref rather than a closure, so it never strides off a stale
16
- * number.
16
+ * number, and it stops at a bound on its own rather than waiting for a
17
+ * release a disabled button may never send.
17
18
  *
18
19
  * Typing is allowed to be briefly invalid — an empty field, a lone `-`, a
19
20
  * trailing `.` — because clamping every keystroke fights the person mid-number.
@@ -37,6 +38,7 @@ import { Text } from "../../primitives/text.js";
37
38
  import { selectionTick } from "../../utils/haptics.js";
38
39
  import { Label } from "../label/index.js";
39
40
  import { normalize, precisionOf } from "./number-input-math.js";
41
+ import { createRepeater } from "./number-input-repeat.js";
40
42
 
41
43
  /** Wait before a held button starts repeating — a tap must not trip it. */
42
44
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -204,26 +206,35 @@ export const NumberInput = /*#__PURE__*/forwardRef(({
204
206
  const clamped = normalize(next, min, max, step);
205
207
  if (tick && haptics) selectionTick();
206
208
  if (!isControlled) setUncontrolled(clamped);
207
- if (clamped !== value) onValueChange?.(clamped);
208
- }, [min, max, step, haptics, isControlled, value, onValueChange]);
209
+ if (clamped !== valueRef.current) onValueChange?.(clamped);
210
+ // Advance the ref now, so the next repeat steps from here even if the
211
+ // render carrying this value has not landed yet.
212
+ valueRef.current = clamped;
213
+ }, [min, max, step, haptics, isControlled, onValueChange]);
209
214
 
210
215
  // --- hold-to-repeat -----------------------------------------------------
211
- const delayRef = useRef(null);
212
- const intervalRef = useRef(null);
213
- const stopRepeat = useCallback(() => {
214
- if (delayRef.current) clearTimeout(delayRef.current);
215
- if (intervalRef.current) clearInterval(intervalRef.current);
216
- delayRef.current = null;
217
- intervalRef.current = null;
218
- }, []);
216
+ // The timer outlives the render that started it, so it calls the latest
217
+ // `commit` through a ref instead of the one it was created with.
218
+ const commitRef = useRef(commit);
219
+ commitRef.current = commit;
220
+ const repeaterRef = useRef(null);
221
+ if (!repeaterRef.current) repeaterRef.current = createRepeater(REPEAT_DELAY, REPEAT_INTERVAL);
222
+ const repeater = repeaterRef.current;
223
+ const stopRepeat = repeater.stop;
219
224
  useEffect(() => stopRepeat, [stopRepeat]);
225
+ useEffect(() => {
226
+ if (disabled) stopRepeat();
227
+ }, [disabled, stopRepeat]);
220
228
  const startRepeat = useCallback(direction => {
221
- const nudge = () => commit(valueRef.current + direction * step, true);
222
- nudge();
223
- delayRef.current = setTimeout(() => {
224
- intervalRef.current = setInterval(nudge, REPEAT_INTERVAL);
225
- }, REPEAT_DELAY);
226
- }, [commit, step]);
229
+ repeater.start(() => {
230
+ const current = valueRef.current;
231
+ const next = normalize(current + direction * step, min, max, step);
232
+ if (next === current) return false;
233
+ commitRef.current(next, true);
234
+ // Keep going only while there is room for another step.
235
+ return direction > 0 ? next < max : next > min;
236
+ });
237
+ }, [repeater, step, min, max]);
227
238
  const atMin = value <= min;
228
239
  const atMax = value >= max;
229
240
  const handleEndEditing = useCallback(() => {
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","useCallback","useEffect","useRef","useState","TextInput","View","tv","useCSSVariable","MinusIcon","PlusIcon","AnimatedPressable","Text","selectionTick","Label","normalize","precisionOf","jsx","_jsx","jsxs","_jsxs","REPEAT_DELAY","REPEAT_INTERVAL","numberInputVariants","slots","container","control","button","field","description","error","variants","variant","outline","filled","size","sm","md","lg","invalid","true","disabled","defaultVariants","ICON_SIZE","FIELD_BASE","paddingVertical","paddingHorizontal","includeFontPadding","textAlignVertical","fontVariant","FIELD_STYLE","fontSize","NumberInput","className","containerClassName","value","controlledValue","defaultValue","min","Infinity","max","step","onValueChange","formatValue","editable","label","errorMessage","isRequired","haptics","placeholder","onFocus","onBlur","returnKeyType","ref","isControlled","undefined","initial","isFinite","uncontrolled","setUncontrolled","valueRef","current","foreground","iconColor","format","v","String","text","setText","focused","setFocused","commit","next","tick","clamped","delayRef","intervalRef","stopRepeat","clearTimeout","clearInterval","startRepeat","direction","nudge","setTimeout","setInterval","atMin","atMax","handleEndEditing","parsed","parseFloat","Number","isNaN","children","isInvalid","isDisabled","pressOpacity","onPressIn","onPressOut","accessibilityRole","accessibilityLabel","accessibilityState","style","opacity","color","strokeWidth","keyboardType","selectTextOnFocus","onChangeText","e","onSubmitEditing","displayName"],"sourceRoot":"../../../../src","sources":["components/number-input/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5E,SAASC,SAAS,EAAEC,IAAI,QAA6C,cAAc;AACnF,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,sBAAa;AACjD,SAASC,iBAAiB,QAAQ,wCAAqC;AACvE,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,aAAa,QAAQ,wBAAqB;AACnD,SAASC,KAAK,QAAQ,mBAAU;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,wBAAqB;;AAE5D;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AACA,MAAMC,YAAY,GAAG,GAAG;AACxB;AACA,MAAMC,eAAe,GAAG,EAAE;AAE1B,MAAMC,mBAAmB,GAAGhB,EAAE,CAAC;EAC7BiB,KAAK,EAAE;IACLC,SAAS,EAAE,gBAAgB;IAC3BC,OAAO,EAAE,gEAAgE;IACzEC,MAAM,EAAE,oCAAoC;IAC5C;IACA;IACAC,KAAK,EAAE,uDAAuD;IAC9DC,WAAW,EAAE,+BA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ACiE,KAAK,EAAEN,WAAW,CAAC,CAAC,CAAC;QACzC,CAAE;QACFiB,UAAU,EAAEpB,UAAW;QACvBqB,iBAAiB,EAAC,QAAQ;QAC1BC,kBAAkB,EAAE,YAAYtD,KAAK,IAAI,OAAO,EAAG;QACnDuD,kBAAkB,EAAE;UAAE/E,QAAQ,EAAEA,QAAQ,IAAIiE;QAAM,CAAE;QACpDe,KAAK,EAAEf,KAAK,GAAG;UAAEgB,OAAO,EAAE;QAAI,CAAC,GAAG/C,SAAU;QAAAqC,QAAA,eAE5C9F,IAAA,CAACR,QAAQ;UAACyB,IAAI,EAAEQ,SAAS,CAACR,IAAI,CAAE;UAACwF,KAAK,EAAExC;QAAU,CAAE;MAAC,CACpC,CAAC;IAAA,CAChB,CAAC,EACNjB,YAAY,gBACXhD,IAAA,CAACN,IAAI;MAACyC,SAAS,EAAE7B,KAAK,CAACM,KAAK,CAAC,CAAE;MAAAkF,QAAA,EAAE9C;IAAY,CAAO,CAAC,GACnDrC,WAAW,gBACbX,IAAA,CAACN,IAAI;MAACyC,SAAS,EAAE7B,KAAK,CAACK,WAAW,CAAC,CAAE;MAAAmF,QAAA,EAAEnF;IAAW,CAAO,CAAC,GACxD,IAAI;EAAA,CACJ,CAAC;AAEX,CACF,CAAC;AAEDuB,WAAW,CAAC8E,WAAW,GAAG,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","useCallback","useEffect","useRef","useState","TextInput","View","tv","useCSSVariable","MinusIcon","PlusIcon","AnimatedPressable","Text","selectionTick","Label","normalize","precisionOf","createRepeater","jsx","_jsx","jsxs","_jsxs","REPEAT_DELAY","REPEAT_INTERVAL","numberInputVariants","slots","container","control","button","field","description","error","variants","variant","outline","filled","size","sm","md","lg","invalid","true","disabled","defaultVariants","ICON_SIZE","FIELD_BASE","paddingVertical","paddingHorizontal","includeFontPadding","textAlignVertical","fontVariant","FIELD_STYLE","fontSize","NumberInput","className","containerClassName","value","controlledValue","defaultValue","min","Infinity","max","step","onValueChange","formatValue","editable","label","errorMessage","isRequired","haptics","placeholder","onFocus","onBlur","returnKeyType","ref","isControlled","undefined","initial","isFinite","uncontrolled","setUncontrolled","valueRef","current","foreground","iconColor","format","v","String","text","setText","focused","setFocused","commit","next","tick","clamped","commitRef","repeaterRef","repeater","stopRepeat","stop","startRepeat","direction","start","atMin","atMax","handleEndEditing","parsed","parseFloat","Number","isNaN","children","isInvalid","isDisabled","pressOpacity","onPressIn","onPressOut","accessibilityRole","accessibilityLabel","accessibilityState","style","opacity","color","strokeWidth","keyboardType","selectTextOnFocus","onChangeText","e","onSubmitEditing","displayName"],"sourceRoot":"../../../../src","sources":["components/number-input/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5E,SAASC,SAAS,EAAEC,IAAI,QAA6C,cAAc;AACnF,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,sBAAa;AACjD,SAASC,iBAAiB,QAAQ,wCAAqC;AACvE,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,aAAa,QAAQ,wBAAqB;AACnD,SAASC,KAAK,QAAQ,mBAAU;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,wBAAqB;AAC5D,SAASC,cAAc,QAAQ,0BAAuB;;AAEtD;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AACA,MAAMC,YAAY,GAAG,GAAG;AACxB;AACA,MAAMC,eAAe,GAAG,EAAE;AAE1B,MAAMC,mBAAmB,GAAGjB,EAAE,CAAC;EAC7BkB,KAAK,EAAE;IACLC,SAAS,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AG,aAAa","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The hold-to-repeat timer behind NumberInput's − and + buttons.
5
+ *
6
+ * A press steps once, then after `delay` keeps stepping every `interval` until
7
+ * it is stopped. Two things keep it from running away:
8
+ *
9
+ * - There is only ever one timer. `start` clears whatever is already running,
10
+ * because a press-in does not always arrive after the previous press-out —
11
+ * quick taps on Android can deliver two press-ins in a row, and a second
12
+ * timer started over the first leaves the first with no handle to clear it.
13
+ * - The step reports whether another one is possible. At a bound the button
14
+ * disables, and a disabled button is not guaranteed to deliver the release
15
+ * that would stop the timer, so the timer stops itself there instead.
16
+ *
17
+ * Kept free of React so it can be tested on its own.
18
+ */
19
+
20
+ export function createRepeater(delay, interval) {
21
+ let delayTimer = null;
22
+ let intervalTimer = null;
23
+ // Bumped by every start and stop. A callback from an earlier generation does
24
+ // nothing, so a timer that fires once more after being cleared cannot step.
25
+ let generation = 0;
26
+ const stop = () => {
27
+ generation += 1;
28
+ if (delayTimer !== null) clearTimeout(delayTimer);
29
+ if (intervalTimer !== null) clearInterval(intervalTimer);
30
+ delayTimer = null;
31
+ intervalTimer = null;
32
+ };
33
+ const start = step => {
34
+ stop();
35
+ const current = generation;
36
+ if (!step()) return;
37
+ delayTimer = setTimeout(() => {
38
+ if (current !== generation) return;
39
+ delayTimer = null;
40
+ intervalTimer = setInterval(() => {
41
+ if (current !== generation) return;
42
+ if (!step()) stop();
43
+ }, interval);
44
+ }, delay);
45
+ };
46
+ return {
47
+ start,
48
+ stop
49
+ };
50
+ }
51
+ //# sourceMappingURL=number-input-repeat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRepeater","delay","interval","delayTimer","intervalTimer","generation","stop","clearTimeout","clearInterval","start","step","current","setTimeout","setInterval"],"sourceRoot":"../../../../src","sources":["components/number-input/number-input-repeat.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAO,SAASA,cAAcA,CAACC,KAAa,EAAEC,QAAgB,EAAY;EACxE,IAAIC,UAAgD,GAAG,IAAI;EAC3D,IAAIC,aAAoD,GAAG,IAAI;EAC/D;EACA;EACA,IAAIC,UAAU,GAAG,CAAC;EAElB,MAAMC,IAAI,GAAGA,CAAA,KAAM;IACjBD,UAAU,IAAI,CAAC;IACf,IAAIF,UAAU,KAAK,IAAI,EAAEI,YAAY,CAACJ,UAAU,CAAC;IACjD,IAAIC,aAAa,KAAK,IAAI,EAAEI,aAAa,CAACJ,aAAa,CAAC;IACxDD,UAAU,GAAG,IAAI;IACjBC,aAAa,GAAG,IAAI;EACtB,CAAC;EAED,MAAMK,KAAK,GAAIC,IAAmB,IAAK;IACrCJ,IAAI,CAAC,CAAC;IACN,MAAMK,OAAO,GAAGN,UAAU;IAC1B,IAAI,CAACK,IAAI,CAAC,CAAC,EAAE;IACbP,UAAU,GAAGS,UAAU,CAAC,MAAM;MAC5B,IAAID,OAAO,KAAKN,UAAU,EAAE;MAC5BF,UAAU,GAAG,IAAI;MACjBC,aAAa,GAAGS,WAAW,CAAC,MAAM;QAChC,IAAIF,OAAO,KAAKN,UAAU,EAAE;QAC5B,IAAI,CAACK,IAAI,CAAC,CAAC,EAAEJ,IAAI,CAAC,CAAC;MACrB,CAAC,EAAEJ,QAAQ,CAAC;IACd,CAAC,EAAED,KAAK,CAAC;EACX,CAAC;EAED,OAAO;IAAEQ,KAAK;IAAEH;EAAK,CAAC;AACxB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/number-input/index.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,SAAS,EAAQ,KAAK,cAAc,EAAkB,MAAM,cAAc,CAAC;AACpF,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAc1D,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,wGA+LvB,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The hold-to-repeat timer behind NumberInput's − and + buttons.
3
+ *
4
+ * A press steps once, then after `delay` keeps stepping every `interval` until
5
+ * it is stopped. Two things keep it from running away:
6
+ *
7
+ * - There is only ever one timer. `start` clears whatever is already running,
8
+ * because a press-in does not always arrive after the previous press-out —
9
+ * quick taps on Android can deliver two press-ins in a row, and a second
10
+ * timer started over the first leaves the first with no handle to clear it.
11
+ * - The step reports whether another one is possible. At a bound the button
12
+ * disables, and a disabled button is not guaranteed to deliver the release
13
+ * that would stop the timer, so the timer stops itself there instead.
14
+ *
15
+ * Kept free of React so it can be tested on its own.
16
+ */
17
+ export interface Repeater {
18
+ /** Step once now, then repeat until `stop`. Replaces any running repeat. */
19
+ start: (step: () => boolean) => void;
20
+ /** Stop repeating. Safe to call when nothing is running. */
21
+ stop: () => void;
22
+ }
23
+ export declare function createRepeater(delay: number, interval: number): Repeater;
24
+ //# sourceMappingURL=number-input-repeat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-input-repeat.d.ts","sourceRoot":"","sources":["../../../../../src/components/number-input/number-input-repeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;IACrC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CA8BxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panelui-native",
3
- "version": "0.102.0",
3
+ "version": "0.102.2",
4
4
  "description": "High-performance React Native UI components for Expo. Semantic design tokens, powered by Uniwind (Tailwind v4) and Reanimated.",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -11,7 +11,8 @@
11
11
  * short delay and then faster, the way a native stepper does — so walking from
12
12
  * 0 to 200 is a press, not two hundred of them. The repeat reads the live
13
13
  * value from a ref rather than a closure, so it never strides off a stale
14
- * number.
14
+ * number, and it stops at a bound on its own rather than waiting for a
15
+ * release a disabled button may never send.
15
16
  *
16
17
  * Typing is allowed to be briefly invalid — an empty field, a lone `-`, a
17
18
  * trailing `.` — because clamping every keystroke fights the person mid-number.
@@ -35,6 +36,7 @@ import { Text } from '../../primitives/text';
35
36
  import { selectionTick } from '../../utils/haptics';
36
37
  import { Label } from '../label';
37
38
  import { normalize, precisionOf } from './number-input-math';
39
+ import { createRepeater } from './number-input-repeat';
38
40
 
39
41
  /** Wait before a held button starts repeating — a tap must not trip it. */
40
42
  const REPEAT_DELAY = 400;
@@ -227,33 +229,42 @@ export const NumberInput = forwardRef<TextInput, NumberInputProps>(
227
229
  const clamped = normalize(next, min, max, step);
228
230
  if (tick && haptics) selectionTick();
229
231
  if (!isControlled) setUncontrolled(clamped);
230
- if (clamped !== value) onValueChange?.(clamped);
232
+ if (clamped !== valueRef.current) onValueChange?.(clamped);
233
+ // Advance the ref now, so the next repeat steps from here even if the
234
+ // render carrying this value has not landed yet.
235
+ valueRef.current = clamped;
231
236
  },
232
- [min, max, step, haptics, isControlled, value, onValueChange]
237
+ [min, max, step, haptics, isControlled, onValueChange]
233
238
  );
234
239
 
235
240
  // --- hold-to-repeat -----------------------------------------------------
236
- const delayRef = useRef<ReturnType<typeof setTimeout> | null>(null);
237
- const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
241
+ // The timer outlives the render that started it, so it calls the latest
242
+ // `commit` through a ref instead of the one it was created with.
243
+ const commitRef = useRef(commit);
244
+ commitRef.current = commit;
238
245
 
239
- const stopRepeat = useCallback(() => {
240
- if (delayRef.current) clearTimeout(delayRef.current);
241
- if (intervalRef.current) clearInterval(intervalRef.current);
242
- delayRef.current = null;
243
- intervalRef.current = null;
244
- }, []);
246
+ const repeaterRef = useRef<ReturnType<typeof createRepeater> | null>(null);
247
+ if (!repeaterRef.current) repeaterRef.current = createRepeater(REPEAT_DELAY, REPEAT_INTERVAL);
248
+ const repeater = repeaterRef.current;
245
249
 
250
+ const stopRepeat = repeater.stop;
246
251
  useEffect(() => stopRepeat, [stopRepeat]);
252
+ useEffect(() => {
253
+ if (disabled) stopRepeat();
254
+ }, [disabled, stopRepeat]);
247
255
 
248
256
  const startRepeat = useCallback(
249
257
  (direction: 1 | -1) => {
250
- const nudge = () => commit(valueRef.current + direction * step, true);
251
- nudge();
252
- delayRef.current = setTimeout(() => {
253
- intervalRef.current = setInterval(nudge, REPEAT_INTERVAL);
254
- }, REPEAT_DELAY);
258
+ repeater.start(() => {
259
+ const current = valueRef.current;
260
+ const next = normalize(current + direction * step, min, max, step);
261
+ if (next === current) return false;
262
+ commitRef.current(next, true);
263
+ // Keep going only while there is room for another step.
264
+ return direction > 0 ? next < max : next > min;
265
+ });
255
266
  },
256
- [commit, step]
267
+ [repeater, step, min, max]
257
268
  );
258
269
 
259
270
  const atMin = value <= min;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The hold-to-repeat timer behind NumberInput's − and + buttons.
3
+ *
4
+ * A press steps once, then after `delay` keeps stepping every `interval` until
5
+ * it is stopped. Two things keep it from running away:
6
+ *
7
+ * - There is only ever one timer. `start` clears whatever is already running,
8
+ * because a press-in does not always arrive after the previous press-out —
9
+ * quick taps on Android can deliver two press-ins in a row, and a second
10
+ * timer started over the first leaves the first with no handle to clear it.
11
+ * - The step reports whether another one is possible. At a bound the button
12
+ * disables, and a disabled button is not guaranteed to deliver the release
13
+ * that would stop the timer, so the timer stops itself there instead.
14
+ *
15
+ * Kept free of React so it can be tested on its own.
16
+ */
17
+
18
+ export interface Repeater {
19
+ /** Step once now, then repeat until `stop`. Replaces any running repeat. */
20
+ start: (step: () => boolean) => void;
21
+ /** Stop repeating. Safe to call when nothing is running. */
22
+ stop: () => void;
23
+ }
24
+
25
+ export function createRepeater(delay: number, interval: number): Repeater {
26
+ let delayTimer: ReturnType<typeof setTimeout> | null = null;
27
+ let intervalTimer: ReturnType<typeof setInterval> | null = null;
28
+ // Bumped by every start and stop. A callback from an earlier generation does
29
+ // nothing, so a timer that fires once more after being cleared cannot step.
30
+ let generation = 0;
31
+
32
+ const stop = () => {
33
+ generation += 1;
34
+ if (delayTimer !== null) clearTimeout(delayTimer);
35
+ if (intervalTimer !== null) clearInterval(intervalTimer);
36
+ delayTimer = null;
37
+ intervalTimer = null;
38
+ };
39
+
40
+ const start = (step: () => boolean) => {
41
+ stop();
42
+ const current = generation;
43
+ if (!step()) return;
44
+ delayTimer = setTimeout(() => {
45
+ if (current !== generation) return;
46
+ delayTimer = null;
47
+ intervalTimer = setInterval(() => {
48
+ if (current !== generation) return;
49
+ if (!step()) stop();
50
+ }, interval);
51
+ }, delay);
52
+ };
53
+
54
+ return { start, stop };
55
+ }