UNPKG

@birhaus/core

Version:

BIRHAUS Core Components - UndoSystem, CommandPalette, AuditTimeline

138 lines (132 loc) 4.14 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import * as React$1 from 'react'; import { ReactNode } from 'react'; interface UndoAction$1 { id: string; type: 'create' | 'update' | 'delete' | 'transfer' | 'approve'; entityType: string; entityId: string; description: string; undoFunction: () => Promise<void>; createdAt: Date; expiresAt: Date; priority: 'low' | 'normal' | 'high' | 'critical'; icon?: ReactNode; metadata?: Record<string, unknown>; } interface UndoContextType { actions: UndoAction$1[]; addAction: (action: Omit<UndoAction$1, 'id' | 'createdAt' | 'expiresAt'>) => string; undoAction: (actionId: string) => Promise<void>; dismissAction: (actionId: string) => void; clearExpired: () => void; getActionsByType: (type: string) => UndoAction$1[]; } declare function useUndo(): UndoContextType; interface UndoProviderProps { children: ReactNode; defaultTimeoutMs?: number; maxActions?: number; } declare function UndoProvider({ children, defaultTimeoutMs, // 10 seconds default maxActions }: UndoProviderProps): react_jsx_runtime.JSX.Element; declare function useUndoAction(): { createUndoableAction: (description: string, undoFunction: () => Promise<void>, options: { type?: UndoAction$1["type"]; entityType: string; entityId: string; priority?: UndoAction$1["priority"]; icon?: ReactNode; timeoutMs?: number; }) => string; }; interface CommandItem { id: string; title: string; description?: string; icon?: React$1.ElementType; category?: string; keywords?: string[]; action: () => void; shortcut?: string; } interface CommandPaletteProps { items: CommandItem[]; placeholder?: string; emptyMessage?: string; recentLabel?: string; maxRecent?: number; } declare function CommandPalette({ items, placeholder, emptyMessage, recentLabel, maxRecent }: CommandPaletteProps): react_jsx_runtime.JSX.Element | null; /** * BIRHAUS Core Types */ interface UndoAction { id: string; type: 'create' | 'update' | 'delete' | 'transfer' | 'approve'; entityType: string; entityId: string; description: string; undoFunction: () => Promise<void>; createdAt: Date; expiresAt: Date; priority: 'low' | 'normal' | 'high' | 'critical'; icon?: React.ReactNode; metadata?: Record<string, unknown>; } interface CognitiveLoadMetrics { visibleChoices: number; primaryNavItems: number; contextualActions: number; primaryActions: number; formFields: number; tableColumns: number; violatesMillersLaw: boolean; violatesFourThreeOne: boolean; cognitiveLoadScore: number; } interface BirthausComplianceReport { score: number; violations: Array<{ principle: number; description: string; severity: 'low' | 'medium' | 'high' | 'critical'; suggestion: string; }>; metrics: CognitiveLoadMetrics; performance: { TTI: number; FCP: number; CLS: number; }; accessibility: { score: number; violations: string[]; }; } /** * BIRHAUS Constants * * Core limits and configuration values that enforce BIRHAUS principles */ declare const BIRHAUS_LIMITS: { readonly MAX_VISIBLE_CHOICES: 7; readonly MIN_VISIBLE_CHOICES: 5; readonly MAX_PRIMARY_NAV_ITEMS: 4; readonly MAX_CONTEXTUAL_ACTIONS: 3; readonly MAX_PRIMARY_ACTIONS: 1; readonly MAX_FIELDS_PER_STEP: 5; readonly MAX_FORM_STEPS: 4; readonly MAX_TTI: 2000; readonly MAX_FCP: 1000; readonly MAX_CLS: 0.1; readonly DEFAULT_TABLE_COLUMNS: 7; readonly MAX_TABLE_ROWS_BEFORE_VIRTUALIZATION: 100; readonly DEFAULT_UNDO_TIMEOUT: 10000; readonly MAX_UNDO_ACTIONS: 5; readonly MIN_TOUCH_TARGET: 44; readonly MIN_CONTRAST_RATIO: 4.5; readonly DEFAULT_TRANSITION_DURATION: 150; readonly REDUCE_MOTION_DURATION: 0; }; export { BIRHAUS_LIMITS, type BirthausComplianceReport, type CognitiveLoadMetrics, CommandPalette, type UndoAction, UndoProvider, useUndo, useUndoAction };