@versini/ui-hooks 6.0.0 → 6.1.0

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.
@@ -1,25 +1,14 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useEffect, useRef } from "react";
19
7
 
20
8
  ;// CONCATENATED MODULE: external "react"
21
9
 
22
10
  ;// CONCATENATED MODULE: ./src/hooks/useClickOutside/useClickOutside.tsx
11
+ // force new release
23
12
 
24
13
  const DEFAULT_EVENTS = [
25
14
  "mousedown",
@@ -44,10 +33,10 @@ const DEFAULT_EVENTS = [
44
33
  const ref = useRef(null);
45
34
  useEffect(()=>{
46
35
  const listener = (event)=>{
47
- /* v8 ignore next 1 */ const target = event ? event.target : undefined;
36
+ /* v8 ignore start */ const target = event ? event.target : undefined;
48
37
  if (Array.isArray(nodes)) {
49
- /* v8 ignore next 2 */ const shouldIgnore = !document.body.contains(target) && target.tagName !== "HTML";
50
- const shouldTrigger = nodes.every((node)=>!!node && !event.composedPath().includes(node));
38
+ const shouldIgnore = !document.body.contains(target) && target.tagName !== "HTML";
39
+ /* v8 ignore stop */ const shouldTrigger = nodes.every((node)=>!!node && !event.composedPath().includes(node));
51
40
  shouldTrigger && !shouldIgnore && handler();
52
41
  } else if (ref.current && !ref.current.contains(target)) {
53
42
  handler();
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useRef } from "react";
19
7
 
@@ -34,10 +22,10 @@ let refCount = 0;
34
22
  * idempotent - calling it multiple times is safe. Checks DOM directly to handle
35
23
  * React Strict Mode double-mounting.
36
24
  */ const ensureHapticElement = ()=>{
37
- /* c8 ignore next 3 */ if (typeof window === "undefined") {
25
+ /* v8 ignore start - SSR check */ if (typeof window === "undefined") {
38
26
  return;
39
27
  }
40
- // First check: do we have valid references that exist in the DOM?
28
+ /* v8 ignore stop */ // First check: do we have valid references that exist in the DOM?
41
29
  if (sharedLabelElement && document.body.contains(sharedLabelElement)) {
42
30
  return;
43
31
  }
@@ -70,10 +58,10 @@ let refCount = 0;
70
58
  * Removes the shared haptic element from the DOM and clears references. Only
71
59
  * called when the last component using the hook unmounts.
72
60
  */ const cleanupHapticElement = ()=>{
73
- if (sharedLabelElement && document.body && document.body.contains(sharedLabelElement)) {
61
+ /* v8 ignore start - cleanup edge case */ if (sharedLabelElement && document.body && document.body.contains(sharedLabelElement)) {
74
62
  document.body.removeChild(sharedLabelElement);
75
63
  }
76
- sharedLabelElement = null;
64
+ /* v8 ignore stop */ sharedLabelElement = null;
77
65
  };
78
66
  /**
79
67
  * Custom hook providing imperative haptic feedback for mobile devices. Uses
@@ -102,7 +90,7 @@ let refCount = 0;
102
90
  refCount++;
103
91
  try {
104
92
  ensureHapticElement();
105
- } catch (error) {
93
+ /* v8 ignore start - error handling for element creation failure */ } catch (error) {
106
94
  /**
107
95
  * If element creation fails, we need to decrement refCount immediately since
108
96
  * the cleanup function won't be registered. This prevents refCount from
@@ -110,7 +98,7 @@ let refCount = 0;
110
98
  */ refCount--;
111
99
  throw error;
112
100
  }
113
- return ()=>{
101
+ /* v8 ignore stop */ return ()=>{
114
102
  /**
115
103
  * Cleanup function: clear all pending timeouts to prevent haptics from
116
104
  * firing after unmount, and decrement the reference count. Only remove the
@@ -161,10 +149,10 @@ let refCount = 0;
161
149
  * ```
162
150
  *
163
151
  */ const haptic = useCallback((count = 1)=>{
164
- /* c8 ignore next 3 */ if (typeof window === "undefined") {
152
+ /* v8 ignore start - SSR check */ if (typeof window === "undefined") {
165
153
  return;
166
154
  }
167
- if (count < 1) {
155
+ /* v8 ignore stop */ if (count < 1) {
168
156
  return;
169
157
  }
170
158
  if (navigator?.vibrate && count > 1) {
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useEffect } from "react";
19
7
  import { getHotkeyHandler, getHotkeyMatcher } from "./utilities.js";
@@ -46,10 +34,10 @@ function useHotkeys(hotkeys, tagsToIgnore = [
46
34
  preventDefault: true
47
35
  }])=>{
48
36
  if (getHotkeyMatcher(hotkey)(event) && shouldFireEvent(event, tagsToIgnore, triggerOnContentEditable)) {
49
- if (options.preventDefault) {
37
+ /* v8 ignore start - preventDefault edge case */ if (options.preventDefault) {
50
38
  event.preventDefault();
51
39
  }
52
- handler(event);
40
+ /* v8 ignore stop */ handler(event);
53
41
  }
54
42
  });
55
43
  };
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
 
19
7
  ;// CONCATENATED MODULE: ./src/hooks/useHotkeys/utilities.ts
@@ -71,7 +59,7 @@ function getHotkeyMatcher(hotkey) {
71
59
  function getHotkeyHandler(hotkeys) {
72
60
  return (event)=>{
73
61
  const _event = "nativeEvent" in event ? event.nativeEvent : event;
74
- hotkeys.forEach(([hotkey, handler, options = {
62
+ /* v8 ignore start - hotkey handler matching */ hotkeys.forEach(([hotkey, handler, options = {
75
63
  preventDefault: true
76
64
  }])=>{
77
65
  if (getHotkeyMatcher(hotkey)(_event)) {
@@ -81,7 +69,7 @@ function getHotkeyHandler(hotkeys) {
81
69
  handler(_event);
82
70
  }
83
71
  });
84
- };
72
+ /* v8 ignore stop */ };
85
73
  }
86
74
 
87
75
  export { getHotkeyHandler, getHotkeyMatcher, parseHotkey };
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useRef, useState } from "react";
19
7
 
@@ -26,7 +14,7 @@ import { useCallback, useRef, useState } from "react";
26
14
  * @returns
27
15
  * ref: React ref object to attach to the element you want to monitor.
28
16
  * inViewport: Boolean indicating if the element is in the viewport.
29
- */ /* v8 ignore next 24 */ function useInViewport() {
17
+ */ /* v8 ignore start */ function useInViewport() {
30
18
  const observer = useRef(null);
31
19
  const [inViewport, setInViewport] = useState(false);
32
20
  const ref = useCallback((node)=>{
@@ -47,6 +35,6 @@ import { useCallback, useRef, useState } from "react";
47
35
  ref,
48
36
  inViewport
49
37
  };
50
- }
38
+ } /* v8 ignore stop */
51
39
 
52
40
  export { useInViewport };
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useRef, useState } from "react";
19
7
 
@@ -42,10 +30,10 @@ import { useCallback, useEffect, useRef, useState } from "react";
42
30
  const fnRef = useRef(null);
43
31
  const start = useCallback(()=>{
44
32
  setActive((old)=>{
45
- if (!old && (!intervalRef.current || intervalRef.current === -1)) {
33
+ /* v8 ignore start - interval reactivation edge case */ if (!old && (!intervalRef.current || intervalRef.current === -1)) {
46
34
  intervalRef.current = window.setInterval(fnRef.current, interval);
47
35
  }
48
- return true;
36
+ /* v8 ignore stop */ return true;
49
37
  });
50
38
  }, [
51
39
  interval
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useRef } from "react";
19
7
 
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useSyncExternalStore } from "react";
19
7
 
@@ -177,11 +165,11 @@ import { useCallback, useEffect, useSyncExternalStore } from "react";
177
165
  } else {
178
166
  setLocalStorageItem(key, nextState);
179
167
  }
180
- /* v8 ignore next 4 */ } catch (e) {
168
+ /* v8 ignore start */ } catch (e) {
181
169
  // Log parsing or storage errors without breaking the application.
182
170
  console.warn(e);
183
171
  }
184
- }, [
172
+ /* v8 ignore stop */ }, [
185
173
  key,
186
174
  store
187
175
  ]);
@@ -214,11 +202,11 @@ import { useCallback, useEffect, useSyncExternalStore } from "react";
214
202
  if (getLocalStorageItem(key) === null && typeof initialValue !== "undefined") {
215
203
  setLocalStorageItem(key, initialValue);
216
204
  }
217
- /* v8 ignore next 4 */ } catch (e) {
205
+ /* v8 ignore start */ } catch (e) {
218
206
  // Log initialization errors without breaking the application.
219
207
  console.warn(e);
220
208
  }
221
- }, [
209
+ /* v8 ignore stop */ }, [
222
210
  key,
223
211
  initialValue
224
212
  ]);
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useMemo } from "react";
19
7
 
@@ -42,10 +30,10 @@ import { useMemo } from "react";
42
30
  function useMergeRefs(refs) {
43
31
  // biome-ignore lint/correctness/useExhaustiveDependencies: refs array is used as dependency but spread for proper comparison
44
32
  return useMemo(()=>{
45
- if (refs.every((ref)=>ref == null)) {
33
+ /* v8 ignore start - all refs null edge case */ if (refs.every((ref)=>ref == null)) {
46
34
  return ()=>{};
47
35
  }
48
- return (value)=>{
36
+ /* v8 ignore stop */ /* v8 ignore start - ref assignment handling */ return (value)=>{
49
37
  refs.forEach((ref)=>{
50
38
  if (typeof ref === "function") {
51
39
  ref(value);
@@ -54,7 +42,7 @@ function useMergeRefs(refs) {
54
42
  }
55
43
  });
56
44
  };
57
- }, [
45
+ /* v8 ignore stop */ }, [
58
46
  ...refs
59
47
  ]);
60
48
  }
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useEffect, useMemo, useRef, useState } from "react";
19
7
  import { useIsMounted } from "../useIsMounted/useIsMounted.js";
@@ -54,11 +42,11 @@ const defaultState = {
54
42
  const ref = useRef(null);
55
43
  const [rect, setRect] = useState(defaultState);
56
44
  const observer = useMemo(()=>{
57
- /* c8 ignore next 3 */ if (typeof ResizeObserver === "undefined") {
45
+ /* v8 ignore start - SSR check for ResizeObserver */ if (typeof ResizeObserver === "undefined") {
58
46
  return null;
59
47
  }
60
- return new ResizeObserver((entries)=>{
61
- const entry = entries[0];
48
+ /* v8 ignore stop */ return new ResizeObserver((entries)=>{
49
+ /* v8 ignore start - resize entry handling */ const entry = entries[0];
62
50
  if (entry) {
63
51
  cancelAnimationFrame(frameID.current);
64
52
  frameID.current = requestAnimationFrame(()=>{
@@ -67,20 +55,20 @@ const defaultState = {
67
55
  }
68
56
  });
69
57
  }
70
- });
58
+ /* v8 ignore stop */ });
71
59
  }, [
72
60
  isMounted
73
61
  ]);
74
62
  useEffect(()=>{
75
- /* c8 ignore next 3 */ if (ref.current) {
63
+ /* v8 ignore start - ref.current check */ if (ref.current) {
76
64
  observer?.observe(ref.current, options);
77
65
  }
78
- return ()=>{
66
+ /* v8 ignore stop */ return ()=>{
79
67
  observer?.disconnect();
80
- /* c8 ignore next 3 */ if (frameID.current) {
68
+ /* v8 ignore start - frameID cleanup */ if (frameID.current) {
81
69
  cancelAnimationFrame(frameID.current);
82
70
  }
83
- };
71
+ /* v8 ignore stop */ };
84
72
  }, [
85
73
  observer,
86
74
  options
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useEffect, useState } from "react";
19
7
 
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useId } from "react";
19
7
 
@@ -29,13 +17,13 @@ function useUniqueId(options) {
29
17
  if (typeof options === "number" || typeof options === "string") {
30
18
  return `${options}${generatedId}`;
31
19
  }
32
- if (typeof options === "object") {
20
+ /* v8 ignore start - object options edge case */ if (typeof options === "object") {
33
21
  const { id, prefix = "" } = options;
34
22
  if (typeof id === "number" || typeof id === "string") {
35
23
  return `${prefix}${id}`;
36
24
  }
37
25
  return `${prefix}${generatedId}`;
38
26
  }
39
- }
27
+ /* v8 ignore stop */ }
40
28
 
41
29
  export { useUniqueId };
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useState } from "react";
19
7
 
@@ -1,19 +1,7 @@
1
1
  /*!
2
- @versini/ui-hooks v6.0.0
2
+ @versini/ui-hooks v6.1.0
3
3
  © 2025 gizmette.com
4
4
  */
5
- try {
6
- if (!window.__VERSINI_UI_HOOKS__) {
7
- window.__VERSINI_UI_HOOKS__ = {
8
- version: "6.0.0",
9
- buildTime: "12/16/2025 06:21 PM EST",
10
- homepage: "https://www.npmjs.com/package/@versini/ui-hooks",
11
- license: "MIT",
12
- };
13
- }
14
- } catch (error) {
15
- // nothing to declare officer
16
- }
17
5
 
18
6
  import { useCallback, useEffect, useState } from "react";
19
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-hooks",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -88,5 +88,5 @@
88
88
  "test:watch": "vitest",
89
89
  "test": "vitest run"
90
90
  },
91
- "gitHead": "30d86d13d4369cc841fc267c970cca423d27bf2f"
91
+ "gitHead": "b2ee2e328ecadfbedcb26d14afa896a30f0ab54b"
92
92
  }