oihana-next-ui 0.1.41 → 0.1.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oihana-next-ui",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "private": false,
5
5
  "description": "Oihana Next.js UI component library — reusable components, hooks and utilities built with React 19, Next.js, Tailwind CSS and DaisyUI",
6
6
  "author": {
@@ -1,28 +1,21 @@
1
- import { useEffect } from 'react' ;
2
-
1
+ import { useEffect } from 'react' ;
3
2
  import { usePathname } from 'next/navigation' ;
4
3
 
5
4
  /**
6
- * React hook that resets scroll position when the route changes.
7
- *
8
- * @param {React.RefObject<HTMLElement>} [ref] - Optional element reference. Defaults to window.
9
- * @param {boolean} [disabled=false] - Whether to disable the scroll reset.
10
- * @param {ScrollBehavior} [behavior='instant'] - Scroll behavior: 'instant' or 'smooth'.
11
- *
12
- * @example
13
- * ```js
14
- * // Reset window scroll on route change
15
- * useResetScroll() ;
16
- *
17
- * // Reset a specific container
18
- * const containerRef = useRef( null ) ;
19
- * useResetScroll( containerRef ) ;
5
+ * Resets scroll position when the route (pathname) changes.
20
6
  *
21
- * // With smooth scroll
22
- * useResetScroll( null , false , 'smooth' ) ;
23
- * ```
7
+ * @param {React.RefObject} [ref] - Optional scroll container ref.
8
+ * @param {boolean} [disabled=false]
9
+ * @param {string} [scrollClassName='drawer-content'] - CSS class of the fallback scroll container.
10
+ * @param {ScrollBehavior} [behavior='smooth'] - Scroll behavior.
24
11
  */
25
- const useResetScroll = ( ref , disabled = false , behavior = 'instant' ) =>
12
+ const useResetScroll =
13
+ (
14
+ ref ,
15
+ disabled = false ,
16
+ scrollClassName = 'drawer-content' ,
17
+ behavior = 'smooth'
18
+ ) =>
26
19
  {
27
20
  const pathname = usePathname() ;
28
21
 
@@ -33,11 +26,13 @@ const useResetScroll = ( ref , disabled = false , behavior = 'instant' ) =>
33
26
  return ;
34
27
  }
35
28
 
36
- const element = ref?.current ?? window ;
29
+ const element = ref?.current
30
+ ?? document.querySelector( `.${ scrollClassName }` )
31
+ ?? window ;
37
32
 
38
- element.scrollTo( { top: 0 , left: 0 , behavior } ) ;
33
+ element.scrollTo( { top : 0 , behavior } ) ;
39
34
  }
40
- , [ pathname , disabled , behavior ] ) ;
35
+ , [ behavior , disabled , pathname , ref , scrollClassName ] ) ;
41
36
  } ;
42
37
 
43
38
  export default useResetScroll ;
package/src/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const version = "0.1.41" ;
1
+ const version = "0.1.43" ;
2
2
 
3
3
  export default version ;