/** * RTL Utility Functions * * Helper functions for handling Right-to-Left (RTL) layouts and styling. * These utilities help components adapt to RTL direction automatically. */ import { ViewStyle, TextStyle, ImageStyle } from 'react-native'; /** * Type for flex direction values */ type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse'; /** * Type for alignment values */ type Alignment = 'left' | 'right' | 'center' | 'flex-start' | 'flex-end'; /** * Flip horizontal flex direction based on RTL state * * @param direction - The flex direction to potentially flip * @param isRTL - Whether the current direction is RTL * @returns The flipped direction if RTL and horizontal, otherwise original * * @example * ```tsx * const { isRTL } = useDirection(); * const flexDirection = flipDirection('row', isRTL); // 'row-reverse' in RTL * ``` */ export declare function flipDirection(direction: FlexDirection, isRTL: boolean): FlexDirection; /** * Flip horizontal value (useful for transforms, positions) * * @param value - The numeric value to flip * @param isRTL - Whether the current direction is RTL * @returns Negative value if RTL, positive if LTR * * @example * ```tsx * const translateX = flipHorizontal(100, isRTL); // -100 in RTL * ``` */ export declare function flipHorizontal(value: number, isRTL: boolean): number; /** * Get physical property name from logical property * * @param prop - Logical property name ('start' or 'end') * @param isRTL - Whether the current direction is RTL * @returns Physical property name ('left' or 'right') * * @example * ```tsx * const side = getLogicalProperty('start', isRTL); // 'right' in RTL, 'left' in LTR * ``` */ export declare function getLogicalProperty(prop: 'start' | 'end', isRTL: boolean): 'left' | 'right'; /** * Swap left/right values in a style object for RTL * * @param style - Style object to transform * @param isRTL - Whether the current direction is RTL * @returns Transformed style object * * @example * ```tsx * const style = transformRTLStyle({ marginLeft: 10, marginRight: 20 }, true); * // Returns: { marginLeft: 20, marginRight: 10 } * ``` */ export declare function transformRTLStyle(style: T, isRTL: boolean): T; /** * Flip text alignment for RTL * * @param align - The alignment to flip * @param isRTL - Whether the current direction is RTL * @returns Flipped alignment */ export declare function flipAlignment(align: Alignment, isRTL: boolean): Alignment; /** * List of icon names that should be mirrored in RTL * These are directional icons that point left or right */ declare const DEFAULT_MIRRORABLE_ICONS: string[]; /** * Check if an icon should be mirrored in RTL * * @param iconName - The name of the icon * @param isRTL - Whether the current direction is RTL * @param customMirrorableIcons - Optional custom list of mirrorable icons * @returns Whether the icon should be mirrored * * @example * ```tsx * const shouldMirror = shouldMirrorIcon('chevron-right', isRTL); * const transform = shouldMirror ? [{ scaleX: -1 }] : undefined; * ``` */ export declare function shouldMirrorIcon(iconName: string, isRTL: boolean, customMirrorableIcons?: string[]): boolean; /** * Get transform style for mirroring an icon * * @param iconName - The name of the icon * @param isRTL - Whether the current direction is RTL * @param customMirrorableIcons - Optional custom list of mirrorable icons * @returns Transform array for horizontal flip or undefined * * @example * ```tsx * const transform = getIconMirrorTransform('chevron-right', isRTL); * * ``` */ export declare function getIconMirrorTransform(iconName: string, isRTL: boolean, customMirrorableIcons?: string[]): { scaleX: number; }[] | undefined; /** * Swap start and end values in an object * Useful for converting logical property values * * @example * ```tsx * const spacing = { start: 10, end: 20 }; * const swapped = swapStartEnd(spacing, isRTL); * // Returns: { start: 20, end: 10 } in RTL * ``` */ export declare function swapStartEnd>(obj: T, isRTL: boolean): T; /** * Get text writing direction for TextInput * * @param isRTL - Whether the current direction is RTL * @returns 'rtl' or 'ltr' */ export declare function getWritingDirection(isRTL: boolean): 'rtl' | 'ltr'; /** * Get default text alignment based on direction * * @param isRTL - Whether the current direction is RTL * @returns 'right' in RTL, 'left' in LTR */ export declare function getDefaultTextAlign(isRTL: boolean): 'left' | 'right'; /** * Mirror a placement string (e.g., for tooltips, popovers) * * @param placement - Placement string (e.g., 'left', 'right', 'top-start') * @param isRTL - Whether the current direction is RTL * @returns Mirrored placement * * @example * ```tsx * const placement = mirrorPlacement('left-start', isRTL); * // Returns 'right-start' in RTL * ``` */ export declare function mirrorPlacement(placement: string, isRTL: boolean): string; /** * Reverse an array if RTL * Useful for reversing breadcrumbs, pagination, etc. * * @param array - Array to potentially reverse * @param isRTL - Whether the current direction is RTL * @returns Reversed array if RTL, original if LTR * * @example * ```tsx * const items = [1, 2, 3]; * const displayed = reverseArray(items, isRTL); * // Returns [3, 2, 1] in RTL * ``` */ export declare function reverseArray(array: T[], isRTL: boolean): T[]; /** * Export the default list of mirrorable icons for customization */ export { DEFAULT_MIRRORABLE_ICONS };