UNPKG

@birhaus/core

Version:

BIRHAUS Core Components - UndoSystem, CommandPalette, AuditTimeline

101 lines (77 loc) 2.25 kB
# @birhaus/core Core functionality for the BIRHAUS design system, implementing the foundational undo-over-confirm pattern and command management. ## Installation ```bash npm install @birhaus/core ``` ## Core Components ### UndoSystem The heart of BIRHAUS design philosophy - replacing annoying confirmation dialogs with user-friendly undo patterns. ```tsx import { UndoSystem } from '@birhaus/core' function DeleteButton() { return ( <button onClick={async () => { await deleteItem(itemId) UndoSystem.addAction({ messageEs: 'Elemento eliminado', messageEn: 'Item deleted', undoAction: () => restoreItem(itemId), timeout: 10000 }) }} > Eliminar </button> ) } ``` ### CommandPalette Spanish-first command interface with cognitive load optimization. ```tsx import { CommandPalette } from '@birhaus/core' const commands = [ { id: 'new-donation', labelEs: 'Nueva donación', labelEn: 'New donation', action: () => navigate('/donacion/nueva') } ] function App() { return ( <div> <CommandPalette commands={commands} placeholderEs="Buscar comando..." placeholderEn="Search command..." /> </div> ) } ``` ## BIRHAUS Principles Implemented - **Undo over Confirm**: Replace confirmation dialogs with undo actions - **Spanish-first**: All text content supports bilingual labeling - **Cognitive Load Reduction**: Command palette limits results to 7±2 items - **Accessibility**: Full keyboard navigation and screen reader support ## API Reference ### UndoSystem - `addAction(config)` - Add undoable action - `undo()` - Undo last action - `clear()` - Clear undo history - `getHistory()` - Get undo action history ### CommandPalette Props: - `commands` - Array of command definitions - `placeholderEs/En` - Search placeholder text - `maxResults` - Limit results (default: 7) - `onCommand` - Command execution callback ## Integration Works seamlessly with: - `@birhaus/primitives` - Use with BirhausButton undo patterns - `@birhaus/patterns` - Advanced workflow patterns - `@birhaus/themes` - Consistent visual theming ## License MIT - see [LICENSE](../../LICENSE) for details.