Skip to content

Global Context ​

System that manages shared configuration and state β€” the "command center" that coordinates all of schepta.

Provider

Provider Pattern centralizes configurations that all components need to share:

πŸ”§ What It Does: ​

ConfigurationScopeBenefitExample
Component RegistryGlobalStandardized componentsMUI as default
Middleware StackGlobalConsistent behaviorUniform validation
Theme ConfigurationGlobalVisual identityColors and fonts
Context ProvidersGlobalShared stateUser, permissions, locale

πŸ“Š Configuration Hierarchy: ​

Provider Hierarchy:

text
scheptaProvider (App Level)
    β”œβ”€β”€ Global Component Registry
    β”œβ”€β”€ Global Middleware  
    β”œβ”€β”€ Theme Provider
    └── Context Providers
        └── FormFactory/MenuFactory (Local)
            β”œβ”€β”€ Local Component Overrides
            └── Local Middleware Overrides

Quick Example:

jsx
<scheptaProvider
  components={{ InputText: MUITextField, Button: MUIButton }}
  middleware={{ withValidation, withAnalytics }}
  theme={{ primary: '#007ACC' }}
>
  <App />
</scheptaProvider>

πŸ’‘ Result: Configure once β†’ Available throughout the application.


πŸš€ Provider Types ​

Each provider manages a specific aspect of the system:

🎨 scheptaProvider - Master Provider: ​

ConfigurationPurposeDefaultOverride Level
componentsGlobal component registryBuilt-in componentsLocal factory props
middlewareGlobal middleware stackBasic middlewareLocal factory props
themeVisual theme configurationDefault themeCSS/styled-components
debugDebug panel configurationAuto (dev mode)Environment variables
cacheCaching strategyReact Query defaultsProvider props

πŸŽ›οΈ Component Registry Provider: ​

Registration TypeScopePriorityUse Case
Default RegistrySystem-wideLowestBuilt-in components
Global RegistryApplication-wideMediumConsistent UI library
Local RegistryFactory-specificHighestComponent overrides
Dynamic RegistryRuntimeVariableA/B testing, themes

πŸ”§ Middleware Provider: ​

Middleware TypeScopeExecutionPurpose
Core MiddlewareSystemAlways executedEssential functionality
Global MiddlewareApplicationConfigurableConsistent behavior
Local MiddlewareFactoryOverride/extendSpecific functionality
Conditional MiddlewareContext-basedConditionalRole/tenant specific

🎨 Theme Provider: ​

Theme AspectConfigurationInheritanceOverride
ColorsPrimary, secondary, etc.CSS variablesComponent props
TypographyFonts, sizes, weightsCSS cascadeInline styles
SpacingMargins, padding, gridCSS classesComponent styles
ComponentsDefault component stylesTheme objectComponent overrides

βš™οΈ Provider Architecture ​

How the provider system works:

πŸ“‹ Provider Initialization: ​

PhaseProcessResultDependencies
1. Provider SetupInitialize provider contextContext availableNone
2. Registry RegistrationRegister global componentsGlobal registry populatedComponent definitions
3. Middleware RegistrationRegister global middlewareMiddleware stack readyMiddleware functions
4. Theme InitializationSetup theme contextTheme availableTheme configuration
5. Context PropagationPropagate to child componentsProviders activeReact/Vue context

🎯 Context Propagation: ​

React Context Usage:

typescript
// Provider contexts
const scheptaContext = createContext<scheptaConfig>();
const ComponentRegistryContext = createContext<ComponentRegistry>();
const MiddlewareContext = createContext<MiddlewareStack>();
const ThemeContext = createContext<ThemeConfig>();

// Hook access
const useschepta = () => useContext(scheptaContext);
const useComponentRegistry = () => useContext(ComponentRegistryContext);
const useMiddleware = () => useContext(MiddlewareContext);
const usescheptaTheme = () => useContext(ThemeContext);

Configuration Inheritance:

typescript
const mergedConfig = {
  // Default configuration
  ...defaultscheptaConfig,
  
  // Provider configuration  
  ...providerConfig,
  
  // Runtime overrides
  ...runtimeConfig
};

πŸ“Š Configuration Patterns ​

Common provider configuration patterns:

🎯 Application-Level Patterns: ​

PatternUse CaseConfigurationBenefits
Single ThemeConsistent appOne theme configVisual consistency
Multi-ThemeWhite-label appTheme per tenantBrand flexibility
Component LibraryDesign systemConsistent componentsDevelopment speed
Micro-frontendsDistributed appScoped configurationsTeam independence

πŸ”§ Component Library Integration: ​

Material-UI Integration:

typescript
<scheptaProvider
  components={{
    InputText: MuiTextField,
    Button: MuiButton,
    Select: MuiSelect,
    Checkbox: MuiCheckbox
  }}
  theme={{
    palette: {
      primary: { main: '#1976d2' },
      secondary: { main: '#dc004e' }
    }
  }}
>
  <App />
</scheptaProvider>

Ant Design Integration:

typescript
<scheptaProvider
  components={{
    InputText: AntInput,
    Button: AntButton,
    Select: AntSelect,
    Checkbox: AntCheckbox
  }}
  theme={{
    token: {
      colorPrimary: '#1890ff',
      colorSuccess: '#52c41a'
    }
  }}
>
  <App />
</scheptaProvider>

🎨 Multi-Tenant Configuration: ​

Tenant-Specific Providers:

typescript
const TenantProvider = ({ tenant, children }) => {
  const tenantConfig = getTenantConfig(tenant);
  
  return (
    <scheptaProvider
      components={tenantConfig.components}
      theme={tenantConfig.theme}
      middleware={tenantConfig.middleware}
    >
      {children}
    </scheptaProvider>
  );
};

Provider Pattern manages configuration for all other concepts: