@sohanemon/utils 4.0.23 → 4.0.25
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.
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const setClientSideCookie: (name: string, value: string, days?: number, path?: string) => void;
|
|
2
|
+
export declare const deleteClientSideCookie: (name: string, path?: string) => void;
|
|
3
|
+
export declare const hasClientSideCookie: (name: string) => boolean;
|
|
4
|
+
export declare const getClientSideCookie: (name: string) => {
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const setClientSideCookie = (name, value, days, path = '/') => {
|
|
2
|
+
let expires = '';
|
|
3
|
+
if (days) {
|
|
4
|
+
const date = new Date();
|
|
5
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
6
|
+
expires = `; expires=${date.toUTCString()}`;
|
|
7
|
+
}
|
|
8
|
+
document.cookie = `${name}=${value || ''}${expires}; path=${path}`;
|
|
9
|
+
};
|
|
10
|
+
export const deleteClientSideCookie = (name, path = '/') => {
|
|
11
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=${path}`;
|
|
12
|
+
};
|
|
13
|
+
export const hasClientSideCookie = (name) => {
|
|
14
|
+
return document.cookie.split('; ').some((row) => row.startsWith(`${name}=`));
|
|
15
|
+
};
|
|
16
|
+
export const getClientSideCookie = (name) => {
|
|
17
|
+
const cookieValue = document.cookie
|
|
18
|
+
.split('; ')
|
|
19
|
+
.find((row) => row.startsWith(`${name}=`))
|
|
20
|
+
?.split('=')[1];
|
|
21
|
+
return { value: cookieValue };
|
|
22
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ClassValue } from 'clsx';
|
|
2
2
|
import type * as React from 'react';
|
|
3
|
+
export * from './cookie';
|
|
3
4
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
4
5
|
export declare function isNavActive(href: string, path: string): boolean;
|
|
5
6
|
export declare function cleanSrc(src: string): string;
|
|
6
7
|
export declare const scrollTo: (containerSelector: string | React.RefObject<HTMLDivElement>, to: "top" | "bottom") => void;
|
|
7
|
-
export declare const getClientSideCookie: (name: string) => string | undefined;
|
package/dist/functions/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { extendTailwindMerge } from 'tailwind-merge';
|
|
3
3
|
import { withFluid } from '@fluid-tailwind/tailwind-merge';
|
|
4
|
+
export * from './cookie';
|
|
4
5
|
export function cn(...inputs) {
|
|
5
6
|
const twMerge = extendTailwindMerge(withFluid);
|
|
6
7
|
return twMerge(clsx(inputs));
|
|
@@ -32,10 +33,3 @@ export const scrollTo = (containerSelector, to) => {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
};
|
|
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
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sohanemon/utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.25",
|
|
4
4
|
"author": "Sohan Emon <sohanemon@outlook.com>",
|
|
5
5
|
"description": "",
|
|
6
6
|
"type": "module",
|
|
@@ -15,30 +15,18 @@
|
|
|
15
15
|
},
|
|
16
16
|
"typesVersions": {
|
|
17
17
|
"*": {
|
|
18
|
-
"core": [
|
|
19
|
-
|
|
20
|
-
]
|
|
21
|
-
"hooks": [
|
|
22
|
-
"dist/hooks/index.d.ts"
|
|
23
|
-
],
|
|
24
|
-
"components": [
|
|
25
|
-
"dist/components/index.d.ts"
|
|
26
|
-
]
|
|
18
|
+
"core": ["dist/index.d.ts"],
|
|
19
|
+
"hooks": ["dist/hooks/index.d.ts"],
|
|
20
|
+
"components": ["dist/components/index.d.ts"]
|
|
27
21
|
}
|
|
28
22
|
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"README.md"
|
|
32
|
-
],
|
|
23
|
+
"files": ["dist", "README.md"],
|
|
33
24
|
"scripts": {
|
|
34
25
|
"build": "tsc",
|
|
35
26
|
"build:watch": "tsc --watch",
|
|
36
27
|
"export": "tsc && npm publish"
|
|
37
28
|
},
|
|
38
|
-
"keywords": [
|
|
39
|
-
"utils",
|
|
40
|
-
"cn"
|
|
41
|
-
],
|
|
29
|
+
"keywords": ["utils", "cn"],
|
|
42
30
|
"license": "ISC",
|
|
43
31
|
"devDependencies": {
|
|
44
32
|
"@types/node": "^22.4.0",
|