فهرست منبع

Bugfix: Cycle import problems fixed.

lfabl 3 ماه پیش
والد
کامیت
71b67fadb1

+ 1 - 1
src/assets/svg/badgeAlertIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/badgeDangerIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/badgeInfoIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/badgeQuestionMarkIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/badgeRightIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/badgeSuccessIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/chevronRightIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/cleanIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/eyeClosedIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/eyeOpenedIcon/index.tsx

@@ -1,6 +1,6 @@
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 1
src/assets/svg/loadingIcon/index.tsx

@@ -8,7 +8,7 @@ import {
 } from "react-native";
 import {
     NCoreUIKitTheme
-} from "../../..";
+} from "../../../core/hooks";
 import {
     type INCoreUIKitIconProps
 } from "../../../types";

+ 1 - 3
src/components/loading/index.tsx

@@ -3,9 +3,7 @@ import {
 } from "react";
 import type ILoadingProps from "./type";
 import stylesheet from "./stylesheet";
-import {
-    LoadingIcon
-} from "../../assets/svg";
+import LoadingIcon from "../../assets/svg/loadingIcon";
 
 const Loading: FC<ILoadingProps> = ({
     color = "primary" as keyof NCoreUIKit.IconContentColors,

+ 1 - 1
src/components/modal/index.tsx

@@ -16,7 +16,7 @@ import {
 import stylesheet from "./stylesheet";
 import {
     NCoreUIKitTheme
-} from "../..";
+} from "../../core/hooks";
 import {
     type RefForwardingComponent
 } from "../../types";

+ 1 - 1
src/components/text/index.tsx

@@ -7,7 +7,7 @@ import {
 import type ITextProps from "./type";
 import {
     NCoreUIKitTheme
-} from "../..";
+} from "../../core/hooks";
 
 const Text: FC<ITextProps> = ({
     variant = "bodyMediumSize",

+ 21 - 0
src/core/hooks.ts

@@ -0,0 +1,21 @@
+import type {
+    NCoreUIKitBase
+} from ".";
+import type {
+    NCoreUIKitConfig,
+    LocalizeType,
+    ThemesType
+} from "../types";
+import type NCoreUIKitLocalizeClass from "../context/localize";
+import type NCoreUIKitModalClass from "../context/modal";
+import type NCoreUIKitThemeClass from "../context/theme";
+
+export let NCoreUIKitLocalize: NCoreUIKitLocalizeClass<LocalizeType>;
+export let NCoreUIKitTheme: NCoreUIKitThemeClass<ThemesType>;
+export let NCoreUIKitModal: NCoreUIKitModalClass;
+
+export const initializeInstances = (NCoreUIKit: NCoreUIKitBase<NCoreUIKitConfig>) => {
+    NCoreUIKitLocalize = NCoreUIKit.NCoreUIKitContext.NCoreUIKitLocalize;
+    NCoreUIKitTheme = NCoreUIKit.NCoreUIKitContext.NCoreUIKitTheme;
+    NCoreUIKitModal = NCoreUIKit.NCoreUIKitContext.NCoreUIKitModal;
+};

+ 44 - 0
src/core/index.tsx

@@ -0,0 +1,44 @@
+import {
+    type ReactNode
+} from "react";
+import {
+    initializeInstances
+} from "./hooks";
+import type {
+    NCoreUIKitConfig
+} from "../types";
+import CoreContext from "../context";
+
+export class NCoreUIKitBase<T extends NCoreUIKitConfig> {
+    NCoreUIKitContext: CoreContext<T>;
+
+    constructor(initialState: T) {
+        this.NCoreUIKitContext = new CoreContext(initialState);
+    }
+
+    Provider = ({
+        children
+    }: {
+        children: ReactNode;
+    }) => {
+        const NCoreUIKitContext = this.NCoreUIKitContext;
+
+        return <NCoreUIKitContext.Provider>
+            {children}
+        </NCoreUIKitContext.Provider>;
+    };
+};
+
+let NCoreUIKit!: NCoreUIKitBase<NCoreUIKitConfig>;
+
+export const setupNCoreUIKit = (initialState: NCoreUIKitConfig, isCustom: boolean = false) => {
+    if(isCustom) {
+        return new NCoreUIKitBase(initialState);
+    } else {
+        NCoreUIKit = new NCoreUIKitBase(initialState);
+
+        initializeInstances(NCoreUIKit);
+
+        return NCoreUIKit;
+    }
+};

+ 8 - 57
src/index.tsx

@@ -1,61 +1,12 @@
-import {
-    type ReactNode
-} from "react";
-import type {
-    NCoreUIKitConfig,
-    LocalizeType,
-    ThemesType
-} from "./types";
-import CoreContext from "./context";
-import {
-    default as NCoreUIKitLocalizeClass
-} from "./context/localize";
-import {
-    default as NCoreUIKitModalClass
-} from "./context/modal";
-import {
-    default as NCoreUIKitThemeClass
-} from "./context/theme";
-
-class NCoreUIKitBase<T extends NCoreUIKitConfig> {
-    NCoreUIKitContext: CoreContext<T>;
-
-    constructor(initialState: T) {
-        this.NCoreUIKitContext = new CoreContext(initialState);
-    }
-
-    Provider = ({
-        children
-    }: {
-        children: ReactNode;
-    }) => {
-        const NCoreUIKitContext = this.NCoreUIKitContext;
-
-        return <NCoreUIKitContext.Provider>
-            {children}
-        </NCoreUIKitContext.Provider>;
-    };
-};
-
-let NCoreUIKit!: NCoreUIKitBase<NCoreUIKitConfig>;
-
-export let NCoreUIKitLocalize: NCoreUIKitLocalizeClass<LocalizeType>;
-export let NCoreUIKitTheme: NCoreUIKitThemeClass<ThemesType>;
-export let NCoreUIKitModal: NCoreUIKitModalClass;
-
-export const setupNCoreUIKit = (initialState: NCoreUIKitConfig, isCustom: boolean = false) => {
-    if(isCustom) {
-        return new NCoreUIKitBase(initialState);
-    } else {
-        NCoreUIKit = new NCoreUIKitBase(initialState);
-
-        NCoreUIKitLocalize = NCoreUIKit.NCoreUIKitContext.NCoreUIKitLocalize;
-        NCoreUIKitModal = NCoreUIKit.NCoreUIKitContext.NCoreUIKitModal;
-        NCoreUIKitTheme = NCoreUIKit.NCoreUIKitContext.NCoreUIKitTheme;
+export {
+    setupNCoreUIKit
+} from "./core";
 
-        return NCoreUIKit;
-    }
-};
+export {
+    NCoreUIKitLocalize,
+    NCoreUIKitModal,
+    NCoreUIKitTheme
+} from "./core/hooks";
 
 export {
     // TextInput,