next-auth-mfelfelani72 0.0.24 → 0.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.
- package/dist/components/base/Image.js +1 -1
- package/dist/components/base/LanguageSwitcher.d.ts +0 -0
- package/dist/components/base/LanguageSwitcher.js +0 -0
- package/dist/components/demo/auth/Login.d.ts +1 -1
- package/dist/components/demo/auth/Login.js +1 -1
- package/dist/components/demo/auth/Register.d.ts +1 -1
- package/dist/components/demo/auth/Register.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/LoginLanding.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/RegisterLanding.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/login/LoginForm.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/login/LoginForm.js +2 -2
- package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/register/RegisterForm.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/register/RegisterForm.js +2 -2
- package/dist/components/demo/auth/layouts/twoColumn/desktop/Login.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/desktop/Login.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/desktop/Register.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/desktop/Register.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/ipad/Login.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/ipad/Login.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/ipad/Register.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/ipad/Register.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/mobile/Login.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/mobile/Login.js +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/mobile/Register.d.ts +1 -1
- package/dist/components/demo/auth/layouts/twoColumn/mobile/Register.js +1 -1
- package/dist/configs/env.d.ts +0 -0
- package/dist/configs/env.js +0 -0
- package/dist/configs/language.d.ts +0 -0
- package/dist/configs/language.js +0 -0
- package/dist/core/auth.d.ts +0 -0
- package/dist/core/auth.js +0 -0
- package/dist/hooks/useTranslation.d.ts +0 -0
- package/dist/hooks/useTranslation.js +0 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +3 -2
- package/dist/libraries/auth/loginHandler.d.ts +0 -0
- package/dist/libraries/auth/loginHandler.js +0 -0
- package/dist/libraries/fonts.d.ts +0 -0
- package/dist/libraries/fonts.js +0 -0
- package/dist/locale/auth/en.json +0 -0
- package/dist/locale/auth/fa.json +0 -0
- package/dist/locale/en.d.ts +0 -0
- package/dist/locale/en.js +0 -0
- package/dist/locale/fa.d.ts +0 -0
- package/dist/locale/fa.js +0 -0
- package/dist/locale/index.d.ts +0 -0
- package/dist/locale/index.js +0 -0
- package/dist/proxy.d.ts +0 -0
- package/dist/proxy.js +0 -0
- package/dist/stores/AppStore.d.ts +0 -0
- package/dist/stores/AppStore.js +0 -0
- package/package.json +1 -1
- package/dist/components/Login.d.ts +0 -14
- package/dist/components/Login.js +0 -61
- package/dist/components/Register.d.ts +0 -1
- package/dist/components/Register.js +0 -41
- package/dist/components/demo/UiLogin.d.ts +0 -10
- package/dist/components/demo/UiLogin.js +0 -26
- package/dist/components/demo/UiRegister.d.ts +0 -12
- package/dist/components/demo/UiRegister.js +0 -15
- package/dist/interfaces/dictionary.d.ts +0 -18
- package/dist/interfaces/dictionary.js +0 -8
- package/dist/interfaces/global.d.ts +0 -65
- package/dist/interfaces/global.js +0 -1
- package/dist/libraries/cn.d.ts +0 -1
- package/dist/libraries/cn.js +0 -12
- package/dist/libraries/debounce.d.ts +0 -10
- package/dist/libraries/debounce.js +0 -17
- package/dist/libraries/detectComponentResponsive.d.ts +0 -10
- package/dist/libraries/detectComponentResponsive.js +0 -24
- package/dist/libraries/detectDeviceFromUA.d.ts +0 -8
- package/dist/libraries/detectDeviceFromUA.js +0 -14
- package/dist/libraries/translation.d.ts +0 -15
- package/dist/libraries/translation.js +0 -70
- package/dist/stores/LangStore.d.ts +0 -10
- package/dist/stores/LangStore.js +0 -87
- package/dist/types.d.ts +0 -10
- package/dist/types.js +0 -1
- package/dist/utilities/app/cookieUtils.d.ts +0 -20
- package/dist/utilities/app/cookieUtils.js +0 -98
|
@@ -27,7 +27,7 @@ import * as motion from "motion/react-client";
|
|
|
27
27
|
import { AnimatePresence } from "motion/react";
|
|
28
28
|
import { cn } from "forma-li";
|
|
29
29
|
// Hooks
|
|
30
|
-
import { useTranslation } from "
|
|
30
|
+
import { useTranslation } from "../../hooks/useTranslation";
|
|
31
31
|
// Constants
|
|
32
32
|
const PHRASE_KEYS = [
|
|
33
33
|
"loading_ahead_of_market",
|
|
File without changes
|
|
File without changes
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { useState, useMemo, lazy } from "react";
|
|
11
11
|
// Components
|
|
12
|
-
const LazyTwoColumn = lazy(() => import("
|
|
12
|
+
const LazyTwoColumn = lazy(() => import("../../../components/demo/auth/layouts/twoColumn/LoginLanding"));
|
|
13
13
|
// Constants
|
|
14
14
|
const LAYOUT_MAP = {
|
|
15
15
|
twoColumn: LazyTwoColumn,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useMemo, lazy } from "react";
|
|
4
4
|
import { cn } from "forma-li";
|
|
5
|
-
const LazyTwoColumn = lazy(() => import("
|
|
5
|
+
const LazyTwoColumn = lazy(() => import("../../../components/demo/auth/layouts/twoColumn/RegisterLanding"));
|
|
6
6
|
const LAYOUT_MAP = {
|
|
7
7
|
twoColumn: LazyTwoColumn,
|
|
8
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LoginComponentProps } from "
|
|
1
|
+
import type { LoginComponentProps } from "../../../../../types";
|
|
2
2
|
export default function TwoColumnLayout(props: LoginComponentProps): import("react").JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RegisterComponentProps } from "
|
|
1
|
+
import type { RegisterComponentProps } from "../../../../../types";
|
|
2
2
|
export default function TwoColumnLayout(props: RegisterComponentProps): import("react").JSX.Element | null;
|
package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/login/LoginForm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LoginComponentProps } from "
|
|
1
|
+
import type { LoginComponentProps } from "../../../../../../../../../types";
|
|
2
2
|
export default function LoginForm({ onSubmit, errors, message, }: LoginComponentProps): import("react").JSX.Element;
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { useState } from "react";
|
|
11
11
|
// Components
|
|
12
|
-
import LocalizedLink from "
|
|
12
|
+
import LocalizedLink from "../../../../../../../../../components/base/LocalizedLink";
|
|
13
13
|
import { InputPassword, InputEmail } from "forma-ui";
|
|
14
14
|
const GoogleIcon = () => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 18 18", children: _jsxs("g", { fill: "none", fillRule: "evenodd", children: [_jsx("path", { fill: "#4285F4", d: "M17.64 9.205c0-.639-.057-1.252-.164-1.841H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.875 2.684-6.615z" }), _jsx("path", { fill: "#34A853", d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18z" }), _jsx("path", { fill: "#FBBC05", d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332z" }), _jsx("path", { fill: "#EA4335", d: "M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z" })] }) }));
|
|
15
15
|
// Hooks
|
|
16
|
-
import { useTranslation } from "
|
|
16
|
+
import { useTranslation } from "../../../../../../../../../hooks/useTranslation";
|
|
17
17
|
export default function LoginForm({ onSubmit, errors, message, }) {
|
|
18
18
|
// Hooks
|
|
19
19
|
const { t } = useTranslation();
|
package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/register/RegisterForm.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RegisterComponentProps } from "
|
|
1
|
+
import type { RegisterComponentProps } from "../../../../../../../../../types";
|
|
2
2
|
declare const RegisterForm: ({ onSubmit, errors, message, }: RegisterComponentProps) => import("react").JSX.Element;
|
|
3
3
|
export default RegisterForm;
|
package/dist/components/demo/auth/layouts/twoColumn/common/theme/default/register/RegisterForm.js
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { useState } from "react";
|
|
11
11
|
// Hooks
|
|
12
|
-
import { useTranslation } from "
|
|
12
|
+
import { useTranslation } from "../../../../../../../../../hooks/useTranslation";
|
|
13
13
|
// Components
|
|
14
14
|
import { InputPassword, InputEmail, InputRePassword } from "forma-ui";
|
|
15
|
-
import LocalizedLink from "
|
|
15
|
+
import LocalizedLink from "../../../../../../../../../components/base/LocalizedLink";
|
|
16
16
|
// Google SVG Icon Component
|
|
17
17
|
// Interface
|
|
18
18
|
const RegisterForm = ({ onSubmit, errors, message, }) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LoginComponentProps } from "
|
|
1
|
+
import type { LoginComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function LoginDesktop(props: LoginComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function LoginDesktop(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RegisterComponentProps } from "
|
|
1
|
+
import type { RegisterComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function RegisterDesktop(props: RegisterComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function RegisterDesktop(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LoginComponentProps } from "
|
|
1
|
+
import type { LoginComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function LoginIpad(props: LoginComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function LoginIpad(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RegisterComponentProps } from "
|
|
1
|
+
import type { RegisterComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function RegisterIpad(props: RegisterComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function RegisterIpad(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LoginComponentProps } from "
|
|
1
|
+
import type { LoginComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function LoginMobile(props: LoginComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function LoginMobile(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RegisterComponentProps } from "
|
|
1
|
+
import type { RegisterComponentProps } from "../../../../../../types";
|
|
2
2
|
export default function RegisterMobile(props: RegisterComponentProps): import("react").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
import dynamic from "next/dynamic";
|
|
12
12
|
// Hooks
|
|
13
|
-
import { useTranslation } from "
|
|
13
|
+
import { useTranslation } from "../../../../../../hooks/useTranslation";
|
|
14
14
|
export default function RegisterMobile(props) {
|
|
15
15
|
// Hooks
|
|
16
16
|
const { t } = useTranslation();
|
package/dist/configs/env.d.ts
CHANGED
|
File without changes
|
package/dist/configs/env.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/configs/language.js
CHANGED
|
File without changes
|
package/dist/core/auth.d.ts
CHANGED
|
File without changes
|
package/dist/core/auth.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,3 @@ export { default as Login } from "./components/demo/auth/Login";
|
|
|
2
2
|
export { default as Register } from "./components/demo/auth/Register";
|
|
3
3
|
export { loginHandler } from "./libraries/auth/loginHandler";
|
|
4
4
|
export { registerHandler } from "./libraries/auth/registerHandler";
|
|
5
|
-
export { auth } from './core/auth';
|
|
6
|
-
export { env, checkEnv } from './configs/env';
|
|
7
|
-
export type { ServerEnv, ClientEnv } from './configs/env';
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { default as Register } from "./components/demo/auth/Register";
|
|
|
4
4
|
// Server handlers
|
|
5
5
|
export { loginHandler } from "./libraries/auth/loginHandler";
|
|
6
6
|
export { registerHandler } from "./libraries/auth/registerHandler";
|
|
7
|
-
export { auth } from './core/auth';
|
|
8
|
-
export { env, checkEnv } from './configs/env';
|
|
7
|
+
// export { auth } from './core/auth';
|
|
8
|
+
// export { env, checkEnv } from './configs/env';
|
|
9
|
+
// export type { ServerEnv, ClientEnv } from './configs/env';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/libraries/fonts.js
CHANGED
|
File without changes
|
package/dist/locale/auth/en.json
CHANGED
|
File without changes
|
package/dist/locale/auth/fa.json
CHANGED
|
File without changes
|
package/dist/locale/en.d.ts
CHANGED
|
File without changes
|
package/dist/locale/en.js
CHANGED
|
File without changes
|
package/dist/locale/fa.d.ts
CHANGED
|
File without changes
|
package/dist/locale/fa.js
CHANGED
|
File without changes
|
package/dist/locale/index.d.ts
CHANGED
|
File without changes
|
package/dist/locale/index.js
CHANGED
|
File without changes
|
package/dist/proxy.d.ts
CHANGED
|
File without changes
|
package/dist/proxy.js
CHANGED
|
File without changes
|
|
File without changes
|
package/dist/stores/AppStore.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { LoginProps } from "../types";
|
|
3
|
-
interface LoginComponentProps {
|
|
4
|
-
onSubmit: (formData: FormData) => void;
|
|
5
|
-
errors?: {
|
|
6
|
-
username?: string;
|
|
7
|
-
password?: string;
|
|
8
|
-
};
|
|
9
|
-
message?: string | null;
|
|
10
|
-
}
|
|
11
|
-
export default function Login({ loginRoute, UiComponent, }: LoginProps & {
|
|
12
|
-
UiComponent?: React.ComponentType<LoginComponentProps>;
|
|
13
|
-
}): React.JSX.Element;
|
|
14
|
-
export {};
|
package/dist/components/Login.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-12-31 06:00:17
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
"use client";
|
|
9
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
import { useState } from "react";
|
|
11
|
-
// Components
|
|
12
|
-
import UiLogin from "./demo/UiLogin";
|
|
13
|
-
export default function Login({ loginRoute, UiComponent, }) {
|
|
14
|
-
// States
|
|
15
|
-
const [errors, setErrors] = useState({});
|
|
16
|
-
const [message, setMessage] = useState(null);
|
|
17
|
-
const [loading, setLoading] = useState(false);
|
|
18
|
-
// Functions
|
|
19
|
-
const handleSubmit = async (formData) => {
|
|
20
|
-
setMessage(null);
|
|
21
|
-
setErrors({});
|
|
22
|
-
const email = formData.get("username") || "";
|
|
23
|
-
const password = formData.get("password") || "";
|
|
24
|
-
const newErrors = {};
|
|
25
|
-
if (!email.trim())
|
|
26
|
-
newErrors.username = "Username is required";
|
|
27
|
-
else if (email.length < 3)
|
|
28
|
-
newErrors.username = "Username must be at least 3 characters";
|
|
29
|
-
if (!password)
|
|
30
|
-
newErrors.password = "Password is required";
|
|
31
|
-
else if (password.length < 6)
|
|
32
|
-
newErrors.password = "Password must be at least 6 characters";
|
|
33
|
-
if (Object.keys(newErrors).length > 0) {
|
|
34
|
-
setErrors(newErrors);
|
|
35
|
-
setMessage("Please fix the errors below.");
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
setLoading(true);
|
|
39
|
-
try {
|
|
40
|
-
const res = await fetch(loginRoute, {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: { "Content-Type": "application/json" },
|
|
43
|
-
body: JSON.stringify({ email, password }),
|
|
44
|
-
});
|
|
45
|
-
const data = await res.json();
|
|
46
|
-
if (!res.ok) {
|
|
47
|
-
setMessage((data === null || data === void 0 ? void 0 : data.message) || "Login failed");
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
setMessage((data === null || data === void 0 ? void 0 : data.message) || "Login successful");
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
setMessage((err === null || err === void 0 ? void 0 : err.message) || "Network error");
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
setLoading(false);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const RenderUi = UiComponent || UiLogin;
|
|
60
|
-
return (_jsx(_Fragment, { children: _jsx("div", { className: "relative z-10 w-full max-w-md px-4", children: _jsx(RenderUi, { onSubmit: handleSubmit, errors: errors, message: message }) }) }));
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function Register(): import("react").JSX.Element;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import UiRegister from "./demo/UiRegister";
|
|
5
|
-
export default function Register() {
|
|
6
|
-
const [errors, setErrors] = useState({});
|
|
7
|
-
const [message, setMessage] = useState(null);
|
|
8
|
-
const validate = (formData) => {
|
|
9
|
-
var _a, _b, _c, _d;
|
|
10
|
-
const newErrors = {};
|
|
11
|
-
const name = (_a = formData.get("name")) === null || _a === void 0 ? void 0 : _a.toString().trim();
|
|
12
|
-
const email = (_b = formData.get("email")) === null || _b === void 0 ? void 0 : _b.toString().trim();
|
|
13
|
-
const password = (_c = formData.get("password")) === null || _c === void 0 ? void 0 : _c.toString();
|
|
14
|
-
const confirmPassword = (_d = formData.get("confirmPassword")) === null || _d === void 0 ? void 0 : _d.toString();
|
|
15
|
-
if (!name)
|
|
16
|
-
newErrors.name = "Name is required";
|
|
17
|
-
if (!email)
|
|
18
|
-
newErrors.email = "Email is required";
|
|
19
|
-
if (!password)
|
|
20
|
-
newErrors.password = "Password is required";
|
|
21
|
-
else if (password.length < 6)
|
|
22
|
-
newErrors.password = "Password must be at least 6 characters";
|
|
23
|
-
if (!confirmPassword)
|
|
24
|
-
newErrors.confirmPassword = "Confirm your password";
|
|
25
|
-
else if (password !== confirmPassword)
|
|
26
|
-
newErrors.confirmPassword = "Passwords do not match";
|
|
27
|
-
return newErrors;
|
|
28
|
-
};
|
|
29
|
-
const handleSubmit = (formData) => {
|
|
30
|
-
const validationErrors = validate(formData);
|
|
31
|
-
setErrors(validationErrors);
|
|
32
|
-
if (Object.keys(validationErrors).length === 0) {
|
|
33
|
-
setMessage(null);
|
|
34
|
-
// onSubmitServer(formData);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
setMessage("Please fix the errors below.");
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
return (_jsx(UiRegister, { onSubmit: handleSubmit, errors: errors, message: message }));
|
|
41
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface ClientLoginProps {
|
|
2
|
-
onSubmit: (formData: FormData) => void;
|
|
3
|
-
errors?: {
|
|
4
|
-
username?: string;
|
|
5
|
-
password?: string;
|
|
6
|
-
};
|
|
7
|
-
message?: string | null;
|
|
8
|
-
}
|
|
9
|
-
export default function UiLogin({ onSubmit, errors, message, }: ClientLoginProps): import("react").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import Image from "next/image";
|
|
5
|
-
import Link from "next/link";
|
|
6
|
-
import { useTranslation } from "../../hooks/useTranslation";
|
|
7
|
-
export default function UiLogin({ onSubmit, errors, message, }) {
|
|
8
|
-
const { t } = useTranslation();
|
|
9
|
-
const [visible, setVisible] = useState(false);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
// trigger the animation on mount
|
|
12
|
-
setVisible(true);
|
|
13
|
-
}, []);
|
|
14
|
-
return (_jsx("div", { className: "fixed inset-0 overflow-hidden flex items-center justify-center bg-gradient-to-br from-purple-900 via-purple-800 to-black p-4", children: _jsxs("div", { className: `w-full max-w-md bg-white/20 backdrop-blur-md rounded-2xl shadow-xl p-8 border border-white/30
|
|
15
|
-
transform transition-all duration-700 ease-out
|
|
16
|
-
${visible ? "opacity-100 scale-100" : "opacity-0 scale-95"}
|
|
17
|
-
`, children: [_jsx("div", { className: "relative w-40 h-20 mx-auto mb-8", children: _jsx(Image, { src: "/images/png/logo.png", alt: "Logo", fill: true, sizes: "auto", className: "object-contain", priority: true }) }), _jsx("h1", { className: "text-2xl font-bold text-center text-white mb-2", children: t("login") }), _jsx("p", { className: "text-center text-gray-200 mb-6 text-sm", children: "Login with your credentials to continue" }), message && (_jsx("div", { role: "alert", className: "mb-4 text-center text-red-300 font-medium", children: message })), _jsxs("form", { onSubmit: (e) => {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
const formData = new FormData(e.currentTarget);
|
|
20
|
-
onSubmit(formData);
|
|
21
|
-
}, noValidate: true, className: "space-y-5", children: [_jsxs("div", { children: [_jsx("label", { htmlFor: "username", className: "block text-sm font-medium text-white mb-1", children: "Username" }), _jsx("input", { id: "username", name: "username", type: "text", placeholder: "Enter your username", required: true, className: `w-full px-4 py-2 rounded-lg bg-white/20 focus:bg-white/30 border focus:outline-none focus:ring-2 text-white placeholder-gray-200 ${(errors === null || errors === void 0 ? void 0 : errors.username)
|
|
22
|
-
? "border-red-500"
|
|
23
|
-
: "border-gray-300 focus:ring-purple-400"}` }), (errors === null || errors === void 0 ? void 0 : errors.username) && (_jsx("p", { className: "mt-1 text-sm text-red-300", children: errors.username }))] }), _jsxs("div", { children: [_jsx("label", { htmlFor: "password", className: "block text-sm font-medium text-white mb-1", children: "Password" }), _jsx("input", { id: "password", name: "password", type: "password", placeholder: "Enter your password", required: true, className: `w-full px-4 py-2 rounded-lg bg-white/20 focus:bg-white/30 border focus:outline-none focus:ring-2 text-white placeholder-gray-200 ${(errors === null || errors === void 0 ? void 0 : errors.password)
|
|
24
|
-
? "border-red-500"
|
|
25
|
-
: "border-gray-300 focus:ring-purple-400"}` }), (errors === null || errors === void 0 ? void 0 : errors.password) && (_jsx("p", { className: "mt-1 text-sm text-red-300", children: errors.password }))] }), _jsx("button", { type: "submit", className: "w-full py-2 bg-purple-700/80 text-white rounded-lg hover:bg-purple-800 transition", children: "Log In" }), _jsxs("div", { className: "flex justify-center gap-4 mt-4", children: [_jsx("button", { type: "button", className: "flex items-center justify-center w-10 h-10 rounded-full bg-red-500 hover:bg-red-600 text-white transition font-bold text-lg", children: "G" }), _jsx("button", { type: "button", className: "flex items-center justify-center w-10 h-10 rounded-full bg-blue-600 hover:bg-blue-700 text-white transition font-bold text-lg", children: "F" }), _jsx("button", { type: "button", className: "flex items-center justify-center w-10 h-10 rounded-full bg-blue-400 hover:bg-blue-500 text-white transition font-bold text-lg", children: "T" })] }), _jsxs("p", { className: "text-center text-sm text-gray-200 mt-4", children: ["Don\u2019t have an account?", " ", _jsx(Link, { href: "/en/register", className: "underline hover:text-white", children: "Register" })] })] })] }) }));
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface UiRegisterProps {
|
|
2
|
-
onSubmit: (formData: FormData) => void;
|
|
3
|
-
errors?: {
|
|
4
|
-
name?: string;
|
|
5
|
-
email?: string;
|
|
6
|
-
password?: string;
|
|
7
|
-
confirmPassword?: string;
|
|
8
|
-
};
|
|
9
|
-
message?: string | null;
|
|
10
|
-
}
|
|
11
|
-
export default function UiRegister({ onSubmit, errors, message, }: UiRegisterProps): import("react").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect } from "react";
|
|
4
|
-
import Image from "next/image";
|
|
5
|
-
import Link from "next/link";
|
|
6
|
-
export default function UiRegister({ onSubmit, errors, message, }) {
|
|
7
|
-
const [visible, setVisible] = useState(false);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setVisible(true); // simple fade+scale animation
|
|
10
|
-
}, []);
|
|
11
|
-
return (_jsx("div", { className: "fixed inset-0 flex items-center justify-center bg-gradient-to-br from-purple-900 via-purple-800 to-black p-4", children: _jsxs("div", { className: `w-full max-w-md bg-white/20 backdrop-blur-md rounded-2xl shadow-xl p-8 border border-white/30 transform transition-all duration-700 ease-out ${visible ? "opacity-100 scale-100" : "opacity-0 scale-95"}`, children: [_jsx("div", { className: "flex justify-center mb-6", children: _jsx(Image, { src: "/logo.png", alt: "Logo", width: 80, height: 80, className: "rounded-full shadow" }) }), _jsx("h1", { className: "text-2xl font-bold text-center text-white mb-2", children: "Create Account" }), _jsx("p", { className: "text-center text-gray-200 mb-6 text-sm", children: "Sign up to get started" }), message && (_jsx("div", { role: "alert", className: "mb-4 text-center text-red-300 font-medium", children: message })), _jsxs("form", { onSubmit: (e) => {
|
|
12
|
-
e.preventDefault();
|
|
13
|
-
onSubmit(new FormData(e.currentTarget));
|
|
14
|
-
}, className: "space-y-5", children: [_jsx("input", { name: "name", placeholder: "Full Name", className: "w-full px-4 py-2 rounded-lg bg-white/20 text-white placeholder-gray-200" }), _jsx("input", { name: "email", type: "email", placeholder: "Email", className: "w-full px-4 py-2 rounded-lg bg-white/20 text-white placeholder-gray-200" }), _jsx("input", { name: "password", type: "password", placeholder: "Password", className: "w-full px-4 py-2 rounded-lg bg-white/20 text-white placeholder-gray-200" }), _jsx("input", { name: "confirmPassword", type: "password", placeholder: "Confirm Password", className: "w-full px-4 py-2 rounded-lg bg-white/20 text-white placeholder-gray-200" }), _jsx("button", { type: "submit", className: "w-full py-2 bg-purple-700/80 text-white rounded-lg hover:bg-purple-800 transition", children: "Sign Up" })] }), _jsxs("div", { className: "flex justify-center gap-4 mt-4", children: [_jsx("button", { className: "flex items-center justify-center w-10 h-10 rounded-full bg-red-500 hover:bg-red-600 text-white font-bold text-lg transition", children: "G" }), _jsx("button", { className: "flex items-center justify-center w-10 h-10 rounded-full bg-blue-600 hover:bg-blue-700 text-white font-bold text-lg transition", children: "F" }), _jsx("button", { className: "flex items-center justify-center w-10 h-10 rounded-full bg-blue-400 hover:bg-blue-500 text-white font-bold text-lg transition", children: "T" })] }), _jsxs("p", { className: "text-center text-sm text-gray-200 mt-4", children: ["Already have an account?", " ", _jsx(Link, { href: "/en/login", className: "underline hover:text-white", children: "Log in" })] })] }) }));
|
|
15
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-12 09:03:23
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
import { Lang } from "../configs/language";
|
|
9
|
-
export type Dictionary = Record<string, string>;
|
|
10
|
-
export interface LangState {
|
|
11
|
-
lang: Lang;
|
|
12
|
-
dir: "ltr" | "rtl";
|
|
13
|
-
refreshKey: number;
|
|
14
|
-
isInitialized: boolean;
|
|
15
|
-
setLang: (newLang: Lang) => void;
|
|
16
|
-
initializeLang: (langFromUrl?: string) => void;
|
|
17
|
-
triggerRefresh?: () => void;
|
|
18
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-12 15:00:49
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
import type { ReactNode } from "react";
|
|
9
|
-
import { type Lang } from "../configs/language";
|
|
10
|
-
import { Dictionary } from "../interfaces/dictionary";
|
|
11
|
-
export interface LangLayoutProps {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
params: Promise<{
|
|
14
|
-
lang: string;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
export interface LangWrapperProps {
|
|
18
|
-
langFromUrl: Lang;
|
|
19
|
-
dictionary: Dictionary;
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
export interface Image {
|
|
23
|
-
src?: string | any;
|
|
24
|
-
alt?: string;
|
|
25
|
-
width?: number;
|
|
26
|
-
height?: number;
|
|
27
|
-
}
|
|
28
|
-
export interface VerticalNewsBox {
|
|
29
|
-
title?: string;
|
|
30
|
-
link?: string;
|
|
31
|
-
image?: Image | string;
|
|
32
|
-
}
|
|
33
|
-
export interface AdvertiseBoxType {
|
|
34
|
-
title?: string;
|
|
35
|
-
content?: string;
|
|
36
|
-
sponsored?: string;
|
|
37
|
-
link?: string;
|
|
38
|
-
image?: Image | string;
|
|
39
|
-
}
|
|
40
|
-
export type FrontBackPair = {
|
|
41
|
-
front: (props: any) => ReactNode;
|
|
42
|
-
back: (props: any) => ReactNode;
|
|
43
|
-
};
|
|
44
|
-
export type SonnerType = "basic" | "success" | "error" | "warning" | "info" | 'loading';
|
|
45
|
-
export type SonnerPosition = "bottom-left" | "bottom-right" | "bottom-center" | "top-left" | "top-right" | "top-center";
|
|
46
|
-
export interface SonnerItem {
|
|
47
|
-
id: string;
|
|
48
|
-
title: ReactNode;
|
|
49
|
-
action: ReactNode | null;
|
|
50
|
-
type: SonnerType;
|
|
51
|
-
duration: number;
|
|
52
|
-
position: SonnerPosition;
|
|
53
|
-
createdAt?: any;
|
|
54
|
-
isPaused?: boolean;
|
|
55
|
-
remainingDuration?: any;
|
|
56
|
-
}
|
|
57
|
-
export interface OpenSonnerParams {
|
|
58
|
-
title: ReactNode;
|
|
59
|
-
action?: ReactNode;
|
|
60
|
-
type?: SonnerType;
|
|
61
|
-
duration?: number;
|
|
62
|
-
position?: SonnerPosition;
|
|
63
|
-
allowDuplicate?: boolean;
|
|
64
|
-
onDismiss?: (...args: any[]) => void;
|
|
65
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/libraries/cn.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function cn(...inputs: any): string;
|
package/dist/libraries/cn.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-12-25 12:50:52
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
type Procedure = (...args: any[]) => void;
|
|
9
|
-
export default function debounce<F extends Procedure>(func: F, timeout?: number): (...args: Parameters<F>) => void;
|
|
10
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-12-25 12:50:52
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
|
-
export default function debounce(func, timeout = 300) {
|
|
9
|
-
let timer;
|
|
10
|
-
return (...args) => {
|
|
11
|
-
if (timer)
|
|
12
|
-
clearTimeout(timer);
|
|
13
|
-
timer = setTimeout(() => {
|
|
14
|
-
func.apply(null, args);
|
|
15
|
-
}, timeout);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
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 const detectDeviceFromUA = (userAgent) => {
|
|
9
|
-
if (/iPad|Tablet/.test(userAgent))
|
|
10
|
-
return "ipad";
|
|
11
|
-
if (/Mobile|Android|iPhone/.test(userAgent))
|
|
12
|
-
return "mobile";
|
|
13
|
-
return "desktop";
|
|
14
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-18 09:36:46
|
|
6
|
-
* @Description: Translation utilities
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { type Lang } from "../configs/language";
|
|
10
|
-
export declare function createTranslator(lang: Lang): {
|
|
11
|
-
t: (key: string, fallback?: string) => string;
|
|
12
|
-
lang: "en" | "fa";
|
|
13
|
-
};
|
|
14
|
-
export declare function simpleTrans(i18nKey: string, values: Record<string, string> | undefined, t: (key: string) => string): string;
|
|
15
|
-
export declare function trans(i18nKey: string, values: Record<string, string>, t: (key: string) => string, ...elements: React.ReactElement[]): React.ReactNode;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-18 09:36:46
|
|
6
|
-
* @Description: Translation utilities
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { getDictionary } from "../locale";
|
|
10
|
-
// Core translation function
|
|
11
|
-
export function createTranslator(lang) {
|
|
12
|
-
const translations = getDictionary(lang);
|
|
13
|
-
function t(key, fallback) {
|
|
14
|
-
if (!translations) {
|
|
15
|
-
console.warn("Translations not loaded for language:", lang);
|
|
16
|
-
return fallback !== null && fallback !== void 0 ? fallback : key;
|
|
17
|
-
}
|
|
18
|
-
const keys = key === null || key === void 0 ? void 0 : key.split(".");
|
|
19
|
-
let value = translations;
|
|
20
|
-
for (const k of keys) {
|
|
21
|
-
if (value && typeof value === "object" && k in value) {
|
|
22
|
-
value = value[k];
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return fallback !== null && fallback !== void 0 ? fallback : key;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return typeof value === "string" ? value : fallback !== null && fallback !== void 0 ? fallback : key;
|
|
29
|
-
}
|
|
30
|
-
return { t, lang };
|
|
31
|
-
}
|
|
32
|
-
// Simple SSR translation function
|
|
33
|
-
export function simpleTrans(i18nKey, values = {}, t) {
|
|
34
|
-
let text = t(i18nKey);
|
|
35
|
-
for (const [key, value] of Object.entries(values)) {
|
|
36
|
-
text = text.replace(new RegExp(`{{${key}}}`, "g"), value);
|
|
37
|
-
}
|
|
38
|
-
return text;
|
|
39
|
-
}
|
|
40
|
-
// Advanced trans function with React elements support
|
|
41
|
-
export function trans(i18nKey, values, t, ...elements) {
|
|
42
|
-
let text = t(i18nKey);
|
|
43
|
-
// Replace values
|
|
44
|
-
for (const [key, value] of Object.entries(values)) {
|
|
45
|
-
text = text.replace(new RegExp(`{{${key}}}`, "g"), value);
|
|
46
|
-
}
|
|
47
|
-
// Split and process
|
|
48
|
-
const parts = text.split(/(<\d+>.*?<\/\d+>)/g);
|
|
49
|
-
const result = [];
|
|
50
|
-
parts.forEach((part, index) => {
|
|
51
|
-
const tagMatch = part.match(/^<(\d+)>(.*?)<\/\d+>$/);
|
|
52
|
-
if (tagMatch) {
|
|
53
|
-
const elementIndex = Number(tagMatch[1]);
|
|
54
|
-
const content = tagMatch[2];
|
|
55
|
-
const element = elements[elementIndex];
|
|
56
|
-
if (React.isValidElement(element)) {
|
|
57
|
-
result.push(React.cloneElement(element, {
|
|
58
|
-
key: index,
|
|
59
|
-
}, content));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
result.push(content);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else if (part) {
|
|
66
|
-
result.push(React.createElement(React.Fragment, { key: index }, part));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-05 12:41:14
|
|
6
|
-
* @Description: Lang store with API routes
|
|
7
|
-
*/
|
|
8
|
-
import { LangState } from "../interfaces/dictionary";
|
|
9
|
-
export declare const useLangStore: import("zustand").UseBoundStore<import("zustand").StoreApi<LangState>>;
|
|
10
|
-
export declare const initializeLang: (langFromUrl?: string) => Promise<void>;
|
package/dist/stores/LangStore.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Author: Mohammad Felfelani
|
|
3
|
-
* @Email: mfelfelani72@gmail.com
|
|
4
|
-
* @Team:
|
|
5
|
-
* @Date: 2025-10-05 12:41:14
|
|
6
|
-
* @Description: Lang store with API routes
|
|
7
|
-
*/
|
|
8
|
-
import { create } from "zustand";
|
|
9
|
-
// Configurations
|
|
10
|
-
import { languages } from "../configs/language";
|
|
11
|
-
export const useLangStore = create()((set, get) => ({
|
|
12
|
-
lang: "en",
|
|
13
|
-
dir: "ltr",
|
|
14
|
-
isInitialized: false,
|
|
15
|
-
refreshKey: 0,
|
|
16
|
-
setLang: async (newLang) => {
|
|
17
|
-
const langConfig = languages[newLang];
|
|
18
|
-
const dir = (langConfig === null || langConfig === void 0 ? void 0 : langConfig.dir) || "ltr";
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch("/api/set-lang", {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
},
|
|
25
|
-
body: JSON.stringify({
|
|
26
|
-
lang: newLang,
|
|
27
|
-
dir: dir,
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
throw new Error("Failed to set language");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error("Error setting language:", error);
|
|
36
|
-
}
|
|
37
|
-
set({
|
|
38
|
-
lang: newLang,
|
|
39
|
-
dir,
|
|
40
|
-
refreshKey: get().refreshKey + 1,
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
triggerRefresh: () => {
|
|
44
|
-
set({ refreshKey: get().refreshKey + 1 });
|
|
45
|
-
},
|
|
46
|
-
initializeLang: async (langFromUrl) => {
|
|
47
|
-
const { isInitialized } = get();
|
|
48
|
-
if (isInitialized) {
|
|
49
|
-
console.log("⏭️ Already initialized");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
let finalLang = "en";
|
|
53
|
-
let finalDir = "ltr";
|
|
54
|
-
console.log("🔍 Initializing lang from URL:", langFromUrl);
|
|
55
|
-
if (langFromUrl && langFromUrl in languages) {
|
|
56
|
-
finalLang = langFromUrl;
|
|
57
|
-
finalDir = languages[finalLang].dir;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
try {
|
|
61
|
-
const response = await fetch("/api/get-lang");
|
|
62
|
-
if (response.ok) {
|
|
63
|
-
const data = await response.json();
|
|
64
|
-
if (data.lang && data.lang in languages) {
|
|
65
|
-
finalLang = data.lang;
|
|
66
|
-
finalDir = data.dir || languages[finalLang].dir;
|
|
67
|
-
console.log(`✅ Lang from cookie via API: ${finalLang}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error("Error getting cookie:", error);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
set({
|
|
76
|
-
lang: finalLang,
|
|
77
|
-
dir: finalDir,
|
|
78
|
-
isInitialized: true,
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
// Helper function
|
|
83
|
-
export const initializeLang = async (langFromUrl) => {
|
|
84
|
-
if (typeof window !== "undefined") {
|
|
85
|
-
await useLangStore.getState().initializeLang(langFromUrl);
|
|
86
|
-
}
|
|
87
|
-
};
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
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, options?: {
|
|
10
|
-
minutes?: number;
|
|
11
|
-
days?: number;
|
|
12
|
-
secure?: boolean;
|
|
13
|
-
}) => void;
|
|
14
|
-
export declare const getCookie: (name: string) => string | null;
|
|
15
|
-
export declare const getCookieServer: (name: string) => Promise<string | null>;
|
|
16
|
-
export declare const getCookieAppLang: () => Promise<{
|
|
17
|
-
lang: string;
|
|
18
|
-
dir: string;
|
|
19
|
-
}>;
|
|
20
|
-
export declare const getCookieAppTheme: () => Promise<"light" | "dark">;
|
|
@@ -1,98 +0,0 @@
|
|
|
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, options) => {
|
|
12
|
-
if (!isBrowser())
|
|
13
|
-
return;
|
|
14
|
-
const expires = new Date();
|
|
15
|
-
if (options === null || options === void 0 ? void 0 : options.minutes) {
|
|
16
|
-
expires.setTime(expires.getTime() + options.minutes * 60 * 1000);
|
|
17
|
-
}
|
|
18
|
-
else if (options === null || options === void 0 ? void 0 : options.days) {
|
|
19
|
-
expires.setDate(expires.getDate() + options.days);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
expires.setFullYear(expires.getFullYear() + 1);
|
|
23
|
-
}
|
|
24
|
-
document.cookie = `
|
|
25
|
-
${name}=${value};
|
|
26
|
-
expires=${expires.toUTCString()};
|
|
27
|
-
path=/;
|
|
28
|
-
SameSite=Lax;
|
|
29
|
-
${(options === null || options === void 0 ? void 0 : options.secure) ? "Secure;" : ""}
|
|
30
|
-
`.trim();
|
|
31
|
-
};
|
|
32
|
-
export const getCookie = (name) => {
|
|
33
|
-
var _a;
|
|
34
|
-
if (!isBrowser())
|
|
35
|
-
return null;
|
|
36
|
-
const value = `; ${document.cookie}`;
|
|
37
|
-
const parts = value.split(`; ${name}=`);
|
|
38
|
-
if (parts.length === 2) {
|
|
39
|
-
return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(";").shift()) || null;
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
export const getCookieServer = async (name) => {
|
|
44
|
-
var _a;
|
|
45
|
-
try {
|
|
46
|
-
const { cookies } = await import("next/headers");
|
|
47
|
-
const cookieStore = await cookies();
|
|
48
|
-
return ((_a = cookieStore.get(name)) === null || _a === void 0 ? void 0 : _a.value) || null;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
console.error("Error getting cookie from server:", error);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
export const getCookieAppLang = async () => {
|
|
56
|
-
var _a, _b, _c;
|
|
57
|
-
let lang = "en";
|
|
58
|
-
let dir = "ltr";
|
|
59
|
-
let appLangCookie = null;
|
|
60
|
-
try {
|
|
61
|
-
if (typeof window === "undefined") {
|
|
62
|
-
// Server-side
|
|
63
|
-
const { cookies } = await import("next/headers");
|
|
64
|
-
const cookieStore = await cookies();
|
|
65
|
-
appLangCookie = ((_a = cookieStore.get("app_lang")) === null || _a === void 0 ? void 0 : _a.value) || null;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
// Client-side
|
|
69
|
-
const cookies = document.cookie.split(";");
|
|
70
|
-
const cookie = cookies.find((c) => c.trim().startsWith("app_lang="));
|
|
71
|
-
appLangCookie = cookie ? decodeURIComponent(cookie.split("=")[1]) : null;
|
|
72
|
-
}
|
|
73
|
-
if (appLangCookie) {
|
|
74
|
-
const appLangData = JSON.parse(appLangCookie);
|
|
75
|
-
lang = ((_b = appLangData.state) === null || _b === void 0 ? void 0 : _b.lang) || "en";
|
|
76
|
-
dir = ((_c = appLangData.state) === null || _c === void 0 ? void 0 : _c.dir) || "ltr";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
console.error("Error in getCookieAppLang:", error);
|
|
81
|
-
}
|
|
82
|
-
return { lang, dir };
|
|
83
|
-
};
|
|
84
|
-
export const getCookieAppTheme = async () => {
|
|
85
|
-
var _a, _b;
|
|
86
|
-
let theme = "light";
|
|
87
|
-
try {
|
|
88
|
-
const { cookies } = await import("next/headers");
|
|
89
|
-
const cookieStore = await cookies();
|
|
90
|
-
const cookieThemeRaw = ((_a = cookieStore.get("app_theme")) === null || _a === void 0 ? void 0 : _a.value) || '{"state":{"theme":"light"}}';
|
|
91
|
-
const parsed = JSON.parse(cookieThemeRaw);
|
|
92
|
-
theme = ((_b = parsed.state) === null || _b === void 0 ? void 0 : _b.theme) === "dark" ? "dark" : "light";
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
console.error("Error getting theme from cookie:", error);
|
|
96
|
-
}
|
|
97
|
-
return theme;
|
|
98
|
-
};
|