@senka-ai/ui
Version:
A modern, type-safe Svelte 5 UI component library with full theme support, accessibility standards, and robust state management patterns
76 lines • 2.85 kB
TypeScript
/**
* Event handler utilities for consistent event handling across components
*/
export interface KeyboardEventConfig {
keys: string[];
preventDefault?: boolean;
stopPropagation?: boolean;
disabled?: boolean;
}
/**
* Creates a standardized keyboard event handler
*/
export declare function createKeyboardHandler(handler: () => void, config?: KeyboardEventConfig): (event: KeyboardEvent) => void;
/**
* Creates a click handler with disabled state support
*/
export declare function createClickHandler(handler: () => void, disabled?: boolean, stopPropagation?: boolean): (event?: Event) => void;
/**
* Creates a safe click handler that prevents action on interactive elements
* Useful for Card components and other containers with clickable children
*/
export declare function createSafeClickHandler(handler: () => void, disabled?: boolean): (event: MouseEvent) => void;
/**
* Common keyboard key sets for different component types
*/
export declare const KeySets: {
readonly ACTIVATION: readonly ["Enter", " "];
readonly NAVIGATION: readonly ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
readonly HORIZONTAL_NAVIGATION: readonly ["ArrowLeft", "ArrowRight"];
readonly VERTICAL_NAVIGATION: readonly ["ArrowUp", "ArrowDown"];
readonly ESCAPE: readonly ["Escape"];
readonly TAB: readonly ["Tab"];
readonly FORM_SUBMISSION: readonly ["Enter"];
readonly SPACE_ONLY: readonly [" "];
readonly ENTER_ONLY: readonly ["Enter"];
};
/**
* Navigation direction enum for better type safety
*/
export declare enum NavigationDirection {
UP = "up",
DOWN = "down",
LEFT = "left",
RIGHT = "right"
}
/**
* Interface for navigation handler configuration
*/
export interface NavigationConfig {
direction: 'horizontal' | 'vertical' | 'both';
wrap?: boolean;
disabled?: boolean;
preventDefault?: boolean;
}
/**
* Creates a navigation handler for arrow key navigation
* Useful for TabBar, dropdown menus, and other navigable components
*/
export declare function createNavigationHandler(onNavigate: (direction: NavigationDirection) => void, config?: NavigationConfig): (event: KeyboardEvent) => void;
/**
* Creates a combined activation and navigation handler
* Perfect for components like TabBar that need both activation and navigation
*/
export declare function createActivationNavigationHandler(onActivate: () => void, onNavigate: (direction: NavigationDirection) => void, config?: {
navigationConfig?: NavigationConfig;
activationConfig?: {
keys?: string[];
preventDefault?: boolean;
};
disabled?: boolean;
}): (event: KeyboardEvent) => void;
/**
* Check if an event target is an interactive element
*/
export declare function isInteractiveElement(element: EventTarget | null): boolean;
//# sourceMappingURL=events.d.ts.map