UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 1.89 kB
{ "version": 3, "sources": ["../../../src/components/block-list/layout.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getLayoutType } from '../../layouts';\nimport { useSettings } from '../use-settings';\n\nexport const defaultLayout = { type: 'default' };\n\nconst Layout = createContext( defaultLayout );\nLayout.displayName = 'BlockLayoutContext';\n\n/**\n * Allows to define the layout.\n */\nexport const LayoutProvider = Layout.Provider;\n\n/**\n * React hook used to retrieve the layout config.\n */\nexport function useLayout() {\n\treturn useContext( Layout );\n}\n\nexport function LayoutStyle( { layout = {}, css, ...props } ) {\n\tconst layoutType = getLayoutType( layout.type );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\tif ( layoutType ) {\n\t\tif ( css ) {\n\t\t\treturn <style>{ css }</style>;\n\t\t}\n\t\tconst layoutStyle = layoutType.getLayoutStyle?.( {\n\t\t\thasBlockGapSupport,\n\t\t\tlayout,\n\t\t\t...props,\n\t\t} );\n\t\tif ( layoutStyle ) {\n\t\t\treturn <style>{ layoutStyle }</style>;\n\t\t}\n\t}\n\treturn null;\n}\n"], "mappings": ";AAGA,SAAS,eAAe,kBAAkB;AAK1C,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AA0BlB;AAxBH,IAAM,gBAAgB,EAAE,MAAM,UAAU;AAE/C,IAAM,SAAS,cAAe,aAAc;AAC5C,OAAO,cAAc;AAKd,IAAM,iBAAiB,OAAO;AAK9B,SAAS,YAAY;AAC3B,SAAO,WAAY,MAAO;AAC3B;AAEO,SAAS,YAAa,EAAE,SAAS,CAAC,GAAG,KAAK,GAAG,MAAM,GAAI;AAC7D,QAAM,aAAa,cAAe,OAAO,IAAK;AAC9C,QAAM,CAAE,eAAgB,IAAI,YAAa,kBAAmB;AAC5D,QAAM,qBAAqB,oBAAoB;AAE/C,MAAK,YAAa;AACjB,QAAK,KAAM;AACV,aAAO,oBAAC,WAAQ,eAAK;AAAA,IACtB;AACA,UAAM,cAAc,WAAW,iBAAkB;AAAA,MAChD;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACJ,CAAE;AACF,QAAK,aAAc;AAClB,aAAO,oBAAC,WAAQ,uBAAa;AAAA,IAC9B;AAAA,EACD;AACA,SAAO;AACR;", "names": [] }