forma-ui 0.0.8 → 0.0.9

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.
Files changed (94) hide show
  1. package/dist/Interfaces/dictionary.d.ts +25 -0
  2. package/dist/Interfaces/dictionary.js +8 -0
  3. package/dist/Interfaces/global.d.ts +21 -0
  4. package/dist/Interfaces/global.js +1 -0
  5. package/dist/Interfaces/meta.d.ts +39 -0
  6. package/dist/Interfaces/meta.js +8 -0
  7. package/dist/app/[lang]/stores/LangStore.d.ts +22 -0
  8. package/dist/app/[lang]/stores/LangStore.js +125 -0
  9. package/dist/components/icon/icon.d.ts +119 -0
  10. package/dist/components/icon/icon.js +454 -0
  11. package/dist/components/ui/Accordion.d.ts +17 -0
  12. package/dist/components/ui/Accordion.js +41 -0
  13. package/dist/components/ui/Button.d.ts +12 -0
  14. package/dist/components/ui/Button.js +48 -0
  15. package/dist/components/ui/CheckBox.d.ts +7 -0
  16. package/dist/components/ui/CheckBox.js +4 -0
  17. package/dist/components/ui/Input.d.ts +11 -0
  18. package/dist/components/ui/Input.js +176 -0
  19. package/dist/components/ui/Input.types.d.ts +45 -0
  20. package/dist/components/ui/Input.types.js +1 -0
  21. package/dist/components/ui/Modal.d.ts +9 -0
  22. package/dist/components/ui/Modal.js +52 -0
  23. package/dist/components/ui/RadioButton.d.ts +9 -0
  24. package/dist/components/ui/RadioButton.js +4 -0
  25. package/dist/components/ui/Table.d.ts +10 -0
  26. package/dist/components/ui/Table.js +4 -0
  27. package/dist/components/ui/Tabs.d.ts +10 -0
  28. package/dist/components/ui/Tabs.js +9 -0
  29. package/dist/configs/language.d.ts +39 -0
  30. package/dist/configs/language.js +50 -0
  31. package/dist/configs/metadata.d.ts +69 -0
  32. package/dist/configs/metadata.js +143 -0
  33. package/dist/dictionaries/en.json +18 -0
  34. package/dist/dictionaries/fa.json +18 -0
  35. package/dist/dictionaries/index.d.ts +35 -0
  36. package/dist/dictionaries/index.js +10 -0
  37. package/dist/hooks/useDevice.d.ts +21 -0
  38. package/dist/hooks/useDevice.js +49 -0
  39. package/dist/hooks/useTranslation.d.ts +4 -0
  40. package/dist/hooks/useTranslation.js +34 -0
  41. package/dist/index.d.ts +10 -0
  42. package/dist/index.js +12 -0
  43. package/dist/libs/api/axiosClient.d.ts +9 -0
  44. package/dist/libs/api/axiosClient.js +34 -0
  45. package/dist/libs/api/cns.d.ts +16 -0
  46. package/dist/libs/api/cns.js +29 -0
  47. package/dist/libs/api/usePostFetch.d.ts +23 -0
  48. package/dist/libs/api/usePostFetch.js +17 -0
  49. package/dist/libs/cn.d.ts +1 -0
  50. package/dist/libs/cn.js +12 -0
  51. package/dist/libs/cookieUtils.d.ts +10 -0
  52. package/dist/libs/cookieUtils.js +28 -0
  53. package/dist/libs/detectComponentResponsive.d.ts +10 -0
  54. package/dist/libs/detectComponentResponsive.js +24 -0
  55. package/dist/libs/detectDeviceFromUA.d.ts +8 -0
  56. package/dist/libs/detectDeviceFromUA.js +14 -0
  57. package/dist/libs/fonts.d.ts +10 -0
  58. package/dist/libs/fonts.js +94 -0
  59. package/dist/libs/metadataHelper.d.ts +17 -0
  60. package/dist/libs/metadataHelper.js +20 -0
  61. package/dist/libs/modal/Modal.d.ts +9 -0
  62. package/dist/libs/modal/Modal.js +41 -0
  63. package/dist/libs/translation.d.ts +5 -0
  64. package/dist/libs/translation.js +30 -0
  65. package/dist/libs/utils.d.ts +2 -0
  66. package/dist/libs/utils.js +6 -0
  67. package/dist/locale/about/en.json +3 -0
  68. package/dist/locale/about/fa.json +3 -0
  69. package/dist/locale/coin/en.json +4 -0
  70. package/dist/locale/coin/fa.json +4 -0
  71. package/dist/locale/en.d.ts +56 -0
  72. package/dist/locale/en.js +16 -0
  73. package/dist/locale/fa.d.ts +59 -0
  74. package/dist/locale/fa.js +16 -0
  75. package/dist/locale/global/en.json +12 -0
  76. package/dist/locale/global/fa.json +16 -0
  77. package/dist/locale/home/en.json +11 -0
  78. package/dist/locale/home/fa.json +11 -0
  79. package/dist/locale/index.d.ts +201 -0
  80. package/dist/locale/index.js +7 -0
  81. package/dist/locale/meta/about/en.json +10 -0
  82. package/dist/locale/meta/about/fa.json +5 -0
  83. package/dist/locale/meta/en.json +15 -0
  84. package/dist/locale/meta/fa.json +15 -0
  85. package/dist/locale/meta/home/en.json +10 -0
  86. package/dist/locale/meta/home/fa.json +5 -0
  87. package/dist/middleware.d.ts +14 -0
  88. package/dist/middleware.js +57 -0
  89. package/dist/store/appStore.d.ts +8 -0
  90. package/dist/store/appStore.js +16 -0
  91. package/dist/tsconfig.build.tsbuildinfo +1 -0
  92. package/dist/utils/nextImageLoader.d.ts +9 -0
  93. package/dist/utils/nextImageLoader.js +15 -0
  94. package/package.json +1 -2
@@ -0,0 +1,69 @@
1
+ import type { Metadata } from "next";
2
+ import type { Lang } from "@/configs/language";
3
+ import { PageMeta } from "@/Interfaces/meta";
4
+ export declare function generatePageMetadata(lang?: Lang, pageKey?: string, customMeta?: Partial<PageMeta>): Promise<Metadata>;
5
+ export declare function generateWebsiteSchema(lang: Lang): {
6
+ "@context": string;
7
+ "@type": string;
8
+ name: string;
9
+ url: string;
10
+ inLanguage: string;
11
+ potentialAction: {
12
+ "@type": string;
13
+ target: string;
14
+ "query-input": string;
15
+ };
16
+ };
17
+ export declare function generateOrganizationSchema(lang: Lang): {
18
+ "@context": string;
19
+ "@type": string;
20
+ name: string;
21
+ url: string;
22
+ logo: string;
23
+ inLanguage: string;
24
+ sameAs: string[];
25
+ };
26
+ export declare function generateArticleSchema(lang: Lang, article: {
27
+ title: string;
28
+ description: string;
29
+ image: string;
30
+ datePublished: string;
31
+ dateModified: string;
32
+ authorName: string;
33
+ authorUrl?: string;
34
+ }): {
35
+ "@context": string;
36
+ "@type": string;
37
+ headline: string;
38
+ description: string;
39
+ image: string;
40
+ datePublished: string;
41
+ dateModified: string;
42
+ author: {
43
+ url?: string | undefined;
44
+ "@type": string;
45
+ name: string;
46
+ };
47
+ publisher: {
48
+ "@type": string;
49
+ name: string;
50
+ logo: {
51
+ "@type": string;
52
+ url: string;
53
+ };
54
+ };
55
+ inLanguage: string;
56
+ };
57
+ export declare function generateBreadcrumbSchema(items: {
58
+ name: string;
59
+ url: string;
60
+ }[]): {
61
+ "@context": string;
62
+ "@type": string;
63
+ itemListElement: {
64
+ "@type": string;
65
+ position: number;
66
+ name: string;
67
+ item: string;
68
+ }[];
69
+ };
@@ -0,0 +1,143 @@
1
+ /* @Author: Mohammad Felfelani
2
+ * @Email: mfelfelani72@gmail.com
3
+ * @Team:
4
+ * @Date: 2025-10-08 15:28:13
5
+ * @Description: Shared metadata generator for all pages
6
+ */
7
+ // Functions
8
+ import { getDictionary } from "@/locale";
9
+ import { getLocale, getSchemaLocale } from "@/configs/language";
10
+ // ---------- Config ----------
11
+ const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "";
12
+ const SITE_NAME = "AimoonHub";
13
+ // ---------- Helper Functions ----------
14
+ function generateCanonicalUrl(lang, path = "") {
15
+ const cleanPath = path.startsWith("/") ? path.slice(1) : path;
16
+ return `${SITE_URL}/${lang}${cleanPath ? `/${cleanPath}` : ""}`;
17
+ }
18
+ function generatePageTitle(pageTitle, baseTitle) {
19
+ return pageTitle === baseTitle ? baseTitle : `${pageTitle} | ${baseTitle}`;
20
+ }
21
+ function combineKeywords(baseKeywords = [], pageKeywords = []) {
22
+ return [...new Set([...baseKeywords, ...pageKeywords])];
23
+ }
24
+ // ---------- Main Metadata Generator ----------
25
+ export async function generatePageMetadata(lang = "en", pageKey, customMeta) {
26
+ const dict = await getDictionary(lang);
27
+ const baseMeta = dict.meta;
28
+ const pageMetaCandidate = pageKey
29
+ ? dict[`meta_${pageKey}`]
30
+ : null;
31
+ const pageMeta = pageMetaCandidate || baseMeta;
32
+ const finalMeta = customMeta
33
+ ? Object.assign(Object.assign({}, pageMeta), customMeta) : pageMeta;
34
+ const pageTitle = generatePageTitle(finalMeta.title, baseMeta.title);
35
+ const canonicalUrl = finalMeta.canonicalUrl || generateCanonicalUrl(lang, pageKey);
36
+ return {
37
+ title: pageTitle,
38
+ description: finalMeta.description,
39
+ keywords: combineKeywords(baseMeta.keywords, finalMeta.keywords).join(", "),
40
+ openGraph: {
41
+ title: pageTitle,
42
+ description: finalMeta.description,
43
+ url: canonicalUrl,
44
+ siteName: baseMeta.title,
45
+ type: "website",
46
+ images: [
47
+ {
48
+ url: `/images/og/og-${lang}${pageKey ? `-${pageKey}` : ""}.jpg`,
49
+ width: 1200,
50
+ height: 630,
51
+ alt: pageTitle,
52
+ },
53
+ ],
54
+ locale: getLocale(lang),
55
+ },
56
+ twitter: {
57
+ card: "summary_large_image",
58
+ title: pageTitle,
59
+ description: finalMeta.description,
60
+ images: [
61
+ `/images/twitter/twitter-${lang}${pageKey ? `-${pageKey}` : ""}.jpg`,
62
+ ],
63
+ },
64
+ robots: finalMeta.robots || { index: true, follow: true },
65
+ alternates: {
66
+ canonical: canonicalUrl,
67
+ languages: {
68
+ en: generateCanonicalUrl("en", pageKey),
69
+ fa: generateCanonicalUrl("fa", pageKey),
70
+ },
71
+ },
72
+ icons: {
73
+ icon: process.env.NODE_ENV == "production"
74
+ ? process.env.NEXT_PUBLIC_BASE_PATH + "/favicon.ico"
75
+ : "/favicon.ico",
76
+ apple: process.env.NODE_ENV == "production"
77
+ ? process.env.NEXT_PUBLIC_BASE_PATH + "/apple-touch-icon.png"
78
+ : "/apple-touch-icon.png",
79
+ },
80
+ };
81
+ }
82
+ // ---------- Schema Generators ----------
83
+ export function generateWebsiteSchema(lang) {
84
+ return {
85
+ "@context": "https://schema.org",
86
+ "@type": "WebSite",
87
+ name: SITE_NAME,
88
+ url: SITE_URL,
89
+ inLanguage: getSchemaLocale(lang),
90
+ potentialAction: {
91
+ "@type": "SearchAction",
92
+ target: `${SITE_URL}/search?q={search_term_string}`,
93
+ "query-input": "required name=search_term_string",
94
+ },
95
+ };
96
+ }
97
+ export function generateOrganizationSchema(lang) {
98
+ return {
99
+ "@context": "https://schema.org",
100
+ "@type": "Organization",
101
+ name: SITE_NAME,
102
+ url: SITE_URL,
103
+ logo: `${SITE_URL}/images/logo/logo.png`,
104
+ inLanguage: getSchemaLocale(lang),
105
+ sameAs: [
106
+ "https://twitter.com/aimoonhub",
107
+ "https://linkedin.com/company/aimoonhub",
108
+ ],
109
+ };
110
+ }
111
+ export function generateArticleSchema(lang, article) {
112
+ return {
113
+ "@context": "https://schema.org",
114
+ "@type": "Article",
115
+ headline: article.title,
116
+ description: article.description,
117
+ image: article.image,
118
+ datePublished: article.datePublished,
119
+ dateModified: article.dateModified,
120
+ author: Object.assign({ "@type": "Person", name: article.authorName }, (article.authorUrl && { url: article.authorUrl })),
121
+ publisher: {
122
+ "@type": "Organization",
123
+ name: SITE_NAME,
124
+ logo: {
125
+ "@type": "ImageObject",
126
+ url: `${SITE_URL}/images/logo/logo.png`,
127
+ },
128
+ },
129
+ inLanguage: getSchemaLocale(lang),
130
+ };
131
+ }
132
+ export function generateBreadcrumbSchema(items) {
133
+ return {
134
+ "@context": "https://schema.org",
135
+ "@type": "BreadcrumbList",
136
+ itemListElement: items.map((item, index) => ({
137
+ "@type": "ListItem",
138
+ position: index + 1,
139
+ name: item.name,
140
+ item: `${SITE_URL}${item.url}`,
141
+ })),
142
+ };
143
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "home": {
3
+ "title": "Welcome to Blog",
4
+ "description": "This is the English home page."
5
+ },
6
+ "about": {
7
+ "title": "About Us",
8
+ "content": "This is about page in English."
9
+ },
10
+ "posts": {
11
+ "title": "Blog Posts",
12
+ "description": "Here are all the posts."
13
+ },
14
+ "postDetail": {
15
+ "title": "Post Detail",
16
+ "content": "This is the detail of post {id}."
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "home": {
3
+ "title": "به وبلاگ خوش آمدید",
4
+ "description": "این صفحه اصلی فارسی است."
5
+ },
6
+ "about": {
7
+ "title": "درباره ما",
8
+ "content": "این صفحه درباره ما به فارسی است."
9
+ },
10
+ "posts": {
11
+ "title": "پست‌های وبلاگ",
12
+ "description": "اینجا همه پست‌ها را می‌بینید."
13
+ },
14
+ "postDetail": {
15
+ "title": "جزئیات پست",
16
+ "content": "این جزئیات پست {id} است."
17
+ }
18
+ }
@@ -0,0 +1,35 @@
1
+ export declare function getDictionary(lang: "en" | "fa"): Promise<{
2
+ home: {
3
+ title: string;
4
+ description: string;
5
+ };
6
+ about: {
7
+ title: string;
8
+ content: string;
9
+ };
10
+ posts: {
11
+ title: string;
12
+ description: string;
13
+ };
14
+ postDetail: {
15
+ title: string;
16
+ content: string;
17
+ };
18
+ } | {
19
+ home: {
20
+ title: string;
21
+ description: string;
22
+ };
23
+ about: {
24
+ title: string;
25
+ content: string;
26
+ };
27
+ posts: {
28
+ title: string;
29
+ description: string;
30
+ };
31
+ postDetail: {
32
+ title: string;
33
+ content: string;
34
+ };
35
+ }>;
@@ -0,0 +1,10 @@
1
+ import en from "./en.json";
2
+ import fa from "./fa.json";
3
+ const dictionaries = {
4
+ en,
5
+ fa,
6
+ };
7
+ export async function getDictionary(lang) {
8
+ var _a;
9
+ return (_a = dictionaries[lang]) !== null && _a !== void 0 ? _a : dictionaries["fa"];
10
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-07 06:31:56
6
+ * @Description:
7
+ */
8
+ type DeviceType = "mobile" | "ipad" | "desktop";
9
+ type Orientation = "landscape" | "portrait";
10
+ interface DeviceInfo {
11
+ type: DeviceType;
12
+ orientation: Orientation;
13
+ screenWidth: number;
14
+ screenHeight: number;
15
+ isTouchDevice: boolean;
16
+ isMobile: boolean;
17
+ isIpad: boolean;
18
+ isDesktop: boolean;
19
+ }
20
+ declare const useDevice: () => DeviceInfo;
21
+ export default useDevice;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-07 06:31:56
6
+ * @Description:
7
+ */
8
+ import { useState, useEffect, useMemo } from "react";
9
+ const useDevice = () => {
10
+ // States
11
+ const [screenWidth, setScreenWidth] = useState(window.innerWidth);
12
+ const [screenHeight, setScreenHeight] = useState(window.innerHeight);
13
+ const [isTouchDevice, setIsTouchDevice] = useState(false);
14
+ // Functions
15
+ useEffect(() => {
16
+ setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
17
+ const handleResize = () => {
18
+ setScreenWidth(window.innerWidth);
19
+ setScreenHeight(window.innerHeight);
20
+ };
21
+ window.addEventListener("resize", handleResize);
22
+ return () => window.removeEventListener("resize", handleResize);
23
+ }, []);
24
+ const deviceInfo = useMemo(() => {
25
+ const orientation = screenWidth > screenHeight ? "landscape" : "portrait";
26
+ let type;
27
+ if (screenWidth < 540) {
28
+ type = "mobile";
29
+ }
30
+ else if (screenWidth >= 540 && screenWidth < 992) {
31
+ type = "ipad";
32
+ }
33
+ else {
34
+ type = "desktop";
35
+ }
36
+ return {
37
+ type,
38
+ orientation,
39
+ screenWidth,
40
+ screenHeight,
41
+ isTouchDevice,
42
+ isMobile: type === "mobile",
43
+ isIpad: type === "ipad",
44
+ isDesktop: type === "desktop",
45
+ };
46
+ }, [screenWidth, screenHeight, isTouchDevice]);
47
+ return deviceInfo;
48
+ };
49
+ export default useDevice;
@@ -0,0 +1,4 @@
1
+ export declare function useTranslation(): {
2
+ t: (key: string, fallback?: string) => string;
3
+ lang: "en" | "fa";
4
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-04 14:27:32
6
+ * @Description:
7
+ */
8
+ "use client";
9
+ // Functions
10
+ import { getDictionary } from "@/locale";
11
+ // Zustand
12
+ import { useLangStore } from "@/LangStore";
13
+ export function useTranslation() {
14
+ const { lang } = useLangStore();
15
+ const translations = getDictionary(lang);
16
+ function t(key, fallback) {
17
+ if (!translations) {
18
+ console.warn("Translations not loaded for language:", lang);
19
+ return fallback !== null && fallback !== void 0 ? fallback : key;
20
+ }
21
+ const keys = key.split(".");
22
+ let value = translations;
23
+ for (const k of keys) {
24
+ if (value && typeof value === "object" && k in value) {
25
+ value = value[k];
26
+ }
27
+ else {
28
+ return fallback !== null && fallback !== void 0 ? fallback : key;
29
+ }
30
+ }
31
+ return typeof value === "string" ? value : fallback !== null && fallback !== void 0 ? fallback : key;
32
+ }
33
+ return { t, lang };
34
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-26 15:32:12
6
+ * @Description:
7
+ */
8
+ export * from "./components/icon/icon";
9
+ export { default as Button } from "./components/ui/Button";
10
+ export { default as Modal } from "./components/ui/Modal";
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-26 15:32:12
6
+ * @Description:
7
+ */
8
+ // Icons
9
+ export * from "./components/icon/icon";
10
+ // Components
11
+ export { default as Button } from "./components/ui/Button";
12
+ export { default as Modal } from "./components/ui/Modal";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:17:37
6
+ * @Description:
7
+ */
8
+ declare const axiosClient: import("axios").AxiosInstance;
9
+ export default axiosClient;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:17:37
6
+ * @Description:
7
+ */
8
+ import axios from "axios";
9
+ // Constants
10
+ const isSSR = typeof window === "undefined";
11
+ const isProduction = process.env.NODE_ENV == "production";
12
+ const baseUrlSSR = process.env.NEXT_PUBLIC_API_URL + "/";
13
+ const baseUrlCSR = isProduction && !isSSR
14
+ ? process.env.NEXT_PUBLIC_BASE_URL +
15
+ "" +
16
+ process.env.NEXT_PUBLIC_BASE_PORT +
17
+ "" +
18
+ process.env.NEXT_PUBLIC_BASE_PATH
19
+ : process.env.NEXT_PUBLIC_BASE_URL + "" + process.env.NEXT_PUBLIC_BASE_PORT;
20
+ const baseURL = isSSR ? baseUrlSSR : baseUrlCSR;
21
+ const axiosClient = axios.create({
22
+ baseURL: baseURL,
23
+ headers: isSSR
24
+ ? {
25
+ "Accept-Version": 1,
26
+ Accept: "application/json",
27
+ "Content-Type": "application/json; charset=utf-8",
28
+ Authorization: process.env.NEXT_PUBLIC_AUTHORIZATION,
29
+ }
30
+ : {},
31
+ withCredentials: isSSR && isProduction,
32
+ withXSRFToken: isSSR && isProduction,
33
+ });
34
+ export default axiosClient;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:23:34
6
+ * @Description:
7
+ */
8
+ interface ConnectParams<T = any> {
9
+ method?: "get" | "post";
10
+ endPoint: string;
11
+ body?: T;
12
+ headers?: Record<string, string>;
13
+ route?: string;
14
+ }
15
+ export declare const cns: <T = any>({ method, endPoint, body, headers, route, }: ConnectParams<T>) => Promise<false | T>;
16
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:23:34
6
+ * @Description:
7
+ */
8
+ import axiosClient from "./axiosClient";
9
+ export const cns = async ({ method = "post", endPoint, body, headers, route, }) => {
10
+ try {
11
+ const config = { headers };
12
+ if (method === "post") {
13
+ const res = await axiosClient.post(endPoint, body, config);
14
+ return res.data;
15
+ }
16
+ else if (method === "get") {
17
+ const res = await axiosClient.get(endPoint, config);
18
+ return res.data;
19
+ }
20
+ throw new Error("Unsupported method: " + method);
21
+ }
22
+ catch (error) {
23
+ console.error({
24
+ message: `Connection to server failed, route: ${route || endPoint}`,
25
+ error,
26
+ });
27
+ return false;
28
+ }
29
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:23:34
6
+ * @Description:
7
+ */
8
+ import { SWRConfiguration } from "swr";
9
+ interface PostFetchParams<T = any> {
10
+ endPoint: string;
11
+ body?: T;
12
+ route?: string;
13
+ }
14
+ interface UsePostFetchConfig extends SWRConfiguration {
15
+ manual?: boolean;
16
+ }
17
+ export declare const usePostFetch: <T = any>(params: PostFetchParams, swrConfig?: UsePostFetchConfig) => {
18
+ data: T | undefined;
19
+ error: any;
20
+ isLoading: boolean;
21
+ mutate: import("swr").KeyedMutator<T>;
22
+ };
23
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 09:23:34
6
+ * @Description:
7
+ */
8
+ "use client";
9
+ import useSWR from "swr";
10
+ // Functions
11
+ import { cns } from "./cns";
12
+ export const usePostFetch = (params, swrConfig) => {
13
+ const key = [params.endPoint, JSON.stringify(params.body)];
14
+ const fetcher = () => cns(Object.assign({ method: "post" }, params));
15
+ const { data, error, isLoading, mutate } = useSWR(key, fetcher, Object.assign(Object.assign({}, swrConfig), { isPaused: () => (swrConfig === null || swrConfig === void 0 ? void 0 : swrConfig.manual) === true }));
16
+ return { data, error, isLoading, mutate };
17
+ };
@@ -0,0 +1 @@
1
+ export declare function cn(...inputs: any): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-14 12:28:28
6
+ * @Description:
7
+ */
8
+ import { clsx } from "clsx";
9
+ import { twMerge } from "tailwind-merge";
10
+ export function cn(...inputs) {
11
+ return twMerge(clsx(inputs));
12
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-06 15:14:10
6
+ * @Description:
7
+ */
8
+ export declare const isBrowser: () => boolean;
9
+ export declare const setCookie: (name: string, value: string) => void;
10
+ export declare const getCookie: (name: string) => string | null;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-06 15:14:10
6
+ * @Description:
7
+ */
8
+ export const isBrowser = () => {
9
+ return typeof window !== "undefined" && typeof document !== "undefined";
10
+ };
11
+ export const setCookie = (name, value) => {
12
+ if (!isBrowser())
13
+ return;
14
+ const expires = new Date();
15
+ expires.setFullYear(expires.getFullYear() + 1);
16
+ document.cookie = `${name}=${value}; expires=${expires.toUTCString()}; path=/; sameSite=lax`;
17
+ };
18
+ export const getCookie = (name) => {
19
+ var _a;
20
+ if (!isBrowser())
21
+ return null;
22
+ const value = `; ${document.cookie}`;
23
+ const parts = value.split(`; ${name}=`);
24
+ if (parts.length === 2) {
25
+ return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(";").shift()) || null;
26
+ }
27
+ return null;
28
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-18 14:06:46
6
+ * @Description:
7
+ */
8
+ import { type ComponentType } from "react";
9
+ declare const detectComponentsResponsive: (MobileComponent: ComponentType<any>, IpadComponent: ComponentType<any>, DesktopComponent: ComponentType<any>) => Promise<ComponentType<any> | string>;
10
+ export default detectComponentsResponsive;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-18 14:06:46
6
+ * @Description:
7
+ */
8
+ import { cookies } from "next/headers";
9
+ const detectComponentsResponsive = async (MobileComponent, IpadComponent, DesktopComponent) => {
10
+ var _a;
11
+ const cookieStore = await cookies();
12
+ const deviceType = (_a = cookieStore.get("device-type")) === null || _a === void 0 ? void 0 : _a.value;
13
+ switch (deviceType) {
14
+ case "mobile":
15
+ return MobileComponent;
16
+ case "ipad":
17
+ return IpadComponent;
18
+ case "desktop":
19
+ return DesktopComponent;
20
+ default:
21
+ return "Unknown";
22
+ }
23
+ };
24
+ export default detectComponentsResponsive;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @Author: Mohammad Felfelani
3
+ * @Email: mfelfelani72@gmail.com
4
+ * @Team:
5
+ * @Date: 2025-10-18 14:06:46
6
+ * @Description:
7
+ */
8
+ export declare const detectDeviceFromUA: (userAgent: string) => "ipad" | "mobile" | "desktop";