@wordpress/block-library 9.13.0 → 9.13.1-next.a9f418477.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/build/block/edit.js +2 -29
  2. package/build/block/edit.js.map +1 -1
  3. package/build/cover/edit/index.js +4 -2
  4. package/build/cover/edit/index.js.map +1 -1
  5. package/build/cover/edit/inspector-controls.js +6 -4
  6. package/build/cover/edit/inspector-controls.js.map +1 -1
  7. package/build/form/index.js +1 -2
  8. package/build/form/index.js.map +1 -1
  9. package/build/form/view.js +10 -5
  10. package/build/form/view.js.map +1 -1
  11. package/build/list-item/hooks/use-merge.js +2 -2
  12. package/build/list-item/hooks/use-merge.js.map +1 -1
  13. package/build/navigation/edit/deleted-navigation-warning.js +9 -2
  14. package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
  15. package/build/navigation-link/edit.js +1 -2
  16. package/build/navigation-link/edit.js.map +1 -1
  17. package/build/navigation-submenu/edit.js +3 -1
  18. package/build/navigation-submenu/edit.js.map +1 -1
  19. package/build/pattern/recursion-detector.js +0 -1
  20. package/build/pattern/recursion-detector.js.map +1 -1
  21. package/build/query/edit/index.js +2 -2
  22. package/build/query/edit/index.js.map +1 -1
  23. package/build/query/edit/inspector-controls/author-control.js +0 -1
  24. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  25. package/build/query/edit/inspector-controls/parent-control.js +0 -1
  26. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  27. package/build/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  28. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  29. package/build/query/edit/{pattern-selection-modal.js → pattern-selection.js} +55 -36
  30. package/build/query/edit/pattern-selection.js.map +1 -0
  31. package/build/query/edit/query-content.js +5 -8
  32. package/build/query/edit/query-content.js.map +1 -1
  33. package/build/query/edit/query-placeholder.js +5 -11
  34. package/build/query/edit/query-placeholder.js.map +1 -1
  35. package/build/query/edit/query-toolbar.js +31 -11
  36. package/build/query/edit/query-toolbar.js.map +1 -1
  37. package/build/separator/deprecated.js +2 -1
  38. package/build/separator/deprecated.js.map +1 -1
  39. package/build/separator/edit.js +29 -4
  40. package/build/separator/edit.js.map +1 -1
  41. package/build/separator/index.js +5 -0
  42. package/build/separator/index.js.map +1 -1
  43. package/build/separator/save.js +3 -2
  44. package/build/separator/save.js.map +1 -1
  45. package/build/template-part/edit/import-controls.js +0 -1
  46. package/build/template-part/edit/import-controls.js.map +1 -1
  47. package/build-module/block/edit.js +3 -30
  48. package/build-module/block/edit.js.map +1 -1
  49. package/build-module/cover/edit/index.js +4 -2
  50. package/build-module/cover/edit/index.js.map +1 -1
  51. package/build-module/cover/edit/inspector-controls.js +6 -4
  52. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  53. package/build-module/form/index.js +1 -2
  54. package/build-module/form/index.js.map +1 -1
  55. package/build-module/form/view.js +10 -5
  56. package/build-module/form/view.js.map +1 -1
  57. package/build-module/list-item/hooks/use-merge.js +2 -2
  58. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  59. package/build-module/navigation/edit/deleted-navigation-warning.js +10 -3
  60. package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
  61. package/build-module/navigation-link/edit.js +1 -2
  62. package/build-module/navigation-link/edit.js.map +1 -1
  63. package/build-module/navigation-submenu/edit.js +3 -1
  64. package/build-module/navigation-submenu/edit.js.map +1 -1
  65. package/build-module/pattern/recursion-detector.js +0 -1
  66. package/build-module/pattern/recursion-detector.js.map +1 -1
  67. package/build-module/query/edit/index.js +1 -1
  68. package/build-module/query/edit/index.js.map +1 -1
  69. package/build-module/query/edit/inspector-controls/author-control.js +0 -1
  70. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  71. package/build-module/query/edit/inspector-controls/parent-control.js +0 -1
  72. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  73. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  74. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  75. package/build-module/query/edit/{pattern-selection-modal.js → pattern-selection.js} +53 -36
  76. package/build-module/query/edit/pattern-selection.js.map +1 -0
  77. package/build-module/query/edit/query-content.js +5 -8
  78. package/build-module/query/edit/query-content.js.map +1 -1
  79. package/build-module/query/edit/query-placeholder.js +6 -12
  80. package/build-module/query/edit/query-placeholder.js.map +1 -1
  81. package/build-module/query/edit/query-toolbar.js +31 -13
  82. package/build-module/query/edit/query-toolbar.js.map +1 -1
  83. package/build-module/separator/deprecated.js +2 -1
  84. package/build-module/separator/deprecated.js.map +1 -1
  85. package/build-module/separator/edit.js +32 -7
  86. package/build-module/separator/edit.js.map +1 -1
  87. package/build-module/separator/index.js +5 -0
  88. package/build-module/separator/index.js.map +1 -1
  89. package/build-module/separator/save.js +3 -2
  90. package/build-module/separator/save.js.map +1 -1
  91. package/build-module/template-part/edit/import-controls.js +0 -1
  92. package/build-module/template-part/edit/import-controls.js.map +1 -1
  93. package/build-style/button/style-rtl.css +3 -3
  94. package/build-style/button/style.css +3 -3
  95. package/build-style/comments/editor-rtl.css +1 -1
  96. package/build-style/comments/editor.css +1 -1
  97. package/build-style/comments/style-rtl.css +1 -1
  98. package/build-style/comments/style.css +1 -1
  99. package/build-style/comments-pagination/editor-rtl.css +1 -0
  100. package/build-style/comments-pagination/editor.css +1 -0
  101. package/build-style/comments-pagination/style-rtl.css +1 -0
  102. package/build-style/comments-pagination/style.css +1 -0
  103. package/build-style/common-rtl.css +17 -17
  104. package/build-style/common.css +17 -17
  105. package/build-style/editor-rtl.css +72 -41
  106. package/build-style/editor.css +72 -41
  107. package/build-style/gallery/style-rtl.css +2 -2
  108. package/build-style/gallery/style.css +2 -2
  109. package/build-style/heading/style-rtl.css +11 -11
  110. package/build-style/heading/style.css +11 -11
  111. package/build-style/image/style-rtl.css +4 -3
  112. package/build-style/image/style.css +4 -3
  113. package/build-style/latest-comments/style-rtl.css +4 -4
  114. package/build-style/latest-comments/style.css +4 -4
  115. package/build-style/latest-posts/style-rtl.css +2 -1
  116. package/build-style/latest-posts/style.css +2 -1
  117. package/build-style/more/editor-rtl.css +1 -1
  118. package/build-style/more/editor.css +1 -1
  119. package/build-style/nextpage/editor-rtl.css +1 -1
  120. package/build-style/nextpage/editor.css +1 -1
  121. package/build-style/post-comments-form/style-rtl.css +2 -2
  122. package/build-style/post-comments-form/style.css +2 -2
  123. package/build-style/post-featured-image/editor-rtl.css +27 -27
  124. package/build-style/post-featured-image/editor.css +27 -27
  125. package/build-style/pullquote/style-rtl.css +1 -0
  126. package/build-style/pullquote/style.css +1 -0
  127. package/build-style/query/editor-rtl.css +30 -0
  128. package/build-style/query/editor.css +30 -0
  129. package/build-style/read-more/style-rtl.css +2 -2
  130. package/build-style/read-more/style.css +2 -2
  131. package/build-style/social-link/editor-rtl.css +2 -2
  132. package/build-style/social-link/editor.css +2 -2
  133. package/build-style/social-links/editor-rtl.css +2 -2
  134. package/build-style/social-links/editor.css +2 -2
  135. package/build-style/social-links/style-rtl.css +2 -2
  136. package/build-style/social-links/style.css +2 -2
  137. package/build-style/style-rtl.css +55 -51
  138. package/build-style/style.css +55 -51
  139. package/build-style/text-columns/style-rtl.css +3 -3
  140. package/build-style/text-columns/style.css +3 -3
  141. package/build-types/lock-unlock.d.ts +1 -1
  142. package/build-types/lock-unlock.d.ts.map +1 -1
  143. package/package.json +35 -34
  144. package/src/block/edit.js +6 -51
  145. package/src/comments-pagination/editor.scss +1 -0
  146. package/src/comments-pagination/style.scss +1 -0
  147. package/src/cover/edit/index.js +4 -1
  148. package/src/cover/edit/inspector-controls.js +10 -3
  149. package/src/cover/index.php +2 -2
  150. package/src/form/block.json +1 -2
  151. package/src/form/index.php +1 -20
  152. package/src/form/view.js +18 -5
  153. package/src/image/style.scss +4 -3
  154. package/src/latest-posts/style.scss +2 -1
  155. package/src/list-item/hooks/use-merge.js +2 -2
  156. package/src/missing/test/edit.native.js +0 -1
  157. package/src/navigation/README.md +1 -0
  158. package/src/navigation/edit/deleted-navigation-warning.js +11 -2
  159. package/src/navigation/index.php +9 -35
  160. package/src/navigation-link/edit.js +0 -6
  161. package/src/navigation-submenu/edit.js +5 -6
  162. package/src/navigation-submenu/index.php +17 -1
  163. package/src/pullquote/style.scss +1 -0
  164. package/src/query/edit/index.js +1 -1
  165. package/src/query/edit/{pattern-selection-modal.js → pattern-selection.js} +53 -33
  166. package/src/query/edit/query-content.js +4 -10
  167. package/src/query/edit/query-placeholder.js +5 -14
  168. package/src/query/edit/query-toolbar.js +38 -17
  169. package/src/query/editor.scss +30 -0
  170. package/src/search/index.php +3 -3
  171. package/src/separator/block.json +5 -0
  172. package/src/separator/deprecated.js +1 -0
  173. package/src/separator/edit.js +28 -3
  174. package/src/separator/save.js +2 -2
  175. package/src/separator/test/edit.js +1 -0
  176. package/tsconfig.tsbuildinfo +1 -1
  177. package/build/query/edit/pattern-selection-modal.js.map +0 -1
  178. package/build-module/query/edit/pattern-selection-modal.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","createBlock","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","Tooltip","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","useInnerBlocksProps","isURL","prependHTTP","safeDecodeURI","useState","useEffect","useRef","__unstableStripHTML","stripHTML","decodeEntities","link","linkIcon","addSubmenu","coreStore","useMergeRefs","usePrevious","LinkUI","updateAttributes","getColors","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","useIsInvalidLink","kind","type","id","isPostType","hasId","Number","isInteger","postStatus","select","getEntityRecord","status","isInvalid","isDraft","getMissingText","missingText","Controls","attributes","setAttributes","setIsLabelFieldFocused","label","url","description","title","rel","children","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","onFocus","onBlur","urlValue","descriptionValue","help","titleValue","relValue","NavigationLinkEdit","isSelected","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","selectBlock","selectPreviousBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","linkUIref","prevUrl","isLabelFieldFocused","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","length","getBlocks","transformToSubmenu","innerBlocks","newSubmenu","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","undefined","opensInNewTab","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksProps","defaultBlock","directInsert","renderAppender","onClick","classes","placeholderText","tooltipText","icon","shortcut","currentTarget","text","identifier","onMerge","__unstableOnSplitAtEnd","placeholder","withoutInteractiveFormatting","allowedFormats","trim","onClose","window","document","activeElement","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tTooltip,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\nimport { getColors } from '../navigation/edit/utils';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [ elementRef ] );\n\n\treturn isDraggingWithin;\n};\n\nconst useIsInvalidLink = ( kind, type, id ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\n};\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\n/*\n * Warning, this duplicated in\n * packages/block-library/src/navigation-submenu/edit.js\n * Consider reuseing this components for both blocks.\n */\nfunction Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {\n\tconst { label, url, description, title, rel } = attributes;\n\treturn (\n\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tonFocus={ () => setIsLabelFieldFocused( true ) }\n\t\t\t\tonBlur={ () => setIsLabelFieldFocused( false ) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ url ? safeDecodeURI( url ) : '' }\n\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t{ url: urlValue },\n\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\tattributes\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t\t<TextareaControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ description || '' }\n\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ title || '' }\n\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Additional information to help clarify the purpose of the link.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ rel || '' }\n\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\thelp={ __(\n\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind } = attributes;\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t\tselectPreviousBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\tconst prevUrl = usePrevious( url );\n\n\t// Change the label using inspector causes rich text to change focus on firefox.\n\t// This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.\n\tconst [ isLabelFieldFocused, setIsLabelFieldFocused ] = useState( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, [\n\t\t\t\t\t\t'core/navigation-link',\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t] ).length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink:\n\t\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t\t'core/navigation',\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t};\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\t// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL\n\t\tif (\n\t\t\t! prevUrl &&\n\t\t\turl &&\n\t\t\tisLinkOpen &&\n\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText();\n\t\t}\n\t}, [ prevUrl, url, isLinkOpen, label ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\tconst tooltipText =\n\t\tisInvalid || isDraft\n\t\t\t? __( 'This item has been deleted, or is a draft' )\n\t\t\t: __( 'This item is missing a link' );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tsetIsLabelFieldFocused={ setIsLabelFieldFocused }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid &&\n\t\t\t\t\t\t\t\t! isDraft &&\n\t\t\t\t\t\t\t\t! isLabelFieldFocused && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid ||\n\t\t\t\t\t\t\t\tisDraft ||\n\t\t\t\t\t\t\t\tisLabelFieldFocused ) && (\n\t\t\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text wp-block-navigation-link__label\">\n\t\t\t\t\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t\t`${ decodeEntities( label ) } ${\n\t\t\t\t\t\t\t\t\t\t\t\t\tisInvalid || isDraft\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? placeholderText\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t\t\t\t}`.trim()\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\t// If there is no link then remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t// Fixes https://github.com/WordPress/gutenberg/issues/61361\n\t\t\t\t\t\t\t\t\t// There's a chance we're closing due to the user selecting the browse all button.\n\t\t\t\t\t\t\t\t\t// Only move focus if the focus is still within the popover ui. If it's not within\n\t\t\t\t\t\t\t\t\t// the popover, it's because something has taken the focus from the popover, and\n\t\t\t\t\t\t\t\t\t// we don't want to steal it back.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlinkUIref.current.contains(\n\t\t\t\t\t\t\t\t\t\t\twindow.document.activeElement\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t// Select the previous block to keep focus nearby\n\t\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Remove the link.\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else if ( ref.current ) {\n\t\t\t\t\t\t\t\t\t// select the ref when adding a new link\n\t\t\t\t\t\t\t\t\tref.current.focus();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Fallback\n\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,OAAO,EACPC,YAAY,QACN,uBAAuB;AAC9B,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cACZ;cACA;cACA;cACA;cACA;cACA,IACCuC,SAAS,CAACrE,OAAO,CAACK,QAAQ,CACzB+H,MAAM,CAACC,QAAQ,CAACC,aACjB,CAAC,EACA;gBACD;gBACA3E,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;cACtC;;cAEA;cACAF,SAAS,CAAE,EAAG,CAAC;cACf;YACD;YAEAS,aAAa,CAAE,KAAM,CAAC;YACtB,IAAKC,QAAQ,EAAG;cACfA,QAAQ,CAAC0B,KAAK,CAAC,CAAC;cAChBzB,WAAW,CAAE,IAAK,CAAC;YACpB,CAAC,MAAM,IAAKK,GAAG,CAACpE,OAAO,EAAG;cACzB;cACAoE,GAAG,CAACpE,OAAO,CAACwF,KAAK,CAAC,CAAC;YACpB,CAAC,MAAM;cACN;cACA7B,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;YACtC;UACD,CAAG;UACHiF,MAAM,EAAGvE,aAAe;UACxBwE,QAAQ,EAAGvC,UAAY;UACvB3D,QAAQ,EAAKmG,YAAY,IAAM;YAC9BxJ,gBAAgB,CACfwJ,YAAY,EACZ9G,aAAa,EACbD,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACC,CAAC,eACJtC,IAAA;QAAA,GAAU4H;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["clsx","createBlock","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","Tooltip","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","useInnerBlocksProps","isURL","prependHTTP","safeDecodeURI","useState","useEffect","useRef","__unstableStripHTML","stripHTML","decodeEntities","link","linkIcon","addSubmenu","coreStore","useMergeRefs","usePrevious","LinkUI","updateAttributes","getColors","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","useIsInvalidLink","kind","type","id","isPostType","hasId","Number","isInteger","postStatus","select","getEntityRecord","status","isInvalid","isDraft","getMissingText","missingText","Controls","attributes","setAttributes","setIsLabelFieldFocused","label","url","description","title","rel","children","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","onFocus","onBlur","urlValue","descriptionValue","help","titleValue","relValue","NavigationLinkEdit","isSelected","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","selectBlock","selectPreviousBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","linkUIref","prevUrl","isLabelFieldFocused","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","length","getBlocks","transformToSubmenu","innerBlocks","newSubmenu","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","undefined","opensInNewTab","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksProps","defaultBlock","directInsert","renderAppender","onClick","classes","placeholderText","tooltipText","icon","shortcut","currentTarget","text","identifier","onMerge","__unstableOnSplitAtEnd","placeholder","withoutInteractiveFormatting","trim","onClose","window","document","activeElement","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tTooltip,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\nimport { getColors } from '../navigation/edit/utils';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [ elementRef ] );\n\n\treturn isDraggingWithin;\n};\n\nconst useIsInvalidLink = ( kind, type, id ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\n};\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\n/*\n * Warning, this duplicated in\n * packages/block-library/src/navigation-submenu/edit.js\n * Consider reuseing this components for both blocks.\n */\nfunction Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {\n\tconst { label, url, description, title, rel } = attributes;\n\treturn (\n\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tonFocus={ () => setIsLabelFieldFocused( true ) }\n\t\t\t\tonBlur={ () => setIsLabelFieldFocused( false ) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ url ? safeDecodeURI( url ) : '' }\n\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t{ url: urlValue },\n\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\tattributes\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t\t<TextareaControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ description || '' }\n\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ title || '' }\n\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Additional information to help clarify the purpose of the link.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ rel || '' }\n\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t} }\n\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\thelp={ __(\n\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PanelBody>\n\t);\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind } = attributes;\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t\tselectPreviousBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\tconst prevUrl = usePrevious( url );\n\n\t// Change the label using inspector causes rich text to change focus on firefox.\n\t// This is a workaround to keep the focus on the label field when label filed is focused we don't render the rich text.\n\tconst [ isLabelFieldFocused, setIsLabelFieldFocused ] = useState( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, [\n\t\t\t\t\t\t'core/navigation-link',\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t] ).length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink:\n\t\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t\t'core/navigation',\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t};\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\t// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL\n\t\tif (\n\t\t\t! prevUrl &&\n\t\t\turl &&\n\t\t\tisLinkOpen &&\n\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText();\n\t\t}\n\t}, [ prevUrl, url, isLinkOpen, label ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\tconst tooltipText =\n\t\tisInvalid || isDraft\n\t\t\t? __( 'This item has been deleted, or is a draft' )\n\t\t\t: __( 'This item is missing a link' );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tsetIsLabelFieldFocused={ setIsLabelFieldFocused }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid &&\n\t\t\t\t\t\t\t\t! isDraft &&\n\t\t\t\t\t\t\t\t! isLabelFieldFocused && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid ||\n\t\t\t\t\t\t\t\tisDraft ||\n\t\t\t\t\t\t\t\tisLabelFieldFocused ) && (\n\t\t\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text wp-block-navigation-link__label\">\n\t\t\t\t\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t\t`${ decodeEntities( label ) } ${\n\t\t\t\t\t\t\t\t\t\t\t\t\tisInvalid || isDraft\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? placeholderText\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t\t\t\t}`.trim()\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\t// If there is no link then remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t// Fixes https://github.com/WordPress/gutenberg/issues/61361\n\t\t\t\t\t\t\t\t\t// There's a chance we're closing due to the user selecting the browse all button.\n\t\t\t\t\t\t\t\t\t// Only move focus if the focus is still within the popover ui. If it's not within\n\t\t\t\t\t\t\t\t\t// the popover, it's because something has taken the focus from the popover, and\n\t\t\t\t\t\t\t\t\t// we don't want to steal it back.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlinkUIref.current.contains(\n\t\t\t\t\t\t\t\t\t\t\twindow.document.activeElement\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t// Select the previous block to keep focus nearby\n\t\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Remove the link.\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else if ( ref.current ) {\n\t\t\t\t\t\t\t\t\t// select the ref when adding a new link\n\t\t\t\t\t\t\t\t\tref.current.focus();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Fallback\n\t\t\t\t\t\t\t\t\tselectPreviousBlock( clientId, true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,OAAO,EACPC,YAAY,QACN,uBAAuB;AAC9B,SAASC,eAAe,EAA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AAM,CAACC,QAAQ,CAACC,aACjB,CAAC,EACA;gBACD;gBACA1E,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;cACtC;;cAEA;cACAF,SAAS,CAAE,EAAG,CAAC;cACf;YACD;YAEAS,aAAa,CAAE,KAAM,CAAC;YACtB,IAAKC,QAAQ,EAAG;cACfA,QAAQ,CAAC0B,KAAK,CAAC,CAAC;cAChBzB,WAAW,CAAE,IAAK,CAAC;YACpB,CAAC,MAAM,IAAKK,GAAG,CAACpE,OAAO,EAAG;cACzB;cACAoE,GAAG,CAACpE,OAAO,CAACwF,KAAK,CAAC,CAAC;YACpB,CAAC,MAAM;cACN;cACA7B,mBAAmB,CAAEL,QAAQ,EAAE,IAAK,CAAC;YACtC;UACD,CAAG;UACHgF,MAAM,EAAGtE,aAAe;UACxBuE,QAAQ,EAAGtC,UAAY;UACvB3D,QAAQ,EAAKkG,YAAY,IAAM;YAC9BvJ,gBAAgB,CACfuJ,YAAY,EACZ7G,aAAa,EACbD,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACC,CAAC,eACJtC,IAAA;QAAA,GAAU4H;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
@@ -389,13 +389,15 @@ export default function NavigationSubmenuEdit({
389
389
  "aria-label": __('Navigation link text'),
390
390
  placeholder: itemLabelPlaceholder,
391
391
  withoutInteractiveFormatting: true,
392
- allowedFormats: ['core/bold', 'core/italic', 'core/image', 'core/strikethrough'],
393
392
  onClick: () => {
394
393
  if (!openSubmenusOnClick && !url) {
395
394
  setIsLinkOpen(true);
396
395
  setOpenedBy(ref.current);
397
396
  }
398
397
  }
398
+ }), description && /*#__PURE__*/_jsx("span", {
399
+ className: "wp-block-navigation-item__description",
400
+ children: description
399
401
  }), !openSubmenusOnClick && isLinkOpen && /*#__PURE__*/_jsx(LinkUI, {
400
402
  clientId: clientId,
401
403
  link: attributes,
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","rel","title","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","shortcut","onClick","currentTarget","disabled","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","urlValue","descriptionValue","help","titleValue","relValue","identifier","onMerge","placeholder","withoutInteractiveFormatting","allowedFormats","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, rel, title } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propogation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Additional information to help clarify the purpose of the link.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,YAAY,QACN,uBAAuB;AAC9B,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,aAAa,EACbC,WAAW,EACXC,mBAAmB,EACnBC,iBAAiB,EACjBC,QAAQ,EACRC,aAAa,EACbC,KAAK,IAAIC,gBAAgB,EACzBC,iBAAiB,QACX,yBAAyB;AAChC,SAASC,KAAK,EAAEC,WAAW,QAAQ,gBAA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C,EACd,CAAEY,eAAe,IAAIE,mBAAmB,kBACzCrC,IAAA;QAAMyF,SAAS,EAAC,mCAAmC;QAAAkB,QAAA,eAClD3G,IAAA,CAACN,eAAe,IAAE;MAAC,CACd,CACN,eACDM,IAAA;QAAA,GAAUiG;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["clsx","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","link","linkIcon","removeSubmenu","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","url","description","rel","title","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","selectBlock","isLinkOpen","setIsLinkOpen","openedBy","setOpenedBy","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","parentCount","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","preventDefault","stopPropagation","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","defaultBlock","directInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","children","icon","shortcut","onClick","currentTarget","disabled","__nextHasNoMarginBottom","__next40pxDefaultSize","value","onChange","labelValue","autoComplete","urlValue","descriptionValue","help","titleValue","relValue","identifier","onMerge","placeholder","withoutInteractiveFormatting","onClose","anchor","onRemove","updatedValue"],"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, rel, title } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)\n\tconst [ openedBy, setOpenedBy ] = useState( null );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propogation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t\tsetOpenedBy( ref.current );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t )\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( event.currentTarget );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Title attribute' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Additional information to help clarify the purpose of the link.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Rel attribute' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The relationship of the linked URL as space-separated link types.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\tsetOpenedBy( ref.current );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ description && (\n\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\tif ( openedBy ) {\n\t\t\t\t\t\t\t\t\topenedBy.focus();\n\t\t\t\t\t\t\t\t\tsetOpenedBy( null );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,WAAW,EACXC,eAAe,EACfC,aAAa,EACbC,YAAY,QACN,uBAAuB;AAC9B,SAASC,eAAe,EAAEC,eAAe,QAAQ,qBAAqB;AACtE,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E;YAAG,CAAE,CAAC;YAC5BzC,KAAK,CAAElB,EAAE,CAAE,eAAgB,CAAC,EAAE,WAAY,CAAC;UAC5C,CAAG;UACHgJ,QAAQ,EAAKe,YAAY,IAAM;YAC9BvI,gBAAgB,CACfuI,YAAY,EACZ1G,aAAa,EACbF,UACD,CAAC;UACF;QAAG,CACH,CACD;MAAA,CACa,CAAC,EACd,CAAEY,eAAe,IAAIE,mBAAmB,kBACzCrC,IAAA;QAAMyF,SAAS,EAAC,mCAAmC;QAAAkB,QAAA,eAClD3G,IAAA,CAACN,eAAe,IAAE;MAAC,CACd,CACN,eACDM,IAAA;QAAA,GAAUiG;MAAgB,CAAI,CAAC;IAAA,CAC3B,CAAC;EAAA,CACL,CAAC;AAEL","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  /**
3
2
  * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.
4
3
  *
@@ -1 +1 @@
1
- {"version":3,"names":["useRegistry","cachedParsers","WeakMap","useParsePatternDependencies","registry","has","deps","Map","set","parsePatternDependencies","bind","get","name","blocks","queue","length","block","shift","innerBlock","_block$innerBlocks","innerBlocks","unshift","registerDependency","attributes","slug","a","b","Set","add","hasCycle","TypeError","visitedNodes","currentPath","_deps$get","dependencies","dependency","delete"],"sources":["@wordpress/block-library/src/pattern/recursion-detector.js"],"sourcesContent":["/**\n * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.\n *\n * This is because this approach for preventing infinite loops due to\n * recursively rendering blocks is specific to the way that the `core/pattern`\n * block behaves in the editor. Any other block types that deal with recursion\n * SHOULD USE THE STANDARD METHOD for avoiding loops:\n *\n * @see https://github.com/WordPress/gutenberg/pull/31455\n * @see packages/block-editor/src/components/recursion-provider/README.md\n */\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Naming is hard.\n *\n * @see useParsePatternDependencies\n *\n * @type {WeakMap<Object, Function>}\n */\nconst cachedParsers = new WeakMap();\n\n/**\n * Hook used by PatternEdit to parse block patterns. It returns a function that\n * takes a pattern and returns nothing but throws an error if the pattern is\n * recursive.\n *\n * @example\n * ```js\n * const parsePatternDependencies = useParsePatternDependencies();\n * parsePatternDependencies( selectedPattern );\n * ```\n *\n * @see parsePatternDependencies\n *\n * @return {Function} A function to parse block patterns.\n */\nexport function useParsePatternDependencies() {\n\tconst registry = useRegistry();\n\n\t// Instead of caching maps, go straight to the point and cache bound\n\t// functions. Each of those functions is bound to a different Map that will\n\t// keep track of patterns in the context of the given registry.\n\tif ( ! cachedParsers.has( registry ) ) {\n\t\tconst deps = new Map();\n\t\tcachedParsers.set(\n\t\t\tregistry,\n\t\t\tparsePatternDependencies.bind( null, deps )\n\t\t);\n\t}\n\treturn cachedParsers.get( registry );\n}\n\n/**\n * Parse a given pattern and traverse its contents to detect any subsequent\n * patterns on which it may depend. Such occurrences will be added to an\n * internal dependency graph. If a circular dependency is detected, an\n * error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {Object} pattern Pattern.\n * @param {string} pattern.name Pattern name.\n * @param {Array} pattern.blocks Pattern's block list.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function parsePatternDependencies( deps, { name, blocks } ) {\n\tconst queue = [ ...blocks ];\n\twhile ( queue.length ) {\n\t\tconst block = queue.shift();\n\t\tfor ( const innerBlock of block.innerBlocks ?? [] ) {\n\t\t\tqueue.unshift( innerBlock );\n\t\t}\n\t\tif ( block.name === 'core/pattern' ) {\n\t\t\tregisterDependency( deps, name, block.attributes.slug );\n\t\t}\n\t}\n}\n\n/**\n * Declare that pattern `a` depends on pattern `b`. If a circular\n * dependency is detected, an error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} a Slug for pattern A.\n * @param {string} b Slug for pattern B.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function registerDependency( deps, a, b ) {\n\tif ( ! deps.has( a ) ) {\n\t\tdeps.set( a, new Set() );\n\t}\n\tdeps.get( a ).add( b );\n\tif ( hasCycle( deps, a ) ) {\n\t\tthrow new TypeError(\n\t\t\t`Pattern ${ a } has a circular dependency and cannot be rendered.`\n\t\t);\n\t}\n}\n\n/**\n * Determine if a given pattern has circular dependencies on other patterns.\n * This will be determined by running a depth-first search on the current state\n * of the graph represented by `patternDependencies`.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} slug Pattern slug.\n * @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.\n * @param {Set<string>} [currentPath] Set to track and backtrack graph paths.\n * @return {boolean} Whether any cycle was found.\n */\nfunction hasCycle(\n\tdeps,\n\tslug,\n\tvisitedNodes = new Set(),\n\tcurrentPath = new Set()\n) {\n\tvisitedNodes.add( slug );\n\tcurrentPath.add( slug );\n\n\tconst dependencies = deps.get( slug ) ?? new Set();\n\n\tfor ( const dependency of dependencies ) {\n\t\tif ( ! visitedNodes.has( dependency ) ) {\n\t\t\tif ( hasCycle( deps, dependency, visitedNodes, currentPath ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if ( currentPath.has( dependency ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Remove the current node from the current path when backtracking\n\tcurrentPath.delete( slug );\n\treturn false;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAA,EAAG;EAC7C,MAA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,CAAC,CAAE,CAAC;EACzB;EACArB,IAAI,CAACK,GAAG,CAAEc,CAAE,CAAC,CAACG,GAAG,CAAEF,CAAE,CAAC;EACtB,IAAKG,QAAQ,CAAEvB,IAAI,EAAEmB,CAAE,CAAC,EAAG;IAC1B,MAAM,IAAIK,SAAS,CAClB,WAAYL,CAAC,oDACd,CAAC;EACF;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,QAAQA,CAChBvB,IAAI,EACJkB,IAAI,EACJO,YAAY,GAAG,IAAIJ,GAAG,CAAC,CAAC,EACxBK,WAAW,GAAG,IAAIL,GAAG,CAAC,CAAC,EACtB;EAAA,IAAAM,SAAA;EACDF,YAAY,CAACH,GAAG,CAAEJ,IAAK,CAAC;EACxBQ,WAAW,CAACJ,GAAG,CAAEJ,IAAK,CAAC;EAEvB,MAAMU,YAAY,IAAAD,SAAA,GAAG3B,IAAI,CAACK,GAAG,CAAEa,IAAK,CAAC,cAAAS,SAAA,cAAAA,SAAA,GAAI,IAAIN,GAAG,CAAC,CAAC;EAElD,KAAM,MAAMQ,UAAU,IAAID,YAAY,EAAG;IACxC,IAAK,CAAEH,YAAY,CAAC1B,GAAG,CAAE8B,UAAW,CAAC,EAAG;MACvC,IAAKN,QAAQ,CAAEvB,IAAI,EAAE6B,UAAU,EAAEJ,YAAY,EAAEC,WAAY,CAAC,EAAG;QAC9D,OAAO,IAAI;MACZ;IACD,CAAC,MAAM,IAAKA,WAAW,CAAC3B,GAAG,CAAE8B,UAAW,CAAC,EAAG;MAC3C,OAAO,IAAI;IACZ;EACD;;EAEA;EACAH,WAAW,CAACI,MAAM,CAAEZ,IAAK,CAAC;EAC1B,OAAO,KAAK;AACb","ignoreList":[]}
1
+ {"version":3,"names":["useRegistry","cachedParsers","WeakMap","useParsePatternDependencies","registry","has","deps","Map","set","parsePatternDependencies","bind","get","name","blocks","queue","length","block","shift","innerBlock","_block$innerBlocks","innerBlocks","unshift","registerDependency","attributes","slug","a","b","Set","add","hasCycle","TypeError","visitedNodes","currentPath","_deps$get","dependencies","dependency","delete"],"sources":["@wordpress/block-library/src/pattern/recursion-detector.js"],"sourcesContent":["/**\n * THIS MODULE IS INTENTIONALLY KEPT WITHIN THE PATTERN BLOCK'S SOURCE.\n *\n * This is because this approach for preventing infinite loops due to\n * recursively rendering blocks is specific to the way that the `core/pattern`\n * block behaves in the editor. Any other block types that deal with recursion\n * SHOULD USE THE STANDARD METHOD for avoiding loops:\n *\n * @see https://github.com/WordPress/gutenberg/pull/31455\n * @see packages/block-editor/src/components/recursion-provider/README.md\n */\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\n\n/**\n * Naming is hard.\n *\n * @see useParsePatternDependencies\n *\n * @type {WeakMap<Object, Function>}\n */\nconst cachedParsers = new WeakMap();\n\n/**\n * Hook used by PatternEdit to parse block patterns. It returns a function that\n * takes a pattern and returns nothing but throws an error if the pattern is\n * recursive.\n *\n * @example\n * ```js\n * const parsePatternDependencies = useParsePatternDependencies();\n * parsePatternDependencies( selectedPattern );\n * ```\n *\n * @see parsePatternDependencies\n *\n * @return {Function} A function to parse block patterns.\n */\nexport function useParsePatternDependencies() {\n\tconst registry = useRegistry();\n\n\t// Instead of caching maps, go straight to the point and cache bound\n\t// functions. Each of those functions is bound to a different Map that will\n\t// keep track of patterns in the context of the given registry.\n\tif ( ! cachedParsers.has( registry ) ) {\n\t\tconst deps = new Map();\n\t\tcachedParsers.set(\n\t\t\tregistry,\n\t\t\tparsePatternDependencies.bind( null, deps )\n\t\t);\n\t}\n\treturn cachedParsers.get( registry );\n}\n\n/**\n * Parse a given pattern and traverse its contents to detect any subsequent\n * patterns on which it may depend. Such occurrences will be added to an\n * internal dependency graph. If a circular dependency is detected, an\n * error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {Object} pattern Pattern.\n * @param {string} pattern.name Pattern name.\n * @param {Array} pattern.blocks Pattern's block list.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function parsePatternDependencies( deps, { name, blocks } ) {\n\tconst queue = [ ...blocks ];\n\twhile ( queue.length ) {\n\t\tconst block = queue.shift();\n\t\tfor ( const innerBlock of block.innerBlocks ?? [] ) {\n\t\t\tqueue.unshift( innerBlock );\n\t\t}\n\t\tif ( block.name === 'core/pattern' ) {\n\t\t\tregisterDependency( deps, name, block.attributes.slug );\n\t\t}\n\t}\n}\n\n/**\n * Declare that pattern `a` depends on pattern `b`. If a circular\n * dependency is detected, an error will be thrown.\n *\n * EXPORTED FOR TESTING PURPOSES ONLY.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} a Slug for pattern A.\n * @param {string} b Slug for pattern B.\n *\n * @throws {Error} If a circular dependency is detected.\n */\nexport function registerDependency( deps, a, b ) {\n\tif ( ! deps.has( a ) ) {\n\t\tdeps.set( a, new Set() );\n\t}\n\tdeps.get( a ).add( b );\n\tif ( hasCycle( deps, a ) ) {\n\t\tthrow new TypeError(\n\t\t\t`Pattern ${ a } has a circular dependency and cannot be rendered.`\n\t\t);\n\t}\n}\n\n/**\n * Determine if a given pattern has circular dependencies on other patterns.\n * This will be determined by running a depth-first search on the current state\n * of the graph represented by `patternDependencies`.\n *\n * @param {Map<string, Set<string>>} deps Map of pattern dependencies.\n * @param {string} slug Pattern slug.\n * @param {Set<string>} [visitedNodes] Set to track visited nodes in the graph.\n * @param {Set<string>} [currentPath] Set to track and backtrack graph paths.\n * @return {boolean} Whether any cycle was found.\n */\nfunction hasCycle(\n\tdeps,\n\tslug,\n\tvisitedNodes = new Set(),\n\tcurrentPath = new Set()\n) {\n\tvisitedNodes.add( slug );\n\tcurrentPath.add( slug );\n\n\tconst dependencies = deps.get( slug ) ?? new Set();\n\n\tfor ( const dependency of dependencies ) {\n\t\tif ( ! visitedNodes.has( dependency ) ) {\n\t\t\tif ( hasCycle( deps, dependency, visitedNodes, currentPath ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if ( currentPath.has( dependency ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Remove the current node from the current path when backtracking\n\tcurrentPath.delete( slug );\n\treturn false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,IAAIC,OAAO,CAAC,CAAC;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,2BAA2BA,CAAA,EAAG;EAC7C,MAAMC,QAAQ,GAAGJ,WAAW,CAAC,CAAC;;EAE9B;EACA;EACA;EACA,IAAK,CAAEC,aAAa,CAACI,GAAG,CAAED,QAAS,CAAC,EAAG;IACtC,MAAME,IAAI,GAAG,IAAIC,GAAG,CAAC,CAAC;IACtBN,aAAa,CAACO,GAAG,CAChBJ,QAAQ,EACRK,wBAAwB,CAACC,IAAI,CAAE,IAAI,EAAEJ,IAAK,CAC3C,CAAC;EACF;EACA,OAAOL,aAAa,CAACU,GAAG,CAAEP,QAAS,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,wBAAwBA,CAAEH,IAAI,EAAE;EAAEM,IAAI;EAAEC;AAAO,CAAC,EAAG;EAClE,MAAMC,KAAK,GAAG,CAAE,GAAGD,MAAM,CAAE;EAC3B,OAAQC,KAAK,CAACC,MAAM,EAAG;IACtB,MAAMC,KAAK,GAAGF,KAAK,CAACG,KAAK,CAAC,CAAC;IAC3B,KAAM,MAAMC,UAAU,KAAAC,kBAAA,GAAIH,KAAK,CAACI,WAAW,cAAAD,kBAAA,cAAAA,kBAAA,GAAI,EAAE,EAAG;MA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GAAG,CAAE8B,UAAW,CAAC,EAAG;MACvC,IAAKN,QAAQ,CAAEvB,IAAI,EAAE6B,UAAU,EAAEJ,YAAY,EAAEC,WAAY,CAAC,EAAG;QAC9D,OAAO,IAAI;MACZ;IACD,CAAC,MAAM,IAAKA,WAAW,CAAC3B,GAAG,CAAE8B,UAAW,CAAC,EAAG;MAC3C,OAAO,IAAI;IACZ;EACD;;EAEA;EACAH,WAAW,CAACI,MAAM,CAAEZ,IAAK,CAAC;EAC1B,OAAO,KAAK;AACb","ignoreList":[]}
@@ -10,7 +10,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
10
10
  */
11
11
  import QueryContent from './query-content';
12
12
  import QueryPlaceholder from './query-placeholder';
13
- import PatternSelectionModal from './pattern-selection-modal';
13
+ import { PatternSelectionModal } from './pattern-selection';
14
14
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  const QueryEdit = props => {
16
16
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useState","store","blockEditorStore","QueryContent","QueryPlaceholder","PatternSelectionModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","QueryEdit","props","clientId","attributes","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","hasInnerBlocks","select","getBlocks","length","Component","children","openPatternSelectionModal"],"sources":["@wordpress/block-library/src/query/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport QueryContent from './query-content';\nimport QueryPlaceholder from './query-placeholder';\nimport PatternSelectionModal from './pattern-selection-modal';\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, attributes } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPlaceholder;\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<PatternSelectionModal\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetIsPatternSelectionModalOpen={\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,qBAAqB,MAAM,2BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9D,MAAMC,SAAS,GAAKC,KAAK,IAAM;EAC9B,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAGF,KAAK;EACtC,MAAM,CAAEG,2BAA2B,EAAEC,8BAA8B,CAAE,GACpEjB,QAAQ,CAAE,KAAM,CAAC;EAClB,MAAMkB,cAAc,GAAGnB,SAAS,CAC7BoB,MAAM,IACP,CAAC,CAAEA,MAAM,CAAEjB,gBAAiB,CAAC,CAACkB,SAAS,CAAEN,QAAS,CAAC,CAACO,MAAM,EAC3D,CAAEP,QAAQ,CACX,CAAC;EACD,MAAMQ,SAAS,GAAGJ,cAAc,GAAGf,YAAY,GAAGC,gBAAgB;EAClE,oBACCO,KAAA,CAAAF,SAAA;IAAAc,QAAA,gBACChB,IAAA,CAACe,SAAS;MAAA,GACJT,KAAK;MACVW,yBAAyB,EAAGA,CAAA,KAC3BP,8BAA8B,CAAE,IAAK;IACrC,CACD,CAAC,EACAD,2BAA2B,iBAC5BT,IAAA,CAACF,qBAAqB;MACrBS,QAAQ,EAAGA,QAAU;MACrBC,UAAU,EAAGA,UAAY;MACzBE,8BAA8B,EAC7BA;IACA,CACD,CACD;EAAA,CACA,CAAC;AAEL,CAAC;AAED,eAAeL,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useState","store","blockEditorStore","QueryContent","QueryPlaceholder","PatternSelectionModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","QueryEdit","props","clientId","attributes","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","hasInnerBlocks","select","getBlocks","length","Component","children","openPatternSelectionModal"],"sources":["@wordpress/block-library/src/query/edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport QueryContent from './query-content';\nimport QueryPlaceholder from './query-placeholder';\nimport { PatternSelectionModal } from './pattern-selection';\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, attributes } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPlaceholder;\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<PatternSelectionModal\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetIsPatternSelectionModalOpen={\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,SAASC,qBAAqB,QAAQ,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE5D,MAAMC,SAAS,GAAKC,KAAK,IAAM;EAC9B,MAAM;IAAEC,QAAQ;IAAEC;EAAW,CAAC,GAAGF,KAAK;EACtC,MAAM,CAAEG,2BAA2B,EAAEC,8BAA8B,CAAE,GACpEjB,QAAQ,CAAE,KAAM,CAAC;EAClB,MAAMkB,cAAc,GAAGnB,SAAS,CAC7BoB,MAAM,IACP,CAAC,CAAEA,MAAM,CAAEjB,gBAAiB,CAAC,CAACkB,SAAS,CAAEN,QAAS,CAAC,CAACO,MAAM,EAC3D,CAAEP,QAAQ,CACX,CAAC;EACD,MAAMQ,SAAS,GAAGJ,cAAc,GAAGf,YAAY,GAAGC,gBAAgB;EAClE,oBACCO,KAAA,CAAAF,SAAA;IAAAc,QAAA,gBACChB,IAAA,CAACe,SAAS;MAAA,GACJT,KAAK;MACVW,yBAAyB,EAAGA,CAAA,KAC3BP,8BAA8B,CAAE,IAAK;IACrC,CACD,CAAC,EACAD,2BAA2B,iBAC5BT,IAAA,CAACF,qBAAqB;MACrBS,QAAQ,EAAGA,QAAU;MACrBC,UAAU,EAAGA,UAAY;MACzBE,8BAA8B,EAC7BA;IACA,CACD,CACD;EAAA,CACA,CAAC;AAEL,CAAC;AAED,eAAeL,SAAS","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  /**
3
2
  * WordPress dependencies
4
3
  */
@@ -1 +1 @@
1
- {"version":3,"names":["__","FormTokenField","useSelect","store","coreStore","getEntitiesInfo","jsx","_jsx","AUTHORS_QUERY","who","per_page","_fields","context","AuthorControl","value","onChange","authorsList","select","getUsers","authorsInfo","normalizedValue","toString","split","sanitizedValue","reduce","accumulator","authorId","author","mapById","push","id","name","getIdByValue","entitiesMappedByName","authorValue","onAuthorChange","newValue","ids","Array","from","mapByName","add","Set","join","label","suggestions","names","__experimentalShowHowTo","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/author-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo } from '../../utils';\n\nconst AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: -1,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nfunction AuthorControl( { value, onChange } ) {\n\tconst authorsList = useSelect( ( select ) => {\n\t\tconst { getUsers } = select( coreStore );\n\t\treturn getUsers( AUTHORS_QUERY );\n\t}, [] );\n\n\tif ( ! authorsList ) {\n\t\treturn null;\n\t}\n\tconst authorsInfo = getEntitiesInfo( authorsList );\n\t/**\n\t * We need to normalize the value because the block operates on a\n\t * comma(`,`) separated string value and `FormTokenFiels` needs an\n\t * array.\n\t */\n\tconst normalizedValue = ! value ? [] : value.toString().split( ',' );\n\t// Returns only the existing authors ids. This prevents the component\n\t// from crashing in the editor, when non existing ids are provided.\n\tconst sanitizedValue = normalizedValue.reduce(\n\t\t( accumulator, authorId ) => {\n\t\t\tconst author = authorsInfo.mapById[ authorId ];\n\t\t\tif ( author ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid: authorId,\n\t\t\t\t\tvalue: author.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\n\tconst getIdByValue = ( entitiesMappedByName, authorValue ) => {\n\t\tconst id = authorValue?.id || entitiesMappedByName[ authorValue ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onAuthorChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, author ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( authorsInfo.mapByName, author );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tonChange( { author: ids.join( ',' ) } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ __( 'Authors' ) }\n\t\t\tvalue={ sanitizedValue }\n\t\t\tsuggestions={ authorsInfo.names }\n\t\t\tonChange={ onAuthorChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t/>\n\t);\n}\n\nexport default AuthorControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9C,MAAMC,aAAa,GAAG;EACrBC,GAAG,EAAE,SAAS;EACdC,QAAQ,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,CAACZ,MAAM,CAAE,CAAEC,WAAW,EAAEE,MAAM,KAAM;MAC3C;MACA,MAAMG,EAAE,GAAGE,YAAY,CAAEb,WAAW,CAACqB,SAAS,EAAEb,MAAO,CAAC;MACxD,IAAKG,EAAE,EAAG;QACTL,WAAW,CAACgB,GAAG,CAAEX,EAAG,CAAC;MACtB;MACA,OAAOL,WAAW;IACnB,CAAC,EAAE,IAAIiB,GAAG,CAAC,CAAE,CACd,CAAC;IACD3B,QAAQ,CAAE;MAAEY,MAAM,EAAEU,GAAG,CAACM,IAAI,CAAE,GAAI;IAAE,CAAE,CAAC;EACxC,CAAC;EACD,oBACCpC,IAAA,CAACN,cAAc;IACd2C,KAAK,EAAG5C,EAAE,CAAE,SAAU,CAAG;IACzBc,KAAK,EAAGS,cAAgB;IACxBsB,WAAW,EAAG1B,WAAW,CAAC2B,KAAO;IACjC/B,QAAQ,EAAGoB,cAAgB;IAC3BY,uBAAuB,EAAG,KAAO;IACjCC,uBAAuB;IACvBC,qBAAqB;EAAA,CACrB,CAAC;AAEJ;AAEA,eAAepC,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["__","FormTokenField","useSelect","store","coreStore","getEntitiesInfo","jsx","_jsx","AUTHORS_QUERY","who","per_page","_fields","context","AuthorControl","value","onChange","authorsList","select","getUsers","authorsInfo","normalizedValue","toString","split","sanitizedValue","reduce","accumulator","authorId","author","mapById","push","id","name","getIdByValue","entitiesMappedByName","authorValue","onAuthorChange","newValue","ids","Array","from","mapByName","add","Set","join","label","suggestions","names","__experimentalShowHowTo","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/author-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo } from '../../utils';\n\nconst AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: -1,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nfunction AuthorControl( { value, onChange } ) {\n\tconst authorsList = useSelect( ( select ) => {\n\t\tconst { getUsers } = select( coreStore );\n\t\treturn getUsers( AUTHORS_QUERY );\n\t}, [] );\n\n\tif ( ! authorsList ) {\n\t\treturn null;\n\t}\n\tconst authorsInfo = getEntitiesInfo( authorsList );\n\t/**\n\t * We need to normalize the value because the block operates on a\n\t * comma(`,`) separated string value and `FormTokenFiels` needs an\n\t * array.\n\t */\n\tconst normalizedValue = ! value ? [] : value.toString().split( ',' );\n\t// Returns only the existing authors ids. This prevents the component\n\t// from crashing in the editor, when non existing ids are provided.\n\tconst sanitizedValue = normalizedValue.reduce(\n\t\t( accumulator, authorId ) => {\n\t\t\tconst author = authorsInfo.mapById[ authorId ];\n\t\t\tif ( author ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid: authorId,\n\t\t\t\t\tvalue: author.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\n\tconst getIdByValue = ( entitiesMappedByName, authorValue ) => {\n\t\tconst id = authorValue?.id || entitiesMappedByName[ authorValue ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onAuthorChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, author ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( authorsInfo.mapByName, author );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tonChange( { author: ids.join( ',' ) } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ __( 'Authors' ) }\n\t\t\tvalue={ sanitizedValue }\n\t\t\tsuggestions={ authorsInfo.names }\n\t\t\tonChange={ onAuthorChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t/>\n\t);\n}\n\nexport default AuthorControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9C,MAAMC,aAAa,GAAG;EACrBC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,CAAC,CAAC;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;AAED,SAASC,aAAaA,CAAE;EAAEC,KAAK;EAAEC;AAAS,CAAC,EAAG;EAC7C,MAAMC,WAAW,GAAGd,SAAS,CAAIe,MAAM,IAAM;IAC5C,MAAM;MAAEC;IAAS,CAAC,GAAGD,MAAM,CAAEb,SAAU,CAAC;IACxC,OAAOc,QAAQ,CAAEV,aAAc,CAAC;EACjC,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEQ,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EACA,MAAMG,WAAW,GAAGd,eAAe,CAAEW,WAAY,CAAC;EAClD;AACD;AACA;AACA;AACA;EACC,MAAMI,eAAe,GAAG,CAAEN,KAAK,GAAG,EAAE,GAAGA,KAAK,CAACO,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAE,GAAI,CAAC;EACpE;EACA;EACA,MAAMC,cAAc,GAAGH,eAAe,CAACI,MAAM,CAC5C,CAAEC,WAAW,EAAEC,QAAQ,KAAM;IAC5B,MAAMC,MAAM,GAAGR,WAAW,CAACS,OAAO,CAAEF,QAAQ,CAAE;IAC9C,IAAKC,MAAM,EAAG;MACbF,WAAW,CAACI,IAAI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names":["__","FormTokenField","useSelect","store","coreStore","useState","useEffect","useMemo","useDebounce","getEntitiesInfo","mapToIHasNameAndId","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","currentParents","length","include","currentParentsInfo","sanitizedValue","reduce","accumulator","id","entity","mapById","push","name","entitiesInfo","names","getIdByValue","entitiesMappedByName","onParentChange","newValue","ids","Array","from","mapByName","add","Set","__next40pxDefaultSize","label","onInputChange","__experimentalShowHowTo","__nextHasNoMarginBottom"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, mapToIHasNameAndId } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,title',\n\tcontext: 'view',\n};\n\nfunction ParentControl( { parents, postType, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\texclude: parents,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, parents ]\n\t);\n\tconst currentParents = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parents?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', postType, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: parents,\n\t\t\t\tper_page: parents.length,\n\t\t\t} );\n\t\t},\n\t\t[ parents ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing parents.\n\tuseEffect( () => {\n\t\tif ( ! parents?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! currentParents?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentParentsInfo = getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( currentParents, 'title.rendered' )\n\t\t);\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = parents.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = currentParentsInfo.mapById[ id ];\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ parents, currentParents ] );\n\n\tconst entitiesInfo = useMemo( () => {\n\t\tif ( ! searchResults?.length ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( searchResults, 'title.rendered' )\n\t\t);\n\t}, [ searchResults ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( entitiesInfo.names );\n\t}, [ entitiesInfo.names, searchHasResolved ] );\n\n\tconst getIdByValue = ( entitiesMappedByName, entity ) => {\n\t\tconst id = entity?.id || entitiesMappedByName?.[ entity ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onParentChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, entity ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( entitiesInfo.mapByName, entity );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( { parents: ids } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parents' ) }\n\t\t\tvalue={ value }\n\t\t\tonInputChange={ debouncedSearch }\n\t\t\tsuggestions={ suggestions }\n\t\t\tonChange={ onParentChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default ParentControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAo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AC3BL,QAAQ,EAAGiC,cAAgB;IAC3BW,uBAAuB,EAAG,KAAO;IACjCC,uBAAuB;EAAA,CACvB,CAAC;AAEJ;AAEA,eAAehD,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["__","FormTokenField","useSelect","store","coreStore","useState","useEffect","useMemo","useDebounce","getEntitiesInfo","mapToIHasNameAndId","jsx","_jsx","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","currentParents","length","include","currentParentsInfo","sanitizedValue","reduce","accumulator","id","entity","mapById","push","name","entitiesInfo","names","getIdByValue","entitiesMappedByName","onParentChange","newValue","ids","Array","from","mapByName","add","Set","__next40pxDefaultSize","label","onInputChange","__experimentalShowHowTo","__nextHasNoMarginBottom"],"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, mapToIHasNameAndId } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,title',\n\tcontext: 'view',\n};\n\nfunction ParentControl( { parents, postType, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t\texclude: parents,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, parents ]\n\t);\n\tconst currentParents = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! parents?.length ) {\n\t\t\t\treturn EMPTY_ARRAY;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'postType', postType, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: parents,\n\t\t\t\tper_page: parents.length,\n\t\t\t} );\n\t\t},\n\t\t[ parents ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing parents.\n\tuseEffect( () => {\n\t\tif ( ! parents?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! currentParents?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentParentsInfo = getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( currentParents, 'title.rendered' )\n\t\t);\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = parents.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = currentParentsInfo.mapById[ id ];\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ parents, currentParents ] );\n\n\tconst entitiesInfo = useMemo( () => {\n\t\tif ( ! searchResults?.length ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn getEntitiesInfo(\n\t\t\tmapToIHasNameAndId( searchResults, 'title.rendered' )\n\t\t);\n\t}, [ searchResults ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) {\n\t\t\treturn;\n\t\t}\n\t\tsetSuggestions( entitiesInfo.names );\n\t}, [ entitiesInfo.names, searchHasResolved ] );\n\n\tconst getIdByValue = ( entitiesMappedByName, entity ) => {\n\t\tconst id = entity?.id || entitiesMappedByName?.[ entity ]?.id;\n\t\tif ( id ) {\n\t\t\treturn id;\n\t\t}\n\t};\n\tconst onParentChange = ( newValue ) => {\n\t\tconst ids = Array.from(\n\t\t\tnewValue.reduce( ( accumulator, entity ) => {\n\t\t\t\t// Verify that new values point to existing entities.\n\t\t\t\tconst id = getIdByValue( entitiesInfo.mapByName, entity );\n\t\t\t\tif ( id ) {\n\t\t\t\t\taccumulator.add( id );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( { parents: ids } );\n\t};\n\treturn (\n\t\t<FormTokenField\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parents' ) }\n\t\t\tvalue={ value }\n\t\t\tonInputChange={ debouncedSearch }\n\t\t\tsuggestions={ suggestions }\n\t\t\tonChange={ onParentChange }\n\t\t\t__experimentalShowHowTo={ false }\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n\nexport default ParentControl;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,uBAA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