UNPKG

watercolor-ui

Version:

A modern minimalist cross-framework component library

219 lines 7.03 kB
/** * Toggle switch state * @param {boolean} currentState - Current switch state * @param {boolean} disabled - Whether switch is disabled * @returns {boolean} New state */ export function toggleState(currentState: boolean, disabled?: boolean): boolean; /** * Handle controlled state change * @param {boolean} newState - New state value * @param {Function} onChange - Change handler * @param {Object} config - Configuration options * @returns {boolean} Whether change was handled */ export function handleStateChange(newState: boolean, onChange: Function, config?: Object): boolean; /** * Get switch state from props * @param {Object} props - Component props * @returns {Object} State information */ export function getSwitchState(props?: Object): Object; /** * Handle click event * @param {Event} event - Click event * @param {boolean} currentState - Current state * @param {Function} onChange - Change handler * @param {Object} config - Configuration * @returns {boolean} New state */ export function handleClick(event: Event, currentState: boolean, onChange: Function, config?: Object): boolean; /** * Handle keyboard event * @param {Event} event - Keyboard event * @param {boolean} currentState - Current state * @param {Function} onChange - Change handler * @param {Object} config - Configuration * @returns {boolean} New state */ export function handleKeyDown(event: Event, currentState: boolean, onChange: Function, config?: Object): boolean; /** * Handle focus event * @param {Event} event - Focus event * @param {Function} onFocus - Focus handler * @param {Object} config - Configuration */ export function handleFocus(event: Event, onFocus: Function, config?: Object): void; /** * Handle blur event * @param {Event} event - Blur event * @param {Function} onBlur - Blur handler * @param {Object} config - Configuration */ export function handleBlur(event: Event, onBlur: Function, config?: Object): void; /** * Generate class names for switch container * @param {Object} props - Component props * @returns {string} Class names */ export function getSwitchClasses(props?: Object): string; /** * Generate class names for switch track * @param {Object} props - Component props * @returns {string} Class names */ export function getTrackClasses(props?: Object): string; /** * Generate class names for switch thumb * @param {Object} props - Component props * @returns {string} Class names */ export function getThumbClasses(props?: Object): string; /** * Validate switch props * @param {Object} props - Component props * @returns {Object} Validation result */ export function validateProps(props?: Object): Object; /** * Validate switch value * @param {*} value - Value to validate * @param {Object} rules - Validation rules * @returns {Object} Validation result */ export function validateValue(value: any, rules?: Object): Object; /** * Generate ARIA attributes for switch * @param {Object} props - Component props * @returns {Object} ARIA attributes */ export function getAriaAttributes(props?: Object): Object; /** * Generate accessibility description * @param {Object} props - Component props * @returns {string} Accessibility description */ export function getAccessibilityDescription(props?: Object): string; /** * Get thumb position based on state * @param {boolean} checked - Switch state * @param {Object} config - Configuration * @returns {Object} Position styles */ export function getThumbPosition(checked: boolean, config?: Object): Object; /** * Get track background based on state * @param {boolean} checked - Switch state * @param {Object} config - Configuration * @returns {string} Background color */ export function getTrackBackground(checked: boolean, config?: Object): string; /** * Create form field data for switch * @param {Object} props - Component props * @returns {Object} Form field data */ export function createFormField(props?: Object): Object; /** * Extract form data from switch * @param {Object} switchData - Switch data * @returns {Object} Form data */ export function extractFormData(switchData?: Object): Object; /** * Debounce switch change handler * @param {Function} handler - Change handler * @param {number} delay - Debounce delay * @returns {Function} Debounced handler */ export function debounceChange(handler: Function, delay?: number): Function; /** * Throttle switch change handler * @param {Function} handler - Change handler * @param {number} delay - Throttle delay * @returns {Function} Throttled handler */ export function throttleChange(handler: Function, delay?: number): Function; /** * Format switch value for display * @param {boolean} value - Switch value * @param {Object} config - Format configuration * @returns {string} Formatted value */ export function formatValue(value: boolean, config?: Object): string; /** * Parse switch value from string * @param {string} value - String value * @returns {boolean} Parsed boolean value */ export function parseValue(value: string): boolean; /** * Check if switch should show loading state * @param {Object} props - Component props * @returns {boolean} Whether to show loading */ export function shouldShowLoading(props?: Object): boolean; /** * Check if switch is interactive * @param {Object} props - Component props * @returns {boolean} Whether switch is interactive */ export function isInteractive(props?: Object): boolean; export namespace SWITCH_SIZES { let sm: string; let md: string; let lg: string; } export namespace SWITCH_COLORS { let primary: string; let secondary: string; let success: string; let warning: string; let error: string; } export namespace SWITCH_VARIANTS { let _default: string; export { _default as default }; export let rounded: string; export let square: string; export let flat: string; export let outline: string; export let ios: string; export let material: string; } export namespace KEY_CODES { let SPACE: number; let ENTER: number; } declare namespace _default { export { SWITCH_SIZES }; export { SWITCH_COLORS }; export { SWITCH_VARIANTS }; export { KEY_CODES }; export { toggleState }; export { handleStateChange }; export { getSwitchState }; export { handleClick }; export { handleKeyDown }; export { handleFocus }; export { handleBlur }; export { getSwitchClasses }; export { getTrackClasses }; export { getThumbClasses }; export { validateProps }; export { validateValue }; export { getAriaAttributes }; export { getAccessibilityDescription }; export { getThumbPosition }; export { getTrackBackground }; export { createFormField }; export { extractFormData }; export { debounceChange }; export { throttleChange }; export { formatValue }; export { parseValue }; export { shouldShowLoading }; export { isInteractive }; } export default _default; //# sourceMappingURL=utils.d.ts.map