import { Size } from '@idealyst/theme'; import type { Breakpoint } from '@idealyst/theme'; import type { ReactNode } from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import { ContainerStyleProps } from '../utils/viewStyleProps'; import type { LayoutChangeEvent } from '../hooks/useWebLayout'; export type { LayoutChangeEvent }; /** * Responsive column count - either a fixed number or a breakpoint map. * * @example * ```tsx * // Fixed columns * * * // Responsive columns * * ``` */ export type ResponsiveColumns = number | Partial>; /** * Gap size between grid items. Uses theme spacing values. */ export type GridGap = Size; /** * Cross-platform grid layout component. * * Arranges children into columns with consistent gap spacing. * Supports responsive column counts that adapt to screen size. * * - **Web**: Uses CSS Grid for optimal layout performance. * - **Native**: Uses percentage-based widths with flexbox wrapping. * * @example * ```tsx * * Item 1 * Item 2 * Item 3 * Item 4 * * ``` */ export interface GridProps extends ContainerStyleProps { /** Grid content - each direct child becomes a grid item */ children?: ReactNode; /** * Number of columns. Can be a fixed number or responsive breakpoint map. * @default 1 */ columns?: ResponsiveColumns; /** * Gap between grid items (both rows and columns). * Uses theme spacing values (theme.sizes.view[size].spacing). * @default 'md' */ gap?: GridGap; /** Additional styles applied to the grid container */ style?: StyleProp; /** Test ID for testing */ testID?: string; /** Called when the grid's layout changes */ onLayout?: (event: LayoutChangeEvent) => void; }