import React from "react"; import UI from "../ui"; import type { RowProps } from "./row.types"; // Re-export types for convenience export type { RowProps } from "./row.types"; /** * Row - A flex container component for 12-column layouts. * * Row provides a type-safe React wrapper around the .col-row utility class, * allowing developers to create responsive column layouts with customizable * gap, alignment, and wrapping behavior. Always includes the .col-row base * class and adds variant utilities based on props. * * ## Key Features * - **Flex Container**: Display flex with wrap enabled by default * - **Customizable Gap**: Control spacing between columns with gap prop * - **Alignment Control**: Justify and align props for layout control * - **Polymorphic**: Render as any semantic HTML element * - **Type-Safe**: Full TypeScript support with literal types * * ## Use Cases * - Multi-column layouts * - Responsive grid systems * - Card grids * - Dashboard layouts * - Form layouts * * @example * // Basic two-column layout * * Left column * Right column * * * @example * // Custom gap and centered alignment * * Column 1 * Column 2 * Column 3 * * * @example * // Semantic HTML with list elements * * Item 1 * Item 2 * Item 3 * * * @example * // Proportional layout - maintains columns on tablets and larger * * Column 1 (50% on tablets+) * Column 2 (50% on tablets+) * * * @see {@link RowProps} for complete props documentation */ export const Row = React.forwardRef( ( { gap, justify, align, wrap, alwaysProportional = false, as = "div", className, classes, children, ...props }, ref ) => { // Deprecation warning in development if (process.env.NODE_ENV === "development" && alwaysProportional) { // eslint-disable-next-line no-console console.warn( "[fpkit] Row: alwaysProportional is deprecated and will be removed in v5.0.0. " + 'Use responsive column utilities instead: className="col-sm-6 col-md-4"' ); } // Build utility classes array - ALWAYS include base class const utilityClasses: string[] = ["col-row"]; // Gap utilities - override default gap if (gap) { utilityClasses.push(`col-row-gap-${gap}`); } // Justify content utilities if (justify) { utilityClasses.push(`col-row-justify-${justify}`); } // Align items utilities if (align) { utilityClasses.push(`col-row-align-${align}`); } // Wrap utilities - only add if not default "wrap" if (wrap && wrap !== "wrap") { utilityClasses.push(`col-row-${wrap}`); } // Proportional layout mode - prevents stacking on tablets and larger if (alwaysProportional) { utilityClasses.push("col-row-proportional"); } // Merge all classes: utilities + className + classes const allClasses = [...utilityClasses, className, classes] .filter(Boolean) .join(" "); return ( {children} ); } ); Row.displayName = "Row"; export default Row;