@sohanemon/utils 4.0.20 → 4.0.22

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.
@@ -4,3 +4,4 @@ export declare function cn(...inputs: ClassValue[]): string;
4
4
  export declare function isNavActive(href: string, path: string): boolean;
5
5
  export declare function cleanSrc(src: string): string;
6
6
  export declare const scrollTo: (containerSelector: string | React.RefObject<HTMLDivElement>, to: "top" | "bottom") => void;
7
+ export declare const getClientSideCookie: (name: string) => string | undefined;
@@ -1,6 +1,8 @@
1
1
  import { clsx } from 'clsx';
2
- import { twMerge } from 'tailwind-merge';
2
+ import { extendTailwindMerge } from 'tailwind-merge';
3
+ import { withFluid } from '@fluid-tailwind/tailwind-merge';
3
4
  export function cn(...inputs) {
5
+ const twMerge = extendTailwindMerge(withFluid);
4
6
  return twMerge(clsx(inputs));
5
7
  }
6
8
  export function isNavActive(href, path) {
@@ -30,3 +32,10 @@ export const scrollTo = (containerSelector, to) => {
30
32
  });
31
33
  }
32
34
  };
35
+ export const getClientSideCookie = (name) => {
36
+ const cookieValue = document.cookie
37
+ .split('; ')
38
+ .find((row) => row.startsWith(`${name}=`))
39
+ ?.split('=')[1];
40
+ return cookieValue;
41
+ };
@@ -28,4 +28,5 @@ export declare const useAsync: <T extends (...args: any) => any>(fn: T, opts?: U
28
28
  };
29
29
  export declare const useQuerySelector: <T extends Element>(selector: string) => T | null;
30
30
  export declare function useIsClient(): boolean;
31
+ export declare function useLockScroll(): void;
31
32
  export {};
@@ -221,3 +221,12 @@ export function useIsClient() {
221
221
  }, []);
222
222
  return isClient;
223
223
  }
224
+ export function useLockScroll() {
225
+ useLayoutEffect(() => {
226
+ const originalStyle = window.getComputedStyle(document.body).overflow;
227
+ document.body.style.overflow = 'hidden';
228
+ return () => {
229
+ document.body.style.overflow = originalStyle;
230
+ };
231
+ }, []);
232
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sohanemon/utils",
3
- "version": "4.0.20",
3
+ "version": "4.0.22",
4
4
  "author": "Sohan Emon <sohanemon@outlook.com>",
5
5
  "description": "",
6
6
  "type": "module",
@@ -46,6 +46,7 @@
46
46
  "typescript": "^5.5.4"
47
47
  },
48
48
  "dependencies": {
49
+ "@fluid-tailwind/tailwind-merge": "^0.0.2",
49
50
  "@iconify/react": "^4.1.1",
50
51
  "clsx": "^2.1.1",
51
52
  "react": "^18.3.1",