@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 4.21 kB
Source Map (JSON)
{"version":3,"file":"deprecated.cjs","names":["useBlockProps","InnerBlocks"],"sources":["../../src/buttons/deprecated.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { InnerBlocks, useBlockProps } from '@wordpress/block-editor';\n\n/**\n * @param {Object} attributes Block's attributes.\n */\nconst migrateWithLayout = ( attributes ) => {\n\tif ( !! attributes.layout ) {\n\t\treturn attributes;\n\t}\n\n\tconst { contentJustification, orientation, ...updatedAttributes } =\n\t\tattributes;\n\n\tif ( contentJustification || orientation ) {\n\t\tObject.assign( updatedAttributes, {\n\t\t\tlayout: {\n\t\t\t\ttype: 'flex',\n\t\t\t\t...( contentJustification && {\n\t\t\t\t\tjustifyContent: contentJustification,\n\t\t\t\t} ),\n\t\t\t\t...( orientation && { orientation } ),\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn updatedAttributes;\n};\n\nconst deprecated = [\n\t{\n\t\tattributes: {\n\t\t\tcontentJustification: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t\torientation: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'horizontal',\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\tanchor: true,\n\t\t\talign: [ 'wide', 'full' ],\n\t\t\t__experimentalExposeControlsToChildren: true,\n\t\t\tspacing: {\n\t\t\t\tblockGap: true,\n\t\t\t\tmargin: [ 'top', 'bottom' ],\n\t\t\t\t__experimentalDefaultControls: {\n\t\t\t\t\tblockGap: true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tisEligible: ( { contentJustification, orientation } ) =>\n\t\t\t!! contentJustification || !! orientation,\n\t\tmigrate: migrateWithLayout,\n\t\tsave( { attributes: { contentJustification, orientation } } ) {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\t{ ...useBlockProps.save( {\n\t\t\t\t\t\tclassName: clsx( {\n\t\t\t\t\t\t\t[ `is-content-justification-${ contentJustification }` ]:\n\t\t\t\t\t\t\t\tcontentJustification,\n\t\t\t\t\t\t\t'is-vertical': orientation === 'vertical',\n\t\t\t\t\t\t} ),\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<InnerBlocks.Content />\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t},\n\t{\n\t\tsupports: {\n\t\t\talign: [ 'center', 'left', 'right' ],\n\t\t\tanchor: true,\n\t\t},\n\t\tsave() {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t<InnerBlocks.Content />\n\t\t\t\t</div>\n\t\t\t);\n\t\t},\n\t\tisEligible( { align } ) {\n\t\t\treturn align && [ 'center', 'left', 'right' ].includes( align );\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\treturn migrateWithLayout( {\n\t\t\t\t...attributes,\n\t\t\t\talign: undefined,\n\t\t\t\t// Floating Buttons blocks shouldn't have been supported in the\n\t\t\t\t// first place. Most users using them probably expected them to\n\t\t\t\t// act like content justification controls, so these blocks are\n\t\t\t\t// migrated to use content justification.\n\t\t\t\t// As for center-aligned Buttons blocks, the content justification\n\t\t\t\t// equivalent will create an identical end result in most cases.\n\t\t\t\tcontentJustification: attributes.align,\n\t\t\t} );\n\t\t},\n\t},\n];\n\nexport default deprecated;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,qBAAsB,eAAgB;CAC3C,IAAK,CAAC,CAAE,WAAW,QAClB,OAAO;CAGR,MAAM,EAAE,sBAAsB,aAAa,GAAG,sBAC7C;CAED,IAAK,wBAAwB,aAC5B,OAAO,OAAQ,mBAAmB,EACjC,QAAQ;EACP,MAAM;EACN,GAAK,wBAAwB,EAC5B,gBAAgB,qBACjB;EACA,GAAK,eAAe,EAAE,YAAY;CACnC,EACD,CAAE;CAGH,OAAO;AACR;AAEA,MAAM,aAAa,CAClB;CACC,YAAY;EACX,sBAAsB,EACrB,MAAM,SACP;EACA,aAAa;GACZ,MAAM;GACN,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