import { SecurityLevel } from "../types/cia"; /** * Widget helper utilities for formatting, sanitization, and display * * Provides utility functions for widget rendering, error handling, and ID * sanitization to ensure consistent widget behavior across the application. * * @example * ```typescript * import { formatSecurityLevel, sanitizeWidgetId, handleWidgetError } from './widgetHelpers'; * * // Format security level * const level = formatSecurityLevel('high'); // 'High' * * // Sanitize widget ID * const id = sanitizeWidgetId('My Widget!'); // 'My-Widget-' * * // Handle widget errors * const errorMsg = handleWidgetError(new Error('Failed to load')); * // 'Error: Failed to load' * ``` */ /** * Format security level string to the standardized format * * Normalizes security level strings to match the SecurityLevel enum values, * handling case variations and trimming whitespace. Essential for ensuring * consistent level representation across the application. * * @param level - Security level string to format * @returns Formatted security level matching SecurityLevel enum * * @example * ```typescript * formatSecurityLevel('high') // 'High' * formatSecurityLevel('VERY HIGH') // 'Very High' * formatSecurityLevel(' low ') // 'Low' * formatSecurityLevel(null) // 'None' * formatSecurityLevel(undefined) // 'None' * formatSecurityLevel('invalid') // 'None' (defaults to None) * ``` */ export declare function formatSecurityLevel(level: SecurityLevel | string | null | undefined): SecurityLevel | string; export declare const getRiskLevelColorClass: (riskLevel: string) => string; export declare const getWidgetColumnSpan: (_size: string) => string; export declare const getWidgetRowSpan: (_size: string) => string; /** * Handle widget errors and format error messages consistently * * Provides consistent error message formatting across all widgets, * handling null/undefined errors gracefully with fallback messages. * * @param error - Error object or null/undefined * @returns Formatted error message string * * @example * ```typescript * handleWidgetError(new Error('Network failed')) // 'Error: Network failed' * handleWidgetError(null) // 'Error: Unknown error' * handleWidgetError(undefined) // 'Error: Unknown error' * * // Usage in error boundary * try { * await loadWidgetData(); * } catch (error) { * const message = handleWidgetError(error as Error); * showNotification(message); * } * ``` */ export declare const handleWidgetError: (error: Error | null | undefined) => string; export declare const KeyValuePair: (props: { label: string; value: string; }) => string; export declare const RiskLevelKeyValue: (props: { level: string; }) => string; /** * Sanitize widget ID to ensure valid HTML/CSS identifiers * * Removes special characters and replaces them with hyphens to create * valid HTML element IDs and CSS class names. Essential for dynamic * widget generation and proper DOM manipulation. * * @param id - Widget identifier string to sanitize * @returns Sanitized ID safe for use in HTML/CSS * * @example * ```typescript * sanitizeWidgetId('my-widget') // 'my-widget' * sanitizeWidgetId('My Widget!') // 'My-Widget-' * sanitizeWidgetId('widget#123') // 'widget-123' * sanitizeWidgetId('test@example.com') // 'test-example-com' * * // Usage in components * const widgetId = sanitizeWidgetId(userInput); *