{
  "version": 3,
  "sources": ["../../src/hooks/list-view.js"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { hasBlockSupport, getBlockType } from '@wordpress/blocks';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { PrivateListView } from '../components/list-view';\nimport InspectorControls from '../components/inspector-controls/fill';\nimport { PrivateBlockContext } from '../components/block-list/private-block-context';\nimport useListViewPanelState from '../components/use-list-view-panel-state';\n\nimport { unlock } from '../lock-unlock';\n\nexport const LIST_VIEW_SUPPORT_KEY = 'listView';\n\n/**\n * Check if the block has list view support.\n *\n * @param {string|Object} nameOrType Block name or block type object.\n * @return {boolean} Whether the block has list view support.\n */\nexport function hasListViewSupport( nameOrType ) {\n\treturn hasBlockSupport( nameOrType, LIST_VIEW_SUPPORT_KEY );\n}\n\n/**\n * Inspector controls panel for list view.\n *\n * @param {Object} props          Component props.\n * @param {string} props.clientId Block client ID.\n * @param {string} props.name     Block name.\n * @return {Element|null} List view inspector controls or null.\n */\nexport function ListViewPanel( { clientId, name } ) {\n\tconst { isSelectionWithinCurrentSection } =\n\t\tuseContext( PrivateBlockContext );\n\n\tconst { isOpened, expandRevision, handleToggle } =\n\t\tuseListViewPanelState( clientId );\n\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { openListViewContentPanel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst isEnabled = hasListViewSupport( name );\n\tconst { hasChildren, isNestedListView } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\t// Avoid showing List Views for both parent and child blocks that have support.\n\t\t\t// In this situation the parent will show the child in its list already.\n\t\t\t// Search parents to see if there's one that also has support, and if so skip rendering.\n\t\t\t// This matches closely the logic in the `BlockCard` component.\n\t\t\tconst parents = getBlockParents( clientId, false );\n\t\t\tconst _isNestedListView = parents.find( ( parentId ) => {\n\t\t\t\tconst parentName = getBlockName( parentId );\n\t\t\t\treturn (\n\t\t\t\t\tparentName === 'core/navigation' ||\n\t\t\t\t\thasBlockSupport( parentName, 'listView' )\n\t\t\t\t);\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tisNestedListView: _isNestedListView,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockType = getBlockType( name );\n\tconst title = blockType?.title || name;\n\n\tif ( ! isEnabled || isNestedListView ) {\n\t\treturn null;\n\t}\n\n\tconst showBlockTitle = isSelectionWithinCurrentSection;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ showBlockTitle ? title : undefined }\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ handleToggle }\n\t\t\t>\n\t\t\t\t{ ! hasChildren && (\n\t\t\t\t\t<p className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t{ __( 'No items yet.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<PrivateListView\n\t\t\t\t\tkey={ `${ clientId }-${ expandRevision }` }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\tisExpanded\n\t\t\t\t\tdescription={ title }\n\t\t\t\t\tshowAppender\n\t\t\t\t\tonSelect={ openListViewContentPanel }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Export block support definition.\n */\nexport default {\n\tedit: ListViewPanel,\n\thasSupport: hasListViewSupport,\n\tattributeKeys: [],\n\tsupportsPatternEditing: true,\n};\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACn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