@wordpress/editor 14.13.1-next.cd6172eb0.0 → 14.14.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 (360) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/pattern-overrides.js +1 -0
  3. package/build/bindings/pattern-overrides.js.map +1 -1
  4. package/build/bindings/post-meta.js +1 -0
  5. package/build/bindings/post-meta.js.map +1 -1
  6. package/build/components/autocompleters/user.js +1 -0
  7. package/build/components/autocompleters/user.js.map +1 -1
  8. package/build/components/block-removal-warnings/index.js +1 -0
  9. package/build/components/block-removal-warnings/index.js.map +1 -1
  10. package/build/components/block-settings-menu/content-only-settings-menu.js +1 -0
  11. package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  12. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +1 -0
  13. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
  14. package/build/components/collab-sidebar/add-comment.js +1 -1
  15. package/build/components/collab-sidebar/add-comment.js.map +1 -1
  16. package/build/components/collab-sidebar/comment-button.js +7 -2
  17. package/build/components/collab-sidebar/comment-button.js.map +1 -1
  18. package/build/components/collab-sidebar/comment-form.js +4 -1
  19. package/build/components/collab-sidebar/comment-form.js.map +1 -1
  20. package/build/components/collab-sidebar/comments.js +199 -185
  21. package/build/components/collab-sidebar/comments.js.map +1 -1
  22. package/build/components/collab-sidebar/index.js +11 -4
  23. package/build/components/collab-sidebar/index.js.map +1 -1
  24. package/build/components/collab-sidebar/utils.js +1 -0
  25. package/build/components/collab-sidebar/utils.js.map +1 -1
  26. package/build/components/deprecated.js +1 -0
  27. package/build/components/deprecated.js.map +1 -1
  28. package/build/components/document-bar/index.js +3 -1
  29. package/build/components/document-bar/index.js.map +1 -1
  30. package/build/components/document-outline/index.js +1 -0
  31. package/build/components/document-outline/index.js.map +1 -1
  32. package/build/components/editor-help/index.native.js +1 -0
  33. package/build/components/editor-help/index.native.js.map +1 -1
  34. package/build/components/editor-notices/index.js +1 -0
  35. package/build/components/editor-notices/index.js.map +1 -1
  36. package/build/components/editor-snackbars/index.js +1 -0
  37. package/build/components/editor-snackbars/index.js.map +1 -1
  38. package/build/components/entities-saved-states/entity-type-list.js +1 -0
  39. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  40. package/build/components/entities-saved-states/hooks/use-is-dirty.js +1 -0
  41. package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  42. package/build/components/entities-saved-states/index.js +1 -0
  43. package/build/components/entities-saved-states/index.js.map +1 -1
  44. package/build/components/error-boundary/index.js +26 -13
  45. package/build/components/error-boundary/index.js.map +1 -1
  46. package/build/components/keyboard-shortcut-help-modal/index.js +1 -0
  47. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  48. package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -0
  49. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  50. package/build/components/list-view-sidebar/index.js +1 -0
  51. package/build/components/list-view-sidebar/index.js.map +1 -1
  52. package/build/components/local-autosave-monitor/index.js +1 -0
  53. package/build/components/local-autosave-monitor/index.js.map +1 -1
  54. package/build/components/mode-switcher/index.js +1 -0
  55. package/build/components/mode-switcher/index.js.map +1 -1
  56. package/build/components/page-attributes/parent.js +1 -0
  57. package/build/components/page-attributes/parent.js.map +1 -1
  58. package/build/components/post-actions/actions.js +1 -0
  59. package/build/components/post-actions/actions.js.map +1 -1
  60. package/build/components/post-actions/index.js +77 -91
  61. package/build/components/post-actions/index.js.map +1 -1
  62. package/build/components/post-author/hook.js +1 -0
  63. package/build/components/post-author/hook.js.map +1 -1
  64. package/build/components/post-card-panel/index.js +56 -23
  65. package/build/components/post-card-panel/index.js.map +1 -1
  66. package/build/components/post-fields/index.js +1 -0
  67. package/build/components/post-fields/index.js.map +1 -1
  68. package/build/components/post-format/index.js +1 -0
  69. package/build/components/post-format/index.js.map +1 -1
  70. package/build/components/post-format/panel.js +1 -0
  71. package/build/components/post-format/panel.js.map +1 -1
  72. package/build/components/post-publish-button/index.js +1 -0
  73. package/build/components/post-publish-button/index.js.map +1 -1
  74. package/build/components/post-publish-panel/maybe-category-panel.js +1 -0
  75. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  76. package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -0
  77. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  78. package/build/components/post-publish-panel/maybe-upload-media.js +1 -0
  79. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  80. package/build/components/post-publish-panel/media-util.js +1 -0
  81. package/build/components/post-publish-panel/media-util.js.map +1 -1
  82. package/build/components/post-publish-panel/prepublish.js +1 -1
  83. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  84. package/build/components/post-saved-state/index.js +1 -0
  85. package/build/components/post-saved-state/index.js.map +1 -1
  86. package/build/components/post-schedule/index.js +1 -0
  87. package/build/components/post-schedule/index.js.map +1 -1
  88. package/build/components/post-taxonomies/flat-term-selector.js +1 -0
  89. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  90. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -0
  91. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  92. package/build/components/post-taxonomies/index.js +1 -0
  93. package/build/components/post-taxonomies/index.js.map +1 -1
  94. package/build/components/post-taxonomies/most-used-terms.js +1 -0
  95. package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
  96. package/build/components/post-template/classic-theme.js +1 -0
  97. package/build/components/post-template/classic-theme.js.map +1 -1
  98. package/build/components/post-template/swap-template-button.js +1 -0
  99. package/build/components/post-template/swap-template-button.js.map +1 -1
  100. package/build/components/post-transform-panel/hooks.js +1 -0
  101. package/build/components/post-transform-panel/hooks.js.map +1 -1
  102. package/build/components/post-type-support-check/index.js +1 -0
  103. package/build/components/post-type-support-check/index.js.map +1 -1
  104. package/build/components/preferences-modal/block-visibility.js +1 -0
  105. package/build/components/preferences-modal/block-visibility.js.map +1 -1
  106. package/build/components/preferences-modal/index.js +1 -0
  107. package/build/components/preferences-modal/index.js.map +1 -1
  108. package/build/components/provider/disable-non-page-content-blocks.js +1 -0
  109. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  110. package/build/components/provider/index.native.js +1 -0
  111. package/build/components/provider/index.native.js.map +1 -1
  112. package/build/components/provider/use-block-editor-settings.js +1 -0
  113. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  114. package/build/components/sidebar/index.js +1 -0
  115. package/build/components/sidebar/index.js.map +1 -1
  116. package/build/components/start-page-options/index.js +1 -0
  117. package/build/components/start-page-options/index.js.map +1 -1
  118. package/build/components/start-template-options/index.js +1 -0
  119. package/build/components/start-template-options/index.js.map +1 -1
  120. package/build/components/template-part-content-panel/index.js +1 -0
  121. package/build/components/template-part-content-panel/index.js.map +1 -1
  122. package/build/components/theme-support-check/index.js +1 -0
  123. package/build/components/theme-support-check/index.js.map +1 -1
  124. package/build/components/visual-editor/use-select-nearest-editable-block.js +1 -0
  125. package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -1
  126. package/build/dataviews/store/private-actions.js +16 -2
  127. package/build/dataviews/store/private-actions.js.map +1 -1
  128. package/build/dataviews/store/reducer.js +1 -0
  129. package/build/dataviews/store/reducer.js.map +1 -1
  130. package/build/hooks/custom-sources-backwards-compatibility.js +1 -0
  131. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  132. package/build/hooks/pattern-overrides.js +1 -0
  133. package/build/hooks/pattern-overrides.js.map +1 -1
  134. package/build/store/actions.js +1 -0
  135. package/build/store/actions.js.map +1 -1
  136. package/build/store/private-actions.js +1 -0
  137. package/build/store/private-actions.js.map +1 -1
  138. package/build/store/private-selectors.js +1 -0
  139. package/build/store/private-selectors.js.map +1 -1
  140. package/build/store/reducer.js +1 -0
  141. package/build/store/reducer.js.map +1 -1
  142. package/build/store/reducer.native.js +1 -0
  143. package/build/store/reducer.native.js.map +1 -1
  144. package/build/store/selectors.js +1 -0
  145. package/build/store/selectors.js.map +1 -1
  146. package/build/utils/get-template-info.js +1 -0
  147. package/build/utils/get-template-info.js.map +1 -1
  148. package/build/utils/pageTypeBadge.js +6 -12
  149. package/build/utils/pageTypeBadge.js.map +1 -1
  150. package/build/utils/terms.js +1 -0
  151. package/build/utils/terms.js.map +1 -1
  152. package/build-module/bindings/pattern-overrides.js +1 -0
  153. package/build-module/bindings/pattern-overrides.js.map +1 -1
  154. package/build-module/bindings/post-meta.js +1 -0
  155. package/build-module/bindings/post-meta.js.map +1 -1
  156. package/build-module/components/autocompleters/user.js +1 -0
  157. package/build-module/components/autocompleters/user.js.map +1 -1
  158. package/build-module/components/block-removal-warnings/index.js +1 -0
  159. package/build-module/components/block-removal-warnings/index.js.map +1 -1
  160. package/build-module/components/block-settings-menu/content-only-settings-menu.js +1 -0
  161. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  162. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +1 -0
  163. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
  164. package/build-module/components/collab-sidebar/add-comment.js +1 -1
  165. package/build-module/components/collab-sidebar/add-comment.js.map +1 -1
  166. package/build-module/components/collab-sidebar/comment-button.js +7 -2
  167. package/build-module/components/collab-sidebar/comment-button.js.map +1 -1
  168. package/build-module/components/collab-sidebar/comment-form.js +4 -1
  169. package/build-module/components/collab-sidebar/comment-form.js.map +1 -1
  170. package/build-module/components/collab-sidebar/comments.js +201 -187
  171. package/build-module/components/collab-sidebar/comments.js.map +1 -1
  172. package/build-module/components/collab-sidebar/index.js +11 -4
  173. package/build-module/components/collab-sidebar/index.js.map +1 -1
  174. package/build-module/components/collab-sidebar/utils.js +1 -0
  175. package/build-module/components/collab-sidebar/utils.js.map +1 -1
  176. package/build-module/components/deprecated.js +1 -0
  177. package/build-module/components/deprecated.js.map +1 -1
  178. package/build-module/components/document-bar/index.js +3 -1
  179. package/build-module/components/document-bar/index.js.map +1 -1
  180. package/build-module/components/document-outline/index.js +1 -0
  181. package/build-module/components/document-outline/index.js.map +1 -1
  182. package/build-module/components/editor-help/index.native.js +1 -0
  183. package/build-module/components/editor-help/index.native.js.map +1 -1
  184. package/build-module/components/editor-notices/index.js +1 -0
  185. package/build-module/components/editor-notices/index.js.map +1 -1
  186. package/build-module/components/editor-snackbars/index.js +1 -0
  187. package/build-module/components/editor-snackbars/index.js.map +1 -1
  188. package/build-module/components/entities-saved-states/entity-type-list.js +1 -0
  189. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  190. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +1 -0
  191. package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
  192. package/build-module/components/entities-saved-states/index.js +1 -0
  193. package/build-module/components/entities-saved-states/index.js.map +1 -1
  194. package/build-module/components/error-boundary/index.js +28 -15
  195. package/build-module/components/error-boundary/index.js.map +1 -1
  196. package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -0
  197. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  198. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -0
  199. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  200. package/build-module/components/list-view-sidebar/index.js +1 -0
  201. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  202. package/build-module/components/local-autosave-monitor/index.js +1 -0
  203. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  204. package/build-module/components/mode-switcher/index.js +1 -0
  205. package/build-module/components/mode-switcher/index.js.map +1 -1
  206. package/build-module/components/page-attributes/parent.js +1 -0
  207. package/build-module/components/page-attributes/parent.js.map +1 -1
  208. package/build-module/components/post-actions/actions.js +1 -0
  209. package/build-module/components/post-actions/actions.js.map +1 -1
  210. package/build-module/components/post-actions/index.js +77 -92
  211. package/build-module/components/post-actions/index.js.map +1 -1
  212. package/build-module/components/post-author/hook.js +1 -0
  213. package/build-module/components/post-author/hook.js.map +1 -1
  214. package/build-module/components/post-card-panel/index.js +59 -24
  215. package/build-module/components/post-card-panel/index.js.map +1 -1
  216. package/build-module/components/post-fields/index.js +1 -0
  217. package/build-module/components/post-fields/index.js.map +1 -1
  218. package/build-module/components/post-format/index.js +1 -0
  219. package/build-module/components/post-format/index.js.map +1 -1
  220. package/build-module/components/post-format/panel.js +1 -0
  221. package/build-module/components/post-format/panel.js.map +1 -1
  222. package/build-module/components/post-publish-button/index.js +1 -0
  223. package/build-module/components/post-publish-button/index.js.map +1 -1
  224. package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -0
  225. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  226. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +1 -0
  227. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  228. package/build-module/components/post-publish-panel/maybe-upload-media.js +1 -0
  229. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  230. package/build-module/components/post-publish-panel/media-util.js +1 -0
  231. package/build-module/components/post-publish-panel/media-util.js.map +1 -1
  232. package/build-module/components/post-publish-panel/prepublish.js +1 -1
  233. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  234. package/build-module/components/post-saved-state/index.js +1 -0
  235. package/build-module/components/post-saved-state/index.js.map +1 -1
  236. package/build-module/components/post-schedule/index.js +1 -0
  237. package/build-module/components/post-schedule/index.js.map +1 -1
  238. package/build-module/components/post-taxonomies/flat-term-selector.js +1 -0
  239. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  240. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +1 -0
  241. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  242. package/build-module/components/post-taxonomies/index.js +1 -0
  243. package/build-module/components/post-taxonomies/index.js.map +1 -1
  244. package/build-module/components/post-taxonomies/most-used-terms.js +1 -0
  245. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  246. package/build-module/components/post-template/classic-theme.js +1 -0
  247. package/build-module/components/post-template/classic-theme.js.map +1 -1
  248. package/build-module/components/post-template/swap-template-button.js +1 -0
  249. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  250. package/build-module/components/post-transform-panel/hooks.js +1 -0
  251. package/build-module/components/post-transform-panel/hooks.js.map +1 -1
  252. package/build-module/components/post-type-support-check/index.js +1 -0
  253. package/build-module/components/post-type-support-check/index.js.map +1 -1
  254. package/build-module/components/preferences-modal/block-visibility.js +1 -0
  255. package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
  256. package/build-module/components/preferences-modal/index.js +1 -0
  257. package/build-module/components/preferences-modal/index.js.map +1 -1
  258. package/build-module/components/provider/disable-non-page-content-blocks.js +1 -0
  259. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  260. package/build-module/components/provider/index.native.js +1 -0
  261. package/build-module/components/provider/index.native.js.map +1 -1
  262. package/build-module/components/provider/use-block-editor-settings.js +1 -0
  263. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  264. package/build-module/components/sidebar/index.js +1 -0
  265. package/build-module/components/sidebar/index.js.map +1 -1
  266. package/build-module/components/start-page-options/index.js +1 -0
  267. package/build-module/components/start-page-options/index.js.map +1 -1
  268. package/build-module/components/start-template-options/index.js +1 -0
  269. package/build-module/components/start-template-options/index.js.map +1 -1
  270. package/build-module/components/template-part-content-panel/index.js +1 -0
  271. package/build-module/components/template-part-content-panel/index.js.map +1 -1
  272. package/build-module/components/theme-support-check/index.js +1 -0
  273. package/build-module/components/theme-support-check/index.js.map +1 -1
  274. package/build-module/components/visual-editor/use-select-nearest-editable-block.js +1 -0
  275. package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -1
  276. package/build-module/dataviews/store/private-actions.js +16 -2
  277. package/build-module/dataviews/store/private-actions.js.map +1 -1
  278. package/build-module/dataviews/store/reducer.js +1 -0
  279. package/build-module/dataviews/store/reducer.js.map +1 -1
  280. package/build-module/hooks/custom-sources-backwards-compatibility.js +1 -0
  281. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  282. package/build-module/hooks/pattern-overrides.js +1 -0
  283. package/build-module/hooks/pattern-overrides.js.map +1 -1
  284. package/build-module/store/actions.js +1 -0
  285. package/build-module/store/actions.js.map +1 -1
  286. package/build-module/store/private-actions.js +1 -0
  287. package/build-module/store/private-actions.js.map +1 -1
  288. package/build-module/store/private-selectors.js +1 -0
  289. package/build-module/store/private-selectors.js.map +1 -1
  290. package/build-module/store/reducer.js +1 -0
  291. package/build-module/store/reducer.js.map +1 -1
  292. package/build-module/store/reducer.native.js +1 -0
  293. package/build-module/store/reducer.native.js.map +1 -1
  294. package/build-module/store/selectors.js +1 -0
  295. package/build-module/store/selectors.js.map +1 -1
  296. package/build-module/utils/get-template-info.js +1 -0
  297. package/build-module/utils/get-template-info.js.map +1 -1
  298. package/build-module/utils/pageTypeBadge.js +6 -12
  299. package/build-module/utils/pageTypeBadge.js.map +1 -1
  300. package/build-module/utils/terms.js +1 -0
  301. package/build-module/utils/terms.js.map +1 -1
  302. package/build-style/style-rtl.css +22 -3
  303. package/build-style/style.css +22 -3
  304. package/build-types/components/autocompleters/user.d.ts +7 -1
  305. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  306. package/build-types/components/collab-sidebar/comment-button.d.ts.map +1 -1
  307. package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -1
  308. package/build-types/components/collab-sidebar/comments.d.ts +11 -7
  309. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -1
  310. package/build-types/components/collab-sidebar/constants.d.ts.map +1 -1
  311. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  312. package/build-types/components/document-bar/index.d.ts.map +1 -1
  313. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  314. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +1 -1
  315. package/build-types/components/media-categories/index.d.ts.map +1 -1
  316. package/build-types/components/pattern-duplicate-modal/index.d.ts.map +1 -1
  317. package/build-types/components/pattern-rename-modal/index.d.ts.map +1 -1
  318. package/build-types/components/post-actions/index.d.ts +5 -0
  319. package/build-types/components/post-actions/index.d.ts.map +1 -1
  320. package/build-types/components/post-card-panel/index.d.ts +13 -4
  321. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  322. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +4 -4
  323. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  324. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +4 -4
  325. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  326. package/build-types/components/post-title/constants.d.ts.map +1 -1
  327. package/build-types/dataviews/api.d.ts.map +1 -1
  328. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  329. package/build-types/dataviews/store/reducer.d.ts +1 -1
  330. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  331. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  332. package/build-types/store/actions.d.ts +7 -9
  333. package/build-types/store/actions.d.ts.map +1 -1
  334. package/build-types/store/private-actions.d.ts +1 -1
  335. package/build-types/store/private-actions.d.ts.map +1 -1
  336. package/build-types/store/private-selectors.d.ts +20 -4
  337. package/build-types/store/private-selectors.d.ts.map +1 -1
  338. package/build-types/store/reducer.d.ts +1 -1
  339. package/build-types/store/selectors.d.ts +376 -76
  340. package/build-types/store/selectors.d.ts.map +1 -1
  341. package/build-types/utils/pageTypeBadge.d.ts +3 -1
  342. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  343. package/package.json +36 -36
  344. package/src/components/collab-sidebar/add-comment.js +1 -1
  345. package/src/components/collab-sidebar/comment-button.js +12 -7
  346. package/src/components/collab-sidebar/comment-form.js +4 -1
  347. package/src/components/collab-sidebar/comments.js +260 -243
  348. package/src/components/collab-sidebar/index.js +10 -2
  349. package/src/components/collab-sidebar/style.scss +10 -1
  350. package/src/components/document-bar/index.js +3 -1
  351. package/src/components/error-boundary/index.js +30 -16
  352. package/src/components/error-boundary/style.scss +5 -1
  353. package/src/components/post-actions/index.js +89 -95
  354. package/src/components/post-card-panel/index.js +65 -29
  355. package/src/components/post-card-panel/style.scss +5 -0
  356. package/src/components/post-publish-panel/prepublish.js +1 -1
  357. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  358. package/src/dataviews/store/private-actions.ts +23 -8
  359. package/src/utils/pageTypeBadge.js +7 -10
  360. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_i18n","_components","_compose","_element","_data","_htmlEntities","_coreData","_blockEditor","_url","_postPanelRow","_terms","_store","_jsxRuntime","getTitle","post","title","rendered","decodeEntities","id","__","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","length","Infinity","exports","PageAttributesParent","editPost","useDispatch","editorStore","fieldValue","setFieldValue","useState","isHierarchical","parentPostId","parentPostTitle","pageItems","useSelect","select","_pType$hierarchical","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","postIsHierarchical","hierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPost","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","buildTermsTree","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","help","options","onFilterValueChange","debounce","onChange","hideLabelFromVision","PostParentToggle","isOpen","onClick","parentTitle","Button","size","variant","sprintf","ParentRow","homeUrl","home","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","default","ref","Dropdown","contentClassName","focusOnMount","renderToggle","onToggle","renderContent","onClose","jsxs","__experimentalInspectorPopoverHeader","createInterpolateElement","filterURLForDisplay","replace","wbr","ExternalLink","href","_default"],"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { isHierarchical, parentPostId, parentPostTitle, pageItems } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\t\tconst query = {\n\t\t\t\t\tper_page: 100,\n\t\t\t\t\texclude: postId,\n\t\t\t\t\tparent_exclude: postId,\n\t\t\t\t\torderby: 'menu_order',\n\t\t\t\t\torder: 'asc',\n\t\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t};\n\n\t\t\t\t// Perform a search when the field is changed.\n\t\t\t\tif ( !! fieldValue ) {\n\t\t\t\t\tquery.search = fieldValue;\n\t\t\t\t}\n\n\t\t\t\tconst parentPost = pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null;\n\n\t\t\t\treturn {\n\t\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\t\tparentPostId: pageId,\n\t\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ fieldValue ]\n\t\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-parent__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<PageAttributesParent />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport default PageAttributesParent;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AAKA,IAAAU,aAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AAAmD,IAAAa,WAAA,GAAAb,OAAA;AAhCnD;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;;AAKA,SAASc,QAAQA,CAAEC,IAAI,EAAG;EACzB,OAAOA,IAAI,EAAEC,KAAK,EAAEC,QAAQ,GACzB,IAAAC,4BAAc,EAAEH,IAAI,CAACC,KAAK,CAACC,Q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H;YAEH,CACD;UAAC,CACC,CAAC;QAAA,CACA,CAAC,eACN,IAAAP,WAAA,CAAAqF,GAAA,EAAClE,oBAAoB,IAAE,CAAC;MAAA,CACpB;IACH,CACH;EAAC,CACW,CAAC;AAEjB;AAAC,IAAAgH,QAAA,GAAAjH,OAAA,CAAAgG,OAAA,GAEc/F,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_removeAccents","_interopRequireDefault","require","_i18n","_components","_compose","_element","_data","_htmlEntities","_coreData","_blockEditor","_url","_postPanelRow","_terms","_store","_jsxRuntime","getTitle","post","title","rendered","decodeEntities","id","__","getItemPriority","name","searchValue","normalizedName","removeAccents","toLowerCase","normalizedSearch","startsWith","length","Infinity","exports","PageAttributesParent","editPost","useDispatch","editorStore","fieldValue","setFieldValue","useState","isHierarchical","parentPostId","parentPostTitle","pageItems","useSelect","select","_pType$hierarchical","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","postIsHierarchical","hierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPost","parentOptions","useMemo","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","buildTermsTree","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId","jsx","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","className","help","options","onFilterValueChange","debounce","onChange","hideLabelFromVision","PostParentToggle","isOpen","onClick","parentTitle","Button","size","variant","sprintf","ParentRow","homeUrl","home","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","offset","shift","default","ref","Dropdown","contentClassName","focusOnMount","renderToggle","onToggle","renderContent","onClose","jsxs","__experimentalInspectorPopoverHeader","createInterpolateElement","filterURLForDisplay","replace","wbr","ExternalLink","href","_default"],"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropdown,\n\tComboboxControl,\n\tExternalLink,\n} from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport {\n\tcreateInterpolateElement,\n\tuseState,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\n/**\n * Renders the Page Attributes Parent component. A dropdown menu in an editor interface\n * for selecting the parent page of a given page.\n *\n * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.\n */\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { isHierarchical, parentPostId, parentPostTitle, pageItems } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\t\tselect( editorStore );\n\t\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst postIsHierarchical = pType?.hierarchical ?? false;\n\t\t\t\tconst query = {\n\t\t\t\t\tper_page: 100,\n\t\t\t\t\texclude: postId,\n\t\t\t\t\tparent_exclude: postId,\n\t\t\t\t\torderby: 'menu_order',\n\t\t\t\t\torder: 'asc',\n\t\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t};\n\n\t\t\t\t// Perform a search when the field is changed.\n\t\t\t\tif ( !! fieldValue ) {\n\t\t\t\t\tquery.search = fieldValue;\n\t\t\t\t}\n\n\t\t\t\tconst parentPost = pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null;\n\n\t\t\t\treturn {\n\t\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\t\tparentPostId: pageId,\n\t\t\t\t\tparentPostTitle: parentPost ? getTitle( parentPost ) : '',\n\t\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ fieldValue ]\n\t\t);\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue, parentPostTitle, parentPostId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nfunction PostParentToggle( { isOpen, onClick } ) {\n\tconst parentPost = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst parentPostId = getEditedPostAttribute( 'parent' );\n\t\tif ( ! parentPostId ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\treturn getEntityRecord( 'postType', postTypeSlug, parentPostId );\n\t}, [] );\n\tconst parentTitle = useMemo(\n\t\t() => ( ! parentPost ? __( 'None' ) : getTitle( parentPost ) ),\n\t\t[ parentPost ]\n\t);\n\treturn (\n\t\t<Button\n\t\t\tsize=\"compact\"\n\t\t\tclassName=\"editor-post-parent__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\t// translators: %s: Current post parent.\n\t\t\t\tsprintf( __( 'Change parent: %s' ), parentTitle )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ parentTitle }\n\t\t</Button>\n\t);\n}\n\nexport function ParentRow() {\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// Site index.\n\t\treturn select( coreStore ).getEntityRecord( 'root', '__unstableBase' )\n\t\t\t?.home;\n\t}, [] );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\treturn (\n\t\t<PostPanelRow label={ __( 'Parent' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tclassName=\"editor-post-parent__panel-dropdown\"\n\t\t\t\tcontentClassName=\"editor-post-parent__panel-dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostParentToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<div className=\"editor-post-parent\">\n\t\t\t\t\t\t<InspectorPopoverHeader\n\t\t\t\t\t\t\ttitle={ __( 'Parent' ) }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<PageAttributesParent />\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport default PageAttributesParent;\n"],"mappings":";;;;;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,IAAA,GAAAT,OAAA;AAKA,IAAAU,aAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AAAmD,IAAAa,WAAA,GAAAb,OAAA;AAhCnD;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;;AAKA,SAASc,QAAQA,CAAEC,IAAI,EAAG;EACzB,OAAOA,IAAI,EAAEC,KAAK,EAAEC,QAAQ,GACzB,IAAAC,4BAAc,EAAEH,IAAI,CAACC,KAAK,CAACC,QAAS,CAAC,GACrC,IAAKF,IAAI,CAACI,EAAE,KAAO,IAAAC,QAAE,EAAE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AAAqF,GAAA,EAAClE,oBAAoB,IAAE,CAAC;MAAA,CACpB;IACH,CACH;EAAC,CACW,CAAC;AAEjB;AAAC,IAAAgH,QAAA,GAAAjH,OAAA,CAAAgG,OAAA,GAEc/F,oBAAoB","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","coreStore","templates","per_page","canUser","kind","name","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","shouldShowSetAsHomepageAction","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","filter","action","i","length","callback","existingCallback","items","argsObject","_items","id","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: select( coreStore ).canUser( 'update', {\n\t\t\t\t\tkind: 'root',\n\t\t\t\t\tname: 'site',\n\t\t\t\t} ),\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst shouldShowSetAsHomepageAction =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowSetAsHomepageAction ) {\n\t\t\tactions.push( setAsHomepageAction );\n\t\t}\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn actions;\n\t}, [\n\t\tcontext,\n\t\tdefaultActions,\n\t\tonActionPerformed,\n\t\tsetAsHomepageAction,\n\t\tshouldShowSetAsHomepageAction,\n\t] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ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QACA,IAAKV,OAAO,CAAEI,CAAC,CAAE,CAACQ,WAAW,EAAG;UAC/B,MAAMC,mBAAmB,GAAGb,OAAO,CAAEI,CAAC,CAAE,CAACQ,WAAW;UACpDZ,OAAO,CAAEI,CAAC,CAAE,GAAG;YACd,GAAGJ,OAAO,CAAEI,CAAC,CAAE;YACfQ,WAAW,EAAIE,KAAK,IAAM;cACzB,oBACC,IAAA5C,WAAA,CAAA6C,GAAA,EAACF,mBAAmB;gBAAA,GACdC,KAAK;gBACVzC,iBAAiB,EAAKqC,MAAM,IAAM;kBACjC,IAAKI,KAAK,CAACzC,iBAAiB,EAAG;oBAC9ByC,KAAK,CAACzC,iBAAiB,CAAEqC,MAAO,CAAC;kBAClC;kBACArC,iBAAiB,CAChB2B,OAAO,CAAEI,CAAC,CAAE,CAACO,EAAE,EACfD,MACD,CAAC;gBACF;cAAG,CACH,CAAC;YAEJ;UACD,CAAC;QACF;MACD;IACD;IAEA,OAAOV,OAAO;EACf,CAAC,EAAE,CACF1B,OAAO,EACPC,cAAc,EACdF,iBAAiB,EACjBoB,mBAAmB,EACnBE,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_store","_lockUnlock","_setAsHomepage","_jsxRuntime","usePostActions","postType","onActionPerformed","context","defaultActions","useSelect","select","getEntityActions","unlock","editorStore","canManageOptions","hasFrontPageTemplate","getEntityRecords","coreStore","templates","per_page","canUser","kind","name","find","template","slug","setAsHomepageAction","useSetAsHomepageAction","shouldShowSetAsHomepageAction","registerPostTypeSchema","useDispatch","useEffect","useMemo","actions","push","filter","action","i","length","callback","existingCallback","items","argsObject","_items","id","RenderModal","ExistingRenderModal","props","jsx"],"sources":["@wordpress/editor/src/components/post-actions/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSetAsHomepageAction } from './set-as-homepage';\n\nexport function usePostActions( { postType, onActionPerformed, context } ) {\n\tconst { defaultActions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityActions } = unlock( select( editorStore ) );\n\t\t\treturn {\n\t\t\t\tdefaultActions: getEntityActions( 'postType', postType ),\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tconst { canManageOptions, hasFrontPageTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst templates = getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tcanManageOptions: select( coreStore ).canUser( 'update', {\n\t\t\t\t\tkind: 'root',\n\t\t\t\t\tname: 'site',\n\t\t\t\t} ),\n\t\t\t\thasFrontPageTemplate: !! templates?.find(\n\t\t\t\t\t( template ) => template?.slug === 'front-page'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst setAsHomepageAction = useSetAsHomepageAction();\n\tconst shouldShowSetAsHomepageAction =\n\t\tcanManageOptions && ! hasFrontPageTemplate;\n\n\tconst { registerPostTypeSchema } = unlock( useDispatch( editorStore ) );\n\tuseEffect( () => {\n\t\tregisterPostTypeSchema( postType );\n\t}, [ registerPostTypeSchema, postType ] );\n\n\treturn useMemo( () => {\n\t\tlet actions = [ ...defaultActions ];\n\t\tif ( shouldShowSetAsHomepageAction ) {\n\t\t\tactions.push( setAsHomepageAction );\n\t\t}\n\n\t\t// Filter actions based on provided context. If not provided\n\t\t// all actions are returned. We'll have a single entry for getting the actions\n\t\t// and the consumer should provide the context to filter the actions, if needed.\n\t\t// Actions should also provide the `context` they support, if it's specific, to\n\t\t// compare with the provided context to get all the actions.\n\t\t// Right now the only supported context is `list`.\n\t\tactions = actions.filter( ( action ) => {\n\t\t\tif ( ! action.context ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn action.context === context;\n\t\t} );\n\n\t\tif ( onActionPerformed ) {\n\t\t\tfor ( let i = 0; i < actions.length; ++i ) {\n\t\t\t\tif ( actions[ i ].callback ) {\n\t\t\t\t\tconst existingCallback = actions[ i ].callback;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tcallback: ( items, argsObject ) => {\n\t\t\t\t\t\t\texistingCallback( items, {\n\t\t\t\t\t\t\t\t...argsObject,\n\t\t\t\t\t\t\t\tonActionPerformed: ( _items ) => {\n\t\t\t\t\t\t\t\t\tif ( argsObject?.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\targsObject.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t_items\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif ( actions[ i ].RenderModal ) {\n\t\t\t\t\tconst ExistingRenderModal = actions[ i ].RenderModal;\n\t\t\t\t\tactions[ i ] = {\n\t\t\t\t\t\t...actions[ i ],\n\t\t\t\t\t\tRenderModal: ( props ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<ExistingRenderModal\n\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\tonActionPerformed={ ( _items ) => {\n\t\t\t\t\t\t\t\t\t\tif ( props.onActionPerformed ) {\n\t\t\t\t\t\t\t\t\t\t\tprops.onActionPerformed( _items );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonActionPerformed(\n\t\t\t\t\t\t\t\t\t\t\tactions[ i ].id,\n\t\t\t\t\t\t\t\t\t\t\t_items\n\t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2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
7
+ exports.ActionModal = ActionModal;
6
8
  exports.default = PostActions;
7
9
  var _data = require("@wordpress/data");
8
10
  var _element = require("@wordpress/element");
@@ -25,14 +27,9 @@ const {
25
27
  Menu,
26
28
  kebabCase
27
29
  } = (0, _lockUnlock.unlock)(_components.privateApis);
28
- function PostActions({
29
- postType,
30
- postId,
31
- onActionPerformed
32
- }) {
33
- const [isActionsMenuOpen, setIsActionsMenuOpen] = (0, _element.useState)(false);
30
+ function useEditedEntityRecordsWithPermissions(postType, postIds) {
34
31
  const {
35
- item,
32
+ items,
36
33
  permissions
37
34
  } = (0, _data.useSelect)(select => {
38
35
  const {
@@ -40,45 +37,60 @@ function PostActions({
40
37
  getEntityRecordPermissions
41
38
  } = (0, _lockUnlock.unlock)(select(_coreData.store));
42
39
  return {
43
- item: getEditedEntityRecord('postType', postType, postId),
44
- permissions: getEntityRecordPermissions('postType', postType, postId)
40
+ items: postIds.map(postId => getEditedEntityRecord('postType', postType, postId)),
41
+ permissions: postIds.map(postId => getEntityRecordPermissions('postType', postType, postId))
45
42
  };
46
- }, [postId, postType]);
47
- const itemWithPermissions = (0, _element.useMemo)(() => {
48
- return {
43
+ }, [postIds, postType]);
44
+ return (0, _element.useMemo)(() => {
45
+ return items.map((item, index) => ({
49
46
  ...item,
50
- permissions
51
- };
52
- }, [item, permissions]);
47
+ permissions: permissions[index]
48
+ }));
49
+ }, [items, permissions]);
50
+ }
51
+ function PostActions({
52
+ postType,
53
+ postId,
54
+ onActionPerformed
55
+ }) {
56
+ const [activeModalAction, setActiveModalAction] = (0, _element.useState)(null);
57
+ const _postIds = (0, _element.useMemo)(() => {
58
+ if (Array.isArray(postId)) {
59
+ return postId;
60
+ }
61
+ return postId ? [postId] : [];
62
+ }, [postId]);
63
+ const itemsWithPermissions = useEditedEntityRecordsWithPermissions(postType, _postIds);
53
64
  const allActions = (0, _actions.usePostActions)({
54
65
  postType,
55
66
  onActionPerformed
56
67
  });
57
68
  const actions = (0, _element.useMemo)(() => {
58
69
  return allActions.filter(action => {
59
- return !action.isEligible || action.isEligible(itemWithPermissions);
70
+ return (!action.isEligible || itemsWithPermissions.some(itemWithPermissions => action.isEligible(itemWithPermissions))) && (itemsWithPermissions.length < 2 || action.supportsBulk);
60
71
  });
61
- }, [allActions, itemWithPermissions]);
62
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Menu, {
63
- open: isActionsMenuOpen,
64
- trigger: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
65
- size: "small",
66
- icon: _icons.moreVertical,
67
- label: (0, _i18n.__)('Actions'),
68
- disabled: !actions.length,
69
- accessibleWhenDisabled: true,
70
- className: "editor-all-actions-button",
71
- onClick: () => setIsActionsMenuOpen(!isActionsMenuOpen)
72
- }),
73
- onOpenChange: setIsActionsMenuOpen,
74
- placement: "bottom-end",
75
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionsDropdownMenuGroup, {
76
- actions: actions,
77
- item: itemWithPermissions,
78
- onClose: () => {
79
- setIsActionsMenuOpen(false);
80
- }
81
- })
72
+ }, [allActions, itemsWithPermissions]);
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
74
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Menu, {
75
+ trigger: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
76
+ size: "small",
77
+ icon: _icons.moreVertical,
78
+ label: (0, _i18n.__)('Actions'),
79
+ disabled: !actions.length,
80
+ accessibleWhenDisabled: true,
81
+ className: "editor-all-actions-button"
82
+ }),
83
+ placement: "bottom-end",
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionsDropdownMenuGroup, {
85
+ actions: actions,
86
+ items: itemsWithPermissions,
87
+ setActiveModalAction: setActiveModalAction
88
+ })
89
+ }), !!activeModalAction && /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionModal, {
90
+ action: activeModalAction,
91
+ items: itemsWithPermissions,
92
+ closeModal: () => setActiveModalAction(null)
93
+ })]
82
94
  });
83
95
  }
84
96
 
@@ -87,7 +99,6 @@ function PostActions({
87
99
  // and the dataviews package should not be using the editor packages directly,
88
100
  // so duplicating the code here seems like the least bad option.
89
101
 
90
- // Copied as is from packages/dataviews/src/item-actions.js
91
102
  function DropdownMenuItemTrigger({
92
103
  action,
93
104
  onClick,
@@ -96,75 +107,50 @@ function DropdownMenuItemTrigger({
96
107
  const label = typeof action.label === 'string' ? action.label : action.label(items);
97
108
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Menu.Item, {
98
109
  onClick: onClick,
99
- hideOnClick: !action.RenderModal,
100
110
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Menu.ItemLabel, {
101
111
  children: label
102
112
  })
103
113
  });
104
114
  }
105
-
106
- // Copied as is from packages/dataviews/src/item-actions.js
107
- // With an added onClose prop.
108
- function ActionWithModal({
115
+ function ActionModal({
109
116
  action,
110
- item,
111
- ActionTrigger,
112
- onClose
117
+ items,
118
+ closeModal
113
119
  }) {
114
- const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
115
- const actionTriggerProps = {
116
- action,
117
- onClick: () => setIsModalOpen(true),
118
- items: [item]
119
- };
120
- const {
121
- RenderModal,
122
- hideModalHeader
123
- } = action;
124
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
125
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ActionTrigger, {
126
- ...actionTriggerProps
127
- }), isModalOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
128
- title: action.modalHeader || action.label,
129
- __experimentalHideHeader: !!hideModalHeader,
130
- onRequestClose: () => {
131
- setIsModalOpen(false);
132
- },
133
- overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
134
- focusOnMount: "firstContentElement",
135
- size: "medium",
136
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderModal, {
137
- items: [item],
138
- closeModal: () => {
139
- setIsModalOpen(false);
140
- onClose();
141
- }
142
- })
143
- })]
120
+ const label = typeof action.label === 'string' ? action.label : action.label(items);
121
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
122
+ title: action.modalHeader || label,
123
+ __experimentalHideHeader: !!action.hideModalHeader,
124
+ onRequestClose: closeModal !== null && closeModal !== void 0 ? closeModal : () => {},
125
+ focusOnMount: "firstContentElement",
126
+ size: "medium",
127
+ overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
128
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(action.RenderModal, {
129
+ items: items,
130
+ closeModal: closeModal
131
+ })
144
132
  });
145
133
  }
146
-
147
- // Copied as is from packages/dataviews/src/item-actions.js
148
- // With an added onClose prop.
149
134
  function ActionsDropdownMenuGroup({
150
135
  actions,
151
- item,
152
- onClose
136
+ items,
137
+ setActiveModalAction
153
138
  }) {
139
+ const registry = (0, _data.useRegistry)();
154
140
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Menu.Group, {
155
141
  children: actions.map(action => {
156
- if (action.RenderModal) {
157
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionWithModal, {
158
- action: action,
159
- item: item,
160
- ActionTrigger: DropdownMenuItemTrigger,
161
- onClose: onClose
162
- }, action.id);
163
- }
164
142
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItemTrigger, {
165
143
  action: action,
166
- onClick: () => action.callback([item]),
167
- items: [item]
144
+ onClick: () => {
145
+ if ('RenderModal' in action) {
146
+ setActiveModalAction(action);
147
+ return;
148
+ }
149
+ action.callback(items, {
150
+ registry
151
+ });
152
+ },
153
+ items: items
168
154
  }, action.id);
169
155
  })
170
156
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","PostActions","postType","postId","onActionPerformed","isActionsMenuOpen","setIsActionsMenuOpen","useState","item","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","itemWithPermissions","useMemo","allActions","usePostActions","actions","filter","action","isEligible","jsx","open","trigger","Button","size","icon","moreVertical","label","__","disabled","length","accessibleWhenDisabled","className","onClick","onOpenChange","placement","children","ActionsDropdownMenuGroup","onClose","DropdownMenuItemTrigger","items","Item","hideOnClick","RenderModal","ItemLabel","ActionWithModal","ActionTrigger","isModalOpen","setIsModalOpen","actionTriggerProps","hideModalHeader","jsxs","Fragment","Modal","title","modalHeader","__experimentalHideHeader","onRequestClose","overlayClassName","id","focusOnMount","closeModal","Group","map","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ isActionsMenuOpen, setIsActionsMenuOpen ] = useState( false );\n\tconst { item, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titem: getEditedEntityRecord( 'postType', postType, postId ),\n\t\t\t\tpermissions: getEntityRecordPermissions(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\tconst itemWithPermissions = useMemo( () => {\n\t\treturn {\n\t\t\t...item,\n\t\t\tpermissions,\n\t\t};\n\t}, [ item, permissions ] );\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t! action.isEligible || action.isEligible( itemWithPermissions )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemWithPermissions ] );\n\n\treturn (\n\t\t<Menu\n\t\t\topen={ isActionsMenuOpen }\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\tsetIsActionsMenuOpen( ! isActionsMenuOpen )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t}\n\t\t\tonOpenChange={ setIsActionsMenuOpen }\n\t\t\tplacement=\"bottom-end\"\n\t\t>\n\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\tactions={ actions }\n\t\t\t\titem={ itemWithPermissions }\n\t\t\t\tonClose={ () => {\n\t\t\t\t\tsetIsActionsMenuOpen( false );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</Menu>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\n// Copied as is from packages/dataviews/src/item-actions.js\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick } hideOnClick={ ! action.RenderModal }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\n// Copied as is from packages/dataviews/src/item-actions.js\n// With an added onClose prop.\nfunction ActionWithModal( { action, item, ActionTrigger, onClose } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => setIsModalOpen( true ),\n\t\titems: [ item ],\n\t};\n\tconst { RenderModal, hideModalHeader } = action;\n\treturn (\n\t\t<>\n\t\t\t<ActionTrigger { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ action.modalHeader || action.label }\n\t\t\t\t\t__experimentalHideHeader={ !! hideModalHeader }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\t\t\taction.id\n\t\t\t\t\t) }` }\n\t\t\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t<RenderModal\n\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t\tcloseModal={ () => {\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// Copied as is from packages/dataviews/src/item-actions.js\n// With an added onClose prop.\nfunction ActionsDropdownMenuGroup( { actions, item, onClose } ) {\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\tif ( action.RenderModal ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionWithModal\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tActionTrigger={ DropdownMenuItemTrigger }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => action.callback( [ item ] ) }\n\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Menu.Group>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAA2C,IAAAQ,WAAA,GAAAR,OAAA;AAlB3C;AACA;AACA;;AAYA;AACA;AACA;;AAIA,MAAM;EAAES,IAAI;EAAEC;AAAU,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAE5C,SAASC,WAAWA,CAAE;EAAEC,QAAQ;EAAEC,MAAM;EAAEC;AAAkB,CAAC,EAAG;EAC9E,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrE,MAAM;IAAEC,IAAI;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EACpCC,MAAM,IAAM;IACb,MAAM;MAAEC,qBAAqB;MAAEC;IAA2B,CAAC,GAC1D,IAAAd,kBAAM,EAAEY,MAAM,CAAEG,eAAU,CAAE,CAAC;IAC9B,OAAO;MACNN,IAAI,EAAEI,qBAAqB,CAAE,UAAU,EAAEV,QAAQ,EAAEC,MAAO,CAAC;MAC3DM,WAAW,EAAEI,0BAA0B,CACtC,UAAU,EACVX,QAAQ,EACRC,MACD;IACD,CAAC;EACF,CAAC,EACD,CAAEA,MA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AEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_i18n","_components","_icons","_coreData","_lockUnlock","_actions","_jsxRuntime","Menu","kebabCase","unlock","componentsPrivateApis","useEditedEntityRecordsWithPermissions","postType","postIds","items","permissions","useSelect","select","getEditedEntityRecord","getEntityRecordPermissions","coreStore","map","postId","useMemo","item","index","PostActions","onActionPerformed","activeModalAction","setActiveModalAction","useState","_postIds","Array","isArray","itemsWithPermissions","allActions","usePostActions","actions","filter","action","isEligible","some","itemWithPermissions","length","supportsBulk","jsxs","Fragment","children","jsx","trigger","Button","size","icon","moreVertical","label","__","disabled","accessibleWhenDisabled","className","placement","ActionsDropdownMenuGroup","ActionModal","closeModal","DropdownMenuItemTrigger","onClick","Item","ItemLabel","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","focusOnMount","overlayClassName","id","RenderModal","registry","useRegistry","Group","callback"],"sources":["@wordpress/editor/src/components/post-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as componentsPrivateApis,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { moreVertical } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { usePostActions } from './actions';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nfunction useEditedEntityRecordsWithPermissions( postType, postIds ) {\n\tconst { items, permissions } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, getEntityRecordPermissions } =\n\t\t\t\tunlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\titems: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEditedEntityRecord( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t\tpermissions: postIds.map( ( postId ) =>\n\t\t\t\t\tgetEntityRecordPermissions( 'postType', postType, postId )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ postIds, postType ]\n\t);\n\n\treturn useMemo( () => {\n\t\treturn items.map( ( item, index ) => ( {\n\t\t\t...item,\n\t\t\tpermissions: permissions[ index ],\n\t\t} ) );\n\t}, [ items, permissions ] );\n}\n\nexport default function PostActions( { postType, postId, onActionPerformed } ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null );\n\tconst _postIds = useMemo( () => {\n\t\tif ( Array.isArray( postId ) ) {\n\t\t\treturn postId;\n\t\t}\n\t\treturn postId ? [ postId ] : [];\n\t}, [ postId ] );\n\n\tconst itemsWithPermissions = useEditedEntityRecordsWithPermissions(\n\t\tpostType,\n\t\t_postIds\n\t);\n\tconst allActions = usePostActions( { postType, onActionPerformed } );\n\n\tconst actions = useMemo( () => {\n\t\treturn allActions.filter( ( action ) => {\n\t\t\treturn (\n\t\t\t\t( ! action.isEligible ||\n\t\t\t\t\titemsWithPermissions.some( ( itemWithPermissions ) =>\n\t\t\t\t\t\taction.isEligible( itemWithPermissions )\n\t\t\t\t\t) ) &&\n\t\t\t\t( itemsWithPermissions.length < 2 || action.supportsBulk )\n\t\t\t);\n\t\t} );\n\t}, [ allActions, itemsWithPermissions ] );\n\n\treturn (\n\t\t<>\n\t\t\t<Menu\n\t\t\t\ttrigger={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tclassName=\"editor-all-actions-button\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tplacement=\"bottom-end\"\n\t\t\t>\n\t\t\t\t<ActionsDropdownMenuGroup\n\t\t\t\t\tactions={ actions }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t/>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ itemsWithPermissions }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n// From now on all the functions on this file are copied as from the dataviews packages,\n// The editor packages should not be using the dataviews packages directly,\n// and the dataviews package should not be using the editor packages directly,\n// so duplicating the code here seems like the least bad option.\n\nfunction DropdownMenuItemTrigger( { action, onClick, items } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal( { action, items, closeModal } ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t\toverlayClassName={ `editor-action-modal editor-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, items, setActiveModalAction } ) {\n\tconst registry = useRegistry();\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( 'RenderModal' in action ) {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AG;YAC9BV,oBAAoB,CAAEU,MAAO,CAAC;YAC9B;UACD;UACAA,MAAM,CAACyC,QAAQ,CAAElE,KAAK,EAAE;YAAE+D;UAAS,CAAE,CAAC;QACvC,CAAG;QACH/D,KAAK,EAAGA;MAAO,GATTyB,MAAM,CAACoC,EAUb,CAAC;IAEJ,CAAE;EAAC,CACQ,CAAC;AAEf","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_element","_data","_htmlEntities","_coreData","_store","_constants","useAuthorsQuery","search","authorId","authors","postAuthor","useSelect","select","getUser","getUsers","coreStore","getEditedPostAttribute","editorStore","_authorId","query","AUTHORS_QUERY","search_columns","BASE_QUERY","authorOptions","useMemo","fetchedAuthors","map","author","value","id","label","decodeEntities","name","foundAuthor","findIndex","currentAuthor","__"],"sources":["@wordpress/editor/src/components/post-author/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY, BASE_QUERY } from './constants';\n\nexport function useAuthorsQuery( search ) {\n\tconst { authorId, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst _authorId = getEditedPostAttribute( 'author' );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t\tquery.search_columns = [ 'name' ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: _authorId,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tpostAuthor: getUser( _authorId, BASE_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tlet currentAuthor = [];\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\tcurrentAuthor = [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t];\n\t\t} else if ( foundAuthor < 0 && ! postAuthor ) {\n\t\t\tcurrentAuthor = [\n\t\t\t\t{\n\t\t\t\t\tvalue: 0,\n\t\t\t\t\tlabel: __( '(No author)' ),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [ ...currentAuthor, ...fetchedAuthors ];\n\t}, [ authors, postAuthor ] );\n\n\treturn { authorId, authorOptions, postAuthor };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIO,SAASO,eAAeA,CAAEC,MAAM,EAAG;EACzC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAChDC,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC;IAAS,CAAC,G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EAAG;MAC7CyB,aAAa,GAAG,CACf;QACCP,KAAK,EAAE,CAAC;QACRE,KAAK,EAAE,IAAAM,QAAE,EAAE,aAAc;MAC1B,CAAC,CACD;IACF;IAEA,OAAO,CAAE,GAAGD,aAAa,EAAE,GAAGV,cAAc,CAAE;EAC/C,CAAC,EAAE,CAAEhB,OAAO,EAAEC,UAAU,CAAG,CAAC;EAE5B,OAAO;IAAEF,QAAQ;IAAEe,aAAa;IAAEb;EAAW,CAAC;AAC/C","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_element","_data","_htmlEntities","_coreData","_store","_constants","useAuthorsQuery","search","authorId","authors","postAuthor","useSelect","select","getUser","getUsers","coreStore","getEditedPostAttribute","editorStore","_authorId","query","AUTHORS_QUERY","search_columns","BASE_QUERY","authorOptions","useMemo","fetchedAuthors","map","author","value","id","label","decodeEntities","name","foundAuthor","findIndex","currentAuthor","__"],"sources":["@wordpress/editor/src/components/post-author/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY, BASE_QUERY } from './constants';\n\nexport function useAuthorsQuery( search ) {\n\tconst { authorId, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst _authorId = getEditedPostAttribute( 'author' );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t\tquery.search_columns = [ 'name' ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: _authorId,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tpostAuthor: getUser( _authorId, BASE_QUERY ),\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tlet currentAuthor = [];\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\tcurrentAuthor = [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t];\n\t\t} else if ( foundAuthor < 0 && ! postAuthor ) {\n\t\t\tcurrentAuthor = [\n\t\t\t\t{\n\t\t\t\t\tvalue: 0,\n\t\t\t\t\tlabel: __( '(No author)' ),\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [ ...currentAuthor, ...fetchedAuthors ];\n\t}, [ authors, postAuthor ] );\n\n\treturn { authorId, authorOptions, postAuthor };\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIO,SAASO,eAAeA,CAAEC,MAAM,EAAG;EACzC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAChDC,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC;IAAS,CAAC,GAAGF,MAAM,CAAEG,eAAU,C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,CACf;QACCP,KAAK,EAAE,CAAC;QACRE,KAAK,EAAE,IAAAM,QAAE,EAAE,aAAc;MAC1B,CAAC,CACD;IACF;IAEA,OAAO,CAAE,GAAGD,aAAa,EAAE,GAAGV,cAAc,CAAE;EAC/C,CAAC,EAAE,CAAEhB,OAAO,EAAEC,UAAU,CAAG,CAAC;EAE5B,OAAO;IAAEF,QAAQ;IAAEe,aAAa;IAAEb;EAAW,CAAC;AAC/C","ignoreList":[]}
@@ -8,6 +8,7 @@ exports.default = PostCardPanel;
8
8
  var _components = require("@wordpress/components");
9
9
  var _coreData = require("@wordpress/core-data");
10
10
  var _data = require("@wordpress/data");
11
+ var _element = require("@wordpress/element");
11
12
  var _i18n = require("@wordpress/i18n");
12
13
  var _htmlEntities = require("@wordpress/html-entities");
13
14
  var _store = require("../../store");
@@ -25,38 +26,67 @@ var _jsxRuntime = require("react/jsx-runtime");
25
26
  * Internal dependencies
26
27
  */
27
28
 
28
- function PostCardPanel({
29
+ /**
30
+ * Renders a title of the post type and the available quick actions available within a 3-dot dropdown.
31
+ *
32
+ * @param {Object} props - Component props.
33
+ * @param {string} [props.postType] - The post type string.
34
+ * @param {string|string[]} [props.postId] - The post id or list of post ids.
35
+ * @param {Function} [props.onActionPerformed] - A callback function for when a quick action is performed.
36
+ * @return {React.ReactNode} The rendered component.
37
+ */function PostCardPanel({
29
38
  postType,
30
39
  postId,
31
40
  onActionPerformed
32
41
  }) {
42
+ const postIds = (0, _element.useMemo)(() => Array.isArray(postId) ? postId : [postId], [postId]);
33
43
  const {
34
- title,
35
- icon
44
+ postTitle,
45
+ icon,
46
+ labels
36
47
  } = (0, _data.useSelect)(select => {
37
- var _select$getEntityReco;
38
48
  const {
39
- getEditedEntityRecord
49
+ getEditedEntityRecord,
50
+ getEntityRecord,
51
+ getPostType
40
52
  } = select(_coreData.store);
41
- const _record = getEditedEntityRecord('postType', postType, postId);
42
53
  const {
43
- default_template_types: templateTypes = []
44
- } = (_select$getEntityReco = select(_coreData.store).getEntityRecord('root', '__unstableBase')) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : {};
45
- const _templateInfo = [_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE].includes(postType) ? (0, _getTemplateInfo.getTemplateInfo)({
46
- template: _record,
47
- templateTypes
48
- }) : {};
54
+ getPostIcon
55
+ } = (0, _lockUnlock.unlock)(select(_store.store));
56
+ let _title = '';
57
+ const _record = getEditedEntityRecord('postType', postType, postIds[0]);
58
+ if (postIds.length === 1) {
59
+ var _getEntityRecord;
60
+ const {
61
+ default_template_types: templateTypes = []
62
+ } = (_getEntityRecord = getEntityRecord('root', '__unstableBase')) !== null && _getEntityRecord !== void 0 ? _getEntityRecord : {};
63
+ const _templateInfo = [_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE].includes(postType) ? (0, _getTemplateInfo.getTemplateInfo)({
64
+ template: _record,
65
+ templateTypes
66
+ }) : {};
67
+ _title = _templateInfo?.title || _record?.title;
68
+ }
49
69
  return {
50
- title: _templateInfo?.title || _record?.title,
51
- icon: (0, _lockUnlock.unlock)(select(_store.store)).getPostIcon(postType, {
70
+ postTitle: _title,
71
+ icon: getPostIcon(postType, {
52
72
  area: _record?.area
53
- })
73
+ }),
74
+ labels: getPostType(postType)?.labels
54
75
  };
55
- }, [postId, postType]);
56
- const pageTypeBadge = (0, _pageTypeBadge.default)();
57
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
76
+ }, [postIds, postType]);
77
+ const pageTypeBadge = (0, _pageTypeBadge.default)(postId);
78
+ let title = (0, _i18n.__)('No title');
79
+ if (labels?.name && postIds.length > 1) {
80
+ title = (0, _i18n.sprintf)(
81
+ // translators: %i number of selected items %s: Name of the plural post type e.g: "Posts".
82
+ (0, _i18n.__)('%i %s'), postId.length, labels?.name);
83
+ } else if (postTitle) {
84
+ title = (0, _htmlEntities.decodeEntities)(postTitle);
85
+ }
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
87
+ spacing: 1,
58
88
  className: "editor-post-card-panel",
59
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
89
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
60
90
  spacing: 2,
61
91
  className: "editor-post-card-panel__header",
62
92
  align: "flex-start",
@@ -67,10 +97,8 @@ function PostCardPanel({
67
97
  numberOfLines: 2,
68
98
  truncate: true,
69
99
  className: "editor-post-card-panel__title",
70
- weight: 500,
71
100
  as: "h2",
72
- lineHeight: "20px",
73
- children: [title ? (0, _htmlEntities.decodeEntities)(title) : (0, _i18n.__)('No title'), pageTypeBadge && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
101
+ children: [title, pageTypeBadge && postIds.length === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
74
102
  className: "editor-post-card-panel__title-badge",
75
103
  children: pageTypeBadge
76
104
  })]
@@ -79,7 +107,12 @@ function PostCardPanel({
79
107
  postId: postId,
80
108
  onActionPerformed: onActionPerformed
81
109
  })]
82
- })
110
+ }), postIds.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
111
+ className: "editor-post-card-panel__description",
112
+ children: (0, _i18n.sprintf)(
113
+ // translators: %s: Name of the plural post type e.g: "Posts".
114
+ (0, _i18n.__)('Changes will be applied to all selected %s.'), labels?.name.toLowerCase())
115
+ })]
83
116
  });
84
117
  }
85
118
  //# sourceMappingURL=index.js.map