@wordpress/editor 14.19.0 → 14.20.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 (121) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/commands/index.js +1 -1
  3. package/build/components/commands/index.js.map +1 -1
  4. package/build/components/document-bar/index.js +3 -2
  5. package/build/components/document-bar/index.js.map +1 -1
  6. package/build/components/document-outline/index.js +21 -1
  7. package/build/components/document-outline/index.js.map +1 -1
  8. package/build/components/document-outline/item.js +32 -20
  9. package/build/components/document-outline/item.js.map +1 -1
  10. package/build/components/entities-saved-states/entity-record-item.js +2 -2
  11. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  12. package/build/components/post-actions/actions.js +10 -8
  13. package/build/components/post-actions/actions.js.map +1 -1
  14. package/build/components/post-card-panel/index.js +3 -3
  15. package/build/components/post-card-panel/index.js.map +1 -1
  16. package/build/components/post-publish-panel/maybe-category-panel.js +19 -3
  17. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  18. package/build/components/post-publish-panel/maybe-tags-panel.js +16 -6
  19. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  20. package/build/components/post-status/index.js +1 -1
  21. package/build/components/post-status/index.js.map +1 -1
  22. package/build/components/post-sticky/index.js +1 -1
  23. package/build/components/post-sticky/index.js.map +1 -1
  24. package/build/components/post-template/hooks.js +6 -5
  25. package/build/components/post-template/hooks.js.map +1 -1
  26. package/build/components/post-template/swap-template-button.js +2 -3
  27. package/build/components/post-template/swap-template-button.js.map +1 -1
  28. package/build/components/post-visibility/index.js +39 -109
  29. package/build/components/post-visibility/index.js.map +1 -1
  30. package/build/components/post-visibility/label.js +2 -2
  31. package/build/components/post-visibility/label.js.map +1 -1
  32. package/build/components/post-visibility/utils.js +14 -15
  33. package/build/components/post-visibility/utils.js.map +1 -1
  34. package/build/components/provider/index.js +7 -4
  35. package/build/components/provider/index.js.map +1 -1
  36. package/build/store/private-selectors.js +1 -1
  37. package/build/store/private-selectors.js.map +1 -1
  38. package/build/store/selectors.js +8 -7
  39. package/build/store/selectors.js.map +1 -1
  40. package/build-module/components/commands/index.js +1 -1
  41. package/build-module/components/commands/index.js.map +1 -1
  42. package/build-module/components/document-bar/index.js +3 -2
  43. package/build-module/components/document-bar/index.js.map +1 -1
  44. package/build-module/components/document-outline/index.js +21 -1
  45. package/build-module/components/document-outline/index.js.map +1 -1
  46. package/build-module/components/document-outline/item.js +32 -20
  47. package/build-module/components/document-outline/item.js.map +1 -1
  48. package/build-module/components/entities-saved-states/entity-record-item.js +2 -2
  49. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  50. package/build-module/components/post-actions/actions.js +10 -8
  51. package/build-module/components/post-actions/actions.js.map +1 -1
  52. package/build-module/components/post-card-panel/index.js +3 -3
  53. package/build-module/components/post-card-panel/index.js.map +1 -1
  54. package/build-module/components/post-publish-panel/maybe-category-panel.js +19 -3
  55. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  56. package/build-module/components/post-publish-panel/maybe-tags-panel.js +16 -6
  57. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  58. package/build-module/components/post-status/index.js +1 -1
  59. package/build-module/components/post-status/index.js.map +1 -1
  60. package/build-module/components/post-sticky/index.js +1 -1
  61. package/build-module/components/post-sticky/index.js.map +1 -1
  62. package/build-module/components/post-template/hooks.js +6 -5
  63. package/build-module/components/post-template/hooks.js.map +1 -1
  64. package/build-module/components/post-template/swap-template-button.js +2 -3
  65. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  66. package/build-module/components/post-visibility/index.js +41 -111
  67. package/build-module/components/post-visibility/index.js.map +1 -1
  68. package/build-module/components/post-visibility/label.js +3 -3
  69. package/build-module/components/post-visibility/label.js.map +1 -1
  70. package/build-module/components/post-visibility/utils.js +13 -14
  71. package/build-module/components/post-visibility/utils.js.map +1 -1
  72. package/build-module/components/provider/index.js +7 -4
  73. package/build-module/components/provider/index.js.map +1 -1
  74. package/build-module/store/private-selectors.js +1 -1
  75. package/build-module/store/private-selectors.js.map +1 -1
  76. package/build-module/store/selectors.js +8 -7
  77. package/build-module/store/selectors.js.map +1 -1
  78. package/build-style/style-rtl.css +4 -138
  79. package/build-style/style.css +4 -138
  80. package/build-types/components/document-outline/index.d.ts.map +1 -1
  81. package/build-types/components/document-outline/item.d.ts +2 -1
  82. package/build-types/components/document-outline/item.d.ts.map +1 -1
  83. package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
  84. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  85. package/build-types/components/post-publish-panel/maybe-category-panel.d.ts.map +1 -1
  86. package/build-types/components/post-publish-panel/maybe-tags-panel.d.ts.map +1 -1
  87. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  88. package/build-types/components/post-template/swap-template-button.d.ts +1 -1
  89. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  90. package/build-types/components/post-visibility/index.d.ts.map +1 -1
  91. package/build-types/components/post-visibility/label.d.ts.map +1 -1
  92. package/build-types/components/post-visibility/utils.d.ts +5 -20
  93. package/build-types/components/post-visibility/utils.d.ts.map +1 -1
  94. package/build-types/components/provider/index.d.ts.map +1 -1
  95. package/build-types/store/private-selectors.d.ts.map +1 -1
  96. package/build-types/store/selectors.d.ts.map +1 -1
  97. package/package.json +37 -37
  98. package/src/components/autocompleters/style.scss +2 -3
  99. package/src/components/commands/index.js +1 -1
  100. package/src/components/document-bar/index.js +2 -2
  101. package/src/components/document-outline/index.js +27 -1
  102. package/src/components/document-outline/item.js +38 -23
  103. package/src/components/document-outline/style.scss +2 -0
  104. package/src/components/entities-saved-states/entity-record-item.js +1 -4
  105. package/src/components/post-actions/actions.js +13 -8
  106. package/src/components/post-card-panel/index.js +2 -2
  107. package/src/components/post-publish-panel/maybe-category-panel.js +20 -5
  108. package/src/components/post-publish-panel/maybe-tags-panel.js +39 -22
  109. package/src/components/post-status/index.js +1 -1
  110. package/src/components/post-sticky/index.js +1 -1
  111. package/src/components/post-template/hooks.js +12 -8
  112. package/src/components/post-template/swap-template-button.js +6 -4
  113. package/src/components/post-visibility/index.js +41 -118
  114. package/src/components/post-visibility/label.js +7 -4
  115. package/src/components/post-visibility/utils.js +11 -8
  116. package/src/components/provider/index.js +9 -4
  117. package/src/store/private-selectors.js +2 -4
  118. package/src/store/selectors.js +9 -14
  119. package/src/style.scss +0 -1
  120. package/tsconfig.tsbuildinfo +1 -1
  121. package/src/components/post-visibility/style.scss +0 -27
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_setAsPostsPage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","coreStore","templates","per_page","canUser","kind","name","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","setAsPostsPageAction","useSetAsPostsPageAction","shouldShowHomepageActions","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","sort","a","b","id","filter","action","i","length","callback","existingCallback","items","argsObject","_items","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\nimport { useSetAsPostsPageAction } from './set-as-posts-page';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: select( coreStore ).canUser( 'update', {\n\t\t\t\t\tkind: 'root',\n\t\t\t\t\tname: 'site',\n\t\t\t\t} ),\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst setAsPostsPageAction = useSetAsPostsPageAction();\n\tconst shouldShowHomepageActions =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowHomepageActions ) {\n\t\t\tactions.push( setAsHomepageAction, setAsPostsPageAction );\n\t\t}\n\n\t\t// Ensure \"Move to trash\" is always the last action.\n\t\tactions = actions.sort( ( a, b ) =>\n\t\t\tb.id === 'move-to-trash' ? -1 : 0\n\t\t);\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n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AiB,EACjBoB,mBAAmB,EACnBE,oBAAoB,EACpBE,yBAAyB,CACxB,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_setAsPostsPage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","canUser","coreStore","canUpdateSettings","kind","name","templates","per_page","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","setAsPostsPageAction","useSetAsPostsPageAction","shouldShowHomepageActions","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","sort","a","b","id","filter","action","i","length","callback","existingCallback","items","argsObject","_items","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\nimport { useSetAsPostsPageAction } from './set-as-posts-page';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, canUser } = select( coreStore );\n\t\t\tconst canUpdateSettings = canUser( 'update', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} );\n\t\t\tconst templates =\n\t\t\t\t'page' === postType && canUpdateSettings\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: [];\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: canUpdateSettings,\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst setAsPostsPageAction = useSetAsPostsPageAction();\n\tconst shouldShowHomepageActions =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowHomepageActions ) {\n\t\t\tactions.push( setAsHomepageAction, setAsPostsPageAction );\n\t\t}\n\n\t\t// Ensure \"Move to trash\" is always the last action.\n\t\tactions = actions.sort( ( a, b ) =>\n\t\t\tb.id === 'move-to-trash' ? -1 : 0\n\t\t);\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\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} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [\n\t\tcontext,\n\t\tdefaultActions,\n\t\tonActionPerformed,\n\t\tsetAsHomepageAction,\n\t\tsetAsPostsPageAction,\n\t\tshouldShowHomepageActions,\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,oBAAoB,EACpBE,yBAAyB,CACxB,CAAC;AACJ","ignoreList":[]}
@@ -52,7 +52,7 @@ function PostCardPanel({
52
52
  } = (0, _data.useSelect)(select => {
53
53
  const {
54
54
  getEditedEntityRecord,
55
- getEntityRecord,
55
+ getCurrentTheme,
56
56
  getPostType
57
57
  } = select(_coreData.store);
58
58
  const {
@@ -61,10 +61,10 @@ function PostCardPanel({
61
61
  let _title = '';
62
62
  const _record = getEditedEntityRecord('postType', postType, postIds[0]);
63
63
  if (postIds.length === 1) {
64
- var _getEntityRecord;
64
+ var _getCurrentTheme;
65
65
  const {
66
66
  default_template_types: templateTypes = []
67
- } = (_getEntityRecord = getEntityRecord('root', '__unstableBase')) !== null && _getEntityRecord !== void 0 ? _getEntityRecord : {};
67
+ } = (_getCurrentTheme = getCurrentTheme()) !== null && _getCurrentTheme !== void 0 ? _getCurrentTheme : {};
68
68
  const _templateInfo = [_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE].includes(postType) ? (0, _getTemplateInfo.getTemplateInfo)({
69
69
  template: _record,
70
70
  templateTypes
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_coreData","_data","_element","_i18n","_dom","_store","_constants","_lockUnlock","_postActions","_interopRequireDefault","_pageTypeBadge","_getTemplateInfo","_jsxRuntime","Badge","unlock","componentsPrivateApis","PostCardPanel","postType","postId","onActionPerformed","postIds","useMemo","Array","isArray","postTitle","icon","labels","useSelect","select","getEditedEntityRecord","getEntityRecord","getPostType","coreStore","getPostIcon","editorStore","_title","_record","length","_getEntityRecord","default_template_types","templateTypes","_templateInfo","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","includes","getTemplateInfo","template","title","area","pageTypeBadge","usePageTypeBadge","__","name","sprintf","stripHTML","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","align","jsx","Icon","__experimentalText","numberOfLines","truncate","as","default","toLowerCase"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport PostActions from '../post-actions';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.\n *\n * @param {Object} props - Component props.\n * @param {string} [props.postType] - The post type string.\n * @param {string|string[]} [props.postId] - The post id or list of post ids.\n * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostCardPanel( {\n\tpostType,\n\tpostId,\n\tonActionPerformed,\n} ) {\n\tconst postIds = useMemo(\n\t\t() => ( Array.isArray( postId ) ? postId : [ postId ] ),\n\t\t[ postId ]\n\t);\n\tconst { postTitle, icon, labels } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecord, getPostType } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getPostIcon } = unlock( select( editorStore ) );\n\t\t\tlet _title = '';\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostIds[ 0 ]\n\t\t\t);\n\t\t\tif ( postIds.length === 1 ) {\n\t\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\t\tgetEntityRecord( 'root', '__unstableBase' ) ?? {};\n\n\t\t\t\tconst _templateInfo = [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t].includes( postType )\n\t\t\t\t\t? getTemplateInfo( {\n\t\t\t\t\t\t\ttemplate: _record,\n\t\t\t\t\t\t\ttemplateTypes,\n\t\t\t\t\t } )\n\t\t\t\t\t: {};\n\t\t\t\t_title = _templateInfo?.title || _record?.title;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostTitle: _title,\n\t\t\t\ticon: getPostIcon( postType, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\tlet title = __( 'No title' );\n\tif ( labels?.name && postIds.length > 1 ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: %i number of selected items %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%i %s' ),\n\t\t\tpostId.length,\n\t\t\tlabels?.name\n\t\t);\n\t} else if ( postTitle ) {\n\t\ttitle = stripHTML( postTitle );\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 } className=\"editor-post-card-panel\">\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\talign=\"flex-start\"\n\t\t\t>\n\t\t\t\t<Icon className=\"editor-post-card-panel__icon\" icon={ icon } />\n\t\t\t\t<Text\n\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\ttruncate\n\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"editor-post-card-panel__title-name\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ pageTypeBadge && postIds.length === 1 && (\n\t\t\t\t\t\t<Badge>{ pageTypeBadge }</Badge>\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t{ postIds.length === 1 && (\n\t\t\t\t\t<PostActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postIds[ 0 ] }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ postIds.length > 1 && (\n\t\t\t\t<Text className=\"editor-post-card-panel__description\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t\t\t\t__( 'Changes will be applied to all selected %s.' ),\n\t\t\t\t\t\tlabels?.name.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAIA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,cAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AAAgE,IAAAa,WAAA,GAAAb,OAAA;AA3BhE;AACA;AACA;;AAcA;AACA;AACA;;AAUA,MAAM;EAAEc;AAAM,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,aAAaA,CAAE;EACtCC,QAAQ;EACRC,MAAM;EACNC;AACD,CAAC,EAAG;EACH,MAA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AO,CAACiB,MAAM,KAAK,CAAC,iBACtC,IAAAzB,WAAA,CAAAkD,GAAA,EAACjD,KAAK;UAAA8C,QAAA,EAAGV;QAAa,CAAS,CAC/B;MAAA,CACI,CAAC,EACL7B,OAAO,CAACiB,MAAM,KAAK,CAAC,iBACrB,IAAAzB,WAAA,CAAAkD,GAAA,EAACtD,YAAA,CAAA4D,OAAW;QACXnD,QAAQ,EAAGA,QAAU;QACrBC,MAAM,EAAGE,OAAO,CAAE,CAAC,CAAI;QACvBD,iBAAiB,EAAGA;MAAmB,CACvC,CACD;IAAA,CACM,CAAC,EACPC,OAAO,CAACiB,MAAM,GAAG,CAAC,iBACnB,IAAAzB,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAkE,kBAAI;MAACN,SAAS,EAAC,qCAAqC;MAAAC,QAAA,EAClD,IAAAN,aAAO;MACR;MACA,IAAAF,QAAE,EAAE,6CAA8C,CAAC,EACnDzB,MAAM,EAAE0B,IAAI,CAACiB,WAAW,CAAC,CAC1B;IAAC,CACI,CACN;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_coreData","_data","_element","_i18n","_dom","_store","_constants","_lockUnlock","_postActions","_interopRequireDefault","_pageTypeBadge","_getTemplateInfo","_jsxRuntime","Badge","unlock","componentsPrivateApis","PostCardPanel","postType","postId","onActionPerformed","postIds","useMemo","Array","isArray","postTitle","icon","labels","useSelect","select","getEditedEntityRecord","getCurrentTheme","getPostType","coreStore","getPostIcon","editorStore","_title","_record","length","_getCurrentTheme","default_template_types","templateTypes","_templateInfo","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","includes","getTemplateInfo","template","title","area","pageTypeBadge","usePageTypeBadge","__","name","sprintf","stripHTML","jsxs","__experimentalVStack","spacing","className","children","__experimentalHStack","align","jsx","Icon","__experimentalText","numberOfLines","truncate","as","default","toLowerCase"],"sources":["@wordpress/editor/src/components/post-card-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalText as Text,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../store/constants';\nimport { unlock } from '../../lock-unlock';\nimport PostActions from '../post-actions';\nimport usePageTypeBadge from '../../utils/pageTypeBadge';\nimport { getTemplateInfo } from '../../utils/get-template-info';\nconst { Badge } = unlock( componentsPrivateApis );\n\n/**\n * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.\n *\n * @param {Object} props - Component props.\n * @param {string} [props.postType] - The post type string.\n * @param {string|string[]} [props.postId] - The post id or list of post ids.\n * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostCardPanel( {\n\tpostType,\n\tpostId,\n\tonActionPerformed,\n} ) {\n\tconst postIds = useMemo(\n\t\t() => ( Array.isArray( postId ) ? postId : [ postId ] ),\n\t\t[ postId ]\n\t);\n\tconst { postTitle, icon, labels } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getCurrentTheme, getPostType } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getPostIcon } = unlock( select( editorStore ) );\n\t\t\tlet _title = '';\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostIds[ 0 ]\n\t\t\t);\n\t\t\tif ( postIds.length === 1 ) {\n\t\t\t\tconst { default_template_types: templateTypes = [] } =\n\t\t\t\t\tgetCurrentTheme() ?? {};\n\n\t\t\t\tconst _templateInfo = [\n\t\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t].includes( postType )\n\t\t\t\t\t? getTemplateInfo( {\n\t\t\t\t\t\t\ttemplate: _record,\n\t\t\t\t\t\t\ttemplateTypes,\n\t\t\t\t\t } )\n\t\t\t\t\t: {};\n\t\t\t\t_title = _templateInfo?.title || _record?.title;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tpostTitle: _title,\n\t\t\t\ticon: getPostIcon( postType, {\n\t\t\t\t\tarea: _record?.area,\n\t\t\t\t} ),\n\t\t\t\tlabels: getPostType( postType )?.labels,\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\tconst pageTypeBadge = usePageTypeBadge( postId );\n\tlet title = __( 'No title' );\n\tif ( labels?.name && postIds.length > 1 ) {\n\t\ttitle = sprintf(\n\t\t\t// translators: %i number of selected items %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t__( '%i %s' ),\n\t\t\tpostId.length,\n\t\t\tlabels?.name\n\t\t);\n\t} else if ( postTitle ) {\n\t\ttitle = stripHTML( postTitle );\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 } className=\"editor-post-card-panel\">\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"editor-post-card-panel__header\"\n\t\t\t\talign=\"flex-start\"\n\t\t\t>\n\t\t\t\t<Icon className=\"editor-post-card-panel__icon\" icon={ icon } />\n\t\t\t\t<Text\n\t\t\t\t\tnumberOfLines={ 2 }\n\t\t\t\t\ttruncate\n\t\t\t\t\tclassName=\"editor-post-card-panel__title\"\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"editor-post-card-panel__title-name\">\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ pageTypeBadge && postIds.length === 1 && (\n\t\t\t\t\t\t<Badge>{ pageTypeBadge }</Badge>\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t{ postIds.length === 1 && (\n\t\t\t\t\t<PostActions\n\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\tpostId={ postIds[ 0 ] }\n\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ postIds.length > 1 && (\n\t\t\t\t<Text className=\"editor-post-card-panel__description\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Name of the plural post type e.g: \"Posts\".\n\t\t\t\t\t\t__( 'Changes will be applied to all selected %s.' ),\n\t\t\t\t\t\tlabels?.name.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAIA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,cAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AAAgE,IAAAa,WAAA,GAAAb,OAAA;AA3BhE;AACA;AACA;;AAcA;AACA;AACA;;AAUA,MAAM;EAAEc;AAAM,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,aAAaA,CAAE;EACtCC,QAAQ;EACRC,MAAM;EACNC;AACD,CAAC,EAAG;EACH,MAAMC,OAAO,GAAG,IAAAC,gBAA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A,CAAAkD,GAAA,EAACjD,KAAK;UAAA8C,QAAA,EAAGV;QAAa,CAAS,CAC/B;MAAA,CACI,CAAC,EACL7B,OAAO,CAACiB,MAAM,KAAK,CAAC,iBACrB,IAAAzB,WAAA,CAAAkD,GAAA,EAACtD,YAAA,CAAA4D,OAAW;QACXnD,QAAQ,EAAGA,QAAU;QACrBC,MAAM,EAAGE,OAAO,CAAE,CAAC,CAAI;QACvBD,iBAAiB,EAAGA;MAAmB,CACvC,CACD;IAAA,CACM,CAAC,EACPC,OAAO,CAACiB,MAAM,GAAG,CAAC,iBACnB,IAAAzB,WAAA,CAAAkD,GAAA,EAAChE,WAAA,CAAAkE,kBAAI;MAACN,SAAS,EAAC,qCAAqC;MAAAC,QAAA,EAClD,IAAAN,aAAO;MACR;MACA,IAAAF,QAAE,EAAE,6CAA8C,CAAC,EACnDzB,MAAM,EAAE0B,IAAI,CAACiB,WAAW,CAAC,CAC1B;IAAC,CACI,CACN;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
@@ -22,7 +22,10 @@ var _jsxRuntime = require("react/jsx-runtime");
22
22
  */
23
23
 
24
24
  function MaybeCategoryPanel() {
25
- const hasNoCategory = (0, _data.useSelect)(select => {
25
+ const {
26
+ hasNoCategory,
27
+ hasSiteCategories
28
+ } = (0, _data.useSelect)(select => {
26
29
  const postType = select(_store.store).getCurrentPostType();
27
30
  const {
28
31
  canUser,
@@ -36,11 +39,19 @@ function MaybeCategoryPanel() {
36
39
  const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
37
40
  const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
38
41
  const categories = categoriesTaxonomy && select(_store.store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
42
+ const siteCategories = postTypeSupportsCategories ? !!select(_coreData.store).getEntityRecords('taxonomy', 'category', {
43
+ exclude: [defaultCategoryId],
44
+ per_page: 1
45
+ })?.length : false;
39
46
 
40
47
  // This boolean should return true if everything is loaded
41
48
  // ( categoriesTaxonomy, defaultCategory )
42
49
  // and the post has not been assigned a category different than "uncategorized".
43
- return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
50
+ const noCategory = !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
51
+ return {
52
+ hasNoCategory: noCategory,
53
+ hasSiteCategories: siteCategories
54
+ };
44
55
  }, []);
45
56
  const [shouldShowPanel, setShouldShowPanel] = (0, _element.useState)(false);
46
57
  (0, _element.useEffect)(() => {
@@ -50,7 +61,12 @@ function MaybeCategoryPanel() {
50
61
  setShouldShowPanel(true);
51
62
  }
52
63
  }, [hasNoCategory]);
53
- if (!shouldShowPanel) {
64
+
65
+ // We only want to show the category panel:
66
+ // if the post type supports categories,
67
+ // if the site has categories other than the default category,
68
+ // and if the post has no other categories than the default category.
69
+ if (!shouldShowPanel || !hasSiteCategories) {
54
70
  return null;
55
71
  }
56
72
  const panelBodyTitle = [(0, _i18n.__)('Suggestion:'), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_components","_coreData","_element","_hierarchicalTermSelector","_interopRequireDefault","_store","_jsxRuntime","MaybeCategoryPanel","hasNoCategory","useSelect","select","postType","editorStore","getCurrentPostType","canUser","getEntityRecord","coreStore","categoriesTaxonomy","defaultCategoryId","kind","name","default_category","undefined","defaultCategory","postTypeSupportsCategories","types","some","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","setShouldShowPanel","useState","useEffect","panelBodyTitle","__","jsx","className","children","jsxs","PanelBody","initialOpen","title","default","slug","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst hasNoCategory = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\t\tconst categoriesTaxonomy = getEntityRecord(\n\t\t\t'root',\n\t\t\t'taxonomy',\n\t\t\t'category'\n\t\t);\n\t\tconst defaultCategoryId = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )?.default_category\n\t\t\t: undefined;\n\t\tconst defaultCategory = defaultCategoryId\n\t\t\t? getEntityRecord( 'taxonomy', 'category', defaultCategoryId )\n\t\t\t: undefined;\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tcategoriesTaxonomy.types.some( ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\treturn (\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory?.id === categories[ 0 ] ) )\n\t\t);\n\t}, [] );\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\tif ( ! shouldShowPanel ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,yBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAbnD;AACA;AACA;;AAOA;AACA;AACA;;AAIA,SAASS,kBAAkBA,CAAA,EAAG;EAC7B,MAAMC,aAAa,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC9C,MAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC;IAC3D,MAAM;MAAEC,OAAO;MAAEC;IAAgB,CAAC,GAAGL,MAAM,CAAEM,eAAU,CAAC;IACxD,MAAMC,kBAAkB,GAAGF,eAAe,CACzC,MAAM,EACN,UAAU,EACV,UACD,CAAC;IACD,MAAMG,iBAAiB,GAAGJ,OAAO,CAAE,MAAM,EAAE;MAC1CK,IAAI,EAAE,MAAM;MACZC,IAAI,EAA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CAAAoC,IAAA,EAAC1C,WAAA,CAAA2C,SAAS;IAACC,WAAW,EAAG,KAAO;IAACC,KAAK,EAAGR,cAAgB;IAAAI,QAAA,gBACxD,IAAAnC,WAAA,CAAAiC,GAAA;MAAAE,QAAA,EACG,IAAAH,QAAE,EACH,oHACD;IAAC,CACC,CAAC,eACJ,IAAAhC,WAAA,CAAAiC,GAAA,EAACpC,yBAAA,CAAA2C,OAAwB;MAACC,IAAI,EAAC;IAAU,CAAE,CAAC;EAAA,CAClC,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEcvC,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_components","_coreData","_element","_hierarchicalTermSelector","_interopRequireDefault","_store","_jsxRuntime","MaybeCategoryPanel","hasNoCategory","hasSiteCategories","useSelect","select","postType","editorStore","getCurrentPostType","canUser","getEntityRecord","coreStore","categoriesTaxonomy","defaultCategoryId","kind","name","default_category","undefined","defaultCategory","postTypeSupportsCategories","types","some","type","categories","getEditedPostAttribute","rest_base","siteCategories","getEntityRecords","exclude","per_page","length","noCategory","id","shouldShowPanel","setShouldShowPanel","useState","useEffect","panelBodyTitle","__","jsx","className","children","jsxs","PanelBody","initialOpen","title","default","slug","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst { hasNoCategory, hasSiteCategories } = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst { canUser, getEntityRecord } = select( coreStore );\n\t\tconst categoriesTaxonomy = getEntityRecord(\n\t\t\t'root',\n\t\t\t'taxonomy',\n\t\t\t'category'\n\t\t);\n\t\tconst defaultCategoryId = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )?.default_category\n\t\t\t: undefined;\n\t\tconst defaultCategory = defaultCategoryId\n\t\t\t? getEntityRecord( 'taxonomy', 'category', defaultCategoryId )\n\t\t\t: undefined;\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tcategoriesTaxonomy.types.some( ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\t\tconst siteCategories = postTypeSupportsCategories\n\t\t\t? !! select( coreStore ).getEntityRecords( 'taxonomy', 'category', {\n\t\t\t\t\texclude: [ defaultCategoryId ],\n\t\t\t\t\tper_page: 1,\n\t\t\t } )?.length\n\t\t\t: false;\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\tconst noCategory =\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory?.id === categories[ 0 ] ) );\n\n\t\treturn {\n\t\t\thasNoCategory: noCategory,\n\t\t\thasSiteCategories: siteCategories,\n\t\t};\n\t}, [] );\n\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\t// We only want to show the category panel:\n\t// if the post type supports categories,\n\t// if the site has categories other than the default category,\n\t// and if the post has no other categories than the default category.\n\tif ( ! shouldShowPanel || ! hasSiteCategories ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,yBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAbnD;AACA;AACA;;AAOA;AACA;AACA;;AAIA,SAASS,kBAAkBA,CAAA,EAAG;EAC7B,MAAM;IAAEC,aAAa;IAAEC;EAAkB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACrE,MAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC;IAC3D,MAAM;MAAEC,OAAO;MAAEC;IAAgB,CAAC,GAAGL,MAAM,CAAEM,eAAU,CAAC;IACxD,MAAMC,kBAAkB,GAAGF,eAAe,CACzC,MAAM,EACN,UAAU,EACV,UACD,CAAC;IACD,MAAMG,iBAAiB,GAAGJ,OAAO,CAAE,MAAM,EAA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,kBAAkB,CAAE,IAAK,CAAC;IAC3B;EACD,CAAC,EAAE,CAAEhC,aAAa,CAAG,CAAC;;EAEtB;EACA;EACA;EACA;EACA,IAAK,CAAE+B,eAAe,IAAI,CAAE9B,iBAAiB,EAAG;IAC/C,OAAO,IAAI;EACZ;EAEA,MAAMkC,cAAc,GAAG,CACtB,IAAAC,QAAE,EAAE,aAAc,CAAC,eACnB,IAAAtC,WAAA,CAAAuC,GAAA;IAAMC,SAAS,EAAC,iCAAiC;IAAAC,QAAA,EAC9C,IAAAH,QAAE,EAAE,mBAAoB;EAAC,GAD0B,OAEhD,CAAC,CACP;EAED,oBACC,IAAAtC,WAAA,CAAA0C,IAAA,EAAChD,WAAA,CAAAiD,SAAS;IAACC,WAAW,EAAG,KAAO;IAACC,KAAK,EAAGR,cAAgB;IAAAI,QAAA,gBACxD,IAAAzC,WAAA,CAAAuC,GAAA;MAAAE,QAAA,EACG,IAAAH,QAAE,EACH,oHACD;IAAC,CACC,CAAC,eACJ,IAAAtC,WAAA,CAAAuC,GAAA,EAAC1C,yBAAA,CAAAiD,OAAwB;MAACC,IAAI,EAAC;IAAU,CAAE,CAAC;EAAA,CAClC,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEc7C,kBAAkB","ignoreList":[]}
@@ -39,7 +39,8 @@ const TagsPanel = () => {
39
39
  };
40
40
  const MaybeTagsPanel = () => {
41
41
  const {
42
- hasTags,
42
+ postHasTags,
43
+ siteHasTags,
43
44
  isPostTypeSupported
44
45
  } = (0, _data.useSelect)(select => {
45
46
  const postType = select(_store.store).getCurrentPostType();
@@ -47,13 +48,22 @@ const MaybeTagsPanel = () => {
47
48
  const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
48
49
  const areTagsFetched = tagsTaxonomy !== undefined;
49
50
  const tags = tagsTaxonomy && select(_store.store).getEditedPostAttribute(tagsTaxonomy.rest_base);
51
+ const siteTags = _isPostTypeSupported ? !!select(_coreData.store).getEntityRecords('taxonomy', 'post_tag', {
52
+ per_page: 1
53
+ })?.length : false;
50
54
  return {
51
- hasTags: !!tags?.length,
55
+ postHasTags: !!tags?.length,
56
+ siteHasTags: siteTags,
52
57
  isPostTypeSupported: areTagsFetched && _isPostTypeSupported
53
58
  };
54
59
  }, []);
55
- const [hadTagsWhenOpeningThePanel] = (0, _element.useState)(hasTags);
56
- if (!isPostTypeSupported) {
60
+ const [hadTagsWhenOpeningThePanel] = (0, _element.useState)(postHasTags);
61
+
62
+ /**
63
+ * We only want to show the tag panel if the post type supports
64
+ * tags and the site has tags.
65
+ */
66
+ if (!isPostTypeSupported || !siteHasTags) {
57
67
  return null;
58
68
  }
59
69
 
@@ -61,9 +71,9 @@ const MaybeTagsPanel = () => {
61
71
  * We only want to show the tag panel if the post didn't have
62
72
  * any tags when the user hit the Publish button.
63
73
  *
64
- * We can't use the prop.hasTags because it'll change to true
74
+ * We can't use the prop.postHasTags because it'll change to true
65
75
  * if the user adds a new tag within the pre-publish panel.
66
- * This would force a re-render and a new prop.hasTags check,
76
+ * This would force a re-render and a new prop.postHasTags check,
67
77
  * hiding this panel and keeping the user from adding
68
78
  * more than one tag.
69
79
  */
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_data","_components","_coreData","_flatTermSelector","_interopRequireDefault","_store","_jsxRuntime","TagsPanel","panelBodyTitle","__","jsx","className","children","jsxs","PanelBody","initialOpen","title","default","slug","__nextHasNoMarginBottom","MaybeTagsPanel","hasTags","isPostTypeSupported","useSelect","select","postType","editorStore","getCurrentPostType","tagsTaxonomy","coreStore","getEntityRecord","_isPostTypeSupported","types","includes","areTagsFetched","undefined","tags","getEditedPostAttribute","rest_base","length","hadTagsWhenOpeningThePanel","useState","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Add tags' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" __nextHasNoMarginBottom />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { hasTags, isPostTypeSupported } = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'taxonomy',\n\t\t\t'post_tag'\n\t\t);\n\t\tconst _isPostTypeSupported = tagsTaxonomy?.types?.includes( postType );\n\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\tconst tags =\n\t\t\ttagsTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t);\n\t\treturn {\n\t\t\thasTags: !! tags?.length,\n\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t};\n\t}, [] );\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( hasTags );\n\n\tif ( ! isPostTypeSupported ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.hasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.hasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\tif ( ! hadTagsWhenOpeningThePanel ) {\n\t\treturn <TagsPanel />;\n\t}\n\n\treturn null;\n};\n\nexport default MaybeTagsPanel;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,iBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAbnD;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMS,SAAS,GAAGA,CAAA,KAAM;EACvB,MAAMC,cAAc,GAAG,CACtB,IAAAC,QAAE,EAAE,aAAc,CAAC,eACnB,IAAAH,WAAA,CAAAI,GAAA;IAAMC,SAAS,EAAC,iCAAiC;IAAAC,QAAA,EAC9C,IAAAH,QAAE,EAAE,UAAW;EAAC,GADmC,OAEhD,CAAC,CACP;EAED,oBACC,IAAAH,WAAA,CAAAO,IAAA,EAACZ,WAAA,CAAAa,SAAS;IAACC,WAAW,EAAG,KAAO;IAACC,KAAK,EAAGR,cAAgB;IAAAI,QAAA,gBACxD,IAAAN,WAAA,CAAAI,GAAA;MAAAE,QAAA,EACG,IAAAH,QAAE,EACH,wHACD;IAAC,CACC,CAAC,eACJ,IAAAH,WAAA,CAAAI,GAAA,EAACP,iBAAA,CAAAc,OAAgB;MAACC,IAAI,EAAC,UAAU;MAACC,uBAAuB;IAAA,CAAE,CAAC;EAAA,CAClD,CAAC;AAEd,CAAC;AAED,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC,OAAO;IAAEC;EAAoB,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACjE,MAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC;IAC3D,MAAMC,YAAY,GAAGJ,MAAM,CAAEK,eAAU,CAAC,CAACC,eAAe,CACvD,MAAM,EACN,UAAU,EACV,UACD,CAAC;IACD,MAAMC,oBAAoB,GAAGH,YAAY,EAAEI,KAAK,EAAEC,QAAQ,CAAER,QAAS,CAAC;IACtE,MAAMS,cAAc,GAAGN,YAAY,KAAKO,SAAS;IACjD,MAAMC,IAAI,GACTR,YAAY,IACZJ,MAAM,CAAEE,YAAY,CAAC,CAACW,sBAAsB,CAC3CT,YAAY,CAACU,SACd,CAAC;IACF,OAAO;MACNjB,OAAO,EAAE,CAAC,CAAEe,IAAI,EAAEG,MAAM;MACxBjB,mBAAmB,EAAEY,cAAc,IAAIH;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM,CAAES,0BAA0B,CAAE,GAAG,IAAAC,iBAAQ,EAAEpB,OAAQ,CAAC;EAE1D,IAAK,CAAEC,mBAAmB,EAAG;IAC5B,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,IAAK,CAAEkB,0BAA0B,EAAG;IACnC,oBAAO,IAAAlC,WAAA,CAAAI,GAAA,EAACH,SAAS,IAAE,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ,CAAC;AAAC,IAAAmC,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEaG,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_data","_components","_coreData","_flatTermSelector","_interopRequireDefault","_store","_jsxRuntime","TagsPanel","panelBodyTitle","__","jsx","className","children","jsxs","PanelBody","initialOpen","title","default","slug","__nextHasNoMarginBottom","MaybeTagsPanel","postHasTags","siteHasTags","isPostTypeSupported","useSelect","select","postType","editorStore","getCurrentPostType","tagsTaxonomy","coreStore","getEntityRecord","_isPostTypeSupported","types","includes","areTagsFetched","undefined","tags","getEditedPostAttribute","rest_base","siteTags","getEntityRecords","per_page","length","hadTagsWhenOpeningThePanel","useState","_default","exports"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-tags-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport FlatTermSelector from '../post-taxonomies/flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst TagsPanel = () => {\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Add tags' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<FlatTermSelector slug=\"post_tag\" __nextHasNoMarginBottom />\n\t\t</PanelBody>\n\t);\n};\n\nconst MaybeTagsPanel = () => {\n\tconst { postHasTags, siteHasTags, isPostTypeSupported } = useSelect(\n\t\t( select ) => {\n\t\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\t\tconst tagsTaxonomy = select( coreStore ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'taxonomy',\n\t\t\t\t'post_tag'\n\t\t\t);\n\t\t\tconst _isPostTypeSupported =\n\t\t\t\ttagsTaxonomy?.types?.includes( postType );\n\t\t\tconst areTagsFetched = tagsTaxonomy !== undefined;\n\t\t\tconst tags =\n\t\t\t\ttagsTaxonomy &&\n\t\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\t\ttagsTaxonomy.rest_base\n\t\t\t\t);\n\t\t\tconst siteTags = _isPostTypeSupported\n\t\t\t\t? !! select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'taxonomy',\n\t\t\t\t\t\t'post_tag',\n\t\t\t\t\t\t{ per_page: 1 }\n\t\t\t\t )?.length\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tpostHasTags: !! tags?.length,\n\t\t\t\tsiteHasTags: siteTags,\n\t\t\t\tisPostTypeSupported: areTagsFetched && _isPostTypeSupported,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ hadTagsWhenOpeningThePanel ] = useState( postHasTags );\n\n\t/**\n\t * We only want to show the tag panel if the post type supports\n\t * tags and the site has tags.\n\t */\n\tif ( ! isPostTypeSupported || ! siteHasTags ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * We only want to show the tag panel if the post didn't have\n\t * any tags when the user hit the Publish button.\n\t *\n\t * We can't use the prop.postHasTags because it'll change to true\n\t * if the user adds a new tag within the pre-publish panel.\n\t * This would force a re-render and a new prop.postHasTags check,\n\t * hiding this panel and keeping the user from adding\n\t * more than one tag.\n\t */\n\tif ( ! hadTagsWhenOpeningThePanel ) {\n\t\treturn <TagsPanel />;\n\t}\n\n\treturn null;\n};\n\nexport default MaybeTagsPanel;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,iBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,IAAAQ,WAAA,GAAAR,OAAA;AAbnD;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAMS,SAAS,GAAGA,CAAA,KAAM;EACvB,MAAMC,cAAc,GAAG,CACtB,IAAAC,QAAE,EAAE,aAAc,CAAC,eACnB,IAAAH,WAAA,CAAAI,GAAA;IAAMC,SAAS,EAAC,iCAAiC;IAAAC,QAA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;MAC5BrB,WAAW,EAAEkB,QAAQ;MACrBjB,mBAAmB,EAAEY,cAAc,IAAIH;IACxC,CAAC;EACF,CAAC,EACD,EACD,CAAC;EACD,MAAM,CAAEY,0BAA0B,CAAE,GAAG,IAAAC,iBAAQ,EAAExB,WAAY,CAAC;;EAE9D;AACD;AACA;AACA;EACC,IAAK,CAAEE,mBAAmB,IAAI,CAAED,WAAW,EAAG;IAC7C,OAAO,IAAI;EACZ;;EAEA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,IAAK,CAAEsB,0BAA0B,EAAG;IACnC,oBAAO,IAAAtC,WAAA,CAAAI,GAAA,EAACH,SAAS,IAAE,CAAC;EACrB;EAEA,OAAO,IAAI;AACZ,CAAC;AAAC,IAAAuC,QAAA,GAAAC,OAAA,CAAA9B,OAAA,GAEaG,cAAc","ignoreList":[]}
@@ -207,7 +207,7 @@ function PostStatus() {
207
207
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
208
208
  __nextHasNoMarginBottom: true,
209
209
  label: (0, _i18n.__)('Password protected'),
210
- help: (0, _i18n.__)('Only visible to those who know the password'),
210
+ help: (0, _i18n.__)('Only visible to those who know the password.'),
211
211
  checked: showPassword,
212
212
  onChange: handleTogglePassword
213
213
  }), showPassword && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_data","_element","_coreData","_blockEditor","_compose","_icons","_constants","_postPanelRow","_interopRequireDefault","_postSticky","_postSchedule","_store","_jsxRuntime","postStatusesInfo","label","__","icon","drafts","draft","pending","private","notAllowed","future","scheduled","publish","published","STATUS_OPTIONS","exports","value","description","DESIGN_POST_TYPES","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostStatus","status","date","password","postId","postType","canEdit","useSelect","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","editorStore","_links","showPassword","setShowPassword","useState","passwordInputId","useInstanceId","editEntityRecord","useDispatch","coreStore","popoverAnchor","setPopoverAnchor","popoverProps","useMemo","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","jsx","default","ref","children","Dropdown","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","Button","variant","size","onClick","sprintf","renderContent","onClose","jsxs","Fragment","__experimentalInspectorPopoverHeader","title","__experimentalVStack","spacing","RadioControl","hideLabelFromVision","options","onChange","selected","PrivatePostSchedule","showPopoverHeaderActions","isCompact","as","CheckboxControl","__nextHasNoMarginBottom","help","checked","TextControl","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div className=\"editor-post-status is-read-only\">\n\t\t\t\t\t{ postStatusesInfo[ status ]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CACP;QAAC,CACJ,CAAC;MAAA,CACN;IACA,CACH,CAAC,gBAEF,IAAAjE,WAAA,CAAAgE,GAAA;MAAKK,SAAS,EAAC,iCAAiC;MAAAF,QAAA,EAC7ClE,gBAAgB,CAAEuB,MAAM,CAAE,EAAEtB;IAAK,CAC/B;EACL,CACY,CAAC;AAEjB","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_data","_element","_coreData","_blockEditor","_compose","_icons","_constants","_postPanelRow","_interopRequireDefault","_postSticky","_postSchedule","_store","_jsxRuntime","postStatusesInfo","label","__","icon","drafts","draft","pending","private","notAllowed","future","scheduled","publish","published","STATUS_OPTIONS","exports","value","description","DESIGN_POST_TYPES","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","PATTERN_POST_TYPE","NAVIGATION_POST_TYPE","PostStatus","status","date","password","postId","postType","canEdit","useSelect","select","_getCurrentPost$_link","getEditedPostAttribute","getCurrentPostId","getCurrentPostType","getCurrentPost","editorStore","_links","showPassword","setShowPassword","useState","passwordInputId","useInstanceId","editEntityRecord","useDispatch","coreStore","popoverAnchor","setPopoverAnchor","popoverProps","useMemo","anchor","headerTitle","placement","offset","shift","includes","updatePost","newStatus","newPassword","newDate","handleTogglePassword","handleStatus","Date","jsx","default","ref","children","Dropdown","className","contentClassName","focusOnMount","renderToggle","onToggle","isOpen","Button","variant","size","onClick","sprintf","renderContent","onClose","jsxs","Fragment","__experimentalInspectorPopoverHeader","title","__experimentalVStack","spacing","RadioControl","hideLabelFromVision","options","onChange","selected","PrivatePostSchedule","showPopoverHeaderActions","isCompact","as","CheckboxControl","__nextHasNoMarginBottom","help","checked","TextControl","placeholder","type","id","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/editor/src/components/post-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\tDropdown,\n\t__experimentalVStack as VStack,\n\tTextControl,\n\tRadioControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n} from '../../store/constants';\nimport PostPanelRow from '../post-panel-row';\nimport PostSticky from '../post-sticky';\nimport { PrivatePostSchedule } from '../post-schedule';\nimport { store as editorStore } from '../../store';\n\nconst postStatusesInfo = {\n\t'auto-draft': { label: __( 'Draft' ), icon: drafts },\n\tdraft: { label: __( 'Draft' ), icon: drafts },\n\tpending: { label: __( 'Pending' ), icon: pending },\n\tprivate: { label: __( 'Private' ), icon: notAllowed },\n\tfuture: { label: __( 'Scheduled' ), icon: scheduled },\n\tpublish: { label: __( 'Published' ), icon: published },\n};\n\nexport const STATUS_OPTIONS = [\n\t{\n\t\tlabel: __( 'Draft' ),\n\t\tvalue: 'draft',\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tlabel: __( 'Pending' ),\n\t\tvalue: 'pending',\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tlabel: __( 'Private' ),\n\t\tvalue: 'private',\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tlabel: __( 'Scheduled' ),\n\t\tvalue: 'future',\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tlabel: __( 'Published' ),\n\t\tvalue: 'publish',\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n];\n\nconst DESIGN_POST_TYPES = [\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n\tPATTERN_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n];\n\nexport default function PostStatus() {\n\tconst { status, date, password, postId, postType, canEdit } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetCurrentPost,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tstatus: getEditedPostAttribute( 'status' ),\n\t\t\t\tdate: getEditedPostAttribute( 'date' ),\n\t\t\t\tpassword: getEditedPostAttribute( 'password' ),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tcanEdit:\n\t\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst [ showPassword, setShowPassword ] = useState( !! password );\n\tconst passwordInputId = useInstanceId(\n\t\tPostStatus,\n\t\t'editor-change-status__password-input'\n\t);\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Status & visibility' ),\n\t\t\theaderTitle: __( 'Status & visibility' ),\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tif ( DESIGN_POST_TYPES.includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\tconst updatePost = ( {\n\t\tstatus: newStatus = status,\n\t\tpassword: newPassword = password,\n\t\tdate: newDate = date,\n\t} ) => {\n\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\tstatus: newStatus,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\tconst handleTogglePassword = ( value ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tupdatePost( { password: '' } );\n\t\t}\n\t};\n\n\tconst handleStatus = ( value ) => {\n\t\tlet newDate = date;\n\t\tlet newPassword = password;\n\t\tif ( status === 'future' && new Date( date ) > new Date() ) {\n\t\t\tnewDate = null;\n\t\t}\n\t\tif ( value === 'private' && password ) {\n\t\t\tnewPassword = '';\n\t\t}\n\t\tupdatePost( {\n\t\t\tstatus: value,\n\t\t\tdate: newDate,\n\t\t\tpassword: newPassword,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Status' ) } ref={ setPopoverAnchor }>\n\t\t\t{ canEdit ? (\n\t\t\t\t<Dropdown\n\t\t\t\t\tclassName=\"editor-post-status\"\n\t\t\t\t\tcontentClassName=\"editor-change-status__content\"\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-status__toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\ticon={ postStatusesInfo[ status ]?.icon }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post status.\n\t\t\t\t\t\t\t\t__( 'Change status: %s' ),\n\t\t\t\t\t\t\t\tpostStatusesInfo[ status ]?.label\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\t\ttitle={ __( 'Status & visibility' ) }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<form>\n\t\t\t\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t\t\t\t<RadioControl\n\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__options\"\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\t\t\tlabel={ __( 'Status' ) }\n\t\t\t\t\t\t\t\t\t\toptions={ STATUS_OPTIONS }\n\t\t\t\t\t\t\t\t\t\tonChange={ handleStatus }\n\t\t\t\t\t\t\t\t\t\tselected={\n\t\t\t\t\t\t\t\t\t\t\tstatus === 'auto-draft'\n\t\t\t\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t\t\t\t: status\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ status === 'future' && (\n\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__publish-date-wrapper\">\n\t\t\t\t\t\t\t\t\t\t\t<PrivatePostSchedule\n\t\t\t\t\t\t\t\t\t\t\t\tshowPopoverHeaderActions={\n\t\t\t\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tisCompact\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ status !== 'private' && (\n\t\t\t\t\t\t\t\t\t\t<VStack\n\t\t\t\t\t\t\t\t\t\t\tas=\"fieldset\"\n\t\t\t\t\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-change-status__password-fieldset\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Password protected'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'Only visible to those who know the password.'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\tchecked={ showPassword }\n\t\t\t\t\t\t\t\t\t\t\t\tonChange={\n\t\t\t\t\t\t\t\t\t\t\t\t\thandleTogglePassword\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t{ showPassword && (\n\t\t\t\t\t\t\t\t\t\t\t\t<div className=\"editor-change-status__password-input\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tupdatePost( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={ password }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Use a secure password'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid={ passwordInputId }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t\t\t</VStack>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div className=\"editor-post-status is-read-only\">\n\t\t\t\t\t{ postStatusesInfo[ status ]?.label }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</PostPanelRow>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAWA,IAAAQ,UAAA,GAAAR,OAAA;AAMA,IAAAS,aAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,WAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AAAmD,IAAAc,WAAA,GAAAd,OAAA;AArCnD;AACA;AACA;;AAuBA;AACA;AACA;;AAYA,MAAMe,gBAAgB,GAAG;EACxB,YAAY,EA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iBACb,IAAAvC,WAAA,CAAAgE,GAAA;gBAAKK,SAAS,EAAC,sCAAsC;gBAAAF,QAAA,eACpD,IAAAnE,WAAA,CAAAgE,GAAA,EAAC/E,WAAA,CAAAoH,WAAW;kBACXnG,KAAK,EAAG,IAAAC,QAAE,EACT,UACD,CAAG;kBACHwF,QAAQ,EAAK3E,KAAK,IACjByC,UAAU,CAAE;oBACX/B,QAAQ,EAAEV;kBACX,CAAE,CACF;kBACDA,KAAK,EAAGU,QAAU;kBAClB4E,WAAW,EAAG,IAAAnG,QAAE,EACf,uBACD,CAAG;kBACHoG,IAAI,EAAC,MAAM;kBACXC,EAAE,EAAG9D,eAAiB;kBACtB+D,qBAAqB;kBACrBP,uBAAuB;kBACvBQ,SAAS,EAAG;gBAAK,CACjB;cAAC,CACE,CACL;YAAA,CACM,CACR,eACD,IAAA1G,WAAA,CAAAgE,GAAA,EAACnE,WAAA,CAAAoE,OAAU,IAAE,CAAC;UAAA,CACP;QAAC,CACJ,CAAC;MAAA,CACN;IACA,CACH,CAAC,gBAEF,IAAAjE,WAAA,CAAAgE,GAAA;MAAKK,SAAS,EAAC,iCAAiC;MAAAF,QAAA,EAC7ClE,gBAAgB,CAAEuB,MAAM,CAAE,EAAEtB;IAAK,CAC/B;EACL,CACY,CAAC;AAEjB","ignoreList":[]}
@@ -35,7 +35,7 @@ var _jsxRuntime = require("react/jsx-runtime");
35
35
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.CheckboxControl, {
36
36
  className: "editor-post-sticky__checkbox-control",
37
37
  label: (0, _i18n.__)('Sticky'),
38
- help: (0, _i18n.__)('Pin this post to the top of the blog'),
38
+ help: (0, _i18n.__)('Pin this post to the top of the blog.'),
39
39
  checked: postSticky,
40
40
  onChange: () => editPost({
41
41
  sticky: !postSticky
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_data","_check","_interopRequireDefault","_store","_jsxRuntime","PostSticky","postSticky","useSelect","select","_select$getEditedPost","editorStore","getEditedPostAttribute","editPost","useDispatch","jsx","default","children","CheckboxControl","className","label","__","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAXnD;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,GACe,SAASO,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEE,YAAY,CAAC,CAACC,sBAAsB,CAAE,QAAS,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEG;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAY,CAAC;EAE/C,oBACC,IAAAN,WAAA,CAAAU,GAAA,EAACb,MAAA,CAAAc,OAAe;IAAAC,QAAA,eACf,IAAAZ,WAAA,CAAAU,GAAA,EAACf,WAAA,CAAAkB,eAAe;MACfC,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;MACxBC,IAAI,EAAG,IAAAD,QAAE,EAAE,sCAAuC,CAAG;MACrDE,OAAO,EAAGhB,UAAY;MACtBiB,QAAQ,EAAGA,CAAA,KAAMX,QAAQ,CAAE;QAAEY,MAAM,EAAE,CAAElB;MAAW,CAAE,CAAG;MACvDmB,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_check","_interopRequireDefault","_store","_jsxRuntime","PostSticky","postSticky","useSelect","select","_select$getEditedPost","editorStore","getEditedPostAttribute","editPost","useDispatch","jsx","default","children","CheckboxControl","className","label","__","help","checked","onChange","sticky","__nextHasNoMarginBottom"],"sources":["@wordpress/editor/src/components/post-sticky/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostStickyCheck from './check';\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostSticky() {\n\tconst postSticky = useSelect( ( select ) => {\n\t\treturn (\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'sticky' ) ?? false\n\t\t);\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\n\treturn (\n\t\t<PostStickyCheck>\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"editor-post-sticky__checkbox-control\"\n\t\t\t\tlabel={ __( 'Sticky' ) }\n\t\t\t\thelp={ __( 'Pin this post to the top of the blog.' ) }\n\t\t\t\tchecked={ postSticky }\n\t\t\t\tonChange={ () => editPost( { sticky: ! postSticky } ) }\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t/>\n\t\t</PostStickyCheck>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAXnD;AACA;AACA;;AAKA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,GACe,SAASO,UAAUA,CAAA,EAAG;EACpC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,qBAAA;IAC3C,QAAAA,qBAAA,GACCD,MAAM,CAAEE,YAAY,CAAC,CAACC,sBAAsB,CAAE,QAAS,CAAC,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;EAEnE,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEG;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAY,CAAC;EAE/C,oBACC,IAAAN,WAAA,CAAAU,GAAA,EAACb,MAAA,CAAAc,OAAe;IAAAC,QAAA,eACf,IAAAZ,WAAA,CAAAU,GAAA,EAACf,WAAA,CAAAkB,eAAe;MACfC,SAAS,EAAC,sCAAsC;MAChDC,KAAK,EAAG,IAAAC,QAAE,EAAE,QAAS,CAAG;MACxBC,IAAI,EAAG,IAAAD,QAAE,EAAE,uCAAwC,CAAG;MACtDE,OAAO,EAAGhB,UAAY;MACtBiB,QAAQ,EAAGA,CAAA,KAAMX,QAAQ,CAAE;QAAEY,MAAM,EAAE,CAAElB;MAAW,CAAE,CAAG;MACvDmB,uBAAuB;IAAA,CACvB;EAAC,CACc,CAAC;AAEpB","ignoreList":[]}
@@ -46,16 +46,17 @@ function useAllowSwitchingTemplates() {
46
46
  kind: 'root',
47
47
  name: 'site'
48
48
  }) ? getEntityRecord('root', 'site') : undefined;
49
- const templates = getEntityRecords('postType', 'wp_template', {
50
- per_page: -1
51
- });
52
49
  const isPostsPage = +postId === siteSettings?.page_for_posts;
50
+ const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front;
53
51
  // If current page is set front page or posts page, we also need
54
52
  // to check if the current theme has a template for it. If not
55
- const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
53
+ const templates = isFrontPage ? getEntityRecords('postType', 'wp_template', {
54
+ per_page: -1
55
+ }) : [];
56
+ const hasFrontPage = isFrontPage && !!templates?.some(({
56
57
  slug
57
58
  }) => slug === 'front-page');
58
- return !isPostsPage && !isFrontPage;
59
+ return !isPostsPage && !hasFrontPage;
59
60
  }, [postId, postType]);
60
61
  }
61
62
  function useTemplates(postType) {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_store","useEditedPostContext","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","templates","per_page","isPostsPage","page_for_posts","isFrontPage","page_on_front","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useMemo","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' &&\n\t\t\t\t+postId === siteSettings?.page_on_front &&\n\t\t\t\ttemplates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGO,SAASI,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEG,YAAY,CAAC;IACtE,OAAO;MACNC,MAAM,EAAEH,gBAAgB,CAAC,CAAC;MAC1BI,QAAQ,EAAEH,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR;AACO,SAASI,0BAA0BA,CAAA,EAAG;EAC5C,MAAM;IAAED,QAAQ;IAAED;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,OAAO,IAAAC,eAAS,EACbC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b,MACCD,sBAAsB,IACtBb,SAAS,EAAEe,MAAM,CACdC,QAAQ,IACTA,QAAQ,CAACC,SAAS,IAClBD,QAAQ,CAACT,IAAI,KAAKI,mBAAmB,IACrC,CAAC,CAAEK,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAEnB,SAAS,EAAEW,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEtB,QAAQ;IAAED;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,MAAMiB,SAAS,GAAGQ,YAAY,CAAElB,QAAS,CAAC;EAC1C,MAAM8B,cAAc,GAAG,IAAApC,eAAS,EAC7BC,MAAM,IAAM;IACb,MAAMoC,IAAI,GAAGpC,MAAM,CAAEU,eAAU,CAAC,CAAC2B,qBAAqB,CACrD,UAAU,EACVhC,QAAQ,EACRD,MACD,CAAC;IACD,OAAOgC,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAE1B,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAE+B,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOpB,SAAS,EAAEuB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACT,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","useEditedPostContext","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","postId","postType","useAllowSwitchingTemplates","canUser","getEntityRecord","getEntityRecords","coreStore","siteSettings","kind","name","undefined","isPostsPage","page_for_posts","isFrontPage","page_on_front","templates","per_page","hasFrontPage","some","slug","useTemplates","post_type","useAvailableTemplates","currentTemplateSlug","useCurrentTemplateSlug","allowSwitchingTemplate","useMemo","filter","template","is_custom","content","raw","entityTemplate","post","getEditedEntityRecord","find"],"sources":["@wordpress/editor/src/components/post-template/hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useEditedPostContext() {\n\treturn useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n}\nexport function useAllowSwitchingTemplates() {\n\tconst { postType, postId } = useEditedPostContext();\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tconst isPostsPage = +postId === siteSettings?.page_for_posts;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && +postId === siteSettings?.page_on_front;\n\t\t\t// If current page is set front page or posts page, we also need\n\t\t\t// to check if the current theme has a template for it. If not\n\t\t\tconst templates = isFrontPage\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: [];\n\t\t\tconst hasFrontPage =\n\t\t\t\tisFrontPage &&\n\t\t\t\t!! templates?.some( ( { slug } ) => slug === 'front-page' );\n\t\t\treturn ! isPostsPage && ! hasFrontPage;\n\t\t},\n\t\t[ postId, postType ]\n\t);\n}\n\nfunction useTemplates( postType ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} ),\n\t\t[ postType ]\n\t);\n}\n\nexport function useAvailableTemplates( postType ) {\n\tconst currentTemplateSlug = useCurrentTemplateSlug();\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst templates = useTemplates( postType );\n\treturn useMemo(\n\t\t() =>\n\t\t\tallowSwitchingTemplate &&\n\t\t\ttemplates?.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== currentTemplateSlug &&\n\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t),\n\t\t[ templates, currentTemplateSlug, allowSwitchingTemplate ]\n\t);\n}\n\nexport function useCurrentTemplateSlug() {\n\tconst { postType, postId } = useEditedPostContext();\n\tconst templates = useTemplates( postType );\n\tconst entityTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst post = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\treturn post?.template;\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tif ( ! entityTemplate ) {\n\t\treturn;\n\t}\n\t// If a page has a `template` set and is not included in the list\n\t// of the theme's templates, do not return it, in order to resolve\n\t// to the current theme's default template.\n\treturn templates?.find( ( template ) => template.slug === entityTemplate )\n\t\t?.slug;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGO,SAASI,oBAAoBA,CAAA,EAAG;EACtC,OAAO,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC/B,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEG,YAAY,CAAC;IACtE,OAAO;MACNC,MAAM,EAAEH,gBAAgB,CAAC,CAAC;MAC1BI,QAAQ,EAAEH,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,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;AAEO,SAASqB,qBAAqBA,CAAErB,QAAQ,EAAG;EACjD,MAAMsB,mBAAmB,GAAGC,sBAAsB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGvB,0BAA0B,CAAC,CAAC;EAC3D,MAAMa,SAAS,GAAGK,YAAY,CAAEnB,QAAS,CAAC;EAC1C,OAAO,IAAAyB,gBAAO,EACb,MACCD,sBAAsB,IACtBV,SAAS,EAAEY,MAAM,CACdC,QAAQ,IACTA,QAAQ,CAACC,SAAS,IAClBD,QAAQ,CAACT,IAAI,KAAKI,mBAAmB,IACrC,CAAC,CAAEK,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;EAC1B,CAAC,EACF,CAAEhB,SAAS,EAAEQ,mBAAmB,EAAEE,sBAAsB,CACzD,CAAC;AACF;AAEO,SAASD,sBAAsBA,CAAA,EAAG;EACxC,MAAM;IAAEvB,QAAQ;IAAED;EAAO,CAAC,GAAGN,oBAAoB,CAAC,CAAC;EACnD,MAAMqB,SAAS,GAAGK,YAAY,CAAEnB,QAAS,CAAC;EAC1C,MAAM+B,cAAc,GAAG,IAAArC,eAAS,EAC7BC,MAAM,IAAM;IACb,MAAMqC,IAAI,GAAGrC,MAAM,CAAEU,eAAU,CAAC,CAAC4B,qBAAqB,CACrD,UAAU,EACVjC,QAAQ,EACRD,MACD,CAAC;IACD,OAAOiC,IAAI,EAAEL,QAAQ;EACtB,CAAC,EACD,CAAE3B,QAAQ,EAAED,MAAM,CACnB,CAAC;EAED,IAAK,CAAEgC,cAAc,EAAG;IACvB;EACD;EACA;EACA;EACA;EACA,OAAOjB,SAAS,EAAEoB,IAAI,CAAIP,QAAQ,IAAMA,QAAQ,CAACT,IAAI,KAAKa,cAAe,CAAC,EACvEb,IAAI;AACR","ignoreList":[]}
@@ -34,9 +34,6 @@ function SwapTemplateButton({
34
34
  const {
35
35
  editEntityRecord
36
36
  } = (0, _data.useDispatch)(_coreData.store);
37
- if (!availableTemplates?.length) {
38
- return null;
39
- }
40
37
  const onTemplateSelect = async template => {
41
38
  editEntityRecord('postType', postType, postId, {
42
39
  template: template.name
@@ -48,6 +45,8 @@ function SwapTemplateButton({
48
45
  };
49
46
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
50
47
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
48
+ disabled: !availableTemplates?.length,
49
+ accessibleWhenDisabled: true,
51
50
  onClick: () => setShowModal(true),
52
51
  children: (0, _i18n.__)('Change template')
53
52
  }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_htmlEntities","_blockEditor","_components","_i18n","_data","_coreData","_blocks","_hooks","_jsxRuntime","SwapTemplateButton","onClick","showModal","setShowModal","useState","postType","postId","useEditedPostContext","availableTemplates","useAvailableTemplates","editEntityRecord","useDispatch","coreStore","length","onTemplateSelect","template","name","undoIgnore","jsxs","Fragment","children","jsx","MenuItem","__","Modal","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","useMemo","map","slug","blocks","parse","content","raw","decodeEntities","rendered","id","__experimentalBlockPatternsList","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tif ( ! availableTemplates?.length ) {\n\t\treturn null;\n\t}\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem onClick={ () => setShowModal( true ) }>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IA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AAGb,mBAAqB;IACrCc,cAAc,EAAGf;EAAU,CAC3B,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_htmlEntities","_blockEditor","_components","_i18n","_data","_coreData","_blocks","_hooks","_jsxRuntime","SwapTemplateButton","onClick","showModal","setShowModal","useState","postType","postId","useEditedPostContext","availableTemplates","useAvailableTemplates","editEntityRecord","useDispatch","coreStore","onTemplateSelect","template","name","undoIgnore","jsxs","Fragment","children","jsx","MenuItem","disabled","length","accessibleWhenDisabled","__","Modal","title","onRequestClose","overlayClassName","isFullScreen","className","TemplatesList","onSelect","templatesAsPatterns","useMemo","map","slug","blocks","parse","content","raw","decodeEntities","rendered","id","__experimentalBlockPatternsList","label","blockPatterns","onClickPattern"],"sources":["@wordpress/editor/src/components/post-template/swap-template-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport { MenuItem, Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useAvailableTemplates, useEditedPostContext } from './hooks';\n\nexport default function SwapTemplateButton( { onClick } ) {\n\tconst [ showModal, setShowModal ] = useState( false );\n\tconst { postType, postId } = useEditedPostContext();\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst onTemplateSelect = async ( template ) => {\n\t\teditEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ template: template.name },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t\tsetShowModal( false ); // Close the template suggestions modal first.\n\t\tonClick();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\tdisabled={ ! availableTemplates?.length }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => setShowModal( true ) }\n\t\t\t>\n\t\t\t\t{ __( 'Change template' ) }\n\t\t\t</MenuItem>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"editor-post-template__swap-template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-post-template__swap-template-modal-content\">\n\t\t\t\t\t\t<TemplatesList\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonSelect={ onTemplateSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction TemplatesList( { postType, onSelect } ) {\n\tconst availableTemplates = useAvailableTemplates( postType );\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tlabel={ __( 'Templates' ) }\n\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\tonClickPattern={ onSelect }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAKA,IAAAQ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