{"version":3,"file":"index.mjs","names":[],"sources":["../../src/responsive-wrapper/index.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport deprecated from '@wordpress/deprecated';\nimport { cloneElement, Children } from '@wordpress/element';\nimport type { ResponsiveWrapperProps } from './types';\n\n/**\n * A wrapper component that maintains its aspect ratio when resized.\n *\n * This component is deprecated. Use the CSS `aspect-ratio` property instead.\n *\n * @deprecated\n *\n * ```jsx\n * import { ResponsiveWrapper } from '@wordpress/components';\n *\n * const MyResponsiveWrapper = () => (\n * \t<ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>\n * \t\t<img\n * \t\t\tsrc=\"https://s.w.org/style/images/about/WordPress-logotype-standard.png\"\n * \t\t\talt=\"WordPress\"\n * \t\t/>\n * \t</ResponsiveWrapper>\n * );\n * ```\n */\nfunction ResponsiveWrapper( {\n\tnaturalWidth,\n\tnaturalHeight,\n\tchildren,\n\tisInline = false,\n}: ResponsiveWrapperProps ) {\n\tdeprecated( 'wp.components.ResponsiveWrapper', {\n\t\tsince: '7.2',\n\t\tversion: '7.4',\n\t\talternative: 'the CSS aspect-ratio property',\n\t} );\n\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn null;\n\t}\n\n\tconst TagName = isInline ? 'span' : 'div';\n\tlet aspectRatio;\n\tif ( naturalWidth && naturalHeight ) {\n\t\taspectRatio = `${ naturalWidth } / ${ naturalHeight }`;\n\t}\n\n\tconst ch = children as React.ReactElement<\n\t\tPick< React.HTMLAttributes< Element >, 'className' | 'style' >\n\t>;\n\n\treturn (\n\t\t<TagName className=\"components-responsive-wrapper\">\n\t\t\t<div>\n\t\t\t\t{ cloneElement( ch, {\n\t\t\t\t\tclassName: clsx(\n\t\t\t\t\t\t'components-responsive-wrapper__content',\n\t\t\t\t\t\tch.props.className\n\t\t\t\t\t),\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\t...ch.props.style,\n\t\t\t\t\t\taspectRatio,\n\t\t\t\t\t},\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</TagName>\n\t);\n}\n\nexport default ResponsiveWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,kBAAmB,EAC3B,cACA,eACA,UACA,WAAW,SACgB;CAC3B,WAAY,mCAAmC;EAC9C,OAAO;EACP,SAAS;EACT,aAAa;CACd,CAAE;CAEF,IAAK,SAAS,MAAO,QAAS,MAAM,GACnC,OAAO;CAGR,MAAM,UAAU,WAAW,SAAS;CACpC,IAAI;CACJ,IAAK,gBAAgB,eACpB,cAAc,GAAI,aAAc,KAAM;CAGvC,MAAM,KAAK;CAIX,OACC,oBAAC,SAAD;EAAS,WAAU;EAClB,UAAA,oBAAC,OAAD,EAAA,UACG,aAAc,IAAI;GACnB,WAAW,KACV,0CACA,GAAG,MAAM,SACV;GACA,OAAO;IACN,GAAG,GAAG,MAAM;IACZ;GACD;EACD,CAAE,EACE,CAAA;CACG,CAAA;AAEX"}