/** @jsxRuntime classic */ /** @jsx jsx */ import { Children, type ReactNode } from 'react' import { jsx } from '../emotion' import { forwardRefWithAs, getChildTag } from '../utils' import { type Theme } from '../types' import { useTheme } from '../theme' import { Box, type BoxProps } from './Box' const alignment = { center: 'center', end: 'flex-end', start: 'flex-start', stretch: 'stretch', } type InlineProps = { /** The value of the "align-items" property. */ align?: keyof typeof alignment /** Each item in the container. */ children: ReactNode /** The size of the gap between each item. */ gap?: keyof Theme['spacing'] } & BoxProps export const Inline = forwardRefWithAs<'div', InlineProps>( ({ align = 'start', children, gap = 'none', ...props }, ref) => { const { spacing } = useTheme() const resolvedAlign = alignment[align] const resolvedGap = spacing[gap] const ChildWrapper = getChildTag(props.as) return ( {Children.map(children, child => child !== null && child !== undefined ? ( {child} ) : null )} ) } )