UNPKG

@wordpress/block-library

Version:
8 lines (7 loc) • 2.07 kB
{ "version": 3, "sources": ["../../src/tabs/edit.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport TabToolbarControls from './tab-toolbar-controls';\nimport useTabListItemsSync from './use-tab-list-items-sync';\n\n/**\n * Only the two structural child blocks are specified here — without inner\n * block entries for core/tab-list or core/tab-panels.\n *\n * If inner blocks were included in this template, `synchronizeBlocksWithTemplate`\n * (called whenever templateLock === 'all') would recurse into the containers and\n * truncate them to the template count, causing data loss when a saved block with\n * more than two tabs is re-opened in the editor.\n *\n * Initial tab/panel creation is delegated to the tab-panels template in\n * tab-panels/edit.js (templateLock: false, applied only when empty).\n */\nconst TABS_TEMPLATE = [ [ 'core/tab-list' ], [ 'core/tab-panels' ] ];\n\nfunction Edit( { clientId } ) {\n\tuseTabListItemsSync( clientId );\n\n\tconst blockProps = useBlockProps();\n\n\tconst innerBlockProps = useInnerBlocksProps( blockProps, {\n\t\t__experimentalCaptureToolbars: true,\n\t\ttemplate: TABS_TEMPLATE,\n\t\ttemplateLock: 'all',\n\t\trenderAppender: false,\n\t} );\n\n\treturn (\n\t\t<div { ...innerBlockProps }>\n\t\t\t<TabToolbarControls tabsClientId={ clientId } />\n\t\t\t{ innerBlockProps.children }\n\t\t</div>\n\t);\n}\n\nexport default Edit;\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAmD;AAKnD,kCAA+B;AAC/B,qCAAgC;AA6B9B;AAfF,IAAM,gBAAgB,CAAE,CAAE,eAAgB,GAAG,CAAE,iBAAkB,CAAE;AAEnE,SAAS,KAAM,EAAE,SAAS,GAAI;AAC7B,qCAAAA,SAAqB,QAAS;AAE9B,QAAM,iBAAa,mCAAc;AAEjC,QAAM,sBAAkB,yCAAqB,YAAY;AAAA,IACxD,+BAA+B;AAAA,IAC/B,UAAU;AAAA,IACV,cAAc;AAAA,IACd,gBAAgB;AAAA,EACjB,CAAE;AAEF,SACC,6CAAC,SAAM,GAAG,iBACT;AAAA,gDAAC,4BAAAC,SAAA,EAAmB,cAAe,UAAW;AAAA,IAC5C,gBAAgB;AAAA,KACnB;AAEF;AAEA,IAAO,eAAQ;", "names": ["useTabListItemsSync", "TabToolbarControls"] }