import { mergeProps } from "@seed-design/dom-utils"; import * as React from "react"; import type { ResponsiveValue } from "../../types/responsive"; import { resolveResponsive, type DistributiveOmit } from "../../utils/styled"; import { Box, type BoxProps } from "../Box/Box"; export type GridProps = DistributiveOmit & { /** * @default "grid" */ display?: ResponsiveValue<"grid" | "none">; /** * Shorthand for `alignItems`. */ align?: BoxProps["alignItems"]; /** * Shorthand for `justifyContent`. */ justify?: BoxProps["justifyContent"]; justifyItems?: "flex-start" | "flex-end" | "center" | "stretch"; /** * Shorthand for `gridTemplateColumns`. * If number, `repeat({columns}, minmax(0, 1fr))` is applied. */ columns?: ResponsiveValue; /** * Shorthand for `gridTemplateRows`. * If number, `repeat({rows}, minmax(0, 1fr))` is applied. */ rows?: ResponsiveValue; // NOTE: grid-template-areas not currently supported here. // since grid-area is a shorthand of grid-column/row (in a grid item), // if we bind grid-area CSS variable together, it causes conflict. /** * Shorthand for `gridAutoFlow`. */ autoFlow?: "row" | "column" | "row dense" | "column dense"; /** * Shorthand for `gridAutoColumns`. */ autoColumns?: string; /** * Shorthand for `gridAutoRows`. */ autoRows?: string; }; function handleGridTemplate(v: number | string): string { return typeof v === "number" ? `repeat(${v}, minmax(0, 1fr))` : v; } export const Grid = React.forwardRef((props, ref) => { const { align, justify, justifyItems, columns, rows, autoFlow, autoColumns, autoRows, ...rest } = props; return ( ); });