@almadar/ui 1.0.0
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/LICENSE +72 -0
- package/README.md +335 -0
- package/dist/ThemeContext-lI5bo85E.d.ts +103 -0
- package/dist/components/index.d.ts +4789 -0
- package/dist/components/index.js +21566 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/index.d.ts +208 -0
- package/dist/context/index.js +443 -0
- package/dist/context/index.js.map +1 -0
- package/dist/event-bus-types-8-cjyMxw.d.ts +65 -0
- package/dist/hooks/index.d.ts +1006 -0
- package/dist/hooks/index.js +2262 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/lib/index.d.ts +291 -0
- package/dist/lib/index.js +431 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/offline-executor-CHr4uAhf.d.ts +401 -0
- package/dist/providers/index.d.ts +386 -0
- package/dist/providers/index.js +1111 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/renderer/index.d.ts +382 -0
- package/dist/renderer/index.js +808 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/stores/index.d.ts +151 -0
- package/dist/stores/index.js +196 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/useUISlots-mnggE9X9.d.ts +105 -0
- package/package.json +121 -0
- package/themes/almadar.css +196 -0
- package/themes/index.css +11 -0
- package/themes/minimalist.css +193 -0
- package/themes/wireframe.css +188 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../hooks/useUISlots.ts","../../context/UISlotContext.tsx","../../context/ThemeContext.tsx","../../context/DesignThemeContext.tsx","../../context/UserContext.tsx"],"names":["createContext","useMemo","useState","useEffect","useCallback","jsx","useContext"],"mappings":";;;;AA0HA,IAAM,aAAA,GAAoD;AAAA,EACxD,IAAA,EAAM,IAAA;AAAA,EACN,OAAA,EAAS,IAAA;AAAA,EACT,KAAA,EAAO,IAAA;AAAA,EACP,MAAA,EAAQ,IAAA;AAAA,EACR,OAAA,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S,CAAC,IAAA,KAAS,IAAA,KAAS,WAAA;AAAA,MAC5B,eAAe,MAAM,KAAA;AAAA,MACrB,UAAA,EAAY,CAAC,KAAA,KAAU,KAAA,CAAM,SAAS,WAAW,CAAA;AAAA,MACjD,mBAAmB,MAAM,KAAA;AAAA,MACzB,cAAc,MAAM;AAAA,KACtB;AAAA,EACF;AAEA,EAAA,OAAO,OAAA;AACT;AAUO,SAAS,WAAW,IAAA,EAAuB;AAChD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,OAAA,EAAQ;AAC5B,EAAA,OAAO,QAAQ,IAAI,CAAA;AACrB;AAMO,SAAS,iBAAiB,UAAA,EAA6B;AAC5D,EAAA,MAAM,EAAE,aAAA,EAAc,GAAI,OAAA,EAAQ;AAClC,EAAA,OAAO,cAAc,UAAU,CAAA;AACjC;AAMO,SAAS,oBAAA,GAA6C;AAC3D,EAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAW,GAAI,OAAA,EAAQ;AACrC,EAAA,OAAO,UAAA,IAAc,OAAO,IAAA,GAAO,MAAA;AACrC","file":"index.js","sourcesContent":["/**\n * useUISlots Hook\n *\n * Core hook for managing UI slot rendering in the trait-driven architecture.\n * Traits use render_ui effects to dynamically render content into slots.\n *\n * Slots:\n * - main: Primary content area\n * - sidebar: Left/right sidebar\n * - modal: Modal overlay\n * - drawer: Slide-in drawer\n * - overlay: Full-screen overlay\n * - center: Centered popup\n * - toast: Toast notifications\n * - hud-top: Game HUD top bar\n * - hud-bottom: Game HUD bottom bar\n * - floating: Draggable floating panel\n *\n * @packageDocumentation\n */\n\nimport { useState, useCallback, useRef, useEffect } from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Valid UI slot names\n */\nexport type UISlot =\n | 'main'\n | 'sidebar'\n | 'modal'\n | 'drawer'\n | 'overlay'\n | 'center'\n | 'toast'\n | 'hud-top'\n | 'hud-bottom'\n | 'floating';\n\n/**\n * Animation types for slot transitions\n */\nexport type SlotAnimation = 'fade' | 'slide' | 'scale' | 'none';\n\n/**\n * Content rendered in a slot\n */\nexport interface SlotContent {\n /** Unique ID for this content */\n id: string;\n /** Pattern/component type to render */\n pattern: string;\n /** Props to pass to the pattern component */\n props: Record<string, unknown>;\n /** Priority for conflict resolution (higher wins) */\n priority: number;\n /** Animation for showing/hiding */\n animation?: SlotAnimation;\n /** Auto-dismiss timestamp (for toasts) */\n autoDismissAt?: number;\n /** Callback when dismissed */\n onDismiss?: () => void;\n /** Source trait that rendered this content */\n sourceTrait?: string;\n}\n\n/**\n * Configuration for render_ui effect\n */\nexport interface RenderUIConfig {\n /** Target slot */\n target: UISlot;\n /** Pattern/component to render */\n pattern: string;\n /** Props for the pattern */\n props?: Record<string, unknown>;\n /** Priority (default: 0) */\n priority?: number;\n /** Animation type */\n animation?: SlotAnimation;\n /** Auto-dismiss after ms (for toasts) */\n autoDismissMs?: number;\n /** Callback on dismiss */\n onDismiss?: () => void;\n /** Source trait name */\n sourceTrait?: string;\n}\n\n/**\n * Callback for slot changes\n */\nexport type SlotChangeCallback = (slot: UISlot, content: SlotContent | null) => void;\n\n/**\n * UI Slot Manager interface\n */\nexport interface UISlotManager {\n /** Current content for each slot */\n slots: Record<UISlot, SlotContent | null>;\n /** Render content to a slot */\n render: (config: RenderUIConfig) => string;\n /** Clear a specific slot */\n clear: (slot: UISlot) => void;\n /** Clear content by ID */\n clearById: (id: string) => void;\n /** Clear all slots */\n clearAll: () => void;\n /** Subscribe to slot changes */\n subscribe: (callback: SlotChangeCallback) => () => void;\n /** Check if a slot has content */\n hasContent: (slot: UISlot) => boolean;\n /** Get content for a slot */\n getContent: (slot: UISlot) => SlotContent | null;\n}\n\n// ============================================================================\n// Default Slots State\n// ============================================================================\n\nconst DEFAULT_SLOTS: Record<UISlot, SlotContent | null> = {\n main: null,\n sidebar: null,\n modal: null,\n drawer: null,\n overlay: null,\n center: null,\n toast: null,\n 'hud-top': null,\n 'hud-bottom': null,\n floating: null,\n};\n\n// ============================================================================\n// ID Generator\n// ============================================================================\n\nlet idCounter = 0;\nfunction generateId(): string {\n return `slot-content-${++idCounter}-${Date.now()}`;\n}\n\n// ============================================================================\n// Hook Implementation\n// ============================================================================\n\n/**\n * Create a UI Slot Manager instance.\n *\n * This is the internal hook that creates the manager.\n * Use `useUISlots()` from context in components.\n */\nexport function useUISlotManager(): UISlotManager {\n const [slots, setSlots] = useState<Record<UISlot, SlotContent | null>>(DEFAULT_SLOTS);\n const subscribersRef = useRef<Set<SlotChangeCallback>>(new Set());\n const timersRef = useRef<Map<string, NodeJS.Timeout>>(new Map());\n\n // Clean up timers on unmount\n useEffect(() => {\n return () => {\n timersRef.current.forEach((timer) => clearTimeout(timer));\n timersRef.current.clear();\n };\n }, []);\n\n // Notify subscribers of slot changes\n const notifySubscribers = useCallback((slot: UISlot, content: SlotContent | null) => {\n subscribersRef.current.forEach((callback) => {\n try {\n callback(slot, content);\n } catch (error) {\n console.error('[UISlots] Subscriber error:', error);\n }\n });\n }, []);\n\n // Render content to a slot\n const render = useCallback((config: RenderUIConfig): string => {\n const id = generateId();\n const content: SlotContent = {\n id,\n pattern: config.pattern,\n props: config.props ?? {},\n priority: config.priority ?? 0,\n animation: config.animation ?? 'fade',\n onDismiss: config.onDismiss,\n sourceTrait: config.sourceTrait,\n };\n\n // Set auto-dismiss timer if specified\n if (config.autoDismissMs && config.autoDismissMs > 0) {\n content.autoDismissAt = Date.now() + config.autoDismissMs;\n const timer = setTimeout(() => {\n setSlots((prev) => {\n if (prev[config.target]?.id === id) {\n // Call onDismiss callback\n content.onDismiss?.();\n notifySubscribers(config.target, null);\n return { ...prev, [config.target]: null };\n }\n return prev;\n });\n timersRef.current.delete(id);\n }, config.autoDismissMs);\n timersRef.current.set(id, timer);\n }\n\n setSlots((prev) => {\n const existing = prev[config.target];\n\n // Priority-based conflict resolution\n if (existing && existing.priority > content.priority) {\n console.warn(\n `[UISlots] Slot \"${config.target}\" already has higher priority content (${existing.priority} > ${content.priority})`\n );\n return prev;\n }\n\n notifySubscribers(config.target, content);\n return { ...prev, [config.target]: content };\n });\n\n return id;\n }, [notifySubscribers]);\n\n // Clear a specific slot\n const clear = useCallback((slot: UISlot) => {\n setSlots((prev) => {\n const content = prev[slot];\n if (content) {\n // Clear any auto-dismiss timer\n const timer = timersRef.current.get(content.id);\n if (timer) {\n clearTimeout(timer);\n timersRef.current.delete(content.id);\n }\n // Call onDismiss callback\n content.onDismiss?.();\n notifySubscribers(slot, null);\n }\n return { ...prev, [slot]: null };\n });\n }, [notifySubscribers]);\n\n // Clear content by ID\n const clearById = useCallback((id: string) => {\n setSlots((prev) => {\n const entry = Object.entries(prev).find(([, content]) => content?.id === id);\n if (entry) {\n const [slot, content] = entry as [UISlot, SlotContent];\n // Clear any auto-dismiss timer\n const timer = timersRef.current.get(id);\n if (timer) {\n clearTimeout(timer);\n timersRef.current.delete(id);\n }\n // Call onDismiss callback\n content.onDismiss?.();\n notifySubscribers(slot, null);\n return { ...prev, [slot]: null };\n }\n return prev;\n });\n }, [notifySubscribers]);\n\n // Clear all slots\n const clearAll = useCallback(() => {\n // Clear all timers\n timersRef.current.forEach((timer) => clearTimeout(timer));\n timersRef.current.clear();\n\n setSlots((prev) => {\n // Call onDismiss for all content\n Object.entries(prev).forEach(([slot, content]) => {\n if (content) {\n content.onDismiss?.();\n notifySubscribers(slot as UISlot, null);\n }\n });\n return DEFAULT_SLOTS;\n });\n }, [notifySubscribers]);\n\n // Subscribe to slot changes\n const subscribe = useCallback((callback: SlotChangeCallback): (() => void) => {\n subscribersRef.current.add(callback);\n return () => {\n subscribersRef.current.delete(callback);\n };\n }, []);\n\n // Check if slot has content\n const hasContent = useCallback((slot: UISlot): boolean => {\n return slots[slot] !== null;\n }, [slots]);\n\n // Get content for a slot\n const getContent = useCallback((slot: UISlot): SlotContent | null => {\n return slots[slot];\n }, [slots]);\n\n return {\n slots,\n render,\n clear,\n clearById,\n clearAll,\n subscribe,\n hasContent,\n getContent,\n };\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport { DEFAULT_SLOTS };\n","/**\n * UISlotContext\n *\n * React context for providing the UI Slot Manager throughout the application.\n * Traits use this context to render content into slots via render_ui effects.\n *\n * Usage:\n * ```tsx\n * // In App.tsx or layout\n * <UISlotProvider>\n * <App />\n * </UISlotProvider>\n *\n * // In trait hooks or components\n * const { render, clear } = useUISlots();\n * render({ target: 'modal', pattern: 'form-section', props: {...} });\n * ```\n *\n * @packageDocumentation\n */\n\nimport React, { createContext, useContext, useMemo } from 'react';\nimport {\n useUISlotManager,\n type UISlotManager,\n type UISlot,\n type SlotContent,\n type RenderUIConfig,\n type SlotAnimation,\n type SlotChangeCallback,\n} from '../hooks/useUISlots';\n\n// ============================================================================\n// Context\n// ============================================================================\n\n/**\n * Context for the UI Slot Manager\n */\nconst UISlotContext = createContext<UISlotManager | null>(null);\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport interface UISlotProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * Provider component that creates and provides the UI Slot Manager.\n *\n * Must wrap any components that use traits with render_ui effects.\n */\nexport function UISlotProvider({ children }: UISlotProviderProps): React.ReactElement {\n const slotManager = useUISlotManager();\n\n // Memoize the context value to prevent unnecessary re-renders\n const contextValue = useMemo(() => slotManager, [slotManager]);\n\n return (\n <UISlotContext.Provider value={contextValue}>\n {children}\n </UISlotContext.Provider>\n );\n}\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook to access the UI Slot Manager.\n *\n * Must be used within a UISlotProvider.\n *\n * @throws Error if used outside of UISlotProvider\n *\n * @example\n * ```tsx\n * function MyTraitHook() {\n * const { render, clear } = useUISlots();\n *\n * const showModal = () => {\n * render({\n * target: 'modal',\n * pattern: 'form-section',\n * props: { title: 'Create Item' },\n * });\n * };\n *\n * const closeModal = () => {\n * clear('modal');\n * };\n *\n * return { showModal, closeModal };\n * }\n * ```\n */\nexport function useUISlots(): UISlotManager {\n const context = useContext(UISlotContext);\n\n if (!context) {\n throw new Error(\n 'useUISlots must be used within a UISlotProvider. ' +\n 'Make sure your component tree is wrapped with <UISlotProvider>.'\n );\n }\n\n return context;\n}\n\n/**\n * Hook to get content for a specific slot.\n *\n * Useful for components that only need to read slot state.\n */\nexport function useSlotContent(slot: UISlot): SlotContent | null {\n const { getContent } = useUISlots();\n return getContent(slot);\n}\n\n/**\n * Hook to check if a slot has content.\n */\nexport function useSlotHasContent(slot: UISlot): boolean {\n const { hasContent } = useUISlots();\n return hasContent(slot);\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport {\n UISlotContext,\n type UISlotManager,\n type UISlot,\n type SlotContent,\n type RenderUIConfig,\n type SlotAnimation,\n type SlotChangeCallback,\n};\n","/**\n * Unified ThemeContext - Single provider for theme and color mode\n *\n * Combines design theme selection (ocean, wireframe, etc.) with\n * color mode (light/dark) into a single, simple system.\n *\n * Uses a single data attribute: data-theme=\"ocean-light\" or data-theme=\"ocean-dark\"\n *\n * @packageDocumentation\n */\n\nimport React, {\n createContext,\n useContext,\n useState,\n useEffect,\n useCallback,\n useMemo,\n} from \"react\";\n\n/** Color mode preference */\nexport type ColorMode = \"light\" | \"dark\" | \"system\";\n\n/** Resolved color mode (what's actually applied) */\nexport type ResolvedMode = \"light\" | \"dark\";\n\n/** Theme definition */\nexport interface ThemeDefinition {\n /** Theme identifier (e.g., \"ocean\", \"wireframe\") */\n name: string;\n /** Display name for UI (e.g., \"Ocean Blue\") */\n displayName?: string;\n /** Whether this theme has light mode styles */\n hasLightMode?: boolean;\n /** Whether this theme has dark mode styles */\n hasDarkMode?: boolean;\n}\n\n/** Built-in themes available in the design system */\nexport const BUILT_IN_THEMES: ThemeDefinition[] = [\n {\n name: \"wireframe\",\n displayName: \"Wireframe\",\n hasLightMode: true,\n hasDarkMode: true,\n },\n {\n name: \"minimalist\",\n displayName: \"Minimalist\",\n hasLightMode: true,\n hasDarkMode: true,\n },\n {\n name: \"almadar\",\n displayName: \"Almadar\",\n hasLightMode: true,\n hasDarkMode: true,\n },\n];\n\n/** Theme context value */\ninterface ThemeContextValue {\n /** Current theme name */\n theme: string;\n /** Current color mode setting (may be 'system') */\n mode: ColorMode;\n /** Resolved color mode (always 'light' or 'dark') */\n resolvedMode: ResolvedMode;\n /** Set the theme */\n setTheme: (theme: string) => void;\n /** Set the color mode */\n setMode: (mode: ColorMode) => void;\n /** Toggle between light and dark modes */\n toggleMode: () => void;\n /** Available themes */\n availableThemes: ThemeDefinition[];\n /** The full theme string applied to data-theme (e.g., \"ocean-light\") */\n appliedTheme: string;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\n/** Storage keys */\nconst THEME_STORAGE_KEY = \"theme\";\nconst MODE_STORAGE_KEY = \"theme-mode\";\n\n/**\n * Get the system preferred color scheme\n */\nfunction getSystemMode(): ResolvedMode {\n if (typeof window === \"undefined\") return \"light\";\n return window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n}\n\n/**\n * Resolve the color mode (handle 'system' preference)\n */\nfunction resolveMode(mode: ColorMode): ResolvedMode {\n if (mode === \"system\") {\n return getSystemMode();\n }\n return mode;\n}\n\nexport interface ThemeProviderProps {\n children: React.ReactNode;\n /** Available themes (will be merged with built-in themes) */\n themes?: readonly ThemeDefinition[] | ThemeDefinition[];\n /** Default theme name */\n defaultTheme?: string;\n /** Default color mode */\n defaultMode?: ColorMode;\n}\n\n/**\n * Unified ThemeProvider component\n *\n * @example\n * ```tsx\n * // Basic usage with built-in themes\n * <ThemeProvider defaultTheme=\"wireframe\" defaultMode=\"light\">\n * <App />\n * </ThemeProvider>\n *\n * // With custom themes from orbital schema\n * import { THEMES } from './generated/theme-manifest';\n * <ThemeProvider themes={THEMES} defaultTheme=\"ocean\" defaultMode=\"system\">\n * <App />\n * </ThemeProvider>\n * ```\n */\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n children,\n themes = [],\n defaultTheme = \"wireframe\",\n defaultMode = \"system\",\n}) => {\n // Merge built-in themes with custom themes\n const availableThemes = useMemo(() => {\n const themeMap = new Map<string, ThemeDefinition>();\n // Add built-in themes first\n BUILT_IN_THEMES.forEach((t) => themeMap.set(t.name, t));\n // Custom themes override built-in if same name\n themes.forEach((t) => themeMap.set(t.name, t));\n return Array.from(themeMap.values());\n }, [themes]);\n\n // Initialize theme from storage or default\n const [theme, setThemeState] = useState<string>(() => {\n if (typeof window === \"undefined\") return defaultTheme;\n const stored = localStorage.getItem(THEME_STORAGE_KEY);\n // Validate stored theme exists\n const validThemes = [\n ...BUILT_IN_THEMES.map((t) => t.name),\n ...themes.map((t) => t.name),\n ];\n if (stored && validThemes.includes(stored)) {\n return stored;\n }\n return defaultTheme;\n });\n\n // Initialize mode from storage or default\n const [mode, setModeState] = useState<ColorMode>(() => {\n if (typeof window === \"undefined\") return defaultMode;\n const stored = localStorage.getItem(MODE_STORAGE_KEY);\n if (stored === \"light\" || stored === \"dark\" || stored === \"system\") {\n return stored;\n }\n return defaultMode;\n });\n\n // Resolved mode (handles 'system' preference)\n const [resolvedMode, setResolvedMode] = useState<ResolvedMode>(() =>\n resolveMode(mode),\n );\n\n // The applied theme string (e.g., \"ocean-light\")\n const appliedTheme = useMemo(\n () => `${theme}-${resolvedMode}`,\n [theme, resolvedMode],\n );\n\n // Update resolved mode when mode changes or system preference changes\n useEffect(() => {\n const updateResolved = () => {\n setResolvedMode(resolveMode(mode));\n };\n\n updateResolved();\n\n // Listen for system theme changes\n if (mode === \"system\") {\n const mediaQuery = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handleChange = () => updateResolved();\n mediaQuery.addEventListener(\"change\", handleChange);\n return () => mediaQuery.removeEventListener(\"change\", handleChange);\n }\n return undefined;\n }, [mode]);\n\n // Apply theme to document\n useEffect(() => {\n const root = document.documentElement;\n root.setAttribute(\"data-theme\", appliedTheme);\n\n // Also set class for Tailwind dark: variant compatibility\n root.classList.remove(\"light\", \"dark\");\n root.classList.add(resolvedMode);\n }, [appliedTheme, resolvedMode]);\n\n // Set theme\n const setTheme = useCallback(\n (newTheme: string) => {\n const validTheme = availableThemes.find((t) => t.name === newTheme);\n if (validTheme) {\n setThemeState(newTheme);\n if (typeof window !== \"undefined\") {\n localStorage.setItem(THEME_STORAGE_KEY, newTheme);\n }\n } else {\n console.warn(\n `Theme \"${newTheme}\" not found. Available: ${availableThemes.map((t) => t.name).join(\", \")}`,\n );\n }\n },\n [availableThemes],\n );\n\n // Set mode\n const setMode = useCallback((newMode: ColorMode) => {\n setModeState(newMode);\n if (typeof window !== \"undefined\") {\n localStorage.setItem(MODE_STORAGE_KEY, newMode);\n }\n }, []);\n\n // Toggle between light and dark\n const toggleMode = useCallback(() => {\n const newMode: ColorMode = resolvedMode === \"dark\" ? \"light\" : \"dark\";\n setMode(newMode);\n }, [resolvedMode, setMode]);\n\n const contextValue = useMemo<ThemeContextValue>(\n () => ({\n theme,\n mode,\n resolvedMode,\n setTheme,\n setMode,\n toggleMode,\n availableThemes,\n appliedTheme,\n }),\n [\n theme,\n mode,\n resolvedMode,\n setTheme,\n setMode,\n toggleMode,\n availableThemes,\n appliedTheme,\n ],\n );\n\n return (\n <ThemeContext.Provider value={contextValue}>\n {children}\n </ThemeContext.Provider>\n );\n};\n\n/**\n * Hook for accessing theme context\n *\n * @returns Theme context value\n *\n * @example\n * ```tsx\n * const { theme, resolvedMode, toggleMode, setTheme } = useTheme();\n *\n * // Toggle dark mode\n * <button onClick={toggleMode}>\n * {resolvedMode === 'dark' ? 'Light' : 'Dark'}\n * </button>\n *\n * // Change theme\n * <select value={theme} onChange={(e) => setTheme(e.target.value)}>\n * {availableThemes.map(t => (\n * <option key={t.name} value={t.name}>{t.displayName || t.name}</option>\n * ))}\n * </select>\n * ```\n */\nexport function useTheme(): ThemeContextValue {\n const context = useContext(ThemeContext);\n if (context === undefined) {\n // Return a default implementation for storybook/testing\n return {\n theme: \"wireframe\",\n mode: \"light\",\n resolvedMode: \"light\",\n setTheme: () => {},\n setMode: () => {},\n toggleMode: () => {},\n availableThemes: BUILT_IN_THEMES,\n appliedTheme: \"wireframe-light\",\n };\n }\n return context;\n}\n\n// Legacy exports for backward compatibility\nexport type Theme = ColorMode;\nexport type ResolvedTheme = ResolvedMode;\nexport type DesignTheme = ThemeDefinition;\n\nexport default ThemeContext;\n","/**\n * DesignThemeContext - DEPRECATED\n *\n * This module is deprecated. Use the unified ThemeProvider from ThemeContext instead.\n *\n * @deprecated Use ThemeProvider and useTheme from './ThemeContext' instead\n * @packageDocumentation\n */\n\nimport {\n useTheme,\n ThemeProvider,\n BUILT_IN_THEMES,\n type ThemeDefinition,\n} from \"./ThemeContext\";\n\n/** @deprecated Use ThemeDefinition from ThemeContext */\nexport type DesignTheme = string;\n\n/**\n * @deprecated Use ThemeProvider from ThemeContext instead\n */\nexport const DesignThemeProvider = ThemeProvider;\n\n/**\n * @deprecated Use useTheme from ThemeContext instead\n *\n * This wrapper provides backward compatibility with the old API.\n */\nexport function useDesignTheme() {\n const { theme, setTheme, availableThemes } = useTheme();\n\n return {\n designTheme: theme,\n setDesignTheme: setTheme,\n availableThemes: availableThemes.map((t) => t.name),\n };\n}\n\nexport default { DesignThemeProvider, useDesignTheme };\n","/**\n * UserContext\n *\n * React context for providing user data throughout the application.\n * Enables @user bindings in S-expressions for role-based UI and permissions.\n *\n * Usage:\n * ```tsx\n * // In App.tsx or layout\n * <UserProvider user={{ id: '123', role: 'admin', permissions: ['read', 'write'] }}>\n * <App />\n * </UserProvider>\n *\n * // In components - access via hook\n * const { user, hasRole, hasPermission } = useUser();\n * if (hasRole('admin')) { ... }\n * if (hasPermission('delete')) { ... }\n * ```\n *\n * @packageDocumentation\n */\n\nimport React, { createContext, useContext, useMemo, useCallback } from 'react';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * User data for @user bindings.\n * Matches UserContext type from evaluator/context.ts\n */\nexport interface UserData {\n /** User's unique ID */\n id: string;\n /** User's email */\n email?: string;\n /** User's display name */\n name?: string;\n /** User's role (for RBAC) */\n role?: string;\n /** User's permissions */\n permissions?: string[];\n /** Additional custom profile fields */\n [key: string]: unknown;\n}\n\n/**\n * User context value.\n */\nexport interface UserContextValue {\n /** Current user data (null if not logged in) */\n user: UserData | null;\n /** Check if user is logged in */\n isLoggedIn: boolean;\n /** Check if user has a specific role */\n hasRole: (role: string) => boolean;\n /** Check if user has a specific permission */\n hasPermission: (permission: string) => boolean;\n /** Check if user has any of the specified roles */\n hasAnyRole: (roles: string[]) => boolean;\n /** Check if user has all of the specified permissions */\n hasAllPermissions: (permissions: string[]) => boolean;\n /** Get a user field by path (for @user.field bindings) */\n getUserField: (path: string) => unknown;\n}\n\n// ============================================================================\n// Anonymous User\n// ============================================================================\n\n/**\n * Anonymous user for when no user is logged in.\n */\nconst ANONYMOUS_USER: UserData = {\n id: 'anonymous',\n role: 'anonymous',\n permissions: [],\n};\n\n// ============================================================================\n// Context\n// ============================================================================\n\nconst UserContext = createContext<UserContextValue | null>(null);\n\n// ============================================================================\n// Provider\n// ============================================================================\n\nexport interface UserProviderProps {\n /** User data (null if not logged in) */\n user?: UserData | null;\n /** Children to render */\n children: React.ReactNode;\n}\n\n/**\n * Provider component that provides user context to the application.\n *\n * Provides RBAC helpers and field access for @user bindings.\n */\nexport function UserProvider({\n user = null,\n children,\n}: UserProviderProps): React.ReactElement {\n // Role check helper\n const hasRole = useCallback(\n (role: string): boolean => {\n if (!user) return role === 'anonymous';\n return user.role === role;\n },\n [user]\n );\n\n // Permission check helper\n const hasPermission = useCallback(\n (permission: string): boolean => {\n if (!user) return false;\n return user.permissions?.includes(permission) ?? false;\n },\n [user]\n );\n\n // Multiple role check\n const hasAnyRole = useCallback(\n (roles: string[]): boolean => {\n if (!user) return roles.includes('anonymous');\n return user.role ? roles.includes(user.role) : false;\n },\n [user]\n );\n\n // Multiple permission check\n const hasAllPermissions = useCallback(\n (permissions: string[]): boolean => {\n if (!user || !user.permissions) return false;\n return permissions.every((p) => user.permissions?.includes(p));\n },\n [user]\n );\n\n // Field access for @user.field bindings\n const getUserField = useCallback(\n (path: string): unknown => {\n const userData = user ?? ANONYMOUS_USER;\n const parts = path.split('.');\n let value: unknown = userData;\n\n for (const segment of parts) {\n if (value === null || value === undefined) {\n return undefined;\n }\n if (typeof value === 'object') {\n value = (value as Record<string, unknown>)[segment];\n } else {\n return undefined;\n }\n }\n\n return value;\n },\n [user]\n );\n\n // Build context value\n const contextValue = useMemo<UserContextValue>(\n () => ({\n user,\n isLoggedIn: user !== null,\n hasRole,\n hasPermission,\n hasAnyRole,\n hasAllPermissions,\n getUserField,\n }),\n [user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]\n );\n\n return <UserContext.Provider value={contextValue}>{children}</UserContext.Provider>;\n}\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook to access the user context.\n *\n * Returns default values if used outside of UserProvider (for resilience).\n *\n * @example\n * ```tsx\n * function AdminPanel() {\n * const { user, hasRole, hasPermission } = useUser();\n *\n * if (!hasRole('admin') && !hasPermission('admin:access')) {\n * return <AccessDenied />;\n * }\n *\n * return <div>Welcome, {user?.name}</div>;\n * }\n * ```\n */\nexport function useUser(): UserContextValue {\n const context = useContext(UserContext);\n\n // Return defaults if not in provider (for resilience)\n if (!context) {\n return {\n user: null,\n isLoggedIn: false,\n hasRole: (role) => role === 'anonymous',\n hasPermission: () => false,\n hasAnyRole: (roles) => roles.includes('anonymous'),\n hasAllPermissions: () => false,\n getUserField: () => undefined,\n };\n }\n\n return context;\n}\n\n// ============================================================================\n// Utility Hooks\n// ============================================================================\n\n/**\n * Hook to check if user has a specific role.\n * Convenience wrapper around useUser().hasRole().\n */\nexport function useHasRole(role: string): boolean {\n const { hasRole } = useUser();\n return hasRole(role);\n}\n\n/**\n * Hook to check if user has a specific permission.\n * Convenience wrapper around useUser().hasPermission().\n */\nexport function useHasPermission(permission: string): boolean {\n const { hasPermission } = useUser();\n return hasPermission(permission);\n}\n\n/**\n * Hook to get user data for @user bindings in S-expressions.\n * Returns the user data object compatible with EvaluationContext.user\n */\nexport function useUserForEvaluation(): UserData | undefined {\n const { user, isLoggedIn } = useUser();\n return isLoggedIn && user ? user : undefined;\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\nexport { UserContext, ANONYMOUS_USER };\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Bus Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the page event bus system.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A KFlow event that can be emitted on the event bus.
|
|
10
|
+
*/
|
|
11
|
+
interface KFlowEvent {
|
|
12
|
+
/** Event type identifier (e.g., 'TASK_COMPLETED', 'VALIDATION_SUCCESS') */
|
|
13
|
+
type: string;
|
|
14
|
+
/** Optional payload data */
|
|
15
|
+
payload?: Record<string, unknown>;
|
|
16
|
+
/** Timestamp when the event was emitted */
|
|
17
|
+
timestamp: number;
|
|
18
|
+
/** Source trait or component that emitted the event */
|
|
19
|
+
source?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Event listener callback function.
|
|
23
|
+
*/
|
|
24
|
+
type EventListener = (event: KFlowEvent) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Function to unsubscribe from events.
|
|
27
|
+
*/
|
|
28
|
+
type Unsubscribe = () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Event bus context type.
|
|
31
|
+
*/
|
|
32
|
+
interface EventBusContextType {
|
|
33
|
+
/**
|
|
34
|
+
* Emit an event to all listeners.
|
|
35
|
+
*
|
|
36
|
+
* @param type - Event type identifier
|
|
37
|
+
* @param payload - Optional payload data
|
|
38
|
+
*/
|
|
39
|
+
emit: (type: string, payload?: Record<string, unknown>) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Subscribe to an event type.
|
|
42
|
+
*
|
|
43
|
+
* @param type - Event type to listen for
|
|
44
|
+
* @param listener - Callback function
|
|
45
|
+
* @returns Unsubscribe function
|
|
46
|
+
*/
|
|
47
|
+
on: (type: string, listener: EventListener) => Unsubscribe;
|
|
48
|
+
/**
|
|
49
|
+
* Subscribe to an event type, but only fire once.
|
|
50
|
+
*
|
|
51
|
+
* @param type - Event type to listen for
|
|
52
|
+
* @param listener - Callback function
|
|
53
|
+
* @returns Unsubscribe function
|
|
54
|
+
*/
|
|
55
|
+
once: (type: string, listener: EventListener) => Unsubscribe;
|
|
56
|
+
/**
|
|
57
|
+
* Check if there are any listeners for an event type.
|
|
58
|
+
*
|
|
59
|
+
* @param type - Event type to check
|
|
60
|
+
* @returns True if there are listeners
|
|
61
|
+
*/
|
|
62
|
+
hasListeners: (type: string) => boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type { EventBusContextType as E, KFlowEvent as K, Unsubscribe as U, EventListener as a };
|