"use client" import { forwardRef } from "react" import { type ConditionalValue, type SystemStyleObject, chakra, } from "../../styled-system" import { compact, mapObject } from "../../utils" import type { BoxProps } from "../box" export interface GridItemProps extends BoxProps { area?: SystemStyleObject["gridArea"] | undefined colSpan?: ConditionalValue | undefined colStart?: ConditionalValue | undefined colEnd?: ConditionalValue | undefined rowStart?: ConditionalValue | undefined rowEnd?: ConditionalValue | undefined rowSpan?: ConditionalValue | undefined } function spanFn(span?: ConditionalValue) { return mapObject(span, (value) => value === "auto" ? "auto" : `span ${value}/span ${value}`, ) } export const GridItem = forwardRef( function GridItem(props, ref) { const { area, colSpan, colStart, colEnd, rowEnd, rowSpan, rowStart, ...rest } = props const styles = compact({ gridArea: area, gridColumn: spanFn(colSpan), gridRow: spanFn(rowSpan), gridColumnStart: colStart, gridColumnEnd: colEnd, gridRowStart: rowStart, gridRowEnd: rowEnd, }) return }, )