@wordpress/block-library 7.15.0 → 7.16.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 (180) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/build/code/utils.js +3 -3
  3. package/build/code/utils.js.map +1 -1
  4. package/build/comments-pagination-numbers/index.js +7 -0
  5. package/build/comments-pagination-numbers/index.js.map +1 -1
  6. package/build/gallery/gallery.js +2 -28
  7. package/build/gallery/gallery.js.map +1 -1
  8. package/build/group/edit.js +1 -1
  9. package/build/group/edit.js.map +1 -1
  10. package/build/navigation/edit/index.js +12 -12
  11. package/build/navigation/edit/index.js.map +1 -1
  12. package/build/paragraph/deprecated.js +49 -10
  13. package/build/paragraph/deprecated.js.map +1 -1
  14. package/build/paragraph/drop-zone.js +99 -0
  15. package/build/paragraph/drop-zone.js.map +1 -0
  16. package/build/paragraph/edit.js +30 -6
  17. package/build/paragraph/edit.js.map +1 -1
  18. package/build/paragraph/save.js +3 -1
  19. package/build/paragraph/save.js.map +1 -1
  20. package/build/post-author/edit.js +20 -2
  21. package/build/post-author/edit.js.map +1 -1
  22. package/build/post-author/index.js +8 -0
  23. package/build/post-author/index.js.map +1 -1
  24. package/build/post-content/edit.js +6 -1
  25. package/build/post-content/edit.js.map +1 -1
  26. package/build/post-featured-image/index.js +1 -1
  27. package/build/post-featured-image/overlay.js +2 -2
  28. package/build/post-featured-image/overlay.js.map +1 -1
  29. package/build/post-terms/index.js +4 -0
  30. package/build/post-terms/index.js.map +1 -1
  31. package/build/query/edit/inspector-controls/author-control.js +2 -1
  32. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  33. package/build/query/edit/inspector-controls/index.js +1 -1
  34. package/build/query/edit/inspector-controls/index.js.map +1 -1
  35. package/build/query/edit/inspector-controls/parent-control.js +2 -1
  36. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  37. package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -1
  38. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  39. package/build/query/utils.js +1 -1
  40. package/build/query/utils.js.map +1 -1
  41. package/build/quote/index.js +0 -1
  42. package/build/quote/index.js.map +1 -1
  43. package/build/site-title/index.js +2 -1
  44. package/build/site-title/index.js.map +1 -1
  45. package/build/template-part/index.js +2 -2
  46. package/build/template-part/index.js.map +1 -1
  47. package/build/video/edit.js +13 -1
  48. package/build/video/edit.js.map +1 -1
  49. package/build-module/code/utils.js +3 -3
  50. package/build-module/code/utils.js.map +1 -1
  51. package/build-module/comments-pagination-numbers/index.js +7 -0
  52. package/build-module/comments-pagination-numbers/index.js.map +1 -1
  53. package/build-module/gallery/gallery.js +2 -29
  54. package/build-module/gallery/gallery.js.map +1 -1
  55. package/build-module/group/edit.js +1 -1
  56. package/build-module/group/edit.js.map +1 -1
  57. package/build-module/navigation/edit/index.js +12 -12
  58. package/build-module/navigation/edit/index.js.map +1 -1
  59. package/build-module/paragraph/deprecated.js +49 -11
  60. package/build-module/paragraph/deprecated.js.map +1 -1
  61. package/build-module/paragraph/drop-zone.js +88 -0
  62. package/build-module/paragraph/drop-zone.js.map +1 -0
  63. package/build-module/paragraph/edit.js +29 -6
  64. package/build-module/paragraph/edit.js.map +1 -1
  65. package/build-module/paragraph/save.js +2 -1
  66. package/build-module/paragraph/save.js.map +1 -1
  67. package/build-module/post-author/edit.js +21 -2
  68. package/build-module/post-author/edit.js.map +1 -1
  69. package/build-module/post-author/index.js +8 -0
  70. package/build-module/post-author/index.js.map +1 -1
  71. package/build-module/post-content/edit.js +6 -1
  72. package/build-module/post-content/edit.js.map +1 -1
  73. package/build-module/post-featured-image/index.js +1 -1
  74. package/build-module/post-featured-image/overlay.js +2 -2
  75. package/build-module/post-featured-image/overlay.js.map +1 -1
  76. package/build-module/post-terms/index.js +4 -0
  77. package/build-module/post-terms/index.js.map +1 -1
  78. package/build-module/query/edit/inspector-controls/author-control.js +2 -1
  79. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  80. package/build-module/query/edit/inspector-controls/index.js +1 -1
  81. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  82. package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
  83. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  84. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -1
  85. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  86. package/build-module/query/utils.js +1 -1
  87. package/build-module/query/utils.js.map +1 -1
  88. package/build-module/quote/index.js +0 -1
  89. package/build-module/quote/index.js.map +1 -1
  90. package/build-module/site-title/index.js +2 -1
  91. package/build-module/site-title/index.js.map +1 -1
  92. package/build-module/template-part/index.js +2 -2
  93. package/build-module/template-part/index.js.map +1 -1
  94. package/build-module/video/edit.js +15 -3
  95. package/build-module/video/edit.js.map +1 -1
  96. package/build-style/classic-rtl.css +85 -0
  97. package/build-style/classic.css +85 -0
  98. package/build-style/code/style-rtl.css +3 -0
  99. package/build-style/code/style.css +3 -0
  100. package/build-style/editor-rtl.css +110 -31
  101. package/build-style/editor.css +110 -31
  102. package/build-style/group/editor-rtl.css +11 -1
  103. package/build-style/group/editor.css +11 -1
  104. package/build-style/image/editor-rtl.css +3 -0
  105. package/build-style/image/editor.css +3 -0
  106. package/build-style/navigation/editor-rtl.css +15 -1
  107. package/build-style/navigation/editor.css +15 -1
  108. package/build-style/navigation/style-rtl.css +3 -0
  109. package/build-style/navigation/style.css +3 -0
  110. package/build-style/paragraph/editor-rtl.css +16 -0
  111. package/build-style/paragraph/editor.css +16 -0
  112. package/build-style/paragraph/style-rtl.css +5 -0
  113. package/build-style/paragraph/style.css +5 -0
  114. package/build-style/post-featured-image/editor-rtl.css +39 -29
  115. package/build-style/post-featured-image/editor.css +39 -29
  116. package/build-style/post-terms/style-rtl.css +4 -1
  117. package/build-style/post-terms/style.css +4 -1
  118. package/build-style/site-title/editor-rtl.css +4 -0
  119. package/build-style/site-title/editor.css +4 -0
  120. package/build-style/site-title/style-rtl.css +79 -0
  121. package/build-style/site-title/style.css +79 -0
  122. package/build-style/style-rtl.css +19 -1
  123. package/build-style/style.css +19 -1
  124. package/build-style/video/editor-rtl.css +22 -0
  125. package/build-style/video/editor.css +22 -0
  126. package/package.json +28 -28
  127. package/src/archives/index.php +4 -7
  128. package/src/categories/index.php +1 -1
  129. package/src/classic.scss +15 -0
  130. package/src/code/style.scss +12 -7
  131. package/src/code/utils.js +3 -3
  132. package/src/comment-author-name/index.php +1 -1
  133. package/src/comment-reply-link/index.php +1 -1
  134. package/src/comment-template/index.php +18 -9
  135. package/src/comments-pagination-numbers/block.json +7 -0
  136. package/src/cover/index.php +1 -1
  137. package/src/gallery/gallery.js +1 -31
  138. package/src/group/edit.js +1 -1
  139. package/src/image/editor.scss +4 -0
  140. package/src/latest-posts/index.php +1 -1
  141. package/src/navigation/edit/index.js +12 -10
  142. package/src/navigation/editor.scss +6 -0
  143. package/src/navigation/style.scss +8 -0
  144. package/src/navigation-submenu/index.php +11 -2
  145. package/src/page-list/index.php +3 -3
  146. package/src/paragraph/deprecated.js +36 -0
  147. package/src/paragraph/drop-zone.js +105 -0
  148. package/src/paragraph/edit.js +37 -9
  149. package/src/paragraph/editor.scss +20 -0
  150. package/src/paragraph/save.js +5 -1
  151. package/src/paragraph/style.scss +5 -0
  152. package/src/post-author/block.json +8 -0
  153. package/src/post-author/edit.js +29 -3
  154. package/src/post-author/index.php +7 -1
  155. package/src/post-content/edit.js +3 -1
  156. package/src/post-featured-image/block.json +1 -1
  157. package/src/post-featured-image/editor.scss +79 -72
  158. package/src/post-featured-image/index.php +18 -24
  159. package/src/post-featured-image/overlay.js +17 -14
  160. package/src/post-terms/block.json +4 -0
  161. package/src/post-terms/style.scss +7 -2
  162. package/src/query/edit/inspector-controls/author-control.js +1 -0
  163. package/src/query/edit/inspector-controls/index.js +1 -4
  164. package/src/query/edit/inspector-controls/parent-control.js +1 -0
  165. package/src/query/edit/inspector-controls/taxonomy-controls.js +1 -0
  166. package/src/query/utils.js +1 -1
  167. package/src/quote/block.json +0 -1
  168. package/src/site-title/block.json +2 -1
  169. package/src/site-title/editor.scss +6 -0
  170. package/src/site-title/style.scss +5 -0
  171. package/src/style.scss +1 -0
  172. package/src/tag-cloud/index.php +1 -8
  173. package/src/template-part/index.js +2 -2
  174. package/src/video/edit.js +19 -0
  175. package/src/video/editor.scss +37 -0
  176. package/build/navigation-submenu/view.js +0 -56
  177. package/build/navigation-submenu/view.js.map +0 -1
  178. package/build-module/navigation-submenu/view.js +0 -54
  179. package/build-module/navigation-submenu/view.js.map +0 -1
  180. package/src/navigation-submenu/view.js +0 -67
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","inherit","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uB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D;AAAS,IAAA,OAAO,EAAG7B,OAAnB;AAA6B,IAAA,MAAM,EAAGD;AAAtC,IADC,GAGD,4BAAC,WAAD,OAJF,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-content/edit.js"],"names":["ReadOnlyContent","userCanEdit","postType","postId","content","blockProps","protected","__html","rendered","EditableContent","layout","context","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","type","blocks","onInput","onChange","id","props","className","value","__experimentalLayout","undefined","Content","queryId","isDescendentOfQueryLoop","Number","isFinite","isEditable","Placeholder","RecursionError","PostContentEdit","attributes","contextPostId","contextPostType","hasAlreadyRendered"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AASA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,SAASA,eAAT,OAA8D;AAAA,MAApC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA;AAAzB,GAAoC;AAC7D,QAAM,IAAMC,OAAN,IAAkB,6BACvB,UADuB,EAEvBF,QAFuB,EAGvB,SAHuB,EAIvBC,MAJuB,CAAxB;AAMA,QAAME,UAAU,GAAG,iCAAnB;AACA,SAAOD,OAAO,SAAP,IAAAA,OAAO,WAAP,IAAAA,OAAO,CAAEE,SAAT,IAAsB,CAAEL,WAAxB,GACN,mCAAUI,UAAV,EACC,4BAAC,oBAAD,QAAW,cAAI,qCAAJ,CAAX,CADD,CADM,GAKN,8DACMA,UADN;AAEC,IAAA,uBAAuB,EAAG;AAAEE,MAAAA,MAAM,EAAEH,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI;AAAnB;AAF3B,KALD;AAUA;;AAED,SAASC,eAAT,QAAqD;AAAA,MAA3B;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAO,GAAG;AAApB,GAA2B;AACpD,QAAM;AAAET,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuB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 } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tstore as blockEditorStore,\n\tWarning,\n} from '@wordpress/block-editor';\nimport { useEntityProp, useEntityBlockEditor } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCanEditEntity } from '../utils/hooks';\n\nfunction ReadOnlyContent( { userCanEdit, postType, postId } ) {\n\tconst [ , , content ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'content',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps();\n\treturn content?.protected && ! userCanEdit ? (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>{ __( 'This content is password protected.' ) }</Warning>\n\t\t</div>\n\t) : (\n\t\t<div\n\t\t\t{ ...blockProps }\n\t\t\tdangerouslySetInnerHTML={ { __html: content?.rendered } }\n\t\t></div>\n\t);\n}\n\nfunction EditableContent( { layout, context = {} } ) {\n\tconst { postType, postId } = context;\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpostType,\n\t\t{ id: postId }\n\t);\n\n\tconst props = useInnerBlocksProps(\n\t\tuseBlockProps( { className: 'entry-content' } ),\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t\t}\n\t);\n\treturn <div { ...props } />;\n}\n\nfunction Content( props ) {\n\tconst { context: { queryId, postType, postId } = {} } = props;\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst isEditable = userCanEdit && ! isDescendentOfQueryLoop;\n\n\treturn isEditable ? (\n\t\t<EditableContent { ...props } />\n\t) : (\n\t\t<ReadOnlyContent\n\t\t\tuserCanEdit={ userCanEdit }\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t/>\n\t);\n}\n\nfunction Placeholder() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'This is the Post Content block, it will display all the blocks in any single post or page.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n\nfunction RecursionError() {\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t</div>\n\t);\n}\n\nexport default function PostContentEdit( { context, attributes } ) {\n\tconst { postId: contextPostId, postType: contextPostType } = context;\n\tconst { layout = {} } = attributes;\n\tconst hasAlreadyRendered = useHasRecursion( contextPostId );\n\n\tif ( contextPostId && contextPostType && hasAlreadyRendered ) {\n\t\treturn <RecursionError />;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ contextPostId }>\n\t\t\t{ contextPostId && contextPostType ? (\n\t\t\t\t<Content context={ context } layout={ layout } />\n\t\t\t) : (\n\t\t\t\t<Placeholder />\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
@@ -84,7 +84,7 @@ const metadata = {
84
84
  color: true,
85
85
  radius: true,
86
86
  width: true,
87
- __experimentalSelector: "img, .block-editor-media-placeholder",
87
+ __experimentalSelector: "img, .block-editor-media-placeholder, .wp-block-post-featured-image__overlay",
88
88
  __experimentalSkipSerialization: true,
89
89
  __experimentalDefaultControls: {
90
90
  color: true,
@@ -57,14 +57,14 @@ const Overlay = _ref => {
57
57
  backgroundImage: gradientValue,
58
58
  ...borderProps.style
59
59
  };
60
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("span", {
60
+ return (0, _element.createElement)(_element.Fragment, null, !!dimRatio && (0, _element.createElement)("span", {
61
61
  "aria-hidden": "true",
62
62
  className: (0, _classnames.default)('wp-block-post-featured-image__overlay', (0, _utils.dimRatioToClass)(dimRatio), {
63
63
  [overlayColor.class]: overlayColor.class,
64
64
  'has-background-dim': dimRatio !== undefined,
65
65
  'has-background-gradient': gradientValue,
66
66
  [gradientClass]: gradientClass
67
- }),
67
+ }, borderProps.className),
68
68
  style: overlayStyles
69
69
  }), (0, _element.createElement)(_blockEditor.InspectorControls, {
70
70
  __experimentalGroup: "color"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-featured-image/overlay.js"],"names":["Overlay","clientId","attributes","setAttributes","overlayColor","setOverlayColor","dimRatio","gradientClass","gradientValue","setGradient","colorGradientSettings","borderProps","overlayStyles","backgroundColor","color","backgroundImage","style","class","undefined","colorValue","label","onColorChange","onGradientChange","isShownByDefault","resetAllFilter","customOverlayColor","gradient","customGradient","newDimRatio"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AAIA;;AAQA;;AACA;;AAKA;;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AAGA,MAAMA,OAAO,GAAG,QAMT;AAAA,MANW;AACjBC,IAAAA,QADiB;AAEjBC,IAAAA,UAFiB;AAGjBC,IAAAA,aAHiB;AAIjB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AAAA,cAAc,EAAET;AAJO,OAAR;AAPjB,KADU,CAHZ;AAmBC,IAAA,OAAO,EAAGjB;AAnBX,KAoBMS,qBApBN,EADD,EAuBC,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAMJ,QAAQ,KAAKY,SAD/B;AAEC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMf,aAAa,CAAE;AAAEG,MAAAA,QAAQ,EAAE;AAAZ,KAAF,CAHjC;AAIC,IAAA,cAAc,EAAG,OAAQ;AACxBA,MAAAA,QAAQ,EAAE;AADc,KAAR,CAJlB;AAOC,IAAA,gBAAgB,MAPjB;AAQC,IAAA,OAAO,EAAGL;AARX,KAUC,4BAAC,wBAAD;AACC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CADT;AAEC,IAAA,KAAK,EAAGK,QAFT;AAGC,IAAA,QAAQ,EAAKsB,WAAF,IACVzB,aAAa,CAAE;AACdG,MAAAA,QAAQ,EAAEsB;AADI,KAAF,CAJf;AAQC,IAAA,GAAG,EAAG,CARP;AASC,IAAA,GAAG,EAAG,GATP;AAUC,IAAA,IAAI,EAAG,EAVR;AAWC,IAAA,QAAQ;AAXT,IAVD,CAvBD,CAfD,CADD;AAkEA,CArFD;;eAuFe,sBAAS,CACvB,6BAAY;AAAExB,EAAAA,YAAY,EAAE;AAAhB,CAAZ,CADuB,CAAT,EAEVJ,OAFU,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\twithColors,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseGradient,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { dimRatioToClass } from './utils';\n\nconst Overlay = ( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\toverlayColor,\n\tsetOverlayColor,\n} ) => {\n\tconst { dimRatio } = attributes;\n\tconst { gradientClass, gradientValue, setGradient } =\n\t\t__experimentalUseGradient();\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst overlayStyles = {\n\t\tbackgroundColor: overlayColor.color,\n\t\tbackgroundImage: gradientValue,\n\t\t...borderProps.style,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'wp-block-post-featured-image__overlay',\n\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t{\n\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\tstyle={ overlayStyles }\n\t\t\t/>\n\t\t\t<InspectorControls __experimentalGroup=\"color\">\n\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolorValue: overlayColor.color,\n\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\tlabel: __( 'Overlay' ),\n\t\t\t\t\t\t\tonColorChange: setOverlayColor,\n\t\t\t\t\t\t\tonGradientChange: setGradient,\n\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\tresetAllFilter: () => ( {\n\t\t\t\t\t\t\t\toverlayColor: undefined,\n\t\t\t\t\t\t\t\tcustomOverlayColor: undefined,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\tcustomGradient: undefined,\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\tpanelId={ clientId }\n\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t/>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => dimRatio !== undefined }\n\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\tonDeselect={ () => setAttributes( { dimRatio: 0 } ) }\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tdimRatio: 0,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ ( newDimRatio ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\tstep={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( Overlay );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-featured-image/overlay.js"],"names":["Overlay","clientId","attributes","setAttributes","overlayColor","setOverlayColor","dimRatio","gradientClass","gradientValue","setGradient","colorGradientSettings","borderProps","overlayStyles","backgroundColor","color","backgroundImage","style","class","undefined","className","colorValue","label","onColorChange","onGradientChange","isShownByDefault","resetAllFilter","customOverlayColor","gradient","customGradient","newDim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/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\twithColors,\n\t__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,\n\t__experimentalUseGradient,\n\t__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { compose } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { dimRatioToClass } from './utils';\n\nconst Overlay = ( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\toverlayColor,\n\tsetOverlayColor,\n} ) => {\n\tconst { dimRatio } = attributes;\n\tconst { gradientClass, gradientValue, setGradient } =\n\t\t__experimentalUseGradient();\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst overlayStyles = {\n\t\tbackgroundColor: overlayColor.color,\n\t\tbackgroundImage: gradientValue,\n\t\t...borderProps.style,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ !! dimRatio && (\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'wp-block-post-featured-image__overlay',\n\t\t\t\t\t\tdimRatioToClass( dimRatio ),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ overlayColor.class ]: overlayColor.class,\n\t\t\t\t\t\t\t'has-background-dim': dimRatio !== undefined,\n\t\t\t\t\t\t\t'has-background-gradient': gradientValue,\n\t\t\t\t\t\t\t[ gradientClass ]: gradientClass,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tborderProps.className\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ overlayStyles }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<InspectorControls __experimentalGroup=\"color\">\n\t\t\t\t<ColorGradientSettingsDropdown\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\tsettings={ [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolorValue: overlayColor.color,\n\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\tlabel: __( 'Overlay' ),\n\t\t\t\t\t\t\tonColorChange: setOverlayColor,\n\t\t\t\t\t\t\tonGradientChange: setGradient,\n\t\t\t\t\t\t\tisShownByDefault: true,\n\t\t\t\t\t\t\tresetAllFilter: () => ( {\n\t\t\t\t\t\t\t\toverlayColor: undefined,\n\t\t\t\t\t\t\t\tcustomOverlayColor: undefined,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\tcustomGradient: undefined,\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\tpanelId={ clientId }\n\t\t\t\t\t{ ...colorGradientSettings }\n\t\t\t\t/>\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => dimRatio !== undefined }\n\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\tonDeselect={ () => setAttributes( { dimRatio: 0 } ) }\n\t\t\t\t\tresetAllFilter={ () => ( {\n\t\t\t\t\t\tdimRatio: 0,\n\t\t\t\t\t} ) }\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Overlay opacity' ) }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ ( newDimRatio ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdimRatio: newDimRatio,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\tstep={ 10 }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n};\n\nexport default compose( [\n\twithColors( { overlayColor: 'background-color' } ),\n] )( Overlay );\n"]}
@@ -64,6 +64,10 @@ const metadata = {
64
64
  link: true
65
65
  }
66
66
  },
67
+ spacing: {
68
+ margin: true,
69
+ padding: true
70
+ },
67
71
  typography: {
68
72
  fontSize: true,
69
73
  lineHeight: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/post-terms/index.js"],"names":["name","metadata","settings","icon","edit","init","enhanceVariations"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,qBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB;;;AAKA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBACC,0BADD,EAEC,oBAFD,EAGCC,eAHD;AAMA,SAAO,wBAAW;AAAEN,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CARM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postCategories as icon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport enhanceVariations from './hooks';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceVariations\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/post-terms/index.js"],"names":["name","metadata","settings","icon","edit","init","enhanceVariations"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,qBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB;;;AAKA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBACC,0BADD,EAEC,oBAFD,EAGCC,eAHD;AAMA,SAAO,wBAAW;AAAEN,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CARM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postCategories as icon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport enhanceVariations from './hooks';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceVariations\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
@@ -93,7 +93,8 @@ function AuthorControl(_ref) {
93
93
  label: (0, _i18n.__)('Authors'),
94
94
  value: sanitizedValue,
95
95
  suggestions: authorsInfo.names,
96
- onChange: onAuthorChange
96
+ onChange: onAuthorChange,
97
+ __experimentalShowHowTo: false
97
98
  });
98
99
  }
99
100
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/author-control.js"],"names":["AUTHORS_QUERY","who","per_page","_fields","context","AuthorControl","value","onChange","authorsList","select","getUsers","coreStore","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","names"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,GAAG,EAAE,SADgB;AAErBC,EAAAA,QAAQ,EAAE,CAAC,CAFU;AAGrBC,EAAAA,OAAO,EAAE,SAHY;AAIrBC,EAAAA,OAAO,EAAE;AAJY,CAAtB;;AAOA,SAASC,aAAT,OAA8C;AAAA,MAAtB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAsB;AAC7C,QAAMC,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAC5C,UAAM;AAAEC,MAAAA;AAAF,QAAeD,MAAM,CAAEE,eAAF,CAA3B;AACA,WAAOD,QAAQ,CAAEV,aAAF,CAAf;AACA,GAHmB,EAGjB,EAHiB,CAApB;;AAKA,MAAK,CAAEQ,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AACD,QAAMI,WAAW,GAAG,4BAAiBJ,WAAjB,CAApB;AACA;AACD;AACA;AACA;AACA;;AACC,QAAMK,eAAe,GAAG,CAAEP,KAAF,GAAU,EAAV,GAAeA,KAAK,CAACQ,QAAN,GAAiBC,KAAjB,CAAwB,GAAxB,CAAvC,CAf6C,CAgB7C;AACA;;AACA,QAAMC,cAAc,GAAGH,eAAe,CAACI,MAAhB,CACtB,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AAC5B,UAAMC,MAAM,GAAGR,WAAW,CAACS,OAAZ,CAAqBF,QAArB,CAAf;;AACA,QAAKC,MAAL,EAAc;AACbF,MAAAA,WAAW,CAACI,IAAZ,CAAkB;AACjBC,QAAAA,EAAE,EAAEJ,QADa;AAEjBb,QAAAA,KAAK,EAAEc,MAAM,CAACI;AAFG,OAAlB;AAIA;;AACD,WAAON,WAAP;AACA,GAVqB,EAWtB,EAXsB,CAAvB;;AAcA,QAAMO,YAAY,GAAG,CAAEC,oBAAF,EAAwBC,WAAxB,KAAyC;AAAA;;AAC7D,UAAMJ,EAAE,GAAG,CAAAI,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEJ,EAAb,+BAAmBG,oBAAoB,CAAEC,WAAF,CAAvC,0DAAmB,sBAAqCJ,EAAxD,CAAX;AACA,QAAKA,EAAL,EAAU,OAAOA,EAAP;AACV,GAHD;;AAIA,QAAMK,cAAc,GAAKC,QAAF,IAAgB;AACtC,UAAMC,GAAG,GAAGC,KAAK,CAACC,IAAN,CACXH,QAAQ,CAACZ,MAAT,CAAiB,CAAEC,WAAF,EAAeE,MAAf,KAA2B;AAC3C;AACA,YAAMG,EAAE,GAAGE,YAAY,CAAEb,WAAW,CAACqB,SAAd,EAAyBb,MAAzB,CAAvB;AACA,UAAKG,EAAL,EAAUL,WAAW,CAACgB,GAAZ,CAAiBX,EAAjB;AACV,aAAOL,WAAP;AACA,KALD,EAKG,IAAIiB,GAAJ,EALH,CADW,CAAZ;AAQA5B,IAAAA,QAAQ,CAAE;AAAEa,MAAAA,MAAM,EAAEU,GAAG,CAACM,IAAJ,CAAU,GAAV;AAAV,KAAF,CAAR;AACA,GAVD;;AAWA,SACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,KAAK,EAAGpB,cAFT;AAGC,IAAA,WAAW,EAAGJ,WAAW,CAACyB,KAH3B;AAIC,IAAA,QAAQ,EAAGT;AAJZ,IADD;AAQA;;eAEcvB,a","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 ) return id;\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 ) accumulator.add( id );\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/>\n\t);\n}\n\nexport default AuthorControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/author-control.js"],"names":["AUTHORS_QUERY","who","per_page","_fields","context","AuthorControl","value","onChange","authorsList","select","getUsers","coreStore","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","names"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,GAAG,EAAE,SADgB;AAErBC,EAAAA,QAAQ,EAAE,CAAC,CAFU;AAGrBC,EAAAA,OAAO,EAAE,SAHY;AAIrBC,EAAAA,OAAO,EAAE;AAJY,CAAtB;;AAOA,SAASC,aAAT,OAA8C;AAAA,MAAtB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAsB;AAC7C,QAAMC,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAC5C,UAAM;AAAEC,MAAAA;AAAF,QAAeD,MAAM,CAAEE,eAAF,CAA3B;AACA,WAAOD,QAAQ,CAAEV,aAAF,CAAf;AACA,GAHmB,EAGjB,EAHiB,CAApB;;AAKA,MAAK,CAAEQ,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AACD,QAAMI,WAAW,GAAG,4BAAiBJ,WAAjB,CAApB;AACA;AACD;AACA;AACA;AACA;;AACC,QAAMK,eAAe,GAAG,CAAEP,KAAF,GAAU,EAAV,GAAeA,KAAK,CAACQ,QAAN,GAAiBC,KAAjB,CAAwB,GAAxB,CAAvC,CAf6C,CAgB7C;AACA;;AACA,QAAMC,cAAc,GAAGH,eAAe,CAACI,MAAhB,CACtB,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AAC5B,UAAMC,MAAM,GAAGR,WAAW,CAACS,OAAZ,CAAqBF,QAArB,CAAf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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 ) return id;\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 ) accumulator.add( id );\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/>\n\t);\n}\n\nexport default AuthorControl;\n"]}
@@ -186,7 +186,7 @@ function QueryInspectorControls(_ref) {
186
186
  label: (0, _i18n.__)('Keyword'),
187
187
  value: querySearch,
188
188
  onChange: setQuerySearch
189
- })), isPostTypeHierarchical && !(0, _utils.isControlAllowed)(allowedControls, 'parents') && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
189
+ })), isPostTypeHierarchical && (0, _utils.isControlAllowed)(allowedControls, 'parents') && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
190
190
  hasValue: () => !!(parents !== null && parents !== void 0 && parents.length),
191
191
  label: (0, _i18n.__)('Parents'),
192
192
  onDeselect: () => setQuery({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["QueryInspectorControls","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomiesInfo","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","type","showOrderControl","showStickyControl","showSettingsPanel","value","columns","Math","max","values","some"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAUA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAgBA;AACA;AACA;AAae,SAASA,sBAAT,OAIX;AAAA,MAJ4C;AAC/CC,IAAAA,UAD+C;AAE/CC,IA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l,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n} from '../../utils';\n\nexport default function QueryInspectorControls( {\n\tattributes,\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomiesInfo = useTaxonomiesInfo( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = displayLayout?.type === 'flex';\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\treturn (\n\t\t<>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\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</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'taxQuery' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'author' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'search' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isPostTypeHierarchical &&\n\t\t\t\t\t\t\t! isControlAllowed(\n\t\t\t\t\t\t\t\tallowedControls,\n\t\t\t\t\t\t\t\t'parents'\n\t\t\t\t\t\t\t) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { parents: [] } )\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\t\t<ParentControl\n\t\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["QueryInspectorControls","attributes","setQuery","setDisplayLayout","query","displayLayout","order","orderBy","author","authorIds","postType","sticky","inherit","taxQuery","parents","allowedControls","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomiesInfo","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","showInheritControl","showPostTypeControl","showColumnsControl","type","showOrderControl","showStickyControl","showSettingsPanel","value","columns","Math","max","values","some"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAUA;;AACA;;AACA;;AA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,EAAGR;AAHZ,IAPD,CA3DH,CADD,CApEF,CADD;AAoJA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport {\n\tusePostTypes,\n\tuseIsPostTypeHierarchical,\n\tuseAllowedControls,\n\tisControlAllowed,\n} from '../../utils';\n\nexport default function QueryInspectorControls( {\n\tattributes,\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst { query, displayLayout } = attributes;\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst allowedControls = useAllowedControls( attributes );\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomiesInfo = useTaxonomiesInfo( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\tconst showInheritControl = isControlAllowed( allowedControls, 'inherit' );\n\tconst showPostTypeControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'postType' );\n\tconst showColumnsControl = displayLayout?.type === 'flex';\n\tconst showOrderControl =\n\t\t! inherit && isControlAllowed( allowedControls, 'order' );\n\tconst showStickyControl =\n\t\t! inherit &&\n\t\tshowSticky &&\n\t\tisControlAllowed( allowedControls, 'sticky' );\n\tconst showSettingsPanel =\n\t\tshowInheritControl ||\n\t\tshowPostTypeControl ||\n\t\tshowColumnsControl ||\n\t\tshowOrderControl ||\n\t\tshowStickyControl;\n\treturn (\n\t\t<>\n\t\t\t{ showSettingsPanel && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t\t{ showInheritControl && (\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\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\t{ showPostTypeControl && (\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called “Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ showColumnsControl && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\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'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Notice>\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\t{ showOrderControl && (\n\t\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ showStickyControl && (\n\t\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\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</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! inherit && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'taxQuery' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\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\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\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\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'author' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isControlAllowed( allowedControls, 'search' ) && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ isPostTypeHierarchical &&\n\t\t\t\t\t\t\tisControlAllowed( allowedControls, 'parents' ) && (\n\t\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\t\tsetQuery( { parents: [] } )\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\t\t<ParentControl\n\t\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -139,7 +139,8 @@ function ParentControl(_ref) {
139
139
  value: value,
140
140
  onInputChange: debouncedSearch,
141
141
  suggestions: suggestions,
142
- onChange: onParentChange
142
+ onChange: onParentChange,
143
+ __experimentalShowHowTo: false
143
144
  });
144
145
  }
145
146
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","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"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,UAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB;;AAMA,SAASC,aAAT,OAA0D;AAAA,MAAlC;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,GAAkC;AACzD,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,EAAV,CAA9B;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAUZ,WAAV,CAA5B;AACA,QAAM,CAAEa,WAAF,EAAeC,cAAf,IAAkC,uBAAUd,WAAV,CAAxC;AACA,QAAMe,eAAe,GAAG,0BAAaL,SAAb,EAAwB,GAAxB,CAAxB;AACA,QAAM;AAAEM,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAuC,qBAC1CC,MAAF,IAAc;AACb,QAAK,CAAET,MAAP,EAAgB;AACf,aAAO;AAAEO,QAAAA,aAAa,EAAEhB,WAAjB;AAA8BiB,QAAAA,iBAAiB,EAAE;AAAjD,OAAP;AACA;;AACD,UAAM;AAAEE,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,QACLF,MAAM,CAAEG,eAAF,CADP;AAEA,UAAMC,YAAY,GAAG,CACpB,UADoB,EAEpBf,QAFoB,EAGpB,EACC,GAAGN,UADJ;AAECQ,MAAAA,MAFD;AAGCc,MAAAA,OAAO,EAAE,WAHV;AAICC,MAAAA,OAAO,EAAElB,OAJV;AAKCmB,MAAAA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ACA,UAAKD,EAAL,EAAUD,WAAW,CAACgB,GAAZ,CAAiBf,EAAjB;AACV,aAAOD,WAAP;AACA,KALD,EAKG,IAAIiB,GAAJ,EALH,CADW,CAAZ;AAQAnC,IAAAA,cAAc,CAAEd,WAAF,CAAd;AACAQ,IAAAA,QAAQ,CAAE;AAAEF,MAAAA,OAAO,EAAEsC;AAAX,KAAF,CAAR;AACA,GAXD;;AAYA,SACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,KAAK,EAAGjC,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAG6B;AALZ,IADD;AASA;;eAEcrC,a","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 ) return EMPTY_ARRAY;\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 ) return;\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 ) return EMPTY_ARRAY;\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 ) return;\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 ) return id;\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 ) accumulator.add( id );\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\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/>\n\t);\n}\n\nexport default ParentControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/parent-control.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","ParentControl","parents","postType","onChange","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","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"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;A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X,KAAF,CAAR;AACA,GAXD;;AAYA,SACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,KAAK,EAAGjC,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAG6B,cALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD;AAUA;;eAEcrC,a","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 ) return EMPTY_ARRAY;\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 ) return;\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 ) return EMPTY_ARRAY;\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 ) return;\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 ) return id;\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 ) accumulator.add( id );\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\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/>\n\t);\n}\n\nexport default ParentControl;\n"]}
@@ -159,7 +159,8 @@ function TaxonomyControls(_ref2) {
159
159
  label: name,
160
160
  value: getExistingTaxQueryValue(slug),
161
161
  suggestions: terms.names,
162
- onChange: onTermsChange(slug)
162
+ onChange: onTermsChange(slug),
163
+ __experimentalShowHowTo: false
163
164
  }));
164
165
  }));
165
166
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","context","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;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n */\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, useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( termsMappedByName, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId = termValue?.id || termsMappedByName[ termValue ]?.id;\n\tif ( termId ) return termId;\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\tfor ( const term in termsMappedByName ) {\n\t\tif ( term.toLocaleLowerCase() === termValueLower ) {\n\t\t\treturn termsMappedByName[ term ].id;\n\t\t}\n\t}\n};\n\nexport const useTaxonomiesInfo = ( postType ) => {\n\tconst taxonomies = useTaxonomies( postType );\n\tconst taxonomiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst termsQuery = { context: 'view', per_page: MAX_FETCHED_TERMS };\n\t\t\tconst _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => {\n\t\t\t\tconst _terms = getEntityRecords( 'taxonomy', slug, termsQuery );\n\t\t\t\treturn {\n\t\t\t\t\tslug,\n\t\t\t\t\tname,\n\t\t\t\t\tterms: getEntitiesInfo( _terms ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn _taxonomiesInfo;\n\t\t},\n\t\t[ taxonomies ]\n\t);\n\treturn taxonomiesInfo;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst taxonomiesInfo = useTaxonomiesInfo( query.postType );\n\tconst onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return;\n\t\tconst termIds = Array.from(\n\t\t\tnewTermValues.reduce( ( accumulator, termValue ) => {\n\t\t\t\tconst termId = getTermIdByTermValue(\n\t\t\t\t\ttaxonomyInfo.terms.mapByName,\n\t\t\t\t\ttermValue\n\t\t\t\t);\n\t\t\t\tif ( termId ) accumulator.add( termId );\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tconst newTaxQuery = {\n\t\t\t...query.taxQuery,\n\t\t\t[ taxonomySlug ]: termIds,\n\t\t};\n\t\tonChange( { taxQuery: newTaxQuery } );\n\t};\n\t// Returns only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst getExistingTaxQueryValue = ( taxonomySlug ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return [];\n\t\treturn ( query.taxQuery?.[ taxonomySlug ] || [] ).reduce(\n\t\t\t( accumulator, termId ) => {\n\t\t\t\tconst term = taxonomyInfo.terms.mapById[ termId ];\n\t\t\t\tif ( term ) {\n\t\t\t\t\taccumulator.push( {\n\t\t\t\t\t\tid: termId,\n\t\t\t\t\t\tvalue: term.name,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t};\n\treturn (\n\t\t<>\n\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\ttaxonomiesInfo.map( ( { slug, name, terms } ) => {\n\t\t\t\t\tif ( ! terms?.names?.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\tclassName=\"block-library-query-inspector__taxonomy-control\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\t\tlabel={ name }\n\t\t\t\t\t\t\t\tvalue={ getExistingTaxQueryValue( slug ) }\n\t\t\t\t\t\t\t\tsuggestions={ terms.names }\n\t\t\t\t\t\t\t\tonChange={ onTermsChange( slug ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","context","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,iBAAF,EAAqBC,SAArB,KAAoC;AAAA;;AAChE;AACA,QAAMC,MAAM,GAAG,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,+BAAiBH,iBAAiB,CAAEC,SAAF,CAAlC,0DAAiB,sBAAgCE,EAAjD,CAAf;AACA,MAAKD,MAAL,EAAc,OAAOA,MAAP;AACd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAME,cAAc,GAAGH,SAAS,CAACI,iBAAV,EAAvB;;AACA,OAAM,MAA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I,CAACe;AAFK,SAAlB;AAIA;;AACD,aAAOe,WAAP;AACA,KAVK,EAWN,EAXM,CAAP;AAaA,GAlBD;;AAmBA,SACC,qDACG,CAAC,EAAE1B,cAAF,aAAEA,cAAF,eAAEA,cAAc,CAAEoC,MAAlB,CAAD,IACDpC,cAAc,CAACS,GAAf,CAAoB,SAA6B;AAAA;;AAAA,QAA3B;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcE,MAAAA;AAAd,KAA2B;;AAChD,QAAK,EAAEA,KAAF,aAAEA,KAAF,+BAAEA,KAAK,CAAEwB,KAAT,yCAAE,aAAcD,MAAhB,CAAL,EAA8B;AAC7B,aAAO,IAAP;AACA;;AACD,WACC;AACC,MAAA,GAAG,EAAG1B,IADP;AAEC,MAAA,SAAS,EAAC;AAFX,OAIC,4BAAC,0BAAD;AACC,MAAA,KAAK,EAAGC,IADT;AAEC,MAAA,KAAK,EAAGqB,wBAAwB,CAAEtB,IAAF,CAFjC;AAGC,MAAA,WAAW,EAAGG,KAAK,CAACwB,KAHrB;AAIC,MAAA,QAAQ,EAAGpB,aAAa,CAAEP,IAAF,CAJzB;AAKC,MAAA,uBAAuB,EAAG;AAL3B,MAJD,CADD;AAcA,GAlBD,CAFF,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\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, useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( termsMappedByName, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId = termValue?.id || termsMappedByName[ termValue ]?.id;\n\tif ( termId ) return termId;\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\tfor ( const term in termsMappedByName ) {\n\t\tif ( term.toLocaleLowerCase() === termValueLower ) {\n\t\t\treturn termsMappedByName[ term ].id;\n\t\t}\n\t}\n};\n\nexport const useTaxonomiesInfo = ( postType ) => {\n\tconst taxonomies = useTaxonomies( postType );\n\tconst taxonomiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst termsQuery = { context: 'view', per_page: MAX_FETCHED_TERMS };\n\t\t\tconst _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => {\n\t\t\t\tconst _terms = getEntityRecords( 'taxonomy', slug, termsQuery );\n\t\t\t\treturn {\n\t\t\t\t\tslug,\n\t\t\t\t\tname,\n\t\t\t\t\tterms: getEntitiesInfo( _terms ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn _taxonomiesInfo;\n\t\t},\n\t\t[ taxonomies ]\n\t);\n\treturn taxonomiesInfo;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst taxonomiesInfo = useTaxonomiesInfo( query.postType );\n\tconst onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return;\n\t\tconst termIds = Array.from(\n\t\t\tnewTermValues.reduce( ( accumulator, termValue ) => {\n\t\t\t\tconst termId = getTermIdByTermValue(\n\t\t\t\t\ttaxonomyInfo.terms.mapByName,\n\t\t\t\t\ttermValue\n\t\t\t\t);\n\t\t\t\tif ( termId ) accumulator.add( termId );\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tconst newTaxQuery = {\n\t\t\t...query.taxQuery,\n\t\t\t[ taxonomySlug ]: termIds,\n\t\t};\n\t\tonChange( { taxQuery: newTaxQuery } );\n\t};\n\t// Returns only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst getExistingTaxQueryValue = ( taxonomySlug ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return [];\n\t\treturn ( query.taxQuery?.[ taxonomySlug ] || [] ).reduce(\n\t\t\t( accumulator, termId ) => {\n\t\t\t\tconst term = taxonomyInfo.terms.mapById[ termId ];\n\t\t\t\tif ( term ) {\n\t\t\t\t\taccumulator.push( {\n\t\t\t\t\t\tid: termId,\n\t\t\t\t\t\tvalue: term.name,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t};\n\treturn (\n\t\t<>\n\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\ttaxonomiesInfo.map( ( { slug, name, terms } ) => {\n\t\t\t\t\tif ( ! terms?.names?.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\tclassName=\"block-library-query-inspector__taxonomy-control\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\t\tlabel={ name }\n\t\t\t\t\t\t\t\tvalue={ getExistingTaxQueryValue( slug ) }\n\t\t\t\t\t\t\t\tsuggestions={ terms.names }\n\t\t\t\t\t\t\t\tonChange={ onTermsChange( slug ) }\n\t\t\t\t\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
@@ -272,7 +272,7 @@ function useAllowedControls(attributes) {
272
272
  return (0, _data.useSelect)(select => {
273
273
  var _select$getActiveBloc;
274
274
 
275
- return (_select$getActiveBloc = select(_blocks.store).getActiveBlockVariation(queryLoopName, attributes)) === null || _select$getActiveBloc === void 0 ? void 0 : _select$getActiveBloc.allowControls;
275
+ return (_select$getActiveBloc = select(_blocks.store).getActiveBlockVariation(queryLoopName, attributes)) === null || _select$getActiveBloc === void 0 ? void 0 : _select$getActiveBloc.allowedControls;
276
276
  }, [attributes]);
277
277
  }
278
278
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowControls","isControlAllowed","allowedControls","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA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AAA,GAD2B,EAO3B,CAAEmC,UAAF,CAP2B,CAA5B;AASA,QAAMyB,SAAS,GAAI,GAAGtB,aAAe,IAAIqB,mBAAqB,EAA9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BtD,MAAF,IAAc;AACb,QAAK,CAAEoD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFxD,MAAM,CAAEyD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE3C,MAAzB,GAAkC0C,SAAlC,GAA8CtB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","queryLoopName","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;;;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AAyD;AAC/D,QAAMuB,mBAAmB,GAAG,qBACzBnD,MAAF;AAAA;;AAAA,qCACCA,MAAM,CAAE6B,aAAF,CAAN,CAAsBC,uBAAtB,CACCC,aADD,EAECH,UAFD,CADD,2DACC,uBAGGnC,IAJJ;AAAA,GAD2B,EAO3B,CAAEmC,UAAF,CAP2B,CAA5B;AASA,QAAMwB,SAAS,GAAI,GAAGrB,aAAe,IAAIoB,mBAAqB,EAA9D;AACA,QAAME,uBAAuB,GAAG,qBAC7BrD,MAAF,IAAc;AACb,QAAK,CAAEmD,mBAAP,EAA6B;AAC5B;AACA;;AACD,UAAM;AACLG,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFvD,MAAM,CAAEwD,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAET,QAAF,CAAzC;AACA,WAAOU,qCAAqC,CAC3CH,SAD2C,EAE3CK,YAF2C,CAA5C;AAIA,GAd8B,EAe/B,CAAEZ,QAAF,EAAYM,mBAAZ,CAf+B,CAAhC;AAiBA,SAAOE,uBAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE1C,MAAzB,GAAkCyC,SAAlC,GAA8CrB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
@@ -59,7 +59,6 @@ const metadata = {
59
59
  },
60
60
  supports: {
61
61
  anchor: true,
62
- __experimentalSlashInserter: true,
63
62
  __experimentalOnEnter: true,
64
63
  typography: {
65
64
  fontSize: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/quote/index.js"],"names":["name","metadata","settings","icon","example","attributes","citation","innerBlocks","content","transforms","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,QAAQ,EAAE;AADC,KADJ;AAIRC,IAAAA,WAAW,EAAE,CACZ;AACCP,MAAAA,IAAI,EAAE,gBADP;AAECK,MAAAA,UAAU,EAAE;AACXG,QAAAA,OAAO,EAAE,cAAI,uCAAJ;AADE;AAFb,KADY;AAJL,GAFc;AAevBC,EAAAA,UAAU,EAAVA,mBAfuB;AAgBvBC,EAAAA,IAAI,EAAJA,aAhBuB;AAiBvBC,EAAAA,IAAI,EAAJA,aAjBuB;AAkBvBC,EAAAA,UAAU,EAAVA;AAlBuB,CAAjB;;;AAqBA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEb,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { quote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcitation: 'Julio Cortázar',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( 'In quoting others, we cite ourselves.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/quote/index.js"],"names":["name","metadata","settings","icon","example","attributes","citation","innerBlocks","content","transforms","edit","save","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,QAAQ,EAAE;AADC,KADJ;AAIRC,IAAAA,WAAW,EAAE,CACZ;AACCP,MAAAA,IAAI,EAAE,gBADP;AAECK,MAAAA,UAAU,EAAE;AACXG,QAAAA,OAAO,EAAE,cAAI,uCAAJ;AADE;AAFb,KADY;AAJL,GAFc;AAevBC,EAAAA,UAAU,EAAVA,mBAfuB;AAgBvBC,EAAAA,IAAI,EAAJA,aAhBuB;AAiBvBC,EAAAA,IAAI,EAAJA,aAjBuB;AAkBvBC,EAAAA,UAAU,EAAVA;AAlBuB,CAAjB;;;AAqBA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEb,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { quote as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcitation: 'Julio Cortázar',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( 'In quoting others, we cite ourselves.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -86,7 +86,8 @@ const metadata = {
86
86
  }
87
87
  }
88
88
  },
89
- editorStyle: "wp-block-site-title-editor"
89
+ editorStyle: "wp-block-site-title-editor",
90
+ style: "wp-block-site-title"
90
91
  };
91
92
  exports.metadata = metadata;
92
93
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/site-title/index.js"],"names":["name","metadata","settings","icon","edit","transforms","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,UAAU,EAAVA,mBAHuB;AAIvBC,EAAAA,UAAU,EAAVA;AAJuB,CAAjB;;;AAOA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEP,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { mapMarker as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\nimport transforms from './transforms';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\ttransforms,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/site-title/index.js"],"names":["name","metadata","settings","icon","edit","transforms","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAEA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,gBADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,UAAU,EAAVA,mBAHuB;AAIvBC,EAAAA,UAAU,EAAVA;AAJuB,CAAjB;;;AAOA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEP,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { mapMarker as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\nimport transforms from './transforms';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\ttransforms,\n\tdeprecated,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -102,14 +102,14 @@ const init = () => {
102
102
  (0, _hooks.addFilter)('blocks.registerBlockType', 'core/template-part', _variations.enhanceTemplatePartVariations); // Prevent adding template parts inside post templates.
103
103
 
104
104
  const DISALLOWED_PARENTS = ['core/post-template', 'core/post-content'];
105
- (0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromPostTemplates', (can, blockType, rootClientId, _ref2) => {
105
+ (0, _hooks.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromPostTemplates', (canInsert, blockType, rootClientId, _ref2) => {
106
106
  let {
107
107
  getBlock,
108
108
  getBlockParentsByBlockName
109
109
  } = _ref2;
110
110
 
111
111
  if (blockType.name !== 'core/template-part') {
112
- return can;
112
+ return canInsert;
113
113
  }
114
114
 
115
115
  for (const disallowedParentType of DISALLOWED_PARENTS) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","init","enhanceTemplatePartVariations","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEC,mBADiB;AAEvBC,EAAAA,mBAAmB,EAAE,QAAuB;AAAA;;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;;AAC3C;AACA;AACA,QAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAED,UAAME,MAAM,GAAG,kBAAQC,eAAR,EAAwBC,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdH,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WACC,mDAAgBA,MAAM,CAACG,KAAvB,kDAAgB,cAAcC,QAA9B,KACA,6BAAaJ,MAAM,CAACF,IAApB,CAFD;AAIA,GAtBsB;AAuBvBO,EAAAA,IAAI,EAAJA;AAvBuB,CAAjB;;;AA0BA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBACC,0BADD,EAEC,oBAFD,EAGCC,yCAHD,EADyB,CAOzB;;AACA,QAAMC,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACA,wBACC,0CADD,EAEC,sCAFD,EAGC,CACCC,GADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,QADJ;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KACI;;AACJ,QAAKH,SAAS,CAAClB,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,aAAOiB,GAAP;AACA;;AAED,SAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,YAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0BnB,IAA1B,MAAmCsB,oBAAnC,IACAD,0BAA0B,CACzBF,YADyB,EAEzBG,oBAFyB,CAA1B,CAGEE,MALH;;AAMA,UAAKD,mBAAL,EAA2B;AAC1B,eAAO,KAAP;AACA;AACD;;AACD,WAAO,IAAP;AACA,GAzBF;AA4BA,SAAO,wBAAW;AAAEvB,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CAtCM","sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) ||\n\t\t\tcapitalCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcan,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn can;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","init","enhanceTemplatePartVariations","DISALLOWED_PARENTS","canInsert","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;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EE,MALH;;AAMA,UAAKD,mBAAL,EAA2B;AAC1B,eAAO,KAAP;AACA;AACD;;AACD,WAAO,IAAP;AACA,GAzBF;AA4BA,SAAO,wBAAW;AAAEvB,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CAtCM","sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) ||\n\t\t\tcapitalCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\nexport const init = () => {\n\taddFilter(\n\t\t'blocks.registerBlockType',\n\t\t'core/template-part',\n\t\tenhanceTemplatePartVariations\n\t);\n\n\t// Prevent adding template parts inside post templates.\n\tconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromPostTemplates',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlock, getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\t\treturn canInsert;\n\t\t\t}\n\n\t\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\t\tconst hasDisallowedParent =\n\t\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\trootClientId,\n\t\t\t\t\t\tdisallowedParentType\n\t\t\t\t\t).length;\n\t\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t);\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
@@ -48,6 +48,17 @@ var _tracks = _interopRequireDefault(require("./tracks"));
48
48
  /**
49
49
  * Internal dependencies
50
50
  */
51
+ // Much of this description is duplicated from MediaPlaceholder.
52
+ const placeholder = content => {
53
+ return (0, _element.createElement)(_components.Placeholder, {
54
+ className: "block-editor-media-placeholder",
55
+ withIllustration: true,
56
+ icon: _icons.video,
57
+ label: (0, _i18n.__)('Video'),
58
+ instructions: (0, _i18n.__)('Upload a video file, pick one from your media library, or add one with a URL.')
59
+ }, content);
60
+ };
61
+
51
62
  const ALLOWED_MEDIA_TYPES = ['video'];
52
63
  const VIDEO_POSTER_ALLOWED_MEDIA_TYPES = ['image'];
53
64
 
@@ -170,7 +181,8 @@ function VideoEdit(_ref) {
170
181
  accept: "video/*",
171
182
  allowedTypes: ALLOWED_MEDIA_TYPES,
172
183
  value: attributes,
173
- onError: onUploadError
184
+ onError: onUploadError,
185
+ placeholder: placeholder
174
186
  }));
175
187
  }
176
188