@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 1.96 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/column/save.js"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { verticalAlignment, width } = attributes;\n\n\tconst wrapperClasses = clsx( {\n\t\t[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,\n\t} );\n\n\tlet style;\n\n\tif ( width && /\\d/.test( width ) ) {\n\t\t// Numbers are handled for backward compatibility as they can be still provided with templates.\n\t\tlet flexBasis = Number.isFinite( width ) ? width + '%' : width;\n\t\t// In some cases we need to round the width to a shorter float.\n\t\tif ( ! Number.isFinite( width ) && width?.endsWith( '%' ) ) {\n\t\t\tconst multiplier = 1000000000000;\n\t\t\t// Shrink the number back to a reasonable float.\n\t\t\tflexBasis =\n\t\t\t\tMath.round( Number.parseFloat( width ) * multiplier ) /\n\t\t\t\t\tmultiplier +\n\t\t\t\t'%';\n\t\t}\n\t\tstyle = { flexBasis };\n\t}\n\n\tconst blockProps = useBlockProps.save( {\n\t\tclassName: wrapperClasses,\n\t\tstyle,\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"],
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,qBAAqB,qBAAqB;AAgC3C;AA9BO,SAAR,KAAuB,EAAE,WAAW,GAAI;AAC9C,QAAM,EAAE,mBAAmB,MAAM,IAAI;AAErC,QAAM,iBAAiB,KAAM;AAAA,IAC5B,CAAE,yBAA0B,iBAAkB,EAAG,GAAG;AAAA,EACrD,CAAE;AAEF,MAAI;AAEJ,MAAK,SAAS,KAAK,KAAM,KAAM,GAAI;AAElC,QAAI,YAAY,OAAO,SAAU,KAAM,IAAI,QAAQ,MAAM;AAEzD,QAAK,CAAE,OAAO,SAAU,KAAM,KAAK,OAAO,SAAU,GAAI,GAAI;AAC3D,YAAM,aAAa;AAEnB,kBACC,KAAK,MAAO,OAAO,WAAY,KAAM,IAAI,UAAW,IACnD,aACD;AAAA,IACF;AACA,YAAQ,EAAE,UAAU;AAAA,EACrB;AAEA,QAAM,aAAa,cAAc,KAAM;AAAA,IACtC,WAAW;AAAA,IACX;AAAA,EACD,CAAE;AACF,QAAM,mBAAmB,oBAAoB,KAAM,UAAW;AAE9D,SAAO,oBAAC,SAAM,GAAG,kBAAmB;AACrC;",
"names": []
}