UNPKG

@zapstra/core-app-shell

Version:

Unified app shell with navigation slots for Zapstra platform apps

102 lines (96 loc) 3.1 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; interface NavigationItem { label: string; icon?: any; path: string; badge?: string; subItems?: Array<{ label: string; path: string; }>; } interface AppShellConfig { appId: string; appName?: string; logo?: { width?: number; topBarSource?: string; accessibilityLabel?: string; }; navigation?: NavigationItem[]; showMobileNavigation?: boolean; theme?: 'zapstra' | 'default'; } interface AppShellContext { config: AppShellConfig; navWidth: number; updateConfig: (updates: Partial<AppShellConfig>) => void; } interface RouteDefinition { path: string; label: string; icon?: any; parent?: string; order?: number; badge?: string; permissions?: string[]; } interface RouteRegistry { register: (appId: string, routes: RouteDefinition[]) => void; unregister: (appId: string) => void; getRoutes: (appId: string) => RouteDefinition[]; getAllRoutes: () => Record<string, RouteDefinition[]>; } interface AppShellProps { config: AppShellConfig; apiKey: string; children: React.ReactNode; isEmbeddedApp?: boolean; i18n?: any; showRouterSpinner?: boolean; } /** * Unified app shell that wraps apps with Shopify providers, navigation, and routing */ declare function AppShell({ config, apiKey, children, isEmbeddedApp, i18n, showRouterSpinner, }: AppShellProps): react_jsx_runtime.JSX.Element; /** * Hook to access app shell context */ declare function useAppShell(): AppShellContext; /** * Update navigation items dynamically */ declare function useUpdateNavigation(): (navigation: NavigationItem[]) => void; /** * Get current navigation width for layout calculations */ declare function useNavigationWidth(): number; /** * Simplified app shell for basic apps */ interface SimpleAppShellProps { appId: string; appName?: string; apiKey: string; navigation?: NavigationItem[]; children: React.ReactNode; theme?: "zapstra" | "default"; } declare function SimpleAppShell({ appId, appName, apiKey, navigation, children, theme, }: SimpleAppShellProps): react_jsx_runtime.JSX.Element; interface AppNavigationProps { items: NavigationItem[]; onWidthChange?: (width: number) => void; theme?: 'zapstra' | 'default'; } declare function AppNavigation({ items, onWidthChange, theme }: AppNavigationProps): react_jsx_runtime.JSX.Element; declare const routeRegistry: RouteRegistry; /** * Convert route definitions to navigation items */ declare function routesToNavigationItems(routes: RouteDefinition[]): NavigationItem[]; /** * Helper to register routes with proper typing */ declare function registerRoutes(appId: string, routes: RouteDefinition[]): void; export { AppNavigation, AppShell, type AppShellConfig, type AppShellContext, type NavigationItem, type RouteDefinition, type RouteRegistry, SimpleAppShell, registerRoutes, routeRegistry, routesToNavigationItems, useAppShell, useNavigationWidth, useUpdateNavigation };