@wordpress/edit-site 6.4.0 → 6.6.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 (234) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-pattern/index.js +6 -1
  3. package/build/components/add-new-pattern/index.js.map +1 -1
  4. package/build/components/add-new-post/index.js +2 -1
  5. package/build/components/add-new-post/index.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +2 -2
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/editor/index.js +71 -20
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/background-panel.js +1 -4
  11. package/build/components/global-styles/background-panel.js.map +1 -1
  12. package/build/components/global-styles/font-families.js +3 -4
  13. package/build/components/global-styles/font-families.js.map +1 -1
  14. package/build/components/global-styles/font-library-modal/context.js +0 -5
  15. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  16. package/build/components/global-styles/font-library-modal/font-collection.js +25 -5
  17. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  18. package/build/components/global-styles/font-library-modal/index.js +1 -8
  19. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  20. package/build/components/global-styles/font-library-modal/installed-fonts.js +23 -7
  21. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  22. package/build/components/global-styles/font-library-modal/upload-fonts.js +2 -3
  23. package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  24. package/build/components/global-styles/screen-block.js +5 -7
  25. package/build/components/global-styles/screen-block.js.map +1 -1
  26. package/build/components/global-styles/screen-css.js +1 -1
  27. package/build/components/global-styles/screen-css.js.map +1 -1
  28. package/build/components/global-styles/screen-typeset.js +40 -0
  29. package/build/components/global-styles/screen-typeset.js.map +1 -0
  30. package/build/components/global-styles/screen-typography-element.js +14 -0
  31. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  32. package/build/components/global-styles/screen-typography.js +4 -6
  33. package/build/components/global-styles/screen-typography.js.map +1 -1
  34. package/build/components/global-styles/shadows-edit-panel.js +51 -59
  35. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  36. package/build/components/global-styles/size-control/index.js +10 -5
  37. package/build/components/global-styles/size-control/index.js.map +1 -1
  38. package/build/components/global-styles/typeset-button.js +97 -0
  39. package/build/components/global-styles/typeset-button.js.map +1 -0
  40. package/build/components/global-styles/typeset.js +80 -0
  41. package/build/components/global-styles/typeset.js.map +1 -0
  42. package/build/components/global-styles/ui.js +4 -0
  43. package/build/components/global-styles/ui.js.map +1 -1
  44. package/build/components/global-styles/utils.js +10 -1
  45. package/build/components/global-styles/utils.js.map +1 -1
  46. package/build/components/page-patterns/fields.js +230 -0
  47. package/build/components/page-patterns/fields.js.map +1 -0
  48. package/build/components/page-patterns/index.js +13 -228
  49. package/build/components/page-patterns/index.js.map +1 -1
  50. package/build/components/page-patterns/use-patterns.js +29 -1
  51. package/build/components/page-patterns/use-patterns.js.map +1 -1
  52. package/build/components/page-templates/fields.js +169 -0
  53. package/build/components/page-templates/fields.js.map +1 -0
  54. package/build/components/page-templates/index.js +10 -177
  55. package/build/components/page-templates/index.js.map +1 -1
  56. package/build/components/post-edit/index.js +46 -34
  57. package/build/components/post-edit/index.js.map +1 -1
  58. package/build/components/post-fields/index.js +50 -28
  59. package/build/components/post-fields/index.js.map +1 -1
  60. package/build/components/post-list/index.js +126 -68
  61. package/build/components/post-list/index.js.map +1 -1
  62. package/build/components/sidebar-dataviews/add-new-view.js +3 -2
  63. package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
  64. package/build/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
  65. package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  66. package/build/components/sidebar-dataviews/dataview-item.js +2 -3
  67. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
  68. package/build/components/sidebar-dataviews/default-views.js +81 -81
  69. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  70. package/build/components/sidebar-dataviews/index.js +3 -42
  71. package/build/components/sidebar-dataviews/index.js.map +1 -1
  72. package/build/components/site-hub/index.js +6 -3
  73. package/build/components/site-hub/index.js.map +1 -1
  74. package/build/components/style-book/index.js +22 -25
  75. package/build/components/style-book/index.js.map +1 -1
  76. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
  77. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  78. package/build/hooks/push-changes-to-global-styles/index.js +3 -3
  79. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  80. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -4
  81. package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  82. package/build/index.js +0 -2
  83. package/build/index.js.map +1 -1
  84. package/build/utils/is-template-removable.js +2 -2
  85. package/build/utils/is-template-removable.js.map +1 -1
  86. package/build/utils/is-template-revertable.js +1 -1
  87. package/build/utils/is-template-revertable.js.map +1 -1
  88. package/build-module/components/add-new-pattern/index.js +6 -1
  89. package/build-module/components/add-new-pattern/index.js.map +1 -1
  90. package/build-module/components/add-new-post/index.js +2 -1
  91. package/build-module/components/add-new-post/index.js.map +1 -1
  92. package/build-module/components/add-new-template/utils.js +2 -2
  93. package/build-module/components/add-new-template/utils.js.map +1 -1
  94. package/build-module/components/editor/index.js +73 -22
  95. package/build-module/components/editor/index.js.map +1 -1
  96. package/build-module/components/global-styles/background-panel.js +1 -4
  97. package/build-module/components/global-styles/background-panel.js.map +1 -1
  98. package/build-module/components/global-styles/font-families.js +3 -4
  99. package/build-module/components/global-styles/font-families.js.map +1 -1
  100. package/build-module/components/global-styles/font-library-modal/context.js +0 -5
  101. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  102. package/build-module/components/global-styles/font-library-modal/font-collection.js +26 -6
  103. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  104. package/build-module/components/global-styles/font-library-modal/index.js +1 -8
  105. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  106. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +23 -7
  107. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  108. package/build-module/components/global-styles/font-library-modal/upload-fonts.js +2 -3
  109. package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  110. package/build-module/components/global-styles/screen-block.js +5 -7
  111. package/build-module/components/global-styles/screen-block.js.map +1 -1
  112. package/build-module/components/global-styles/screen-css.js +1 -1
  113. package/build-module/components/global-styles/screen-css.js.map +1 -1
  114. package/build-module/components/global-styles/screen-typeset.js +34 -0
  115. package/build-module/components/global-styles/screen-typeset.js.map +1 -0
  116. package/build-module/components/global-styles/screen-typography-element.js +14 -0
  117. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  118. package/build-module/components/global-styles/screen-typography.js +4 -6
  119. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  120. package/build-module/components/global-styles/shadows-edit-panel.js +52 -60
  121. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  122. package/build-module/components/global-styles/size-control/index.js +10 -5
  123. package/build-module/components/global-styles/size-control/index.js.map +1 -1
  124. package/build-module/components/global-styles/typeset-button.js +89 -0
  125. package/build-module/components/global-styles/typeset-button.js.map +1 -0
  126. package/build-module/components/global-styles/typeset.js +71 -0
  127. package/build-module/components/global-styles/typeset.js.map +1 -0
  128. package/build-module/components/global-styles/ui.js +4 -0
  129. package/build-module/components/global-styles/ui.js.map +1 -1
  130. package/build-module/components/global-styles/utils.js +10 -1
  131. package/build-module/components/global-styles/utils.js.map +1 -1
  132. package/build-module/components/page-patterns/fields.js +223 -0
  133. package/build-module/components/page-patterns/fields.js.map +1 -0
  134. package/build-module/components/page-patterns/index.js +14 -231
  135. package/build-module/components/page-patterns/index.js.map +1 -1
  136. package/build-module/components/page-patterns/use-patterns.js +26 -0
  137. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  138. package/build-module/components/page-templates/fields.js +160 -0
  139. package/build-module/components/page-templates/fields.js.map +1 -0
  140. package/build-module/components/page-templates/index.js +12 -178
  141. package/build-module/components/page-templates/index.js.map +1 -1
  142. package/build-module/components/post-edit/index.js +49 -37
  143. package/build-module/components/post-edit/index.js.map +1 -1
  144. package/build-module/components/post-fields/index.js +50 -28
  145. package/build-module/components/post-fields/index.js.map +1 -1
  146. package/build-module/components/post-list/index.js +128 -70
  147. package/build-module/components/post-list/index.js.map +1 -1
  148. package/build-module/components/sidebar-dataviews/add-new-view.js +3 -2
  149. package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
  150. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
  151. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
  152. package/build-module/components/sidebar-dataviews/dataview-item.js +2 -3
  153. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
  154. package/build-module/components/sidebar-dataviews/default-views.js +81 -81
  155. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  156. package/build-module/components/sidebar-dataviews/index.js +3 -42
  157. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  158. package/build-module/components/site-hub/index.js +7 -4
  159. package/build-module/components/site-hub/index.js.map +1 -1
  160. package/build-module/components/style-book/index.js +23 -26
  161. package/build-module/components/style-book/index.js.map +1 -1
  162. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
  163. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  164. package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
  165. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  166. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
  167. package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
  168. package/build-module/index.js +0 -2
  169. package/build-module/index.js.map +1 -1
  170. package/build-module/utils/is-template-removable.js +2 -2
  171. package/build-module/utils/is-template-removable.js.map +1 -1
  172. package/build-module/utils/is-template-revertable.js +1 -1
  173. package/build-module/utils/is-template-revertable.js.map +1 -1
  174. package/build-style/posts-rtl.css +201 -25
  175. package/build-style/posts.css +201 -25
  176. package/build-style/style-rtl.css +307 -69
  177. package/build-style/style.css +307 -69
  178. package/package.json +41 -41
  179. package/src/components/add-new-pattern/index.js +8 -3
  180. package/src/components/add-new-post/index.js +2 -1
  181. package/src/components/add-new-template/style.scss +1 -1
  182. package/src/components/add-new-template/utils.js +10 -6
  183. package/src/components/editor/index.js +80 -22
  184. package/src/components/editor/style.scss +60 -2
  185. package/src/components/global-styles/background-panel.js +0 -3
  186. package/src/components/global-styles/font-families.js +3 -5
  187. package/src/components/global-styles/font-library-modal/context.js +0 -5
  188. package/src/components/global-styles/font-library-modal/font-collection.js +34 -10
  189. package/src/components/global-styles/font-library-modal/index.js +2 -7
  190. package/src/components/global-styles/font-library-modal/installed-fonts.js +26 -6
  191. package/src/components/global-styles/font-library-modal/style.scss +2 -2
  192. package/src/components/global-styles/font-library-modal/upload-fonts.js +2 -2
  193. package/src/components/global-styles/screen-block.js +2 -4
  194. package/src/components/global-styles/screen-css.js +3 -1
  195. package/src/components/global-styles/screen-typeset.js +42 -0
  196. package/src/components/global-styles/screen-typography-element.js +14 -0
  197. package/src/components/global-styles/screen-typography.js +4 -4
  198. package/src/components/global-styles/shadows-edit-panel.js +67 -73
  199. package/src/components/global-styles/size-control/index.js +9 -6
  200. package/src/components/global-styles/style.scss +4 -7
  201. package/src/components/global-styles/typeset-button.js +93 -0
  202. package/src/components/global-styles/typeset.js +73 -0
  203. package/src/components/global-styles/ui.js +5 -0
  204. package/src/components/global-styles/utils.js +13 -1
  205. package/src/components/layout/style.scss +8 -0
  206. package/src/components/page-patterns/fields.js +251 -0
  207. package/src/components/page-patterns/index.js +19 -246
  208. package/src/components/page-patterns/style.scss +82 -85
  209. package/src/components/page-patterns/use-patterns.js +33 -0
  210. package/src/components/page-templates/fields.js +157 -0
  211. package/src/components/page-templates/index.js +19 -170
  212. package/src/components/page-templates/style.scss +14 -5
  213. package/src/components/post-edit/index.js +58 -35
  214. package/src/components/post-fields/index.js +88 -25
  215. package/src/components/post-list/index.js +135 -79
  216. package/src/components/sidebar-dataviews/add-new-view.js +3 -4
  217. package/src/components/sidebar-dataviews/custom-dataviews-list.js +1 -0
  218. package/src/components/sidebar-dataviews/dataview-item.js +2 -2
  219. package/src/components/sidebar-dataviews/default-views.js +95 -95
  220. package/src/components/sidebar-dataviews/index.js +3 -37
  221. package/src/components/site-hub/index.js +11 -2
  222. package/src/components/site-icon/style.scss +4 -1
  223. package/src/components/style-book/index.js +27 -32
  224. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -0
  225. package/src/hooks/push-changes-to-global-styles/index.js +3 -3
  226. package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +2 -3
  227. package/src/index.js +0 -2
  228. package/src/utils/is-template-removable.js +4 -2
  229. package/src/utils/is-template-revertable.js +2 -1
  230. package/build/utils/clone-deep.js +0 -15
  231. package/build/utils/clone-deep.js.map +0 -1
  232. package/build-module/utils/clone-deep.js +0 -9
  233. package/build-module/utils/clone-deep.js.map +0 -1
  234. package/src/utils/clone-deep.js +0 -8
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_editor","_i18n","_cloneDeep","_interopRequireDefault","_lockUnlock","GlobalStylesContext","areGlobalStyleConfigsEqual","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","removePropertiesFromObject","object","properties","length","Object","keys","key","includes","hasThemeVariation","title","settings","styles","__","useCurrentMergeThemeStyleVariationsWithUserConfig","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","userVariation","useContext","propertiesAsString","toString","useMemo","clonedUserVariation","cloneDeep","userVariationWithoutProperties","variationsWithPropertiesAndBase","filter","variation","isVariationWithProperties","map","variationsByProperties","filterObjectByProperties","newObject","forEach","newFilter","exports","variationWithProperties"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport cloneDeep from '../../utils/clone-deep';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(\n\tblockEditorPrivateApis\n);\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of properties from an object.\n *\n * @param {Object} object The object to remove the properties from.\n * @param {string[]} properties The properties to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertiesFromObject( object, properties ) {\n\tif ( ! properties?.length ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertiesFromObject( object[ key ], properties );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * Checks whether a style variation is empty.\n *\n * @param {Object} variation A style variation object.\n * @param {string} variation.title The title of the variation.\n * @param {Object} variation.settings The settings of the variation.\n * @param {Object} variation.styles The styles of the variation.\n * @return {boolean} Whether the variation is empty.\n */\nfunction hasThemeVariation( { title, settings, styles } ) {\n\treturn (\n\t\ttitle === __( 'Default' ) || // Always preserve the default variation.\n\t\tObject.keys( settings ).length > 0 ||\n\t\tObject.keys( styles ).length > 0\n\t);\n}\n\n/**\n * Fetches the current theme style variations that contain only the specified properties\n * and merges them with the user config.\n *\n * @param {string[]} properties The properties to filter by.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig(\n\tproperties = []\n) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: userVariation } = useContext( GlobalStylesContext );\n\n\tconst propertiesAsString = properties.toString();\n\n\treturn useMemo( () => {\n\t\tconst clonedUserVariation = cloneDeep( userVariation );\n\n\t\t// Get user variation and remove the settings for the given property.\n\t\tconst userVariationWithoutProperties = removePropertiesFromObject(\n\t\t\tclonedUserVariation,\n\t\t\tproperties\n\t\t);\n\t\tuserVariationWithoutProperties.title = __( 'Default' );\n\n\t\tconst variationsWithPropertiesAndBase = variationsFromTheme\n\t\t\t.filter( ( variation ) => {\n\t\t\t\treturn isVariationWithProperties( variation, properties );\n\t\t\t} )\n\t\t\t.map( ( variation ) => {\n\t\t\t\treturn mergeBaseAndUserConfigs(\n\t\t\t\t\tuserVariationWithoutProperties,\n\t\t\t\t\tvariation\n\t\t\t\t);\n\t\t\t} );\n\n\t\tconst variationsByProperties = [\n\t\t\tuserVariationWithoutProperties,\n\t\t\t...variationsWithPropertiesAndBase,\n\t\t];\n\n\t\t/*\n\t\t * Filter out variations with no settings or styles.\n\t\t */\n\t\treturn variationsByProperties?.length\n\t\t\t? variationsByProperties.filter( hasThemeVariation )\n\t\t\t: [];\n\t}, [ propertiesAsString, userVariation, variationsFromTheme ] );\n}\n\n/**\n * Returns a new object, with properties specified in `properties` array.,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given properties.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the properties are `[ 'test' ]`.\n *\n * @param {Object} object The object to filter\n * @param {string[]} properties The properties to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperties = ( object, properties ) => {\n\tif ( ! object || ! properties?.length ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperties(\n\t\t\t\tobject[ key ],\n\t\t\t\tproperties\n\t\t\t);\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Compares a style variation to the same variation filtered by the specified properties.\n * Returns true if the variation contains only the properties specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string[]} properties The properties to compare.\n * @return {boolean} Whether the variation contains only the specified properties.\n */\nexport function isVariationWithProperties( variation, properties ) {\n\tconst variationWithProperties = filterObjectByProperties(\n\t\tcloneDeep( variation ),\n\t\tproperties\n\t);\n\n\treturn areGlobalStyleConfigsEqual( variationWithProperties, variation );\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,UAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,MAAM;EAAES,mBAAmB;EAAEC;AAA2B,CAAC,GAAG,IAAAC,kBAAM,EACjEC,wBACD,CAAC;AACD,MAAM;EAAEC;AAAwB,CAAC,GAAG,IAAAF,kBAAM,EAAEG,mBAAkB,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,0BAA0BA,CAAEC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,IAAM;IACzC,IAAKJ,UAAU,CAACK,QAAQ,CAAED,GAAI,CAAC,EAAG;MACjC8B,SAAS,CAAE9B,GAAG,CAAE,GAAGL,MAAM,CAAEK,GAAG,CAAE;IACjC,CAAC,MAAM,IAAK,OAAOL,MAAM,CAAEK,GAAG,CAAE,KAAK,QAAQ,EAAG;MAC/C,MAAMgC,SAAS,GAAGH,wBAAwB,CACzClC,MAAM,CAAEK,GAAG,CAAE,EACbJ,UACD,CAAC;MACD,IAAKE,MAAM,CAACC,IAAI,CAAEiC,SAAU,CAAC,CAACnC,MAAM,EAAG;QACtCiC,SAAS,CAAE9B,GAAG,CAAE,GAAGgC,SAAS;MAC7B;IACD;EACD,CAAE,CAAC;EACH,OAAOF,SAAS;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAG,OAAA,CAAAJ,wBAAA,GAAAA,wBAAA;AAQO,SAASH,yBAAyBA,CAAED,SAAS,EAAE7B,UAAU,EAAG;EAClE,MAAMsC,uBAAuB,GAAGL,wBAAwB,CACvD,IAAAR,kBAAS,EAAEI,SAAU,CAAC,EACtB7B,UACD,CAAC;EAED,OAAOP,0BAA0B,CAAE6C,uBAAuB,EAAET,SAAU,CAAC;AACxE","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_coreData","_element","_blockEditor","_editor","_i18n","_lockUnlock","GlobalStylesContext","areGlobalStyleConfigsEqual","unlock","blockEditorPrivateApis","mergeBaseAndUserConfigs","editorPrivateApis","removePropertiesFromObject","object","properties","length","Object","keys","key","includes","hasThemeVariation","title","settings","styles","__","useCurrentMergeThemeStyleVariationsWithUserConfig","variationsFromTheme","useSelect","select","_variationsFromTheme","coreStore","__experimentalGetCurrentThemeGlobalStylesVariations","user","userVariation","useContext","propertiesAsString","toString","useMemo","clonedUserVariation","structuredClone","userVariationWithoutProperties","variationsWithPropertiesAndBase","filter","variation","isVariationWithProperties","map","variationsByProperties","filterObjectByProperties","newObject","forEach","newFilter","exports","variationWithProperties"],"sources":["@wordpress/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(\n\tblockEditorPrivateApis\n);\nconst { mergeBaseAndUserConfigs } = unlock( editorPrivateApis );\n\n/**\n * Removes all instances of properties from an object.\n *\n * @param {Object} object The object to remove the properties from.\n * @param {string[]} properties The properties to remove.\n * @return {Object} The modified object.\n */\nexport function removePropertiesFromObject( object, properties ) {\n\tif ( ! properties?.length ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertiesFromObject( object[ key ], properties );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * Checks whether a style variation is empty.\n *\n * @param {Object} variation A style variation object.\n * @param {string} variation.title The title of the variation.\n * @param {Object} variation.settings The settings of the variation.\n * @param {Object} variation.styles The styles of the variation.\n * @return {boolean} Whether the variation is empty.\n */\nfunction hasThemeVariation( { title, settings, styles } ) {\n\treturn (\n\t\ttitle === __( 'Default' ) || // Always preserve the default variation.\n\t\tObject.keys( settings ).length > 0 ||\n\t\tObject.keys( styles ).length > 0\n\t);\n}\n\n/**\n * Fetches the current theme style variations that contain only the specified properties\n * and merges them with the user config.\n *\n * @param {string[]} properties The properties to filter by.\n * @return {Object[]|*} The merged object.\n */\nexport function useCurrentMergeThemeStyleVariationsWithUserConfig(\n\tproperties = []\n) {\n\tconst { variationsFromTheme } = useSelect( ( select ) => {\n\t\tconst _variationsFromTheme =\n\t\t\tselect(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetCurrentThemeGlobalStylesVariations();\n\n\t\treturn {\n\t\t\tvariationsFromTheme: _variationsFromTheme || [],\n\t\t};\n\t}, [] );\n\tconst { user: userVariation } = useContext( GlobalStylesContext );\n\n\tconst propertiesAsString = properties.toString();\n\n\treturn useMemo( () => {\n\t\tconst clonedUserVariation = structuredClone( userVariation );\n\n\t\t// Get user variation and remove the settings for the given property.\n\t\tconst userVariationWithoutProperties = removePropertiesFromObject(\n\t\t\tclonedUserVariation,\n\t\t\tproperties\n\t\t);\n\t\tuserVariationWithoutProperties.title = __( 'Default' );\n\n\t\tconst variationsWithPropertiesAndBase = variationsFromTheme\n\t\t\t.filter( ( variation ) => {\n\t\t\t\treturn isVariationWithProperties( variation, properties );\n\t\t\t} )\n\t\t\t.map( ( variation ) => {\n\t\t\t\treturn mergeBaseAndUserConfigs(\n\t\t\t\t\tuserVariationWithoutProperties,\n\t\t\t\t\tvariation\n\t\t\t\t);\n\t\t\t} );\n\n\t\tconst variationsByProperties = [\n\t\t\tuserVariationWithoutProperties,\n\t\t\t...variationsWithPropertiesAndBase,\n\t\t];\n\n\t\t/*\n\t\t * Filter out variations with no settings or styles.\n\t\t */\n\t\treturn variationsByProperties?.length\n\t\t\t? variationsByProperties.filter( hasThemeVariation )\n\t\t\t: [];\n\t}, [ propertiesAsString, userVariation, variationsFromTheme ] );\n}\n\n/**\n * Returns a new object, with properties specified in `properties` array.,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given properties.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the properties are `[ 'test' ]`.\n *\n * @param {Object} object The object to filter\n * @param {string[]} properties The properties to filter by\n * @return {Object} The merged object.\n */\nexport const filterObjectByProperties = ( object, properties ) => {\n\tif ( ! object || ! properties?.length ) {\n\t\treturn {};\n\t}\n\n\tconst newObject = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperties(\n\t\t\t\tobject[ key ],\n\t\t\t\tproperties\n\t\t\t);\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Compares a style variation to the same variation filtered by the specified properties.\n * Returns true if the variation contains only the properties specified.\n *\n * @param {Object} variation The variation to compare.\n * @param {string[]} properties The properties to compare.\n * @return {boolean} Whether the variation contains only the specified properties.\n */\nexport function isVariationWithProperties( variation, properties ) {\n\tconst variationWithProperties = filterObjectByProperties(\n\t\tstructuredClone( variation ),\n\t\tproperties\n\t);\n\n\treturn areGlobalStyleConfigsEqual( variationWithProperties, variation );\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAQA;AACA;AACA;;AAGA,MAAM;EAAEO,mBAAmB;EAAEC;AAA2B,CAAC,GAAG,IAAAC,kBAAM,EACjEC,wBACD,CAAC;AACD,MAAM;EAAEC;AAAwB,CAAC,GAAG,IAAAF,kBAAM,EAAEG,mBAAkB,CAAC;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,0BAA0BA,CAAEC,MAAM,EAAEC,UAAU,EAAG;EAChE,IAAK,CAAEA,UAAU,EAAEC,MAAM,EAAG;IAC3B,OAAO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AG,CAAE,GAAGL,MAAM,CAAEK,GAAG,CAAE;IACjC,CAAC,MAAM,IAAK,OAAOL,MAAM,CAAEK,GAAG,CAAE,KAAK,QAAQ,EAAG;MAC/C,MAAMgC,SAAS,GAAGH,wBAAwB,CACzClC,MAAM,CAAEK,GAAG,CAAE,EACbJ,UACD,CAAC;MACD,IAAKE,MAAM,CAACC,IAAI,CAAEiC,SAAU,CAAC,CAACnC,MAAM,EAAG;QACtCiC,SAAS,CAAE9B,GAAG,CAAE,GAAGgC,SAAS;MAC7B;IACD;EACD,CAAE,CAAC;EACH,OAAOF,SAAS;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAG,OAAA,CAAAJ,wBAAA,GAAAA,wBAAA;AAQO,SAASH,yBAAyBA,CAAED,SAAS,EAAE7B,UAAU,EAAG;EAClE,MAAMsC,uBAAuB,GAAGL,wBAAwB,CACvDR,eAAe,CAAEI,SAAU,CAAC,EAC5B7B,UACD,CAAC;EAED,OAAOP,0BAA0B,CAAE6C,uBAAuB,EAAET,SAAU,CAAC;AACxE","ignoreList":[]}
package/build/index.js CHANGED
@@ -67,7 +67,6 @@ var _posts = require("./posts");
67
67
  */
68
68
 
69
69
  const {
70
- registerDefaultActions,
71
70
  registerCoreBlockBindingsSources,
72
71
  bootstrapBlockBindingsSourcesFromServer
73
72
  } = (0, _lockUnlock.unlock)(_editor.privateApis);
@@ -100,7 +99,6 @@ function initializeEditor(id, settings) {
100
99
  enableFSEBlocks: true
101
100
  });
102
101
  }
103
- registerDefaultActions();
104
102
 
105
103
  // We dispatch actions and update the store synchronously before rendering
106
104
  // so that we won't trigger unnecessary re-renders with useEffect.
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_blockLibrary","_data","_deprecated","_interopRequireDefault","_element","_editor","_preferences","_widgets","_store","_lockUnlock","_app","_jsxRuntime","_pluginTemplateSettingPanel","_deprecated2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_posts","registerDefaultActions","registerCoreBlockBindingsSources","bootstrapBlockBindingsSourcesFromServer","unlock","editorPrivateApis","initializeEditor","id","settings","target","document","getElementById","root","createRoot","dispatch","blocksStore","reapplyBlockTypeFilters","coreBlocks","__experimentalGetCoreBlocks","filter","name","registerCoreBlocks","blockBindingsSources","setFreeformFallbackBlockName","registerLegacyWidgetBlock","inserter","registerWidgetGroupBlock","globalThis","IS_GUTENBERG_PLUGIN","__experimentalRegisterExperimentalCoreBlocks","enableFSEBlocks","preferencesStore","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","jsx","StrictMode","children","default","reinitializeEditor","deprecated","since","version"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport { unlock } from './lock-unlock';\nimport App from './components/app';\n\nconst {\n\tregisterDefaultActions,\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n} = unlock( editorPrivateApis );\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tbootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );\n\tregisterCoreBlockBindingsSources();\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\tregisterDefaultActions();\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\twelcomeGuidePage: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\tdistractionFree: false,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tinactivePanels: [],\n\t\tkeepCaretInsideBlock: false,\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<App />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\nexport { store } from './store';\nexport * from './deprecated';\n\n// Temporary: While the posts dashboard is being iterated on\n// it's being built in the same package as the site editor.\nexport { initializePostsDashboard } from './posts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAIA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAQAA,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,IAAA,GAAAP,sBAAA,CAAAJ,OAAA;AAAmC,IAAAY,WAAA,GAAAZ,OAAA;AAwFnC,IAAAa,2BAAA,GAAAT,sBAAA,CAAAJ,OAAA;AAEA,IAAAc,YAAA,GAAAd,OAAA;AAAAe,MAAA,CAAAC,IAAA,CAAAF,YAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cA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AAAiF,UAAU;IAAAC,QAAA,eACV,IAAA3E,WAAA,CAAAyE,GAAA,EAAC1E,IAAA,CAAA6E,OAAG,IAAE;EAAC,CACI,CACb,CAAC;EAED,OAAOjD,IAAI;AACZ;AAEO,SAASkD,kBAAkBA,CAAA,EAAG;EACpC,IAAAC,mBAAU,EAAE,gCAAgC,EAAE;IAC7CC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAMA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","_blockLibrary","_data","_deprecated","_interopRequireDefault","_element","_editor","_preferences","_widgets","_store","_lockUnlock","_app","_jsxRuntime","_pluginTemplateSettingPanel","_deprecated2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_posts","registerCoreBlockBindingsSources","bootstrapBlockBindingsSourcesFromServer","unlock","editorPrivateApis","initializeEditor","id","settings","target","document","getElementById","root","createRoot","dispatch","blocksStore","reapplyBlockTypeFilters","coreBlocks","__experimentalGetCoreBlocks","filter","name","registerCoreBlocks","blockBindingsSources","setFreeformFallbackBlockName","registerLegacyWidgetBlock","inserter","registerWidgetGroupBlock","globalThis","IS_GUTENBERG_PLUGIN","__experimentalRegisterExperimentalCoreBlocks","enableFSEBlocks","preferencesStore","setDefaults","welcomeGuide","welcomeGuideStyles","welcomeGuidePage","welcomeGuideTemplate","allowRightClickOverrides","distractionFree","editorMode","fixedToolbar","focusMode","inactivePanels","keepCaretInsideBlock","openPanels","showBlockBreadcrumbs","showListViewByDefault","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","jsx","StrictMode","children","default","reinitializeEditor","deprecated","since","version"],"sources":["@wordpress/edit-site/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot, StrictMode } from '@wordpress/element';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport { unlock } from './lock-unlock';\nimport App from './components/app';\n\nconst {\n\tregisterCoreBlockBindingsSources,\n\tbootstrapBlockBindingsSourcesFromServer,\n} = unlock( editorPrivateApis );\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tbootstrapBlockBindingsSourcesFromServer( settings?.blockBindingsSources );\n\tregisterCoreBlockBindingsSources();\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\twelcomeGuidePage: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\tdistractionFree: false,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tinactivePanels: [],\n\t\tkeepCaretInsideBlock: false,\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<StrictMode>\n\t\t\t<App />\n\t\t</StrictMode>\n\t);\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\nexport { store } from './store';\nexport * from './deprecated';\n\n// Temporary: While the posts dashboard is being iterated on\n// it's being built in the same package as the site editor.\nexport { initializePostsDashboard } from './posts';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AA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C7CC,oBAAoB,EAAE3C,QAAQ,CAAC2C,oBAAoB;IACnDC,wBAAwB,EAAE5C,QAAQ,CAAC4C;EACpC,CAAE,CAAC;;EAEH;EACAC,MAAM,CAACC,gBAAgB,CAAE,UAAU,EAAIC,CAAC,IAAMA,CAAC,CAACC,cAAc,CAAC,CAAC,EAAE,KAAM,CAAC;EACzEH,MAAM,CAACC,gBAAgB,CAAE,MAAM,EAAIC,CAAC,IAAMA,CAAC,CAACC,cAAc,CAAC,CAAC,EAAE,KAAM,CAAC;EAErE5C,IAAI,CAAC6C,MAAM,eACV,IAAAvE,WAAA,CAAAwE,GAAA,EAAC/E,QAAA,CAAAgF,UAAU;IAAAC,QAAA,eACV,IAAA1E,WAAA,CAAAwE,GAAA,EAACzE,IAAA,CAAA4E,OAAG,IAAE;EAAC,CACI,CACb,CAAC;EAED,OAAOjD,IAAI;AACZ;AAEO,SAASkD,kBAAkBA,CAAA,EAAG;EACpC,IAAAC,mBAAU,EAAE,gCAAgC,EAAE;IAC7CC,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAMA;AACA","ignoreList":[]}
@@ -13,12 +13,12 @@ var _constants = require("./constants");
13
13
  * Check if a template is removable.
14
14
  *
15
15
  * @param {Object} template The template entity to check.
16
- * @return {boolean} Whether the template is revertable.
16
+ * @return {boolean} Whether the template is removable.
17
17
  */
18
18
  function isTemplateRemovable(template) {
19
19
  if (!template) {
20
20
  return false;
21
21
  }
22
- return template.source === _constants.TEMPLATE_ORIGINS.custom && !template.has_theme_file;
22
+ return template.source === _constants.TEMPLATE_ORIGINS.custom && !Boolean(template.plugin) && !template.has_theme_file;
23
23
  }
24
24
  //# sourceMappingURL=is-template-removable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","isTemplateRemovable","template","source","TEMPLATE_ORIGINS","custom","has_theme_file"],"sources":["@wordpress/edit-site/src/utils/is-template-removable.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from './constants';\n\n/**\n * Check if a template is removable.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is revertable.\n */\nexport default function isTemplateRemovable( template ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttemplate.source === TEMPLATE_ORIGINS.custom && ! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,mBAAmBA,CAAEC,QAAQ,EAAG;EACvD,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EAEA,OACCA,QAAQ,CAACC,MAAM,KAAKC,2BAAgB,CAACC,MAAM,IAAI,CAAEH,QAAQ,CAACI,cAAc;AAE1E","ignoreList":[]}
1
+ {"version":3,"names":["_constants","require","isTemplateRemovable","template","source","TEMPLATE_ORIGINS","custom","Boolean","plugin","has_theme_file"],"sources":["@wordpress/edit-site/src/utils/is-template-removable.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from './constants';\n\n/**\n * Check if a template is removable.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is removable.\n */\nexport default function isTemplateRemovable( template ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\ttemplate.source === TEMPLATE_ORIGINS.custom &&\n\t\t! Boolean( template.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,mBAAmBA,CAAEC,QAAQ,EAAG;EACvD,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EAEA,OACCA,QAAQ,CAACC,MAAM,KAAKC,2BAAgB,CAACC,MAAM,IAC3C,CAAEC,OAAO,CAAEJ,QAAQ,CAACK,MAAO,CAAC,IAC5B,CAAEL,QAAQ,CAACM,cAAc;AAE3B","ignoreList":[]}
@@ -20,7 +20,7 @@ function isTemplateRevertable(template) {
20
20
  return false;
21
21
  }
22
22
  /* eslint-disable camelcase */
23
- return template?.source === _constants.TEMPLATE_ORIGINS.custom && template?.has_theme_file;
23
+ return template?.source === _constants.TEMPLATE_ORIGINS.custom && (Boolean(template?.plugin) || template?.has_theme_file);
24
24
  /* eslint-enable camelcase */
25
25
  }
26
26
  //# sourceMappingURL=is-template-revertable.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","isTemplateRevertable","template","source","TEMPLATE_ORIGINS","custom","has_theme_file"],"sources":["@wordpress/edit-site/src/utils/is-template-revertable.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from './constants';\n\n/**\n * Check if a template is revertable to its original theme-provided template file.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is revertable.\n */\nexport default function isTemplateRevertable( template ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t/* eslint-disable camelcase */\n\treturn (\n\t\ttemplate?.source === TEMPLATE_ORIGINS.custom && template?.has_theme_file\n\t);\n\t/* eslint-enable camelcase */\n}\n"],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,oBAAoBA,CAAEC,QAAQ,EAAG;EACxD,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA,OACCA,QAAQ,EAAEC,MAAM,KAAKC,2BAAgB,CAACC,MAAM,IAAIH,QAAQ,EAAEI,cAAc;EAEzE;AACD","ignoreList":[]}
1
+ {"version":3,"names":["_constants","require","isTemplateRevertable","template","source","TEMPLATE_ORIGINS","custom","Boolean","plugin","has_theme_file"],"sources":["@wordpress/edit-site/src/utils/is-template-revertable.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { TEMPLATE_ORIGINS } from './constants';\n\n/**\n * Check if a template is revertable to its original theme-provided template file.\n *\n * @param {Object} template The template entity to check.\n * @return {boolean} Whether the template is revertable.\n */\nexport default function isTemplateRevertable( template ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t/* eslint-disable camelcase */\n\treturn (\n\t\ttemplate?.source === TEMPLATE_ORIGINS.custom &&\n\t\t( Boolean( template?.plugin ) || template?.has_theme_file )\n\t);\n\t/* eslint-enable camelcase */\n}\n"],"mappings":";;;;;;AAGA,IAAAA,UAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,oBAAoBA,CAAEC,QAAQ,EAAG;EACxD,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA,OACCA,QAAQ,EAAEC,MAAM,KAAKC,2BAAgB,CAACC,MAAM,KAC1CC,OAAO,CAAEJ,QAAQ,EAAEK,MAAO,CAAC,IAAIL,QAAQ,EAAEM,cAAc,CAAE;EAE5D;AACD","ignoreList":[]}
@@ -166,7 +166,12 @@ export default function AddNewPattern() {
166
166
  // When we're not handling template parts, we should
167
167
  // add or create the proper pattern category.
168
168
  if (postType !== TEMPLATE_PART_POST_TYPE) {
169
- const currentCategory = categoryMap.values().find(term => term.name === categoryId);
169
+ /*
170
+ * categoryMap.values() returns an iterator.
171
+ * Iterator.prototype.find() is not yet widely supported.
172
+ * Convert to array to use the Array.prototype.find method.
173
+ */
174
+ const currentCategory = Array.from(categoryMap.values()).find(term => term.name === categoryId);
170
175
  if (currentCategory) {
171
176
  currentCategoryId = currentCategory.id || (await findOrCreateTerm(currentCategory.label));
172
177
  }
@@ -1 +1 @@
1
- {"version":3,"names":["DropdownMenu","useState","useRef","__","sprintf","symbol","symbolFilled","upload","useSelect","useDispatch","privateApis","routerPrivateApis","editPatternsPrivateApis","store","patternsStore","noticesStore","coreStore","editorPrivateApis","unlock","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","TEMPLATE_PART_POST_TYPE","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHistory","CreatePatternModal","useAddPatternCategory","CreateTemplatePartModal","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","createPatternFromFile","createSuccessNotice","createErrorNotice","patternUploadInputRef","isBlockBasedTheme","addNewPatternLabel","addNewTemplatePartLabel","canCreatePattern","canCreateTemplatePart","select","getCurrentTheme","getPostType","canUser","is_block_theme","user","labels","add_new_item","kind","name","handleCreatePattern","pattern","push","postId","id","postType","canvas","handleCreateTemplatePart","templatePart","handleError","controls","icon","onClick","title","current","click","categoryMap","findOrCreateTerm","length","children","toggleProps","variant","showTooltip","__next40pxDefaultSize","text","label","onClose","onSuccess","onError","closeModal","blocks","onCreate","type","accept","hidden","ref","onChange","event","file","target","files","params","categoryId","getLocationWithParams","currentCategoryId","currentCategory","values","find","term","undefined","raw","err","message","value"],"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { symbol, symbolFilled, upload } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editPatternsPrivateApis,\n\tstore as patternsStore,\n} from '@wordpress/patterns';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\n\nconst { useHistory } = unlock( routerPrivateApis );\nconst { CreatePatternModal, useAddPatternCategory } = unlock(\n\teditPatternsPrivateApis\n);\nconst { CreateTemplatePartModal } = unlock( editorPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { createPatternFromFile } = unlock( useDispatch( patternsStore ) );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst patternUploadInputRef = useRef();\n\tconst {\n\t\tisBlockBasedTheme,\n\t\taddNewPatternLabel,\n\t\taddNewTemplatePartLabel,\n\t\tcanCreatePattern,\n\t\tcanCreateTemplatePart,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getPostType, canUser } = select( coreStore );\n\t\treturn {\n\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\taddNewPatternLabel: getPostType( PATTERN_TYPES.user )?.labels\n\t\t\t\t?.add_new_item,\n\t\t\taddNewTemplatePartLabel: getPostType( TEMPLATE_PART_POST_TYPE )\n\t\t\t\t?.labels?.add_new_item,\n\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\tcanCreatePattern: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: PATTERN_TYPES.user,\n\t\t\t} ),\n\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: TEMPLATE_PART_POST_TYPE,\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\n\tfunction handleCreatePattern( { pattern } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: TEMPLATE_PART_POST_TYPE,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [];\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbol,\n\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\ttitle: addNewPatternLabel,\n\t\t} );\n\t}\n\n\tif ( isBlockBasedTheme && canCreateTemplatePart ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: addNewTemplatePartLabel,\n\t\t} );\n\t}\n\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: upload,\n\t\t\tonClick: () => {\n\t\t\t\tpatternUploadInputRef.current.click();\n\t\t\t},\n\t\t\ttitle: __( 'Import pattern from JSON' ),\n\t\t} );\n\t}\n\n\tconst { categoryMap, findOrCreateTerm } = useAddPatternCategory();\n\tif ( controls.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ addNewPatternLabel && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tvariant: 'primary',\n\t\t\t\t\t\tshowTooltip: false,\n\t\t\t\t\t\t__next40pxDefaultSize: true,\n\t\t\t\t\t} }\n\t\t\t\t\ttext={ addNewPatternLabel }\n\t\t\t\t\tlabel={ addNewPatternLabel }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tonClose={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonSuccess={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\".json\"\n\t\t\t\thidden\n\t\t\t\tref={ patternUploadInputRef }\n\t\t\t\tonChange={ async ( event ) => {\n\t\t\t\t\tconst file = event.target.files?.[ 0 ];\n\t\t\t\t\tif ( ! file ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tparams: { postType, categoryId },\n\t\t\t\t\t\t} = history.getLocationWithParams();\n\t\t\t\t\t\tlet currentCategoryId;\n\t\t\t\t\t\t// When we're not handling template parts, we should\n\t\t\t\t\t\t// add or create the proper pattern category.\n\t\t\t\t\t\tif ( postType !== TEMPLATE_PART_POST_TYPE ) {\n\t\t\t\t\t\t\tconst currentCategory = categoryMap\n\t\t\t\t\t\t\t\t.values()\n\t\t\t\t\t\t\t\t.find( ( term ) => term.name === categoryId );\n\t\t\t\t\t\t\tif ( currentCategory ) {\n\t\t\t\t\t\t\t\tcurrentCategoryId =\n\t\t\t\t\t\t\t\t\tcurrentCategory.id ||\n\t\t\t\t\t\t\t\t\t( await findOrCreateTerm(\n\t\t\t\t\t\t\t\t\t\tcurrentCategory.label\n\t\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\tconst pattern = await createPatternFromFile(\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tcurrentCategoryId\n\t\t\t\t\t\t\t\t? [ currentCategoryId ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Navigate to the All patterns category for the newly created pattern\n\t\t\t\t\t\t// if we're not on that page already and if we're not in the `my-patterns`\n\t\t\t\t\t\t// category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! currentCategoryId &&\n\t\t\t\t\t\t\tcategoryId !== 'my-patterns'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\t\t\t\t\t\tcategoryId: PATTERN_DEFAULT_CATEGORY,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The imported pattern's title.\n\t\t\t\t\t\t\t\t__( 'Imported \"%s\" from JSON.' ),\n\t\t\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'import-pattern-success',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tcreateErrorNotice( err.message, {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'import-pattern-error',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tevent.target.value = '';\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,EAAEC,YAAY,EAAEC,MAAM,QAAQ,kBAAkB;AAC/D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,S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AAC0B,IAAI,CAAE;cACbG,QAAQ,EAAE3C,aAAa,CAACiC,IAAI;cAC5B+C,UAAU,EAAE/E;YACb,CAAE,CAAC;UACJ;UAEAmB,mBAAmB,CAClBnC,OAAO;UACN;UACAD,EAAE,CAAE,0BAA2B,CAAC,EAChCuD,OAAO,CAACY,KAAK,CAACqC,GACf,CAAC,EACD;YACClB,IAAI,EAAE,UAAU;YAChB5B,EAAE,EAAE;UACL,CACD,CAAC;QACF,CAAC,CAAC,OAAQ+C,GAAG,EAAG;UACfpE,iBAAiB,CAAEoE,GAAG,CAACC,OAAO,EAAE;YAC/BpB,IAAI,EAAE,UAAU;YAChB5B,EAAE,EAAE;UACL,CAAE,CAAC;QACJ,CAAC,SAAS;UACTiC,KAAK,CAACE,MAAM,CAACc,KAAK,GAAG,EAAE;QACxB;MACD;IAAG,CACH,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["DropdownMenu","useState","useRef","__","sprintf","symbol","symbolFilled","upload","useSelect","useDispatch","privateApis","routerPrivateApis","editPatternsPrivateApis","store","patternsStore","noticesStore","coreStore","editorPrivateApis","unlock","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","TEMPLATE_PART_POST_TYPE","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHistory","CreatePatternModal","useAddPatternCategory","CreateTemplatePartModal","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","createPatternFromFile","createSuccessNotice","createErrorNotice","patternUploadInputRef","isBlockBasedTheme","addNewPatternLabel","addNewTemplatePartLabel","canCreatePattern","canCreateTemplatePart","select","getCurrentTheme","getPostType","canUser","is_block_theme","user","labels","add_new_item","kind","name","handleCreatePattern","pattern","push","postId","id","postType","canvas","handleCreateTemplatePart","templatePart","handleError","controls","icon","onClick","title","current","click","categoryMap","findOrCreateTerm","length","children","toggleProps","variant","showTooltip","__next40pxDefaultSize","text","label","onClose","onSuccess","onError","closeModal","blocks","onCreate","type","accept","hidden","ref","onChange","event","file","target","files","params","categoryId","getLocationWithParams","currentCategoryId","currentCategory","Array","from","values","find","term","undefined","raw","err","message","value"],"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { symbol, symbolFilled, upload } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport {\n\tprivateApis as editPatternsPrivateApis,\n\tstore as patternsStore,\n} from '@wordpress/patterns';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { privateApis as editorPrivateApis } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../../utils/constants';\n\nconst { useHistory } = unlock( routerPrivateApis );\nconst { CreatePatternModal, useAddPatternCategory } = unlock(\n\teditPatternsPrivateApis\n);\nconst { CreateTemplatePartModal } = unlock( editorPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { createPatternFromFile } = unlock( useDispatch( patternsStore ) );\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst patternUploadInputRef = useRef();\n\tconst {\n\t\tisBlockBasedTheme,\n\t\taddNewPatternLabel,\n\t\taddNewTemplatePartLabel,\n\t\tcanCreatePattern,\n\t\tcanCreateTemplatePart,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getPostType, canUser } = select( coreStore );\n\t\treturn {\n\t\t\tisBlockBasedTheme: getCurrentTheme()?.is_block_theme,\n\t\t\taddNewPatternLabel: getPostType( PATTERN_TYPES.user )?.labels\n\t\t\t\t?.add_new_item,\n\t\t\taddNewTemplatePartLabel: getPostType( TEMPLATE_PART_POST_TYPE )\n\t\t\t\t?.labels?.add_new_item,\n\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\tcanCreatePattern: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: PATTERN_TYPES.user,\n\t\t\t} ),\n\t\t\tcanCreateTemplatePart: canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: TEMPLATE_PART_POST_TYPE,\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\n\tfunction handleCreatePattern( { pattern } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: TEMPLATE_PART_POST_TYPE,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\tconst controls = [];\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbol,\n\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\ttitle: addNewPatternLabel,\n\t\t} );\n\t}\n\n\tif ( isBlockBasedTheme && canCreateTemplatePart ) {\n\t\tcontrols.push( {\n\t\t\ticon: symbolFilled,\n\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\ttitle: addNewTemplatePartLabel,\n\t\t} );\n\t}\n\n\tif ( canCreatePattern ) {\n\t\tcontrols.push( {\n\t\t\ticon: upload,\n\t\t\tonClick: () => {\n\t\t\t\tpatternUploadInputRef.current.click();\n\t\t\t},\n\t\t\ttitle: __( 'Import pattern from JSON' ),\n\t\t} );\n\t}\n\n\tconst { categoryMap, findOrCreateTerm } = useAddPatternCategory();\n\tif ( controls.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ addNewPatternLabel && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tvariant: 'primary',\n\t\t\t\t\t\tshowTooltip: false,\n\t\t\t\t\t\t__next40pxDefaultSize: true,\n\t\t\t\t\t} }\n\t\t\t\t\ttext={ addNewPatternLabel }\n\t\t\t\t\tlabel={ addNewPatternLabel }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tonClose={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonSuccess={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<input\n\t\t\t\ttype=\"file\"\n\t\t\t\taccept=\".json\"\n\t\t\t\thidden\n\t\t\t\tref={ patternUploadInputRef }\n\t\t\t\tonChange={ async ( event ) => {\n\t\t\t\t\tconst file = event.target.files?.[ 0 ];\n\t\t\t\t\tif ( ! file ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tparams: { postType, categoryId },\n\t\t\t\t\t\t} = history.getLocationWithParams();\n\t\t\t\t\t\tlet currentCategoryId;\n\t\t\t\t\t\t// When we're not handling template parts, we should\n\t\t\t\t\t\t// add or create the proper pattern category.\n\t\t\t\t\t\tif ( postType !== TEMPLATE_PART_POST_TYPE ) {\n\t\t\t\t\t\t\t/*\n\t\t\t\t\t\t\t * categoryMap.values() returns an iterator.\n\t\t\t\t\t\t\t * Iterator.prototype.find() is not yet widely supported.\n\t\t\t\t\t\t\t * Convert to array to use the Array.prototype.find method.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tconst currentCategory = Array.from(\n\t\t\t\t\t\t\t\tcategoryMap.values()\n\t\t\t\t\t\t\t).find( ( term ) => term.name === categoryId );\n\t\t\t\t\t\t\tif ( currentCategory ) {\n\t\t\t\t\t\t\t\tcurrentCategoryId =\n\t\t\t\t\t\t\t\t\tcurrentCategory.id ||\n\t\t\t\t\t\t\t\t\t( await findOrCreateTerm(\n\t\t\t\t\t\t\t\t\t\tcurrentCategory.label\n\t\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\tconst pattern = await createPatternFromFile(\n\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\tcurrentCategoryId\n\t\t\t\t\t\t\t\t? [ currentCategoryId ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Navigate to the All patterns category for the newly created pattern\n\t\t\t\t\t\t// if we're not on that page already and if we're not in the `my-patterns`\n\t\t\t\t\t\t// category.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! currentCategoryId &&\n\t\t\t\t\t\t\tcategoryId !== 'my-patterns'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\t\tpostType: PATTERN_TYPES.user,\n\t\t\t\t\t\t\t\tcategoryId: PATTERN_DEFAULT_CATEGORY,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The imported pattern's title.\n\t\t\t\t\t\t\t\t__( 'Imported \"%s\" from JSON.' ),\n\t\t\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'import-pattern-success',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch ( err ) {\n\t\t\t\t\t\tcreateErrorNotice( err.message, {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'import-pattern-error',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tevent.target.value = '';\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,EAAEC,YAAY,EAAEC,MAAM,QAAQ,kBAAkB;AAC/D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SACCD,WAAW,IAAIE,uBAAuB,EACtCC,KAAK,IAAIC,aAAa,QAChB,qBAAqB;AAC5B,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AACzD,SAASN,WAAW,IAAIO,iBAAiB,QAAQ,mBAAmB;;AAEpE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SACCC,aAAa,EACbC,wBAAwB,EACxBC,uBAAuB,QACjB,uB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AE;UACL,CACD,CAAC;QACF,CAAC,CAAC,OAAQiD,GAAG,EAAG;UACftE,iBAAiB,CAAEsE,GAAG,CAACC,OAAO,EAAE;YAC/BtB,IAAI,EAAE,UAAU;YAChB5B,EAAE,EAAE;UACL,CAAE,CAAC;QACJ,CAAC,SAAS;UACTiC,KAAK,CAACE,MAAM,CAACgB,KAAK,GAAG,EAAE;QACxB;MACD;IAAG,CACH,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
@@ -70,9 +70,10 @@ export default function AddNewPostModal({
70
70
  children: /*#__PURE__*/_jsx("form", {
71
71
  onSubmit: createPost,
72
72
  children: /*#__PURE__*/_jsxs(VStack, {
73
- spacing: 3,
73
+ spacing: 4,
74
74
  children: [/*#__PURE__*/_jsx(TextControl, {
75
75
  __next40pxDefaultSize: true,
76
+ __nextHasNoMarginBottom: true,
76
77
  label: __('Title'),
77
78
  onChange: setTitle,
78
79
  placeholder: __('No title'),
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useRegistry","useSelect","useState","store","coreStore","noticesStore","decodeEntities","serialize","synchronizeBlocksWithTemplate","jsx","_jsx","jsxs","_jsxs","AddNewPostModal","postType","onSave","onClose","labels","select","getPostType","isCreatingPost","setIsCreatingPost","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","resolveSelect","createPost","event","preventDefault","postTypeObject","newPage","status","slug","content","template","length","undefined","throwOnError","rendered","type","error","errorMessage","message","code","singular_name","onRequestClose","focusOnMount","size","children","onSubmit","spacing","__next40pxDefaultSize","label","onChange","placeholder","value","justify","variant","onClick","isBusy"],"sources":["@wordpress/edit-site/src/components/add-new-post/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { serialize, synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\nexport default function AddNewPostModal( { postType, onSave, onClose } ) {\n\tconst labels = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( postType )?.labels,\n\t\t[ postType ]\n\t);\n\tconst [ isCreatingPost, setIsCreatingPost ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { resolveSelect } = useRegistry();\n\n\tasync function createPost( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPost ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPost( true );\n\t\ttry {\n\t\t\tconst postTypeObject =\n\t\t\t\tawait resolveSelect( coreStore ).getPostType( postType );\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title || __( 'No title' ),\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t!! postTypeObject.template &&\n\t\t\t\t\t\tpostTypeObject.template.length\n\t\t\t\t\t\t\t? serialize(\n\t\t\t\t\t\t\t\t\tsynchronizeBlocksWithTemplate(\n\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\tpostTypeObject.template\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created post e.g: \"Hello world\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newPage.title?.rendered || title )\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the item.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPost( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\t// translators: %s: post type singular_name label e.g: \"Page\".\n\t\t\t\tsprintf( __( 'Draft new: %s' ), labels?.singular_name )\n\t\t\t}\n\t\t\tonRequestClose={ onClose }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ createPost }>\n\t\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBus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E;MACP,CAAE,CAAC;IACJ,CAAC,SAAS;MACTpB,iBAAiB,CAAE,KAAM,CAAC;IAC3B;EACD;EAEA,oBACCX,IAAA,CAACnB,KAAK;IACL+B,KAAK;IACJ;IACAxB,OAAO,CAAED,EAAE,CAAE,eAAgB,CAAC,EAAEoB,MAAM,EAAE6B,aAAc,CACtD;IACDC,cAAc,EAAG/B,OAAS;IAC1BgC,YAAY,EAAC,qBAAqB;IAClCC,IAAI,EAAC,OAAO;IAAAC,QAAA,eAEZxC,IAAA;MAAMyC,QAAQ,EAAGvB,UAAY;MAAAsB,QAAA,eAC5BtC,KAAA,CAACjB,MAAM;QAACyD,OAAO,EAAG,CAAG;QAAAF,QAAA,gBACpBxC,IAAA,CAACd,WAAW;UACXyD,qBAAqB;UACrBC,KAAK,EAAGzD,EAAE,CAAE,OAAQ,CAAG;UACvB0D,QAAQ,EAAGhC,QAAU;UACrBiC,WAAW,EAAG3D,EAAE,CAAE,UAAW,CAAG;UAChC4D,KAAK,EAAGnC;QAAO,CACf,CAAC,eACFV,KAAA,CAACnB,MAAM;UAAC2D,OAAO,EAAG,CAAG;UAACM,OAAO,EAAC,KAAK;UAAAR,QAAA,gBAClCxC,IAAA,CAACpB,MAAM;YACN+D,qBAAqB;YACrBM,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAG5C,OAAS;YAAAkC,QAAA,EAEjBrD,EAAE,CAAE,QAAS;UAAC,CACT,CAAC,eACTa,IAAA,CAACpB,MAAM;YACN+D,qBAAqB;YACrBM,OAAO,EAAC,SAAS;YACjBlB,IAAI,EAAC,QAAQ;YACboB,MAAM,EAAGzC,cAAgB;YACzB,iBAAgBA,cAAgB;YAAA8B,QAAA,EAE9BrD,EAAE,CAAE,cAAe;UAAC,CACf,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
1
+ {"version":3,"names":["Button","Modal","__experimentalHStack","HStack","__experimentalVStack","VStack","TextControl","__","sprintf","useDispatch","useRegistry","useSelect","useState","store","coreStore","noticesStore","decodeEntities","serialize","synchronizeBlocksWithTemplate","jsx","_jsx","jsxs","_jsxs","AddNewPostModal","postType","onSave","onClose","labels","select","getPostType","isCreatingPost","setIsCreatingPost","title","setTitle","saveEntityRecord","createErrorNotice","createSuccessNotice","resolveSelect","createPost","event","preventDefault","postTypeObject","newPage","status","slug","content","template","length","undefined","throwOnError","rendered","type","error","errorMessage","message","code","singular_name","onRequestClose","focusOnMount","size","children","onSubmit","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","onChange","placeholder","value","justify","variant","onClick","isBusy"],"sources":["@wordpress/edit-site/src/components/add-new-post/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { serialize, synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\nexport default function AddNewPostModal( { postType, onSave, onClose } ) {\n\tconst labels = useSelect(\n\t\t( select ) => select( coreStore ).getPostType( postType )?.labels,\n\t\t[ postType ]\n\t);\n\tconst [ isCreatingPost, setIsCreatingPost ] = useState( false );\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { resolveSelect } = useRegistry();\n\n\tasync function createPost( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( isCreatingPost ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingPost( true );\n\t\ttry {\n\t\t\tconst postTypeObject =\n\t\t\t\tawait resolveSelect( coreStore ).getPostType( postType );\n\t\t\tconst newPage = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\tstatus: 'draft',\n\t\t\t\t\ttitle,\n\t\t\t\t\tslug: title || __( 'No title' ),\n\t\t\t\t\tcontent:\n\t\t\t\t\t\t!! postTypeObject.template &&\n\t\t\t\t\t\tpostTypeObject.template.length\n\t\t\t\t\t\t\t? serialize(\n\t\t\t\t\t\t\t\t\tsynchronizeBlocksWithTemplate(\n\t\t\t\t\t\t\t\t\t\t[],\n\t\t\t\t\t\t\t\t\t\tpostTypeObject.template\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSave( newPage );\n\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created post e.g: \"Hello world\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\tdecodeEntities( newPage.title?.rendered || title )\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the item.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingPost( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\t// translators: %s: post type singular_name label e.g: \"Page\".\n\t\t\t\tsprintf( __( 'Draft new: %s' ), labels?.singular_name )\n\t\t\t}\n\t\t\tonRequestClose={ onClose }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ createPost }>\n\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack spacing={ 2 } justify=\"end\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isCreatingPost }\n\t\t\t\t\t\t\taria-disabled={ isCreatingPost }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create draft' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,QACL,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACrE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;A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UAChC6D,KAAK,EAAGpC;QAAO,CACf,CAAC,eACFV,KAAA,CAACnB,MAAM;UAAC2D,OAAO,EAAG,CAAG;UAACO,OAAO,EAAC,KAAK;UAAAT,QAAA,gBAClCxC,IAAA,CAACpB,MAAM;YACN+D,qBAAqB;YACrBO,OAAO,EAAC,UAAU;YAClBC,OAAO,EAAG7C,OAAS;YAAAkC,QAAA,EAEjBrD,EAAE,CAAE,QAAS;UAAC,CACT,CAAC,eACTa,IAAA,CAACpB,MAAM;YACN+D,qBAAqB;YACrBO,OAAO,EAAC,SAAS;YACjBnB,IAAI,EAAC,QAAQ;YACbqB,MAAM,EAAG1C,cAAgB;YACzB,iBAAgBA,cAAgB;YAAA8B,QAAA,EAE9BrD,EAAE,CAAE,cAAe;UAAC,CACf,CAAC;QAAA,CACF,CAAC;MAAA,CACF;IAAC,CACJ;EAAC,CACD,CAAC;AAEV","ignoreList":[]}
@@ -121,7 +121,7 @@ export function usePostTypeArchiveMenuItems() {
121
121
  // `icon` is the `menu_icon` property of a post type. We
122
122
  // only handle `dashicons` for now, even if the `menu_icon`
123
123
  // also supports urls and svg as values.
124
- icon: postType.icon?.startsWith('dashicons-') ? postType.icon.slice(10) : archive,
124
+ icon: typeof postType.icon === 'string' && postType.icon.startsWith('dashicons-') ? postType.icon.slice(10) : archive,
125
125
  templatePrefix: 'archive'
126
126
  };
127
127
  }) || [], [postTypesWithArchives, existingTemplates, needsUniqueIdentifier]);
@@ -199,7 +199,7 @@ export const usePostTypeMenuItems = onClickMenuItem => {
199
199
  // `icon` is the `menu_icon` property of a post type. We
200
200
  // only handle `dashicons` for now, even if the `menu_icon`
201
201
  // also supports urls and svg as values.
202
- icon: icon?.startsWith('dashicons-') ? icon.slice(10) : post,
202
+ icon: typeof icon === 'string' && icon.startsWith('dashicons-') ? icon.slice(10) : post,
203
203
  templatePrefix: templatePrefixes[slug]
204
204
  };
205
205
  const hasEntities = postTypesInfo?.[slug]?.hasEntities;
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","decodeEntities","useMemo","useCallback","__","sprintf","blockMeta","post","archive","TEMPLATE_POST_TYPE","EMPTY_OBJECT","getValueFromObjectPath","object","path","value","split","forEach","fieldName","mapToIHasNameAndId","entities","map","entity","name","useExistingTemplates","select","getEntityRecords","per_page","useDefaultTemplateTypes","__experimentalGetDefaultTemplateTypes","usePublicPostTypes","postTypes","getPostTypes","excludedPostTypes","filter","viewable","slug","includes","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","usePostTypeArchiveMenuItems","publicPostTypes","postTypesWithArchives","postType","has_archive","existingTemplates","postTypeLabels","reduce","accumulator","labels","singularName","singular_name","toLowerCase","needsUniqueIdentifier","some","existingTemplate","title","description","icon","startsWith","slice","templatePrefix","usePostTypeMenuItems","onClickMenuItem","defaultTemplateTypes","templateLabels","templateName","template_name","templatePrefixes","suffix","postTypesInfo","useEntitiesInfo","existingTemplateSlugs","menuItems","generalTemplateSlug","defaultTemplateType","find","_slug","hasGeneralTemplate","_needsUniqueIdentifier","menuItemTitle","menuItem","hasEntities","onClick","template","type","config","recordNamePath","queryArgs","search","_fields","orderBy","exclude","existingEntitiesIds","getSpecificTemplate","suggestion","templateSlug","push","postTypesMenuItems","key","defaultPostTypesMenuItems","useTaxonomiesMenuItems","publicTaxonomies","taxonomyLabels","taxonomiesInfo","taxonomy","taxonomiesMenuItems","defaultTaxonomiesMenuItems","USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX","user","USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS","who","useAuthorMenuItem","authorInfo","authorMenuItem","search_items","not_found","all_items","useExistingTemplateSlugs","existingSlugs","Object","entries","prefix","slugsWithTemplates","_accumulator","_prefix","substring","length","useTemplatesToExclude","entityName","additionalQueryParameters","slugsToExcludePerEntity","recordsToExcludePerEntity","entitiesWithTemplates","context","entitiesHasRecords","keys","id","entitiesInfo"],"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplateTypes(),\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon: postType.icon?.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the template e.g: \"Single Item: Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Single item: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon: icon?.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the template e.g: \"Products by Category\"; %2s: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the taxonomy e.g: \"Category\"; %2s: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = `author-${ suggestion.slug }`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: ['apple'] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\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\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\n\t);\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\ttemplatePrefixes,\n\t\t\trecordsToExcludePerEntity,\n\t\t\tentityName,\n\t\t\tadditionalQueryParameters,\n\t\t]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;;AAE3D;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,MAAMC,YAAY,GAAG,CAAC,CAAC;;AAEvB;AACA;AACA;AACA;AACA;;AAEA,MAAMC,sBAAsB,GAAGA,CAAEC,MAAM,EAAEC,IAAI,KAAM;EAClD,IAAIC,KAAK,GAAGF,MAAM;EAClBC,IAAI,CAACE,KAAK,CAAE,GAAI,CAAC,CAACC,OAAO,CAAIC,SAAS,IAAM;IAC3CH,KAAK,GAAGA,KAAK,GAAIG,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,OAAOH,KAAK;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,kBAAkB,GAAGA,CAAEC,QAAQ,EAAEN,IAAI,KAAM;EACvD,OAAO,CAAEM,QAAQ,IAAI,E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AEuH;MAAG,CAAC,KAAMA,EACf,CAAC,IAAI,EAAE;MACRzF,WAAW,CAAEf,IAAI,CAAE,GAAG;QACrBiD,WAAW,EAAEqD,kBAAkB,CAAEtG,IAAI,CAAE;QACvC4D;MACD,CAAC;MACD,OAAO7C,WAAW;IACnB,CAAC,EACD,CAAC,CACF,CAAC;EACF,CAAC,EAAE,CAAEoB,gBAAgB,EAAEgE,yBAAyB,EAAEG,kBAAkB,CAAG,CAAC;EACxE,OAAOG,YAAY;AACpB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","decodeEntities","useMemo","useCallback","__","sprintf","blockMeta","post","archive","TEMPLATE_POST_TYPE","EMPTY_OBJECT","getValueFromObjectPath","object","path","value","split","forEach","fieldName","mapToIHasNameAndId","entities","map","entity","name","useExistingTemplates","select","getEntityRecords","per_page","useDefaultTemplateTypes","__experimentalGetDefaultTemplateTypes","usePublicPostTypes","postTypes","getPostTypes","excludedPostTypes","filter","viewable","slug","includes","usePublicTaxonomies","taxonomies","getTaxonomies","visibility","publicly_queryable","usePostTypeArchiveMenuItems","publicPostTypes","postTypesWithArchives","postType","has_archive","existingTemplates","postTypeLabels","reduce","accumulator","labels","singularName","singular_name","toLowerCase","needsUniqueIdentifier","some","existingTemplate","title","description","icon","startsWith","slice","templatePrefix","usePostTypeMenuItems","onClickMenuItem","defaultTemplateTypes","templateLabels","templateName","template_name","templatePrefixes","suffix","postTypesInfo","useEntitiesInfo","existingTemplateSlugs","menuItems","generalTemplateSlug","defaultTemplateType","find","_slug","hasGeneralTemplate","_needsUniqueIdentifier","menuItemTitle","menuItem","hasEntities","onClick","template","type","config","recordNamePath","queryArgs","search","_fields","orderBy","exclude","existingEntitiesIds","getSpecificTemplate","suggestion","templateSlug","push","postTypesMenuItems","key","defaultPostTypesMenuItems","useTaxonomiesMenuItems","publicTaxonomies","taxonomyLabels","taxonomiesInfo","taxonomy","taxonomiesMenuItems","defaultTaxonomiesMenuItems","USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX","user","USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS","who","useAuthorMenuItem","authorInfo","authorMenuItem","search_items","not_found","all_items","useExistingTemplateSlugs","existingSlugs","Object","entries","prefix","slugsWithTemplates","_accumulator","_prefix","substring","length","useTemplatesToExclude","entityName","additionalQueryParameters","slugsToExcludePerEntity","recordsToExcludePerEntity","entitiesWithTemplates","context","entitiesHasRecords","keys","id","entitiesInfo"],"sources":["@wordpress/edit-site/src/components/add-new-template/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { blockMeta, post, archive } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\n\nconst EMPTY_OBJECT = {};\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.split( '.' ).forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( getValueFromObjectPath( entity, path ) ),\n\t} ) );\n};\n\n/**\n * @typedef {Object} EntitiesInfo\n * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..).\n * @property {number[]} existingEntitiesIds An array of the existing entities ids.\n */\n\nexport const useExistingTemplates = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\nexport const useDefaultTemplateTypes = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplateTypes(),\n\t\t[]\n\t);\n};\n\nconst usePublicPostTypes = () => {\n\tconst postTypes = useSelect(\n\t\t( select ) => select( coreStore ).getPostTypes( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\treturn postTypes?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t}, [ postTypes ] );\n};\n\nconst usePublicTaxonomies = () => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t[]\n\t);\n\treturn useMemo( () => {\n\t\treturn taxonomies?.filter(\n\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t);\n\t}, [ taxonomies ] );\n};\n\nexport function usePostTypeArchiveMenuItems() {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst postTypesWithArchives = useMemo(\n\t\t() => publicPostTypes?.filter( ( postType ) => postType.has_archive ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst existingTemplates = useExistingTemplates();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst postTypeLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\t\taccumulator[ singularName ] =\n\t\t\t\t\t( accumulator[ singularName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst singularName = labels.singular_name.toLowerCase();\n\t\t\treturn postTypeLabels[ singularName ] > 1 && singularName !== slug;\n\t\t},\n\t\t[ postTypeLabels ]\n\t);\n\treturn useMemo(\n\t\t() =>\n\t\t\tpostTypesWithArchives\n\t\t\t\t?.filter(\n\t\t\t\t\t( postType ) =>\n\t\t\t\t\t\t! ( existingTemplates || [] ).some(\n\t\t\t\t\t\t\t( existingTemplate ) =>\n\t\t\t\t\t\t\t\texistingTemplate.slug ===\n\t\t\t\t\t\t\t\t'archive-' + postType.slug\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( postType ) => {\n\t\t\t\t\tlet title;\n\t\t\t\t\tif ( needsUniqueIdentifier( postType ) ) {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Archive: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name,\n\t\t\t\t\t\t\tpostType.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttitle = sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Archive: %s' ),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tslug: 'archive-' + postType.slug,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Displays an archive with the latest posts of type: %s.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType.labels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof postType.icon === 'string' &&\n\t\t\t\t\t\t\tpostType.icon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? postType.icon.slice( 10 )\n\t\t\t\t\t\t\t\t: archive,\n\t\t\t\t\t\ttemplatePrefix: 'archive',\n\t\t\t\t\t};\n\t\t\t\t} ) || [],\n\t\t[ postTypesWithArchives, existingTemplates, needsUniqueIdentifier ]\n\t);\n}\n\nexport const usePostTypeMenuItems = ( onClickMenuItem ) => {\n\tconst publicPostTypes = usePublicPostTypes();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst templateLabels = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { labels } ) => {\n\t\t\t\tconst templateName = (\n\t\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t\t).toLowerCase();\n\t\t\t\taccumulator[ templateName ] =\n\t\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst needsUniqueIdentifier = useCallback(\n\t\t( { labels, slug } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\treturn templateLabels[ templateName ] > 1 && templateName !== slug;\n\t\t},\n\t\t[ templateLabels ]\n\t);\n\n\t// `page`is a special case in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicPostTypes?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( slug !== 'page' ) {\n\t\t\t\t\tsuffix = `single-${ suffix }`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicPostTypes ]\n\t);\n\tconst postTypesInfo = useEntitiesInfo( 'postType', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicPostTypes || [] ).reduce(\n\t\t( accumulator, postType ) => {\n\t\t\tconst { slug, labels, icon } = postType;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier( postType );\n\t\t\tlet menuItemTitle =\n\t\t\t\tlabels.template_name ||\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t__( 'Single item: %s' ),\n\t\t\t\t\tlabels.singular_name\n\t\t\t\t);\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the template e.g: \"Single Item: Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the post type e.g: \"Post\"; %2s: Slug of the post type e.g: \"book\".\n\t\t\t\t\t\t\t__( 'Single item: %1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t\t\t\t__( 'Displays a single item: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t\t\t\t// also supports urls and svg as values.\n\t\t\t\t\t\ticon:\n\t\t\t\t\t\t\ttypeof icon === 'string' &&\n\t\t\t\t\t\t\ticon.startsWith( 'dashicons-' )\n\t\t\t\t\t\t\t\t? icon.slice( 10 )\n\t\t\t\t\t\t\t\t: post,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = postTypesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'postType',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\trecordNamePath: 'title.rendered',\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,title,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'relevance' : 'modified',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\tpostTypesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default post types\n\t// and one for the rest.\n\tconst postTypesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, postType ) => {\n\t\t\t\t\tconst { slug } = postType;\n\t\t\t\t\tlet key = 'postTypesMenuItems';\n\t\t\t\t\tif ( slug === 'page' ) {\n\t\t\t\t\t\tkey = 'defaultPostTypesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( postType );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultPostTypesMenuItems: [], postTypesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn postTypesMenuItems;\n};\n\nexport const useTaxonomiesMenuItems = ( onClickMenuItem ) => {\n\tconst publicTaxonomies = usePublicTaxonomies();\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\t// `category` and `post_tag` are special cases in template hierarchy.\n\tconst templatePrefixes = useMemo(\n\t\t() =>\n\t\t\tpublicTaxonomies?.reduce( ( accumulator, { slug } ) => {\n\t\t\t\tlet suffix = slug;\n\t\t\t\tif ( ! [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\t\t\tsuffix = `taxonomy-${ suffix }`;\n\t\t\t\t}\n\t\t\t\tif ( slug === 'post_tag' ) {\n\t\t\t\t\tsuffix = `tag`;\n\t\t\t\t}\n\t\t\t\taccumulator[ slug ] = suffix;\n\t\t\t\treturn accumulator;\n\t\t\t}, {} ),\n\t\t[ publicTaxonomies ]\n\t);\n\t// We need to keep track of naming conflicts. If a conflict\n\t// occurs, we need to add slug.\n\tconst taxonomyLabels = publicTaxonomies?.reduce(\n\t\t( accumulator, { labels } ) => {\n\t\t\tconst templateName = (\n\t\t\t\tlabels.template_name || labels.singular_name\n\t\t\t).toLowerCase();\n\t\t\taccumulator[ templateName ] =\n\t\t\t\t( accumulator[ templateName ] || 0 ) + 1;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{}\n\t);\n\tconst needsUniqueIdentifier = ( labels, slug ) => {\n\t\tif ( [ 'category', 'post_tag' ].includes( slug ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst templateName = (\n\t\t\tlabels.template_name || labels.singular_name\n\t\t).toLowerCase();\n\t\treturn taxonomyLabels[ templateName ] > 1 && templateName !== slug;\n\t};\n\tconst taxonomiesInfo = useEntitiesInfo( 'taxonomy', templatePrefixes );\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst menuItems = ( publicTaxonomies || [] ).reduce(\n\t\t( accumulator, taxonomy ) => {\n\t\t\tconst { slug, labels } = taxonomy;\n\t\t\t// We need to check if the general template is part of the\n\t\t\t// defaultTemplateTypes. If it is, just use that info and\n\t\t\t// augment it with the specific template functionality.\n\t\t\tconst generalTemplateSlug = templatePrefixes[ slug ];\n\t\t\tconst defaultTemplateType = defaultTemplateTypes?.find(\n\t\t\t\t( { slug: _slug } ) => _slug === generalTemplateSlug\n\t\t\t);\n\t\t\tconst hasGeneralTemplate =\n\t\t\t\texistingTemplateSlugs?.includes( generalTemplateSlug );\n\t\t\tconst _needsUniqueIdentifier = needsUniqueIdentifier(\n\t\t\t\tlabels,\n\t\t\t\tslug\n\t\t\t);\n\t\t\tlet menuItemTitle = labels.template_name || labels.singular_name;\n\t\t\tif ( _needsUniqueIdentifier ) {\n\t\t\t\tmenuItemTitle = labels.template_name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the template e.g: \"Products by Category\"; %2s: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.template_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %1s: Name of the taxonomy e.g: \"Category\"; %2s: Slug of the taxonomy e.g: \"product_cat\".\n\t\t\t\t\t\t\t__( '%1$s (%2$s)' ),\n\t\t\t\t\t\t\tlabels.singular_name,\n\t\t\t\t\t\t\tslug\n\t\t\t\t\t );\n\t\t\t}\n\t\t\tconst menuItem = defaultTemplateType\n\t\t\t\t? {\n\t\t\t\t\t\t...defaultTemplateType,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tslug: generalTemplateSlug,\n\t\t\t\t\t\ttitle: menuItemTitle,\n\t\t\t\t\t\tdescription: sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the taxonomy e.g: \"Product Categories\".\n\t\t\t\t\t\t\t__( 'Displays taxonomy: %s.' ),\n\t\t\t\t\t\t\tlabels.singular_name\n\t\t\t\t\t\t),\n\t\t\t\t\t\ticon: blockMeta,\n\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\n\t\t\t\t };\n\t\t\tconst hasEntities = taxonomiesInfo?.[ slug ]?.hasEntities;\n\t\t\t// We have a different template creation flow only if they have entities.\n\t\t\tif ( hasEntities ) {\n\t\t\t\tmenuItem.onClick = ( template ) => {\n\t\t\t\t\tonClickMenuItem( {\n\t\t\t\t\t\ttype: 'taxonomy',\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\t\t\torderBy: search ? 'name' : 'count',\n\t\t\t\t\t\t\t\t\texclude:\n\t\t\t\t\t\t\t\t\t\ttaxonomiesInfo[ slug ]\n\t\t\t\t\t\t\t\t\t\t\t.existingEntitiesIds,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\t\t\tconst templateSlug = `${ templatePrefixes[ slug ] }-${ suggestion.slug }`;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\t\t\ttemplatePrefix: templatePrefixes[ slug ],\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\tlabels,\n\t\t\t\t\t\thasGeneralTemplate,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t} );\n\t\t\t\t};\n\t\t\t}\n\t\t\t// We don't need to add the menu item if there are no\n\t\t\t// entities and the general template exists.\n\t\t\tif ( ! hasGeneralTemplate || hasEntities ) {\n\t\t\t\taccumulator.push( menuItem );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t},\n\t\t[]\n\t);\n\t// Split menu items into two groups: one for the default taxonomies\n\t// and one for the rest.\n\tconst taxonomiesMenuItems = useMemo(\n\t\t() =>\n\t\t\tmenuItems.reduce(\n\t\t\t\t( accumulator, taxonomy ) => {\n\t\t\t\t\tconst { slug } = taxonomy;\n\t\t\t\t\tlet key = 'taxonomiesMenuItems';\n\t\t\t\t\tif ( [ 'category', 'tag' ].includes( slug ) ) {\n\t\t\t\t\t\tkey = 'defaultTaxonomiesMenuItems';\n\t\t\t\t\t}\n\t\t\t\t\taccumulator[ key ].push( taxonomy );\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{ defaultTaxonomiesMenuItems: [], taxonomiesMenuItems: [] }\n\t\t\t),\n\t\t[ menuItems ]\n\t);\n\treturn taxonomiesMenuItems;\n};\n\nconst USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { user: 'author' };\nconst USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { user: { who: 'authors' } };\nexport function useAuthorMenuItem( onClickMenuItem ) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst authorInfo = useEntitiesInfo(\n\t\t'root',\n\t\tUSE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX,\n\t\tUSE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS\n\t);\n\tlet authorMenuItem = defaultTemplateTypes?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( ! authorMenuItem ) {\n\t\tauthorMenuItem = {\n\t\t\tdescription: __(\n\t\t\t\t'Displays latest posts written by a single author.'\n\t\t\t),\n\t\t\tslug: 'author',\n\t\t\ttitle: 'Author',\n\t\t};\n\t}\n\tconst hasGeneralTemplate = !! existingTemplates?.find(\n\t\t( { slug } ) => slug === 'author'\n\t);\n\tif ( authorInfo.user?.hasEntities ) {\n\t\tauthorMenuItem = { ...authorMenuItem, templatePrefix: 'author' };\n\t\tauthorMenuItem.onClick = ( template ) => {\n\t\t\tonClickMenuItem( {\n\t\t\t\ttype: 'root',\n\t\t\t\tslug: 'user',\n\t\t\t\tconfig: {\n\t\t\t\t\tqueryArgs: ( { search } ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t_fields: 'id,name,slug,link',\n\t\t\t\t\t\t\torderBy: search ? 'name' : 'registered_date',\n\t\t\t\t\t\t\texclude: authorInfo.user.existingEntitiesIds,\n\t\t\t\t\t\t\twho: 'authors',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t\tgetSpecificTemplate: ( suggestion ) => {\n\t\t\t\t\t\tconst templateSlug = `author-${ suggestion.slug }`;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: templateSlug,\n\t\t\t\t\t\t\tslug: templateSlug,\n\t\t\t\t\t\t\ttemplatePrefix: 'author',\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tlabels: {\n\t\t\t\t\tsingular_name: __( 'Author' ),\n\t\t\t\t\tsearch_items: __( 'Search Authors' ),\n\t\t\t\t\tnot_found: __( 'No authors found.' ),\n\t\t\t\t\tall_items: __( 'All Authors' ),\n\t\t\t\t},\n\t\t\t\thasGeneralTemplate,\n\t\t\t\ttemplate,\n\t\t\t} );\n\t\t};\n\t}\n\tif ( ! hasGeneralTemplate || authorInfo.user?.hasEntities ) {\n\t\treturn authorMenuItem;\n\t}\n}\n\n/**\n * Helper hook that filters all the existing templates by the given\n * object with the entity's slug as key and the template prefix as value.\n *\n * Example:\n * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ]\n * `templatePrefixes` is: { post_tag: 'tag' }\n * It will return: { post_tag: ['apple'] }\n *\n * Note: We append the `-` to the given template prefix in this function for our checks.\n *\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value.\n */\nconst useExistingTemplateSlugs = ( templatePrefixes ) => {\n\tconst existingTemplates = useExistingTemplates();\n\tconst existingSlugs = useMemo( () => {\n\t\treturn Object.entries( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, [ slug, prefix ] ) => {\n\t\t\t\tconst slugsWithTemplates = ( existingTemplates || [] ).reduce(\n\t\t\t\t\t( _accumulator, existingTemplate ) => {\n\t\t\t\t\t\tconst _prefix = `${ prefix }-`;\n\t\t\t\t\t\tif ( existingTemplate.slug.startsWith( _prefix ) ) {\n\t\t\t\t\t\t\t_accumulator.push(\n\t\t\t\t\t\t\t\texistingTemplate.slug.substring(\n\t\t\t\t\t\t\t\t\t_prefix.length\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\treturn _accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tif ( slugsWithTemplates.length ) {\n\t\t\t\t\taccumulator[ slug ] = slugsWithTemplates;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, existingTemplates ] );\n\treturn existingSlugs;\n};\n\n/**\n * Helper hook that finds the existing records with an associated template,\n * as they need to be excluded from the template suggestions.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value.\n */\nconst useTemplatesToExclude = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = {}\n) => {\n\tconst slugsToExcludePerEntity =\n\t\tuseExistingTemplateSlugs( templatePrefixes );\n\tconst recordsToExcludePerEntity = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.entries( slugsToExcludePerEntity || {} ).reduce(\n\t\t\t\t( accumulator, [ slug, slugsWithTemplates ] ) => {\n\t\t\t\t\tconst entitiesWithTemplates = select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\tslug: slugsWithTemplates,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} );\n\t\t\t\t\tif ( entitiesWithTemplates?.length ) {\n\t\t\t\t\t\taccumulator[ slug ] = entitiesWithTemplates;\n\t\t\t\t\t}\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[ slugsToExcludePerEntity ]\n\t);\n\treturn recordsToExcludePerEntity;\n};\n\n/**\n * Helper hook that returns information about an entity having\n * records that we can create a specific template for.\n *\n * For example we can search for `terms` in `taxonomy` entity or\n * `posts` in `postType` entity.\n *\n * First we need to find the existing records with an associated template,\n * to query afterwards for any remaining record, by excluding them.\n *\n * @param {string} entityName The entity's name.\n * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value.\n * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value.\n * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value.\n */\nconst useEntitiesInfo = (\n\tentityName,\n\ttemplatePrefixes,\n\tadditionalQueryParameters = EMPTY_OBJECT\n) => {\n\tconst recordsToExcludePerEntity = useTemplatesToExclude(\n\t\tentityName,\n\t\ttemplatePrefixes,\n\t\tadditionalQueryParameters\n\t);\n\tconst entitiesHasRecords = useSelect(\n\t\t( select ) => {\n\t\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t\t( accumulator, slug ) => {\n\t\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t\t) || [];\n\t\t\t\t\taccumulator[ slug ] = !! select(\n\t\t\t\t\t\tcoreStore\n\t\t\t\t\t).getEntityRecords( entityName, slug, {\n\t\t\t\t\t\tper_page: 1,\n\t\t\t\t\t\t_fields: 'id',\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t\texclude: existingEntitiesIds,\n\t\t\t\t\t\t...additionalQueryParameters[ slug ],\n\t\t\t\t\t} )?.length;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t},\n\t\t[\n\t\t\ttemplatePrefixes,\n\t\t\trecordsToExcludePerEntity,\n\t\t\tentityName,\n\t\t\tadditionalQueryParameters,\n\t\t]\n\t);\n\tconst entitiesInfo = useMemo( () => {\n\t\treturn Object.keys( templatePrefixes || {} ).reduce(\n\t\t\t( accumulator, slug ) => {\n\t\t\t\tconst existingEntitiesIds =\n\t\t\t\t\trecordsToExcludePerEntity?.[ slug ]?.map(\n\t\t\t\t\t\t( { id } ) => id\n\t\t\t\t\t) || [];\n\t\t\t\taccumulator[ slug ] = {\n\t\t\t\t\thasEntities: entitiesHasRecords[ slug ],\n\t\t\t\t\texistingEntitiesIds,\n\t\t\t\t};\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t}, [ templatePrefixes, recordsToExcludePerEntity, entitiesHasRecords ] );\n\treturn entitiesInfo;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,IAAI,EAAEC,OAAO,QAAQ,kBAAkB;;AAE3D;AACA;AACA;AACA,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,MAAMC,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