{"version":3,"file":"Box.mjs","sources":["../../../../src/components/Box/Box.tsx"],"sourcesContent":["'use client'\n\nimport { createElement, forwardRef } from 'react'\n\nimport classNames from 'classnames'\n\nimport {\n  getLayoutStyles,\n  getMarginStyles,\n  splitByLayoutProps,\n  splitByMarginProps,\n} from '~/src/types/props-helpers'\n\nimport { type BoxProps } from './Box.types'\n\nimport styles from './Box.module.scss'\n\n/**\n * `Box` is a primitive layout component. It provides an easy way to access design tokens.\n * @example\n *\n * ```tsx\n * <Box\n *   width=\"100px\"\n *   height=\"100px\"\n *   p=\"6px\"\n *   m=\"6px\"\n *   bgColor=\"fill-neutral-light\"\n * >\n *   <div>{ ... }</div>\n * </Box>\n * ```\n */\nexport const Box = forwardRef<HTMLElement, BoxProps>(\n  function Box(props, forwardedRef) {\n    const [marginProps, marginRest] = splitByMarginProps(props)\n    const [layoutProps, layoutRest] = splitByLayoutProps(marginRest)\n    const marginStyles = getMarginStyles(marginProps)\n    const layoutStyles = getLayoutStyles(layoutProps)\n\n    const {\n      children,\n      style,\n      className,\n      as = 'div',\n      display,\n      ...rest\n    } = layoutRest\n\n    /**\n     * NOTE: Using the createElement function directly because of a ref type related error.\n     * TODO: Fix type error.\n     */\n    return createElement(\n      as,\n      {\n        ref: forwardedRef,\n        style: {\n          ...marginStyles.style,\n          ...layoutStyles.style,\n          ...style,\n        },\n        className: classNames(\n          styles.Box,\n          display && styles[`display-${display}`],\n          marginStyles.className,\n          layoutStyles.className,\n          className\n        ),\n        'data-testid': 'bezier-box',\n        ...rest,\n      },\n      children\n    )\n  }\n)\n"],"names":["Box","forwardRef","props","forwardedRef","marginProps","marginRest","splitByMarginProps","layoutProps","layoutRest","splitByLayoutProps","marginStyles","getMarginStyles","layoutStyles","getLayoutStyles","children","style","className","as","display","rest","createElement","ref","classNames","styles"],"mappings":";;;;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,GAAG,gBAAGC,UAAU,CAC3B,SAASD,GAAGA,CAACE,KAAK,EAAEC,YAAY,EAAE;EAChC,MAAM,CAACC,WAAW,EAAEC,UAAU,CAAC,GAAGC,kBAAkB,CAACJ,KAAK,CAAC;EAC3D,MAAM,CAACK,WAAW,EAAEC,UAAU,CAAC,GAAGC,kBAAkB,CAACJ,UAAU,CAAC;AAChE,EAAA,MAAMK,YAAY,GAAGC,eAAe,CAACP,WAAW,CAAC;AACjD,EAAA,MAAMQ,YAAY,GAAGC,eAAe,CAACN,WAAW,CAAC;EAEjD,MAAM;IACJO,QAAQ;IACRC,KAAK;IACLC,SAAS;AACTC,IAAAA,EAAE,GAAG,KAAK;IACVC,OAAO;IACP,GAAGC;AACL,GAAC,GAAGX,UAAU;;AAEd;AACJ;AACA;AACA;EACI,oBAAOY,aAAa,CAClBH,EAAE,EACF;AACEI,IAAAA,GAAG,EAAElB,YAAY;AACjBY,IAAAA,KAAK,EAAE;MACL,GAAGL,YAAY,CAACK,KAAK;MACrB,GAAGH,YAAY,CAACG,KAAK;MACrB,GAAGA;KACJ;IACDC,SAAS,EAAEM,UAAU,CACnBC,MAAM,CAACvB,GAAG,EACVkB,OAAO,IAAIK,MAAM,CAAC,CAAA,QAAA,EAAWL,OAAO,CAAE,CAAA,CAAC,EACvCR,YAAY,CAACM,SAAS,EACtBJ,YAAY,CAACI,SAAS,EACtBA,SACF,CAAC;AACD,IAAA,aAAa,EAAE,YAAY;IAC3B,GAAGG;GACJ,EACDL,QACF,CAAC;AACH,CACF;;;;"}