import { createElement, type AllHTMLAttributes, type ElementType, type Ref, } from 'react'; import clsx from 'clsx'; import * as resetStyles from '../styles/reset.css'; import { sprinkles, type Sprinkles } from '../styles/sprinkles.css'; export interface BoxProps extends Omit< AllHTMLAttributes, | 'className' | 'content' | 'height' | 'translate' | 'color' | 'width' | 'cursor' >, Sprinkles { component?: ElementType; className?: Parameters[0]; ref?: Ref; } export const Box = ({ component = 'div', className, padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, margin, marginX, marginY, marginTop, marginBottom, marginLeft, marginRight, display, alignItems, justifyContent, flexDirection, flexWrap, flexGrow, flexShrink, borderRadius, position, top, bottom, left, right, inset, background, color, width, zIndex, opacity, pointerEvents, cursor, textAlign, maxWidth, minWidth, transition, overflow, ...restProps }: BoxProps) => { const atomClasses = clsx( resetStyles.base, resetStyles.element[component as keyof typeof resetStyles.element], sprinkles({ padding, paddingX, paddingY, paddingTop, paddingBottom, paddingLeft, paddingRight, margin, marginX, marginY, marginTop, marginBottom, marginLeft, marginRight, display, alignItems, justifyContent, flexDirection, flexWrap, flexGrow, flexShrink, borderRadius, position, top, bottom, left, right, inset, background, color, width, zIndex, opacity, pointerEvents, cursor, textAlign, maxWidth, minWidth, transition, overflow, }), className, ); return createElement(component, { className: atomClasses, ...restProps }); };