@erpsquad/common 1.8.101 → 1.8.102
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/providers/ERPUIProvider/index.esm.js +6 -0
- package/dist/components/providers/ERPUIProvider/index.esm.js.map +1 -1
- package/dist/components/providers/ERPUIProvider/index.js +2 -1
- package/dist/components/providers/ERPUIProvider/index.js.map +1 -1
- package/dist/style.css +75 -75
- package/package.json +1 -1
|
@@ -8,6 +8,8 @@ import { LanguageProvider } from "../../../contexts/languageContext/index.esm.js
|
|
|
8
8
|
import { PageProvider } from "../../../contexts/page-context/index.esm.js";
|
|
9
9
|
import { PermissionsProvider } from "../../../contexts/permission-context/index.esm.js";
|
|
10
10
|
import MUIThemeWrapper from "../../../theme/themeWrapper/index.esm.js";
|
|
11
|
+
import { Loader } from "../../loader/index.esm.js";
|
|
12
|
+
import { useAppTranslations } from "../../../hooks/use-translations/index.esm.js";
|
|
11
13
|
import { initializeApiConfig } from "../../../utils/api-config/index.esm.js";
|
|
12
14
|
import { initializeApiBaseUrls } from "../../../utils/api/index.esm.js";
|
|
13
15
|
import { createLibraryStore } from "../../../redux/store/index.esm.js";
|
|
@@ -58,6 +60,10 @@ const ERPUIProvider = ({
|
|
|
58
60
|
console.error("Failed to initialize API configuration:", error);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
63
|
+
const { isLoading } = useAppTranslations();
|
|
64
|
+
if (isLoading) {
|
|
65
|
+
return /* @__PURE__ */ jsx(Loader, {});
|
|
66
|
+
}
|
|
61
67
|
const store = React__default.useMemo(() => {
|
|
62
68
|
if (!useRedux) return null;
|
|
63
69
|
if (reduxStore) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n const { isLoading } = useAppTranslations();\n if (isLoading) {\n return <Loader />;\n }\n // Create or use provided Redux store\n const store = React.useMemo(() => {\n if (!useRedux) return null;\n\n if (reduxStore) {\n return reduxStore;\n }\n\n return createLibraryStore(additionalReducers, apiClient);\n }, [useRedux, reduxStore, additionalReducers, apiClient]);\n\n // Create theme\n const theme = React.useMemo(() => {\n if (customTheme) {\n return customTheme;\n }\n\n const themeCreator = themeMode === 'dark' ? createDarkTheme : createLightTheme;\n const { theme: generatedTheme } = themeCreator(primaryColor, direction);\n return generatedTheme;\n }, [customTheme, themeMode, primaryColor, direction]);\n\n // Context value\n const contextValue: ERPUIContextValue = {\n useRedux,\n apiClient,\n theme,\n themeMode,\n direction,\n primaryColor,\n };\n\n // Build provider tree from inside out\n let content = (\n <ERPUIContext.Provider value={contextValue}>\n {/* <ThemeProvider theme={theme}>\n {enableCssBaseline && <CssBaseline />} */}\n {/* <Suspense fallback={<Loader />}> */}\n <MUIThemeWrapper theme={theme} enableCssBaseline={enableCssBaseline}>\n {children}\n </MUIThemeWrapper>\n {/* </Suspense> */}\n {/* </ThemeProvider> */}\n </ERPUIContext.Provider>\n );\n\n // Wrap with snackbar provider if enabled\n if (enableSnackbar) {\n content = (\n <SnackbarProvider {...snackbarConfig}>\n {content}\n </SnackbarProvider>\n );\n }\n\n // Wrap with page provider if enabled\n if (enablePages) {\n content = (\n <PageProvider>\n {content}\n </PageProvider>\n );\n }\n\n // Wrap with permissions provider if enabled\n if (enablePermissions) {\n content = (\n <PermissionsProvider>\n {content}\n </PermissionsProvider>\n );\n }\n\n // Wrap with language provider if enabled\n if (enableLanguage) {\n content = (\n <LanguageProvider>\n {content}\n </LanguageProvider>\n );\n }\n\n // Wrap with auth provider if enabled\n if (enableAuth) {\n content = (\n <AuthProvider>\n {content}\n </AuthProvider>\n );\n }\n\n // Wrap with router if enabled\n if (enableRouter) {\n content = (\n <BrowserRouter>\n {content}\n </BrowserRouter>\n );\n }\n\n // Wrap with Redux provider if enabled\n if (useRedux && store) {\n content = (\n <ReduxProvider store={store}>\n {content}\n </ReduxProvider>\n );\n }\n\n return content;\n};\n\nexport default ERPUIProvider;"],"names":["React","ReduxProvider"],"mappings":";;;;;;;;;;;;;;;;AA6BA,MAAM,eAAe,cAAiC;AAAA,EACpD,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AACb,CAAC;AAEM,MAAM,WAAW,MAAM,WAAW,YAAY;AAyC9C,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA;AAAA,EAGA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,qBAAqB,CAAA;AAAA;AAAA,EAGrB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ;AAAA,EACA,YAAY;AAAA;AAAA,EAGZ,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,eAAe;AAAA;AAAA,EACf,iBAAiB;AAAA;AAAA,EAGjB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,cAAc,EAAE,UAAU,OAAO,YAAY,QAAA;AAAA,IAC7C,kBAAkB;AAAA,EAAA;AAAA;AAAA,EAIpB,WAAW;AACb,MAAM;AAKJ,QAAM,gBAAgBA,eAAM,OAAO,KAAK;AAExC,MAAI,qBAAqB,CAAC,cAAc,SAAS;AAC/C,QAAI;AACF,0BAAoB,iBAAiB;AACrC,4BAAA;AACA,oBAAc,UAAU;AAAA,IAC1B,SAAS,OAAO;AACd,cAAQ,MAAM,2CAA2C,KAAK;AAAA,IAChE;AAAA,EACF;AACA,QAAM,EAAE,UAAA,IAAc,mBAAA;AACtB,MAAI,WAAW;AACb,+BAAQ,QAAA,EAAO;AAAA,EACjB;AAEA,QAAM,QAAQA,eAAM,QAAQ,MAAM;AAChC,QAAI,CAAC,SAA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react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),i=require("react-redux"),t=require("../../../node_modules/notistack/notistack.esm/index.js"),n=require("react-router-dom"),s=require("../../../contexts/AuthContext/index.js"),o=require("../../../contexts/languageContext/index.js"),a=require("../../../contexts/page-context/index.js"),u=require("../../../contexts/permission-context/index.js"),d=require("../../../theme/themeWrapper/index.js"),l=require("../../loader/index.js"),c=require("../../../hooks/use-translations/index.js"),x=require("../../../utils/api-config/index.js"),h=require("../../../utils/api/index.js"),m=require("../../../redux/store/index.js"),j=require("../../../theme/theme-impl/index.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=/* @__PURE__ */p(r);const f=r.createContext({useRedux:!1,themeMode:"light",direction:"ltr"}),q=({children:r,useRedux:p=!1,reduxStore:q,apiClient:P,additionalReducers:b={},theme:v,themeMode:C="light",primaryColor:k,direction:R="ltr",enableAuth:y=!0,enableLanguage:A=!0,enablePages:L=!0,enablePermissions:M=!0,enableRouter:S=!1,enableSnackbar:B=!0,enableCssBaseline:z=!0,snackbarConfig:T={maxSnack:3,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:5e3},apiConfig:U})=>{const _=g.default.useRef(!1);if(U&&!_.current)try{x.initializeApiConfig(U),h.initializeApiBaseUrls(),_.current=!0}catch(H){}const{isLoading:D}=c.useAppTranslations();if(D)/* @__PURE__ */
|
|
2
|
+
return e.jsx(l.Loader,{});const E=g.default.useMemo(()=>p?q||m.createLibraryStore(b,P):null,[p,q,b,P]),I=g.default.useMemo(()=>{if(v)return v;const e="dark"===C?j.createDarkTheme:j.createLightTheme,{theme:r}=e(k,R);return r},[v,C,k,R]),O={useRedux:p,apiClient:P,theme:I,themeMode:C,direction:R,primaryColor:k};let w=/* @__PURE__ */e.jsx(f.Provider,{value:O,children:/* @__PURE__ */e.jsx(d.default,{theme:I,enableCssBaseline:z,children:r})});return B&&(w=/* @__PURE__ */e.jsx(t.SnackbarProvider,{...T,children:w})),L&&(w=/* @__PURE__ */e.jsx(a.PageProvider,{children:w})),M&&(w=/* @__PURE__ */e.jsx(u.PermissionsProvider,{children:w})),A&&(w=/* @__PURE__ */e.jsx(o.LanguageProvider,{children:w})),y&&(w=/* @__PURE__ */e.jsx(s.AuthProvider,{children:w})),S&&(w=/* @__PURE__ */e.jsx(n.BrowserRouter,{children:w})),p&&E&&(w=/* @__PURE__ */e.jsx(i.Provider,{store:E,children:w})),w};exports.ERPUIProvider=q,exports.default=q,exports.useERPUI=()=>r.useContext(f);
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/providers/ERPUIProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, ReactNode, Suspense } from 'react';\nimport { Provider as ReduxProvider } from 'react-redux';\nimport { ThemeProvider } from '@mui/material/styles';\nimport CssBaseline from '@mui/material/CssBaseline';\nimport { SnackbarProvider } from 'notistack';\nimport { BrowserRouter } from 'react-router-dom';\nimport { createLibraryStore, ApiClientConfig } from '../../redux';\nimport { createLightTheme, createDarkTheme, Color } from '../../theme';\nimport { AuthProvider } from '../../contexts/AuthContext';\nimport { LanguageProvider } from '../../contexts/languageContext';\nimport { PageProvider } from '../../contexts/page-context';\nimport { PermissionsProvider } from '../../contexts/permission-context';\nimport MUIThemeWrapper from '../../theme/themeWrapper';\nimport Loader from '../loader';\nimport useAppTranslations from '../../hooks/use-translations';\nimport '../../utils/i18n';\nimport { initializeApiConfig, ApiConfig } from '../../utils/api-config';\nimport { initializeApiBaseUrls } from '../../utils/api';\n\n// Context for library configuration\ninterface ERPUIContextValue {\n useRedux: boolean;\n apiClient?: ApiClientConfig;\n theme?: any;\n themeMode: 'light' | 'dark';\n direction: 'ltr' | 'rtl';\n primaryColor?: Color;\n}\n\nconst ERPUIContext = createContext<ERPUIContextValue>({\n useRedux: false,\n themeMode: 'light',\n direction: 'ltr',\n});\n\nexport const useERPUI = () => useContext(ERPUIContext);\n\n// Provider props interface\ninterface ERPUIProviderProps {\n children: ReactNode;\n\n // Redux configuration\n useRedux?: boolean;\n reduxStore?: any;\n apiClient?: ApiClientConfig;\n additionalReducers?: Record<string, any>;\n\n // Theme configuration\n theme?: any;\n themeMode?: 'light' | 'dark';\n primaryColor?: Color;\n direction?: 'ltr' | 'rtl';\n\n // Context providers configuration\n enableAuth?: boolean;\n enableLanguage?: boolean;\n enablePages?: boolean;\n enablePermissions?: boolean;\n enableRouter?: boolean;\n enableSnackbar?: boolean;\n\n // Other configuration\n enableCssBaseline?: boolean;\n snackbarConfig?: {\n maxSnack?: number;\n anchorOrigin?: {\n vertical: 'top' | 'bottom';\n horizontal: 'left' | 'center' | 'right';\n };\n autoHideDuration?: number;\n };\n\n // API configuration\n apiConfig?: ApiConfig;\n}\n\nexport const ERPUIProvider: React.FC<ERPUIProviderProps> = ({\n children,\n\n // Redux props\n useRedux = false,\n reduxStore,\n apiClient,\n additionalReducers = {},\n\n // Theme props\n theme: customTheme,\n themeMode = 'light',\n primaryColor,\n direction = 'ltr',\n\n // Context providers configuration\n enableAuth = true,\n enableLanguage = true,\n enablePages = true,\n enablePermissions = true,\n enableRouter = false, // Default false since consuming app usually provides router\n enableSnackbar = true,\n\n // Other props\n enableCssBaseline = true,\n snackbarConfig = {\n maxSnack: 3,\n anchorOrigin: { vertical: 'top', horizontal: 'right' },\n autoHideDuration: 5000,\n },\n\n // API configuration\n apiConfig: providedApiConfig,\n}) => {\n\n // Initialize API configuration synchronously before first render\n // This prevents \"API configuration not initialized\" errors when components\n // try to use the API during initial render\n const isInitialized = React.useRef(false);\n\n if (providedApiConfig && !isInitialized.current) {\n try {\n initializeApiConfig(providedApiConfig);\n initializeApiBaseUrls();\n isInitialized.current = true;\n } catch (error) {\n console.error('Failed to initialize API configuration:', error);\n }\n }\n const { isLoading } = useAppTranslations();\n if (isLoading) {\n return <Loader />;\n }\n // Create or use provided Redux store\n const store = React.useMemo(() => {\n if (!useRedux) return null;\n\n if (reduxStore) {\n return reduxStore;\n }\n\n return createLibraryStore(additionalReducers, apiClient);\n }, [useRedux, reduxStore, additionalReducers, apiClient]);\n\n // Create theme\n const theme = React.useMemo(() => {\n if (customTheme) {\n return customTheme;\n }\n\n const themeCreator = themeMode === 'dark' ? createDarkTheme : createLightTheme;\n const { theme: generatedTheme } = themeCreator(primaryColor, direction);\n return generatedTheme;\n }, [customTheme, themeMode, primaryColor, direction]);\n\n // Context value\n const contextValue: ERPUIContextValue = {\n useRedux,\n apiClient,\n theme,\n themeMode,\n direction,\n primaryColor,\n };\n\n // Build provider tree from inside out\n let content = (\n <ERPUIContext.Provider value={contextValue}>\n {/* <ThemeProvider theme={theme}>\n {enableCssBaseline && <CssBaseline />} */}\n {/* <Suspense fallback={<Loader />}> */}\n <MUIThemeWrapper theme={theme} enableCssBaseline={enableCssBaseline}>\n {children}\n </MUIThemeWrapper>\n {/* </Suspense> */}\n {/* </ThemeProvider> */}\n </ERPUIContext.Provider>\n );\n\n // Wrap with snackbar provider if enabled\n if (enableSnackbar) {\n content = (\n <SnackbarProvider {...snackbarConfig}>\n {content}\n </SnackbarProvider>\n );\n }\n\n // Wrap with page provider if enabled\n if (enablePages) {\n content = (\n <PageProvider>\n {content}\n </PageProvider>\n );\n }\n\n // Wrap with permissions provider if enabled\n if (enablePermissions) {\n content = (\n <PermissionsProvider>\n {content}\n </PermissionsProvider>\n );\n }\n\n // Wrap with language provider if enabled\n if (enableLanguage) {\n content = (\n <LanguageProvider>\n {content}\n </LanguageProvider>\n );\n }\n\n // Wrap with auth provider if enabled\n if (enableAuth) {\n content = (\n <AuthProvider>\n {content}\n </AuthProvider>\n );\n }\n\n // Wrap with router if enabled\n if (enableRouter) {\n content = (\n <BrowserRouter>\n {content}\n </BrowserRouter>\n );\n }\n\n // Wrap with Redux provider if enabled\n if (useRedux && store) {\n content = (\n <ReduxProvider store={store}>\n {content}\n </ReduxProvider>\n );\n }\n\n return content;\n};\n\nexport default ERPUIProvider;"],"names":["ERPUIContext","createContext","useRedux","themeMode","direction","ERPUIProvider","children","reduxStore","apiClient","additionalReducers","theme","customTheme","primaryColor","enableAuth","enableLanguage","enablePages","enablePermissions","enableRouter","enableSnackbar","enableCssBaseline","snackbarConfig","maxSnack","anchorOrigin","vertical","horizontal","autoHideDuration","apiConfig","providedApiConfig","isInitialized","React","useRef","current","initializeApiConfig","initializeApiBaseUrls","error","isLoading","useAppTranslations","Loader","store","useMemo","createLibraryStore","themeCreator","createDarkTheme","createLightTheme","generatedTheme","contextValue","content","jsx","Provider","value","MUIThemeWrapper","SnackbarProvider","PageProvider","PermissionsProvider","LanguageProvider","AuthProvider","BrowserRouter","ReduxProvider","useContext"],"mappings":"k3BA6BA,MA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