UNPKG

@wordpress/edit-post

Version:
8 lines (7 loc) 2.12 kB
{ "version": 3, "sources": ["../../../src/components/back-button/fullscreen-mode-close.js"], "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\nfunction FullscreenModeClose( { showTooltip, icon, href, initialPost } ) {\n\tconst postType = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\treturn getPostType( initialPost?.type || getCurrentPostType() );\n\t\t},\n\t\t[ initialPost?.type ]\n\t);\n\n\tif ( ! postType ) {\n\t\treturn null;\n\t}\n\n\tconst buttonHref =\n\t\thref ??\n\t\taddQueryArgs( 'edit.php', {\n\t\t\tpost_type: postType.slug,\n\t\t} );\n\n\tconst buttonLabel = postType?.labels?.view_items ?? __( 'Back' );\n\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\thref={ buttonHref }\n\t\t\tlabel={ buttonLabel }\n\t\t\tshowTooltip={ showTooltip }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\ticon={ icon ?? ( isRTL() ? chevronRight : chevronLeft ) }\n\t\t/>\n\t);\n}\n\nexport default FullscreenModeClose;\n"], "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,IAAI,aAAa;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,aAAa,oBAAoB;AAC1C,SAAS,SAAS,mBAAmB;AACrC,SAAS,SAAS,iBAAiB;AAyBjC;AAvBF,SAAS,oBAAqB,EAAE,aAAa,MAAM,MAAM,YAAY,GAAI;AACxE,QAAM,WAAW;AAAA,IAChB,CAAE,WAAY;AACb,YAAM,EAAE,mBAAmB,IAAI,OAAQ,WAAY;AACnD,YAAM,EAAE,YAAY,IAAI,OAAQ,SAAU;AAC1C,aAAO,YAAa,aAAa,QAAQ,mBAAmB,CAAE;AAAA,IAC/D;AAAA,IACA,CAAE,aAAa,IAAK;AAAA,EACrB;AAEA,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,aACL,QACA,aAAc,YAAY;AAAA,IACzB,WAAW,SAAS;AAAA,EACrB,CAAE;AAEH,QAAM,cAAc,UAAU,QAAQ,cAAc,GAAI,MAAO;AAE/D,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,MAAO;AAAA,MACP,OAAQ;AAAA,MACR;AAAA,MACA,iBAAgB;AAAA,MAChB,MAAO,SAAU,MAAM,IAAI,eAAe;AAAA;AAAA,EAC3C;AAEF;AAEA,IAAO,gCAAQ;", "names": [] }