@birhaus/provider
Version:
BIRHAUS Provider - Context provider for real-time UX validation and cognitive load monitoring
90 lines (87 loc) • 3.44 kB
text/typescript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
import { BirhausScore } from '@birhaus/primitives';
export { BIRHAUS_ENV_CONFIG, BIRHAUS_PERFORMANCE, BIRHAUS_SCORING, DEFAULT_BIRHAUS_CONFIG } from '@birhaus/primitives';
interface BirhausConfig {
/** Strict mode enforcement (throws on violations in dev) */
strictMode?: boolean;
/** Track cognitive load violations in real-time */
cognitiveLoadTracking?: boolean;
/** Monitor performance budgets */
performanceBudgets?: boolean;
/** Validate accessibility in real-time */
accessibilityValidation?: boolean;
/** Enforce Spanish-first design */
spanishFirst?: boolean;
/** Enforce undo-over-confirm pattern */
undoOverConfirm?: boolean;
/** Enforce Miller's Law limits */
millerLawEnforcement?: boolean;
/** Enable progressive disclosure suggestions */
progressiveDisclosure?: boolean;
/** Show development warnings and hints */
showWarnings?: boolean;
/** Detailed logging for debugging */
detailedLogging?: boolean;
/** Enable analytics collection */
analyticsEnabled?: boolean;
}
interface BirhausProviderProps {
/** Primary language (defaults to Spanish-first) */
language?: 'es' | 'en';
/** Configuration options */
config?: BirhausConfig;
/** Custom theme object */
theme?: Record<string, unknown>;
/** Analytics endpoint for UX data */
analyticsEndpoint?: string;
/** Custom score thresholds */
scoreThresholds?: {
warning: number;
critical: number;
};
/** Development mode features */
devMode?: boolean;
/** Child components */
children: ReactNode;
/** Called when violations are detected */
onViolation?: (violation: BirhausViolation) => void;
/** Called when score changes */
onScoreChange?: (score: BirhausScore) => void;
}
interface BirhausViolation {
type: 'cognitive' | 'accessibility' | 'spanish' | 'performance' | 'confirmation';
severity: 'warning' | 'error' | 'critical';
element: Element | null;
message: string;
messageEs: string;
messageEn: string;
recommendation: string;
birhausPrinciple: number;
timestamp: Date;
}
interface BirhausContextType {
/** Current configuration */
config: BirhausConfig;
/** Current language */
language: 'es' | 'en';
/** Current theme */
theme: Record<string, unknown>;
/** Current Birhaus score */
score: BirhausScore | null;
/** List of current violations */
violations: BirhausViolation[];
/** Translation function */
t: (key: string, fallback?: string) => string;
/** Report a violation */
reportViolation: (violation: Omit<BirhausViolation, 'timestamp'>) => void;
/** Update configuration */
updateConfig: (newConfig: Partial<BirhausConfig>) => void;
/** Change language */
setLanguage: (language: 'es' | 'en') => void;
/** Force score recalculation */
recalculateScore: () => Promise<void>;
}
declare function BirhausProvider({ language, config: userConfig, theme, analyticsEndpoint, scoreThresholds, devMode, children, onViolation, onScoreChange }: BirhausProviderProps): react_jsx_runtime.JSX.Element;
declare function useBirhaus(): BirhausContextType;
export { type BirhausConfig, type BirhausContextType, BirhausProvider, type BirhausViolation, BirhausProvider as Provider, useBirhaus };