@wordpress/editor 13.27.2 → 13.28.1

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 (365) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/index.js +2 -0
  3. package/build/bindings/index.js.map +1 -1
  4. package/build/bindings/pattern-overrides.js +17 -0
  5. package/build/bindings/pattern-overrides.js.map +1 -0
  6. package/build/bindings/post-meta.js +3 -5
  7. package/build/bindings/post-meta.js.map +1 -1
  8. package/build/components/autocompleters/user.js +1 -2
  9. package/build/components/autocompleters/user.js.map +1 -1
  10. package/build/components/autosave-monitor/index.js +1 -2
  11. package/build/components/autosave-monitor/index.js.map +1 -1
  12. package/build/components/block-manager/category.js +1 -2
  13. package/build/components/block-manager/category.js.map +1 -1
  14. package/build/components/block-manager/checklist.js +1 -2
  15. package/build/components/block-manager/checklist.js.map +1 -1
  16. package/build/components/block-manager/index.js +1 -2
  17. package/build/components/block-manager/index.js.map +1 -1
  18. package/build/components/deprecated.js +52 -104
  19. package/build/components/deprecated.js.map +1 -1
  20. package/build/components/document-bar/index.js +5 -6
  21. package/build/components/document-bar/index.js.map +1 -1
  22. package/build/components/document-outline/check.js +1 -2
  23. package/build/components/document-outline/check.js.map +1 -1
  24. package/build/components/document-outline/index.js +1 -2
  25. package/build/components/document-outline/index.js.map +1 -1
  26. package/build/components/document-outline/item.js +1 -2
  27. package/build/components/document-outline/item.js.map +1 -1
  28. package/build/components/document-tools/index.js +1 -2
  29. package/build/components/document-tools/index.js.map +1 -1
  30. package/build/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  31. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  32. package/build/components/editor-canvas/index.js +28 -16
  33. package/build/components/editor-canvas/index.js.map +1 -1
  34. package/build/components/editor-help/add-blocks.native.js +1 -2
  35. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  36. package/build/components/editor-help/customize-blocks.native.js +1 -2
  37. package/build/components/editor-help/customize-blocks.native.js.map +1 -1
  38. package/build/components/editor-help/help-detail-navigation-screen.native.js +1 -2
  39. package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  40. package/build/components/editor-help/help-get-support-button.native.js +1 -2
  41. package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
  42. package/build/components/editor-help/help-section-title.native.js +1 -2
  43. package/build/components/editor-help/help-section-title.native.js.map +1 -1
  44. package/build/components/editor-help/help-topic-row.native.js +1 -2
  45. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  46. package/build/components/editor-help/icon-move-blocks.native.js +1 -2
  47. package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
  48. package/build/components/editor-help/index.native.js +1 -2
  49. package/build/components/editor-help/index.native.js.map +1 -1
  50. package/build/components/editor-help/intro-to-blocks.native.js +1 -2
  51. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  52. package/build/components/editor-help/move-blocks.native.js +1 -2
  53. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  54. package/build/components/editor-help/remove-blocks.native.js +1 -2
  55. package/build/components/editor-help/remove-blocks.native.js.map +1 -1
  56. package/build/components/editor-history/redo.js +1 -2
  57. package/build/components/editor-history/redo.js.map +1 -1
  58. package/build/components/editor-history/undo.js +1 -2
  59. package/build/components/editor-history/undo.js.map +1 -1
  60. package/build/components/editor-notices/index.js +1 -2
  61. package/build/components/editor-notices/index.js.map +1 -1
  62. package/build/components/editor-snackbars/index.js +3 -1
  63. package/build/components/editor-snackbars/index.js.map +1 -1
  64. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  65. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  66. package/build/components/entities-saved-states/entity-type-list.js +7 -7
  67. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  68. package/build/components/entities-saved-states/index.js +4 -1
  69. package/build/components/entities-saved-states/index.js.map +1 -1
  70. package/build/components/error-boundary/index.js +1 -2
  71. package/build/components/error-boundary/index.js.map +1 -1
  72. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -2
  73. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  74. package/build/components/index.js +4 -6
  75. package/build/components/index.js.map +1 -1
  76. package/build/components/list-view-sidebar/index.js +43 -36
  77. package/build/components/list-view-sidebar/index.js.map +1 -1
  78. package/build/components/local-autosave-monitor/index.js +1 -2
  79. package/build/components/local-autosave-monitor/index.js.map +1 -1
  80. package/build/components/media-categories/index.js +1 -2
  81. package/build/components/media-categories/index.js.map +1 -1
  82. package/build/components/offline-status/index.native.js +1 -2
  83. package/build/components/offline-status/index.native.js.map +1 -1
  84. package/build/components/page-attributes/check.js +1 -2
  85. package/build/components/page-attributes/check.js.map +1 -1
  86. package/build/components/page-attributes/panel.js +1 -2
  87. package/build/components/page-attributes/panel.js.map +1 -1
  88. package/build/components/page-attributes/parent.js +1 -2
  89. package/build/components/page-attributes/parent.js.map +1 -1
  90. package/build/components/post-author/combobox.js +6 -60
  91. package/build/components/post-author/combobox.js.map +1 -1
  92. package/build/components/post-author/constants.js +7 -5
  93. package/build/components/post-author/constants.js.map +1 -1
  94. package/build/components/post-author/hook.js +72 -0
  95. package/build/components/post-author/hook.js.map +1 -0
  96. package/build/components/post-author/index.js +1 -2
  97. package/build/components/post-author/index.js.map +1 -1
  98. package/build/components/post-author/panel.js +1 -2
  99. package/build/components/post-author/panel.js.map +1 -1
  100. package/build/components/post-author/select.js +6 -24
  101. package/build/components/post-author/select.js.map +1 -1
  102. package/build/components/post-comments/index.js +1 -2
  103. package/build/components/post-comments/index.js.map +1 -1
  104. package/build/components/post-discussion/panel.js +1 -2
  105. package/build/components/post-discussion/panel.js.map +1 -1
  106. package/build/components/post-excerpt/check.js +1 -2
  107. package/build/components/post-excerpt/check.js.map +1 -1
  108. package/build/components/post-excerpt/index.js +1 -2
  109. package/build/components/post-excerpt/index.js.map +1 -1
  110. package/build/components/post-excerpt/plugin.js +1 -2
  111. package/build/components/post-excerpt/plugin.js.map +1 -1
  112. package/build/components/post-featured-image/check.js +1 -2
  113. package/build/components/post-featured-image/check.js.map +1 -1
  114. package/build/components/post-featured-image/index.js +1 -2
  115. package/build/components/post-featured-image/index.js.map +1 -1
  116. package/build/components/post-featured-image/panel.js +1 -2
  117. package/build/components/post-featured-image/panel.js.map +1 -1
  118. package/build/components/post-format/check.js +1 -2
  119. package/build/components/post-format/check.js.map +1 -1
  120. package/build/components/post-format/index.js +1 -2
  121. package/build/components/post-format/index.js.map +1 -1
  122. package/build/components/post-last-revision/check.js +1 -2
  123. package/build/components/post-last-revision/check.js.map +1 -1
  124. package/build/components/post-last-revision/index.js +6 -5
  125. package/build/components/post-last-revision/index.js.map +1 -1
  126. package/build/components/post-last-revision/panel.js +1 -2
  127. package/build/components/post-last-revision/panel.js.map +1 -1
  128. package/build/components/post-panel-row/index.js +1 -2
  129. package/build/components/post-panel-row/index.js.map +1 -1
  130. package/build/components/post-pending-status/check.js +1 -2
  131. package/build/components/post-pending-status/check.js.map +1 -1
  132. package/build/components/post-pending-status/index.js +1 -2
  133. package/build/components/post-pending-status/index.js.map +1 -1
  134. package/build/components/post-pingbacks/index.js +1 -2
  135. package/build/components/post-pingbacks/index.js.map +1 -1
  136. package/build/components/post-publish-button/index.js +1 -2
  137. package/build/components/post-publish-button/index.js.map +1 -1
  138. package/build/components/post-publish-button/label.js +1 -2
  139. package/build/components/post-publish-button/label.js.map +1 -1
  140. package/build/components/post-publish-panel/index.js +1 -2
  141. package/build/components/post-publish-panel/index.js.map +1 -1
  142. package/build/components/post-publish-panel/maybe-category-panel.js +1 -2
  143. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  144. package/build/components/post-publish-panel/maybe-tags-panel.js +22 -26
  145. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  146. package/build/components/post-publish-panel/postpublish.js +1 -2
  147. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  148. package/build/components/post-publish-panel/prepublish.js +1 -2
  149. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  150. package/build/components/post-schedule/index.js +0 -1
  151. package/build/components/post-schedule/index.js.map +1 -1
  152. package/build/components/post-schedule/label.js +1 -1
  153. package/build/components/post-schedule/label.js.map +1 -1
  154. package/build/components/post-schedule/panel.js +1 -0
  155. package/build/components/post-schedule/panel.js.map +1 -1
  156. package/build/components/post-slug/index.js +1 -2
  157. package/build/components/post-slug/index.js.map +1 -1
  158. package/build/components/post-switch-to-draft-button/index.js +1 -0
  159. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  160. package/build/components/post-sync-status/index.js +1 -1
  161. package/build/components/post-sync-status/index.js.map +1 -1
  162. package/build/components/post-taxonomies/check.js +8 -15
  163. package/build/components/post-taxonomies/check.js.map +1 -1
  164. package/build/components/post-taxonomies/flat-term-selector.js +1 -2
  165. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  166. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  167. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  168. package/build/components/post-taxonomies/index.js +14 -15
  169. package/build/components/post-taxonomies/index.js.map +1 -1
  170. package/build/components/post-taxonomies/panel.js +1 -2
  171. package/build/components/post-taxonomies/panel.js.map +1 -1
  172. package/build/components/post-template/block-theme.js +12 -11
  173. package/build/components/post-template/block-theme.js.map +1 -1
  174. package/build/components/post-template/classic-theme.js +10 -11
  175. package/build/components/post-template/classic-theme.js.map +1 -1
  176. package/build/components/post-template/create-new-template-modal.js +4 -5
  177. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  178. package/build/components/post-template/panel.js +5 -1
  179. package/build/components/post-template/panel.js.map +1 -1
  180. package/build/components/post-title/constants.js +2 -4
  181. package/build/components/post-title/constants.js.map +1 -1
  182. package/build/components/post-title/index.js +2 -3
  183. package/build/components/post-title/index.js.map +1 -1
  184. package/build/components/post-title/index.native.js +1 -2
  185. package/build/components/post-title/index.native.js.map +1 -1
  186. package/build/components/post-title/post-title-raw.js +1 -2
  187. package/build/components/post-title/post-title-raw.js.map +1 -1
  188. package/build/components/post-trash/check.js +1 -2
  189. package/build/components/post-trash/check.js.map +1 -1
  190. package/build/components/post-trash/index.js +1 -0
  191. package/build/components/post-trash/index.js.map +1 -1
  192. package/build/components/post-type-support-check/index.js +1 -2
  193. package/build/components/post-type-support-check/index.js.map +1 -1
  194. package/build/components/post-url/panel.js +1 -0
  195. package/build/components/post-url/panel.js.map +1 -1
  196. package/build/components/post-visibility/utils.js +1 -2
  197. package/build/components/post-visibility/utils.js.map +1 -1
  198. package/build/components/preferences-modal/enable-panel.js +1 -2
  199. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  200. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +1 -2
  201. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
  202. package/build/components/preferences-modal/index.js +0 -1
  203. package/build/components/preferences-modal/index.js.map +1 -1
  204. package/build/components/provider/constants.js +1 -2
  205. package/build/components/provider/constants.js.map +1 -1
  206. package/build/components/provider/index.js +12 -6
  207. package/build/components/provider/index.js.map +1 -1
  208. package/build/components/provider/index.native.js +4 -6
  209. package/build/components/provider/index.native.js.map +1 -1
  210. package/build/components/provider/use-block-editor-settings.js +2 -3
  211. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  212. package/build/components/provider/use-block-editor-settings.native.js +1 -2
  213. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  214. package/build/components/provider/with-registry-provider.js +1 -2
  215. package/build/components/provider/with-registry-provider.js.map +1 -1
  216. package/build/components/table-of-contents/index.js +1 -2
  217. package/build/components/table-of-contents/index.js.map +1 -1
  218. package/build/components/table-of-contents/panel.js +1 -2
  219. package/build/components/table-of-contents/panel.js.map +1 -1
  220. package/build/components/template-validation-notice/index.js +1 -2
  221. package/build/components/template-validation-notice/index.js.map +1 -1
  222. package/build/components/theme-support-check/index.js +1 -2
  223. package/build/components/theme-support-check/index.js.map +1 -1
  224. package/build/hooks/pattern-partial-syncing.js +9 -2
  225. package/build/hooks/pattern-partial-syncing.js.map +1 -1
  226. package/build/private-apis.js +1 -2
  227. package/build/private-apis.js.map +1 -1
  228. package/build/store/actions.js +32 -63
  229. package/build/store/actions.js.map +1 -1
  230. package/build/store/constants.js +7 -14
  231. package/build/store/constants.js.map +1 -1
  232. package/build/store/defaults.js +1 -2
  233. package/build/store/defaults.js.map +1 -1
  234. package/build/store/index.js +4 -6
  235. package/build/store/index.js.map +1 -1
  236. package/build/store/private-selectors.js +1 -2
  237. package/build/store/private-selectors.js.map +1 -1
  238. package/build/store/reducer.js +2 -3
  239. package/build/store/reducer.js.map +1 -1
  240. package/build/store/reducer.native.js +2 -4
  241. package/build/store/reducer.native.js.map +1 -1
  242. package/build/store/selectors.js +72 -144
  243. package/build/store/selectors.js.map +1 -1
  244. package/build/store/selectors.native.js +1 -2
  245. package/build/store/selectors.native.js.map +1 -1
  246. package/build-module/bindings/index.js +2 -0
  247. package/build-module/bindings/index.js.map +1 -1
  248. package/build-module/bindings/pattern-overrides.js +11 -0
  249. package/build-module/bindings/pattern-overrides.js.map +1 -0
  250. package/build-module/bindings/post-meta.js +3 -4
  251. package/build-module/bindings/post-meta.js.map +1 -1
  252. package/build-module/components/document-bar/index.js +5 -6
  253. package/build-module/components/document-bar/index.js.map +1 -1
  254. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  255. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  256. package/build-module/components/editor-canvas/index.js +27 -14
  257. package/build-module/components/editor-canvas/index.js.map +1 -1
  258. package/build-module/components/editor-snackbars/index.js +4 -1
  259. package/build-module/components/editor-snackbars/index.js.map +1 -1
  260. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  261. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  262. package/build-module/components/entities-saved-states/entity-type-list.js +8 -8
  263. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  264. package/build-module/components/entities-saved-states/index.js +6 -3
  265. package/build-module/components/entities-saved-states/index.js.map +1 -1
  266. package/build-module/components/list-view-sidebar/index.js +44 -37
  267. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  268. package/build-module/components/post-author/combobox.js +8 -61
  269. package/build-module/components/post-author/combobox.js.map +1 -1
  270. package/build-module/components/post-author/constants.js +5 -2
  271. package/build-module/components/post-author/constants.js.map +1 -1
  272. package/build-module/components/post-author/hook.js +65 -0
  273. package/build-module/components/post-author/hook.js.map +1 -0
  274. package/build-module/components/post-author/select.js +7 -24
  275. package/build-module/components/post-author/select.js.map +1 -1
  276. package/build-module/components/post-last-revision/index.js +6 -4
  277. package/build-module/components/post-last-revision/index.js.map +1 -1
  278. package/build-module/components/post-publish-panel/maybe-tags-panel.js +24 -27
  279. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  280. package/build-module/components/post-schedule/index.js +0 -1
  281. package/build-module/components/post-schedule/index.js.map +1 -1
  282. package/build-module/components/post-schedule/label.js +1 -1
  283. package/build-module/components/post-schedule/label.js.map +1 -1
  284. package/build-module/components/post-schedule/panel.js +1 -0
  285. package/build-module/components/post-schedule/panel.js.map +1 -1
  286. package/build-module/components/post-switch-to-draft-button/index.js +1 -0
  287. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  288. package/build-module/components/post-sync-status/index.js +1 -1
  289. package/build-module/components/post-sync-status/index.js.map +1 -1
  290. package/build-module/components/post-taxonomies/check.js +9 -14
  291. package/build-module/components/post-taxonomies/check.js.map +1 -1
  292. package/build-module/components/post-taxonomies/index.js +15 -15
  293. package/build-module/components/post-taxonomies/index.js.map +1 -1
  294. package/build-module/components/post-template/block-theme.js +12 -11
  295. package/build-module/components/post-template/block-theme.js.map +1 -1
  296. package/build-module/components/post-template/classic-theme.js +9 -9
  297. package/build-module/components/post-template/classic-theme.js.map +1 -1
  298. package/build-module/components/post-template/create-new-template-modal.js +4 -5
  299. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  300. package/build-module/components/post-template/panel.js +5 -1
  301. package/build-module/components/post-template/panel.js.map +1 -1
  302. package/build-module/components/post-title/index.js +1 -2
  303. package/build-module/components/post-title/index.js.map +1 -1
  304. package/build-module/components/post-trash/index.js +1 -0
  305. package/build-module/components/post-trash/index.js.map +1 -1
  306. package/build-module/components/post-url/panel.js +1 -0
  307. package/build-module/components/post-url/panel.js.map +1 -1
  308. package/build-module/components/preferences-modal/index.js +0 -1
  309. package/build-module/components/preferences-modal/index.js.map +1 -1
  310. package/build-module/components/provider/index.js +10 -2
  311. package/build-module/components/provider/index.js.map +1 -1
  312. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  313. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  314. package/build-module/components/table-of-contents/panel.js +0 -1
  315. package/build-module/components/table-of-contents/panel.js.map +1 -1
  316. package/build-module/hooks/pattern-partial-syncing.js +9 -2
  317. package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
  318. package/build-module/store/actions.js +1 -1
  319. package/build-module/store/actions.js.map +1 -1
  320. package/build-module/store/reducer.js +1 -1
  321. package/build-module/store/reducer.js.map +1 -1
  322. package/build-style/style-rtl.css +28 -22
  323. package/build-style/style.css +28 -22
  324. package/package.json +32 -32
  325. package/src/bindings/index.js +2 -0
  326. package/src/bindings/pattern-overrides.js +11 -0
  327. package/src/bindings/post-meta.js +2 -3
  328. package/src/components/document-bar/index.js +22 -17
  329. package/src/components/editor-canvas/edit-template-blocks-notification.js +31 -30
  330. package/src/components/editor-canvas/index.js +39 -10
  331. package/src/components/editor-snackbars/index.js +6 -3
  332. package/src/components/entities-saved-states/entity-record-item.js +1 -4
  333. package/src/components/entities-saved-states/entity-type-list.js +8 -8
  334. package/src/components/entities-saved-states/index.js +17 -4
  335. package/src/components/entities-saved-states/style.scss +5 -0
  336. package/src/components/list-view-sidebar/index.js +60 -47
  337. package/src/components/list-view-sidebar/style.scss +20 -20
  338. package/src/components/post-author/combobox.js +5 -61
  339. package/src/components/post-author/constants.js +6 -2
  340. package/src/components/post-author/hook.js +63 -0
  341. package/src/components/post-author/select.js +5 -25
  342. package/src/components/post-last-revision/index.js +6 -6
  343. package/src/components/post-last-revision/style.scss +3 -6
  344. package/src/components/post-panel-row/style.scss +3 -3
  345. package/src/components/post-publish-panel/maybe-tags-panel.js +27 -37
  346. package/src/components/post-publish-panel/style.scss +3 -1
  347. package/src/components/post-schedule/label.js +1 -1
  348. package/src/components/post-schedule/panel.js +1 -0
  349. package/src/components/post-schedule/test/label.js +19 -7
  350. package/src/components/post-switch-to-draft-button/index.js +1 -0
  351. package/src/components/post-sync-status/index.js +8 -2
  352. package/src/components/post-taxonomies/check.js +11 -15
  353. package/src/components/post-taxonomies/index.js +15 -22
  354. package/src/components/post-taxonomies/test/index.js +37 -51
  355. package/src/components/post-template/block-theme.js +29 -22
  356. package/src/components/post-template/classic-theme.js +10 -13
  357. package/src/components/post-template/create-new-template-modal.js +7 -9
  358. package/src/components/post-template/panel.js +5 -1
  359. package/src/components/post-trash/index.js +1 -0
  360. package/src/components/post-url/panel.js +1 -0
  361. package/src/components/provider/index.js +22 -2
  362. package/src/components/provider/use-block-editor-settings.js +1 -1
  363. package/src/hooks/pattern-partial-syncing.js +23 -4
  364. package/src/store/actions.js +1 -1
  365. package/src/store/reducer.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Flex","FlexItem","__","useSelect","useDispatch","useCallback","useRef","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","EntityTypeList","useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","removeNotice","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","ref","className","gap","isBlock","as","variant","disabled","onClick","map","list"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\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\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t<p>\n\t\t\t\t\t{ isDirty\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Select the items you want to save.' ) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,uBAAuB,IAAIC,SAAS,QAAQ,oBAAoB;AACzE,SAASJ,KAAK,IAAIK,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,UAAU,QAAQ,sBAAsB;AAEjD,MAAMC,wBAAwB,GAAG,CAChC;EACCC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE;AACP,CAAC,CACD;AAED,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM;AACd;AAEA,eAAe,SAASC,mBAAmBA,CAAE;EAAEC;AAAM,CAAC,EAAG;EACxD,MAAMC,YAAY,GAAGR,UAAU,CAAC,CAAC;EACjC,OACCS,aAAA,CAACC,6BAA6B;IAACH,KAAK,EAAGA,KAAO;IAAA,GAAMC;EAAY,CAAI,CAAC;AAEvE;AAEA,OAAO,SAASE,6BAA6BA,CAAE;EAC9CC,gBAAgB,GAAGC,SAAS;EAC5BL,KAAK;EACLM,MAAM,GAAGT,QAAQ;EACjBU,WAAW,EAAEC,eAAe,GAAGH,SAAS;EACxCI,SAAS,GAAG5B,EAAE,CAAE,MAAO,CAAC;E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MH,YAAY,CAAC;EAC7B,CAAE,CAAC;EAEH,OACClE,aAAA;IACCsE,GAAG,EAAGH,aAAe;IAAA,GAChBC,eAAe;IACpBG,SAAS,EAAC;EAA8B,GAExCvE,aAAA,CAACvB,IAAI;IAAC8F,SAAS,EAAC,qCAAqC;IAACC,GAAG,EAAG;EAAG,GAC9DxE,aAAA,CAACtB,QAAQ;IACR+F,OAAO;IACPC,EAAE,EAAGlG,MAAQ;IACb8F,GAAG,EAAG1D,aAAe;IACrB+D,OAAO,EAAC,SAAS;IACjBC,QAAQ,EAAG,CAAEvE,WAAa;IAC1BwE,OAAO,EAAGnC,mBAAqB;IAC/B6B,SAAS,EAAC;EAA2C,GAEnDhE,SACO,CAAC,EACXP,aAAA,CAACtB,QAAQ;IACR+F,OAAO;IACPC,EAAE,EAAGlG,MAAQ;IACbmG,OAAO,EAAC,WAAW;IACnBE,OAAO,EAAGX;EAAc,GAEtBvF,EAAE,CAAE,QAAS,CACN,CACL,CAAC,EAEPqB,aAAA;IAAKuE,SAAS,EAAC;EAAoC,GAClDvE,aAAA;IAAQuE,SAAS,EAAC;EAA4C,GAC3D5F,EAAE,CAAE,wBAAyB,CACxB,CAAC,EACPuB,gBAAgB,EAClBF,aAAA,YACGS,OAAO,GACN9B,EAAE,CACF,4EACA,CAAC,GACDA,EAAE,CAAE,oCAAqC,CAC1C,CACC,CAAC,EAEJsD,yBAAyB,CAAC6C,GAAG,CAAIC,IAAI,IAAM;IAC5C,OACC/E,aAAA,CAACV,cAAc;MACduD,GAAG,EAAGkC,IAAI,CAAE,CAAC,CAAE,CAACrF,IAAM;MACtBqF,IAAI,EAAGA,IAAM;MACbpE,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
1
+ {"version":3,"names":["Button","Flex","FlexItem","__","_n","sprintf","useSelect","useDispatch","useCallback","useRef","createInterpolateElement","store","coreStore","blockEditorStore","__experimentalUseDialog","useDialog","noticesStore","EntityTypeList","useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","__unstableMarkLastChangeAsPersistent","createSuccessNotice","createErrorNotice","removeNotice","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","saveDialogRef","saveDialogProps","onClose","ref","className","gap","isBlock","as","variant","disabled","onClick","strong","map","list"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\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\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t<p>\n\t\t\t\t\t{ isDirty\n\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: %d: number of site changes waiting to be saved. */\n\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t'There is <strong>%d site change</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\t'There are <strong>%d site changes</strong> waiting to be saved.',\n\t\t\t\t\t\t\t\t\t\tsortedPartitionedSavables.length\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tsortedPartitionedSavables.length\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{ strong: <strong /> }\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Select the items you want to save.' ) }\n\t\t\t\t</p>\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,WAAW,EACXC,MAAM,EACNC,wBAAwB,QAClB,oBAAoB;AAC3B,SAASC,KAAK,IAAIC,SAAS,QA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,CAAC,EACXP,aAAA,CAACzB,QAAQ;IACRkG,OAAO;IACPC,EAAE,EAAGrG,MAAQ;IACbsG,OAAO,EAAC,WAAW;IACnBE,OAAO,EAAGX;EAAc,GAEtB1F,EAAE,CAAE,QAAS,CACN,CACL,CAAC,EAEPwB,aAAA;IAAKuE,SAAS,EAAC;EAAoC,GAClDvE,aAAA;IAAQuE,SAAS,EAAC;EAA4C,GAC3D/F,EAAE,CAAE,wBAAyB,CACxB,CAAC,EACP0B,gBAAgB,EAClBF,aAAA,YACGS,OAAO,GACN1B,wBAAwB,CACxBL,OAAO,EACN;EACAD,EAAE,CACD,+DAA+D,EAC/D,iEAAiE,EACjEwD,yBAAyB,CAACqB,MAC3B,CAAC,EACDrB,yBAAyB,CAACqB,MAC3B,CAAC,EACD;IAAEwB,MAAM,EAAE9E,aAAA,eAAS;EAAE,CACrB,CAAC,GACDxB,EAAE,CAAE,oCAAqC,CAC1C,CACC,CAAC,EAEJyD,yBAAyB,CAAC8C,GAAG,CAAIC,IAAI,IAAM;IAC5C,OACChF,aAAA,CAACV,cAAc;MACduD,GAAG,EAAGmC,IAAI,CAAE,CAAC,CAAE,CAACtF,IAAM;MACtBsF,IAAI,EAAGA,IAAM;MACbrE,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
@@ -3,7 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { __experimentalListView as ListView } from '@wordpress/block-editor';
6
- import { Button, TabPanel } from '@wordpress/components';
6
+ import { Button, privateApis as componentsPrivateApis } from '@wordpress/components';
7
7
  import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
8
8
  import { useDispatch, useSelect } from '@wordpress/data';
9
9
  import { focus } from '@wordpress/dom';
@@ -19,6 +19,9 @@ import { ESCAPE } from '@wordpress/keycodes';
19
19
  import ListViewOutline from './list-view-outline';
20
20
  import { unlock } from '../../lock-unlock';
21
21
  import { store as editorStore } from '../../store';
22
+ const {
23
+ Tabs
24
+ } = unlock(componentsPrivateApis);
22
25
  export default function ListViewSidebar() {
23
26
  const {
24
27
  setIsListViewOpened
@@ -51,7 +54,7 @@ export default function ListViewSidebar() {
51
54
  // This ref refers to the sidebar as a whole.
52
55
  const sidebarRef = useRef();
53
56
  // This ref refers to the tab panel.
54
- const tabPanelRef = useRef();
57
+ const tabsRef = useRef();
55
58
  // This ref refers to the list view application area.
56
59
  const listViewRef = useRef();
57
60
 
@@ -67,7 +70,7 @@ export default function ListViewSidebar() {
67
70
  */
68
71
  function handleSidebarFocus(currentTab) {
69
72
  // Tab panel focus.
70
- const tabPanelFocus = focus.tabbable.find(tabPanelRef.current)[0];
73
+ const tabPanelFocus = focus.tabbable.find(tabsRef.current)[0];
71
74
  // List view tab is selected.
72
75
  if (currentTab === 'list-view') {
73
76
  // Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
@@ -92,51 +95,55 @@ export default function ListViewSidebar() {
92
95
  // This only fires when the sidebar is open because of the conditional rendering.
93
96
  // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
94
97
  useShortcut('core/editor/toggle-list-view', handleToggleListViewShortcut);
95
-
96
- /**
97
- * Render tab content for a given tab name.
98
- *
99
- * @param {string} tabName The name of the tab to render.
100
- */
101
- function renderTabContent(tabName) {
102
- if (tabName === 'list-view') {
103
- return createElement("div", {
104
- className: "editor-list-view-sidebar__list-view-panel-content"
105
- }, createElement(ListView, {
106
- dropZoneElement: dropZoneElement
107
- }));
108
- }
109
- return createElement(ListViewOutline, null);
110
- }
111
98
  return (
112
99
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
113
100
  createElement("div", {
114
101
  className: "editor-list-view-sidebar",
115
102
  onKeyDown: closeOnEscape,
116
103
  ref: sidebarRef
104
+ }, createElement(Tabs, {
105
+ onSelect: tabName => setTab(tabName),
106
+ selectOnMove: false
107
+ // The initial tab value is set explicitly to avoid an initial
108
+ // render where no tab is selected. This ensures that the
109
+ // tabpanel height is correct so the relevant scroll container
110
+ // can be rendered internally.
111
+ ,
112
+ initialTabId: "list-view"
113
+ }, createElement("div", {
114
+ className: "edit-post-editor__document-overview-panel__header"
117
115
  }, createElement(Button, {
118
116
  className: "editor-list-view-sidebar__close-button",
119
117
  icon: closeSmall,
120
118
  label: __('Close'),
121
119
  onClick: closeListView
122
- }), createElement(TabPanel, {
123
- className: "editor-list-view-sidebar__tab-panel",
124
- ref: tabPanelRef,
125
- onSelect: tabName => setTab(tabName),
126
- selectOnMove: false,
127
- tabs: [{
128
- name: 'list-view',
129
- title: _x('List View', 'Post overview'),
130
- className: 'editor-list-view-sidebar__panel-tab'
131
- }, {
132
- name: 'outline',
133
- title: _x('Outline', 'Post overview'),
134
- className: 'editor-list-view-sidebar__panel-tab'
135
- }]
136
- }, currentTab => createElement("div", {
137
- className: "editor-list-view-sidebar__list-view-container",
138
- ref: listViewContainerRef
139
- }, renderTabContent(currentTab.name))))
120
+ }), createElement(Tabs.TabList, {
121
+ className: "editor-list-view-sidebar__tabs-tablist",
122
+ ref: tabsRef
123
+ }, createElement(Tabs.Tab, {
124
+ className: "editor-list-view-sidebar__tabs-tab",
125
+ tabId: "list-view"
126
+ }, _x('List View', 'Post overview')), createElement(Tabs.Tab, {
127
+ className: "editor-list-view-sidebar__tabs-tab",
128
+ tabId: "outline"
129
+ }, _x('Outline', 'Post overview')))), createElement(Tabs.TabPanel, {
130
+ ref: listViewContainerRef,
131
+ className: "editor-list-view-sidebar__tabs-tabpanel",
132
+ tabId: "list-view",
133
+ focusable: false
134
+ }, createElement("div", {
135
+ className: "editor-list-view-sidebar__list-view-container"
136
+ }, createElement("div", {
137
+ className: "editor-list-view-sidebar__list-view-panel-content"
138
+ }, createElement(ListView, {
139
+ dropZoneElement: dropZoneElement
140
+ })))), createElement(Tabs.TabPanel, {
141
+ className: "editor-list-view-sidebar__tabs-tabpanel",
142
+ tabId: "outline",
143
+ focusable: false
144
+ }, createElement("div", {
145
+ className: "editor-list-view-sidebar__list-view-container"
146
+ }, createElement(ListViewOutline, null)))))
140
147
  );
141
148
  }
142
149
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalListView","ListView","Button","TabPanel","useFocusOnMount","useMergeRefs","useDispatch","useSelect","focus","useCallback","useRef","useState","__","_x","closeSmall","useShortcut","ESCAPE","ListViewOutline","unlock","store","editorStore","ListViewSidebar","setIsListViewOpened","getListViewToggleRef","focusOnMountRef","closeListView","current","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","tab","setTab","sidebarRef","tabPanelRef","listViewRef","listViewContainerRef","handleSidebarFocus","currentTab","tabPanelFocus","tabbable","find","listViewApplicationFocus","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","renderTabContent","tabName","createElement","className","onKeyDown","ref","icon","label","onClick","onSelect","selectOnMove","tabs","name","title"],"sources":["@wordpress/editor/src/components/list-view-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport { Button, TabPanel } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewOutline from './list-view-outline';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editorStore );\n\tconst { getListViewToggleRef } = unlock( useSelect( editorStore ) );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tgetListViewToggleRef().current?.focus();\n\t}, [ getListViewToggleRef, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\t// Tracks our current tab.\n\tconst [ tab, setTab ] = useState( 'list-view' );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the tab panel.\n\tconst tabPanelRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t// Must merge the refs together so focus can be handled properly in the next function.\n\tconst listViewContainerRef = useMergeRefs( [\n\t\tfocusOnMountRef,\n\t\tlistViewRef,\n\t\tsetDropZoneElement,\n\t] );\n\n\t/*\n\t * Callback function to handle list view or outline focus.\n\t *\n\t * @param {string} currentTab The current tab. Either list view or outline.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus( currentTab ) {\n\t\t// Tab panel focus.\n\t\tconst tabPanelFocus = focus.tabbable.find( tabPanelRef.current )[ 0 ];\n\t\t// List view tab is selected.\n\t\tif ( currentTab === 'list-view' ) {\n\t\t\t// Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.\n\t\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\t\tlistViewRef.current\n\t\t\t)[ 0 ];\n\t\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\t\tlistViewApplicationFocus\n\t\t\t)\n\t\t\t\t? listViewApplicationFocus\n\t\t\t\t: tabPanelFocus;\n\t\t\tlistViewFocusArea.focus();\n\t\t\t// Outline tab is selected.\n\t\t} else {\n\t\t\ttabPanelFocus.focus();\n\t\t}\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or outline does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus( tab );\n\t\t}\n\t}, [ closeListView, tab ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );\n\n\t/**\n\t * Render tab content for a given tab name.\n\t *\n\t * @param {string} tabName The name of the tab to render.\n\t */\n\tfunction renderTabContent( tabName ) {\n\t\tif ( tabName === 'list-view' ) {\n\t\t\treturn (\n\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-panel-content\">\n\t\t\t\t\t<ListView dropZoneElement={ dropZoneElement } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\t\treturn <ListViewOutline />;\n\t}\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"editor-list-view-sidebar\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-list-view-sidebar__close-button\"\n\t\t\t\ticon={ closeSmall }\n\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\tonClick={ closeListView }\n\t\t\t/>\n\t\t\t<TabPanel\n\t\t\t\tclassName=\"editor-list-view-sidebar__tab-panel\"\n\t\t\t\tref={ tabPanelRef }\n\t\t\t\tonSelect={ ( tabName ) => setTab( tabName ) }\n\t\t\t\tselectOnMove={ false }\n\t\t\t\ttabs={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'list-view',\n\t\t\t\t\t\ttitle: _x( 'List View', 'Post overview' ),\n\t\t\t\t\t\tclassName: 'editor-list-view-sidebar__panel-tab',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'outline',\n\t\t\t\t\t\ttitle: _x( 'Outline', 'Post overview' ),\n\t\t\t\t\t\tclassName: 'editor-list-view-sidebar__panel-tab',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ ( currentTab ) => (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__list-view-container\"\n\t\t\t\t\t\tref={ listViewContainerRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ renderTabContent( currentTab.name ) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TabPanel>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,QAAQ,QAAQ,yBAAyB;AAC5E,SAASC,MAAM,EAAEC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,eAAe,EAAEC,YAAY,QAAQ,oBAAoB;AAClE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAClE,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,MAAM,QAAQ,qBAAqB;;AAE5C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,eAAeA,CAAA,EAAG;EACzC,MAAM;IAAEC;EAAoB,CAAC,GAAGhB,WAAW,CA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AAG3C,UAAY;MACnB4C,KAAK,EAAG9C,EAAE,CAAE,OAAQ,CAAG;MACvB+C,OAAO,EAAGlC;IAAe,CACzB,CAAC,EACF4B,aAAA,CAAClD,QAAQ;MACRmD,SAAS,EAAC,qCAAqC;MAC/CE,GAAG,EAAGnB,WAAa;MACnBuB,QAAQ,EAAKR,OAAO,IAAMjB,MAAM,CAAEiB,OAAQ,CAAG;MAC7CS,YAAY,EAAG,KAAO;MACtBC,IAAI,EAAG,CACN;QACCC,IAAI,EAAE,WAAW;QACjBC,KAAK,EAAEnD,EAAE,CAAE,WAAW,EAAE,eAAgB,CAAC;QACzCyC,SAAS,EAAE;MACZ,CAAC,EACD;QACCS,IAAI,EAAE,SAAS;QACfC,KAAK,EAAEnD,EAAE,CAAE,SAAS,EAAE,eAAgB,CAAC;QACvCyC,SAAS,EAAE;MACZ,CAAC;IACC,GAECb,UAAU,IACbY,aAAA;MACCC,SAAS,EAAC,+CAA+C;MACzDE,GAAG,EAAGjB;IAAsB,GAE1BY,gBAAgB,CAAEV,UAAU,CAACsB,IAAK,CAChC,CAEG,CACN;EAAC;AAER"}
1
+ {"version":3,"names":["__experimentalListView","ListView","Button","privateApis","componentsPrivateApis","useFocusOnMount","useMergeRefs","useDispatch","useSelect","focus","useCallback","useRef","useState","__","_x","closeSmall","useShortcut","ESCAPE","ListViewOutline","unlock","store","editorStore","Tabs","ListViewSidebar","setIsListViewOpened","getListViewToggleRef","focusOnMountRef","closeListView","current","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","tab","setTab","sidebarRef","tabsRef","listViewRef","listViewContainerRef","handleSidebarFocus","currentTab","tabPanelFocus","tabbable","find","listViewApplicationFocus","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","createElement","className","onKeyDown","ref","onSelect","tabName","selectOnMove","initialTabId","icon","label","onClick","TabList","Tab","tabId","TabPanel","focusable"],"sources":["@wordpress/editor/src/components/list-view-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalListView as ListView } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport ListViewOutline from './list-view-outline';\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editorStore );\n\tconst { getListViewToggleRef } = unlock( useSelect( editorStore ) );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tgetListViewToggleRef().current?.focus();\n\t}, [ getListViewToggleRef, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\t// Tracks our current tab.\n\tconst [ tab, setTab ] = useState( 'list-view' );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the tab panel.\n\tconst tabsRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t// Must merge the refs together so focus can be handled properly in the next function.\n\tconst listViewContainerRef = useMergeRefs( [\n\t\tfocusOnMountRef,\n\t\tlistViewRef,\n\t\tsetDropZoneElement,\n\t] );\n\n\t/*\n\t * Callback function to handle list view or outline focus.\n\t *\n\t * @param {string} currentTab The current tab. Either list view or outline.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus( currentTab ) {\n\t\t// Tab panel focus.\n\t\tconst tabPanelFocus = focus.tabbable.find( tabsRef.current )[ 0 ];\n\t\t// List view tab is selected.\n\t\tif ( currentTab === 'list-view' ) {\n\t\t\t// Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.\n\t\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\t\tlistViewRef.current\n\t\t\t)[ 0 ];\n\t\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\t\tlistViewApplicationFocus\n\t\t\t)\n\t\t\t\t? listViewApplicationFocus\n\t\t\t\t: tabPanelFocus;\n\t\t\tlistViewFocusArea.focus();\n\t\t\t// Outline tab is selected.\n\t\t} else {\n\t\t\ttabPanelFocus.focus();\n\t\t}\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or outline does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus( tab );\n\t\t}\n\t}, [ closeListView, tab ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut( 'core/editor/toggle-list-view', handleToggleListViewShortcut );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"editor-list-view-sidebar\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<Tabs\n\t\t\t\tonSelect={ ( tabName ) => setTab( tabName ) }\n\t\t\t\tselectOnMove={ false }\n\t\t\t\t// The initial tab value is set explicitly to avoid an initial\n\t\t\t\t// render where no tab is selected. This ensures that the\n\t\t\t\t// tabpanel height is correct so the relevant scroll container\n\t\t\t\t// can be rendered internally.\n\t\t\t\tinitialTabId=\"list-view\"\n\t\t\t>\n\t\t\t\t<div className=\"edit-post-editor__document-overview-panel__header\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__close-button\"\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\t/>\n\t\t\t\t\t<Tabs.TabList\n\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tablist\"\n\t\t\t\t\t\tref={ tabsRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tab\"\n\t\t\t\t\t\t\ttabId=\"list-view\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'List View', 'Post overview' ) }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tab\"\n\t\t\t\t\t\t\ttabId=\"outline\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Outline', 'Post overview' ) }\n\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t</div>\n\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tref={ listViewContainerRef }\n\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tabpanel\"\n\t\t\t\t\ttabId=\"list-view\"\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-container\">\n\t\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-panel-content\">\n\t\t\t\t\t\t\t<ListView dropZoneElement={ dropZoneElement } />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tclassName=\"editor-list-view-sidebar__tabs-tabpanel\"\n\t\t\t\t\ttabId=\"outline\"\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"editor-list-view-sidebar__list-view-container\">\n\t\t\t\t\t\t<ListViewOutline />\n\t\t\t\t\t</div>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,sBAAsB,IAAIC,QAAQ,QAAQ,yBAAyB;AAC5E,SACCC,MAAM,EACNC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,eAAe,EAAEC,YAAY,QAAQ,oBAAoB;AAClE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAClE,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,MAAM,QAAQ,qBAAqB;;AAE5C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,MAAM;EAAEC;AAAK,CAAC,GAAGH,MAAM,CAAEf,qBAAsB,CAAC;AAEhD,eAAe,SAASmB,eAAeA,CAAA,EAAG;EACzC,MAAM;IAAEC;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,CAAG;MACvBkD,OAAO,EAAGpC;IAAe,CACzB,CAAC,EACF0B,aAAA,CAAC/B,IAAI,CAAC0C,OAAO;MACZV,SAAS,EAAC,wCAAwC;MAClDE,GAAG,EAAGjB;IAAS,GAEfc,aAAA,CAAC/B,IAAI,CAAC2C,GAAG;MACRX,SAAS,EAAC,oCAAoC;MAC9CY,KAAK,EAAC;IAAW,GAEfpD,EAAE,CAAE,WAAW,EAAE,eAAgB,CAC1B,CAAC,EACXuC,aAAA,CAAC/B,IAAI,CAAC2C,GAAG;MACRX,SAAS,EAAC,oCAAoC;MAC9CY,KAAK,EAAC;IAAS,GAEbpD,EAAE,CAAE,SAAS,EAAE,eAAgB,CACxB,CACG,CACV,CAAC,EAENuC,aAAA,CAAC/B,IAAI,CAAC6C,QAAQ;MACbX,GAAG,EAAGf,oBAAsB;MAC5Ba,SAAS,EAAC,yCAAyC;MACnDY,KAAK,EAAC,WAAW;MACjBE,SAAS,EAAG;IAAO,GAEnBf,aAAA;MAAKC,SAAS,EAAC;IAA+C,GAC7DD,aAAA;MAAKC,SAAS,EAAC;IAAmD,GACjED,aAAA,CAACpD,QAAQ;MAACiC,eAAe,EAAGA;IAAiB,CAAE,CAC3C,CACD,CACS,CAAC,EAChBmB,aAAA,CAAC/B,IAAI,CAAC6C,QAAQ;MACbb,SAAS,EAAC,yCAAyC;MACnDY,KAAK,EAAC,SAAS;MACfE,SAAS,EAAG;IAAO,GAEnBf,aAAA;MAAKC,SAAS,EAAC;IAA+C,GAC7DD,aAAA,CAACnC,eAAe,MAAE,CACd,CACS,CACV,CACF;EAAC;AAER"}
@@ -3,73 +3,25 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { debounce } from '@wordpress/compose';
6
- import { useState, useMemo } from '@wordpress/element';
7
- import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { useState } from '@wordpress/element';
7
+ import { useDispatch } from '@wordpress/data';
8
8
  import { __ } from '@wordpress/i18n';
9
9
  import { ComboboxControl } from '@wordpress/components';
10
- import { decodeEntities } from '@wordpress/html-entities';
11
- import { store as coreStore } from '@wordpress/core-data';
12
10
 
13
11
  /**
14
12
  * Internal dependencies
15
13
  */
16
14
  import { store as editorStore } from '../../store';
17
- import { AUTHORS_QUERY } from './constants';
18
- function PostAuthorCombobox() {
15
+ import { useAuthorsQuery } from './hook';
16
+ export default function PostAuthorCombobox() {
19
17
  const [fieldValue, setFieldValue] = useState();
20
- const {
21
- authorId,
22
- isLoading,
23
- authors,
24
- postAuthor
25
- } = useSelect(select => {
26
- const {
27
- getUser,
28
- getUsers,
29
- isResolving
30
- } = select(coreStore);
31
- const {
32
- getEditedPostAttribute
33
- } = select(editorStore);
34
- const author = getUser(getEditedPostAttribute('author'), {
35
- context: 'view'
36
- });
37
- const query = {
38
- ...AUTHORS_QUERY
39
- };
40
- if (fieldValue) {
41
- query.search = fieldValue;
42
- }
43
- return {
44
- authorId: getEditedPostAttribute('author'),
45
- postAuthor: author,
46
- authors: getUsers(query),
47
- isLoading: isResolving('core', 'getUsers', [query])
48
- };
49
- }, [fieldValue]);
50
18
  const {
51
19
  editPost
52
20
  } = useDispatch(editorStore);
53
- const authorOptions = useMemo(() => {
54
- const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
55
- return {
56
- value: author.id,
57
- label: decodeEntities(author.name)
58
- };
59
- });
60
-
61
- // Ensure the current author is included in the dropdown list.
62
- const foundAuthor = fetchedAuthors.findIndex(({
63
- value
64
- }) => postAuthor?.id === value);
65
- if (foundAuthor < 0 && postAuthor) {
66
- return [{
67
- value: postAuthor.id,
68
- label: decodeEntities(postAuthor.name)
69
- }, ...fetchedAuthors];
70
- }
71
- return fetchedAuthors;
72
- }, [authors, postAuthor]);
21
+ const {
22
+ authorId,
23
+ authorOptions
24
+ } = useAuthorsQuery(fieldValue);
73
25
 
74
26
  /**
75
27
  * Handle author selection.
@@ -93,9 +45,6 @@ function PostAuthorCombobox() {
93
45
  const handleKeydown = inputValue => {
94
46
  setFieldValue(inputValue);
95
47
  };
96
- if (!postAuthor) {
97
- return null;
98
- }
99
48
  return createElement(ComboboxControl, {
100
49
  __nextHasNoMarginBottom: true,
101
50
  __next40pxDefaultSize: true,
@@ -104,9 +53,7 @@ function PostAuthorCombobox() {
104
53
  value: authorId,
105
54
  onFilterValueChange: debounce(handleKeydown, 300),
106
55
  onChange: handleSelect,
107
- isLoading: isLoading,
108
56
  allowReset: false
109
57
  });
110
58
  }
111
- export default PostAuthorCombobox;
112
59
  //# sourceMappingURL=combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["debounce","useState","useMemo","useSelect","useDispatch","__","ComboboxControl","decodeEntities","store","coreStore","editorStore","AUTHORS_QUERY","PostAuthorCombobox","fieldValue","setFieldValue","authorId","isLoading","authors","postAuthor","select","getUser","getUsers","isResolving","getEditedPostAttribute","author","context","query","search","editPost","authorOptions","fetchedAuthors","map","value","id","label","name","foundAuthor","findIndex","handleSelect","postAuthorId","handleKeydown","inputValue","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","options","onFilterValueChange","onChange","allowReset"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\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 } from './constants';\n\nfunction PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { authorId, isLoading, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers, isResolving } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst author = getUser( getEditedPostAttribute( 'author' ), {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: getEditedPostAttribute( 'author' ),\n\t\t\t\tpostAuthor: author,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tisLoading: isResolving( 'core', 'getUsers', [ query ] ),\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\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\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\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\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\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\tif ( ! postAuthor ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tisLoading={ isLoading }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorCombobox;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,QAAQ,aAAa;AAE3C,SAASC,kBAAkBA,CAAA,EAAG;EAC7B,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAGb,QAAQ,CAAC,CAAC;EAEhD,MAAM;IAAEc,QAAQ;IAAEC,SAAS;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGf,SAAS,CAC3DgB,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC,QAAQ;MAAEC;IAAY,CAAC,GAAGH,MAAM,CAAEV,SAAU,CAAC;IAC9D,MAAM;MAAEc;IAAuB,CAAC,GAAGJ,MAAM,CAAET,WAAY,CAAC;IACxD,MAAMc,MAAM,GAAGJ,OAAO,CAAEG,sBAAsB,CAAE,QAAS,CAAC,EAAE;MAC3DE,OAAO,EAAE;IACV,CAAE,CAAC;IACH,MAAMC,KAAK,GAAG;MAAE,GAAGf;IAAc,CAAC;IAElC,IAAKE,UAAU,EAAG;MACjBa,KAAK,CAACC,MAAM,GAAGd,UAAU;IAC1B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C,MAAMC,aAAa,GAAKC,UAAU,IAAM;IACvC3B,aAAa,CAAE2B,UAAW,CAAC;EAC5B,CAAC;EAED,IAAK,CAAEvB,UAAU,EAAG;IACnB,OAAO,IAAI;EACZ;EAEA,OACCwB,aAAA,CAACpC,eAAe;IACfqC,uBAAuB;IACvBC,qBAAqB;IACrBV,KAAK,EAAG7B,EAAE,CAAE,QAAS,CAAG;IACxBwC,OAAO,EAAGhB,aAAe;IACzBG,KAAK,EAAGjB,QAAU;IAClB+B,mBAAmB,EAAG9C,QAAQ,CAAEwC,aAAa,EAAE,GAAI,CAAG;IACtDO,QAAQ,EAAGT,YAAc;IACzBtB,SAAS,EAAGA,SAAW;IACvBgC,UAAU,EAAG;EAAO,CACpB,CAAC;AAEJ;AAEA,eAAepC,kBAAkB"}
1
+ {"version":3,"names":["debounce","useState","useDispatch","__","ComboboxControl","store","editorStore","useAuthorsQuery","PostAuthorCombobox","fieldValue","setFieldValue","editPost","authorId","authorOptions","handleSelect","postAuthorId","author","handleKeydown","inputValue","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","label","options","value","onFilterValueChange","onChange","allowReset"],"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery( fieldValue );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\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\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,uBAAuB;;AAEvD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,eAAe,QAAQ,QAAQ;AAExC,eAAe,SAASC,kBAAkBA,CAAA,EAAG;EAC5C,MAAM,CAAEC,UAAU,EAAEC,aAAa,CAAE,GAAGT,QAAQ,CAAC,CAAC;EAEhD,MAAM;IAAEU;EAAS,CAAC,GAAGT,WAAW,CAAEI,WAAY,CAAC;EAC/C,MAAM;IAAEM,QAAQ;IAAEC;EAAc,CAAC,GAAGN,eAAe,CAAEE,UAAW,CAAC;;EAEjE;AACD;AACA;AACA;AACA;EACC,MAAMK,YAAY,GAAKC,YAAY,IAAM;IACxC,IAAK,CAAEA,YAAY,EAAG;MACrB;IACD;IACAJ,QAAQ,CAAE;MAAEK,MAAM,EAAED;IAAa,CAAE,CAAC;EACrC,CAAC;;EAED;AACD;AACA;AACA;AACA;EACC,MAAME,aAAa,GAAKC,UAAU,IAAM;IACvCR,aAAa,CAAEQ,UAAW,CAAC;EAC5B,CAAC;EAED,OACCC,aAAA,CAACf,eAAe;IACfgB,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAGnB,EAAE,CAAE,QAAS,CAAG;IACxBoB,OAAO,EAAGV,aAAe;IACzBW,KAAK,EAAGZ,QAAU;IAClBa,mBAAmB,EAAGzB,QAAQ,CAAEiB,aAAa,EAAE,GAAI,CAAG;IACtDS,QAAQ,EAAGZ,YAAc;IACzBa,UAAU,EAAG;EAAO,CACpB,CAAC;AAEJ"}
@@ -1,7 +1,10 @@
1
+ export const BASE_QUERY = {
2
+ _fields: 'id,name',
3
+ context: 'view' // Allows non-admins to perform requests.
4
+ };
1
5
  export const AUTHORS_QUERY = {
2
6
  who: 'authors',
3
7
  per_page: 50,
4
- _fields: 'id,name',
5
- context: 'view' // Allows non-admins to perform requests.
8
+ ...BASE_QUERY
6
9
  };
7
10
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AUTHORS_QUERY","who","per_page","_fields","context"],"sources":["@wordpress/editor/src/components/post-author/constants.js"],"sourcesContent":["export const AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: 50,\n\t_fields: 'id,name',\n\tcontext: 'view', // Allows non-admins to perform requests.\n};\n"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG;EAC5BC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,EAAE;EACZC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,MAAM,CAAE;AAClB,CAAC"}
1
+ {"version":3,"names":["BASE_QUERY","_fields","context","AUTHORS_QUERY","who","per_page"],"sources":["@wordpress/editor/src/components/post-author/constants.js"],"sourcesContent":["export const BASE_QUERY = {\n\t_fields: 'id,name',\n\tcontext: 'view', // Allows non-admins to perform requests.\n};\n\nexport const AUTHORS_QUERY = {\n\twho: 'authors',\n\tper_page: 50,\n\t...BASE_QUERY,\n};\n"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;EACzBC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,MAAM,CAAE;AAClB,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC5BC,GAAG,EAAE,SAAS;EACdC,QAAQ,EAAE,EAAE;EACZ,GAAGL;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMemo } from '@wordpress/element';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { decodeEntities } from '@wordpress/html-entities';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../../store';
13
+ import { AUTHORS_QUERY, BASE_QUERY } from './constants';
14
+ export function useAuthorsQuery(search) {
15
+ const {
16
+ authorId,
17
+ authors,
18
+ postAuthor
19
+ } = useSelect(select => {
20
+ const {
21
+ getUser,
22
+ getUsers
23
+ } = select(coreStore);
24
+ const {
25
+ getEditedPostAttribute
26
+ } = select(editorStore);
27
+ const _authorId = getEditedPostAttribute('author');
28
+ const query = {
29
+ ...AUTHORS_QUERY
30
+ };
31
+ if (search) {
32
+ query.search = search;
33
+ }
34
+ return {
35
+ authorId: _authorId,
36
+ authors: getUsers(query),
37
+ postAuthor: getUser(_authorId, BASE_QUERY)
38
+ };
39
+ }, [search]);
40
+ const authorOptions = useMemo(() => {
41
+ const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
42
+ return {
43
+ value: author.id,
44
+ label: decodeEntities(author.name)
45
+ };
46
+ });
47
+
48
+ // Ensure the current author is included in the dropdown list.
49
+ const foundAuthor = fetchedAuthors.findIndex(({
50
+ value
51
+ }) => postAuthor?.id === value);
52
+ if (foundAuthor < 0 && postAuthor) {
53
+ return [{
54
+ value: postAuthor.id,
55
+ label: decodeEntities(postAuthor.name)
56
+ }, ...fetchedAuthors];
57
+ }
58
+ return fetchedAuthors;
59
+ }, [authors, postAuthor]);
60
+ return {
61
+ authorId,
62
+ authorOptions
63
+ };
64
+ }
65
+ //# sourceMappingURL=hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","useSelect","decodeEntities","store","coreStore","editorStore","AUTHORS_QUERY","BASE_QUERY","useAuthorsQuery","search","authorId","authors","postAuthor","select","getUser","getUsers","getEditedPostAttribute","_authorId","query","authorOptions","fetchedAuthors","map","author","value","id","label","name","foundAuthor","findIndex"],"sources":["@wordpress/editor/src/components/post-author/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\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}\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\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\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\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\treturn { authorId, authorOptions };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,EAAEC,UAAU,QAAQ,aAAa;AAEvD,OAAO,SAASC,eAAeA,CAAEC,MAAM,EAAG;EACzC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAW,CAAC,GAAGX,SAAS,CAChDY,MAAM,IAAM;IACb,MAAM;MAAEC,OAAO;MAAEC;IAAS,CAAC,GAAGF,MAAM,CAAET,SAAU,CAAC;IACjD,MAAM;MAAEY;IAAuB,CAAC,GAAGH,MAAM,CAAER,WAAY,CAAC;IACxD,MAAMY,SAAS,GAAGD,sBAAsB,CAAE,QAAS,CAAC;IACpD,MAAME,KAAK,GAAG;MAAE,GAAGZ;IAAc,CAAC;IAElC,IAAKG,MAAM,EAAG;MACbS,KAAK,CAACT,MAAM,GAAGA,MAAM;IACtB;IAEA,OAAO;MACNC,QAAQ,EAAEO,SAAS;MACnBN,OAAO,EAAEI,QAAQ,CAAEG,KAAM,CAAC;MAC1BN,UAAU,EAAEE,OAAO,CAAEG,SAAS,EAAEV,UAAW;IAC5C,CAAC;EACF,CAAC,EACD,CAAEE,MAAM,CACT,CAAC;EAED,MAAMU,aAAa,GAAGnB,OAAO,CAAE,MAAM;IACpC,MAAMoB,cAAc,GAAG,CAAET,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,EAAGU,GAAG,CAAIC,MAAM,IAAM;MAC3D,OAAO;QACNC,KAAK,EAAED,MAAM,CAACE,EAAE;QAChBC,KAAK,EAAEvB,cAAc,CAAEoB,MAAM,CAACI,IAAK;MACpC,CAAC;IACF,CAAE,CAAC;;IAEH;IACA,MAAMC,WAAW,GAAGP,cAAc,CAACQ,SAAS,CAC3C,CAAE;MAAEL;IAAM,CAAC,KAAMX,UAAU,EAAEY,EAAE,KAAKD,KACrC,CAAC;IAED,IAAKI,WAAW,GAAG,CAAC,IAAIf,UAAU,EAAG;MACpC,OAAO,CACN;QACCW,KAAK,EAAEX,UAAU,CAACY,EAAE;QACpBC,KAAK,EAAEvB,cAAc,CAAEU,UAAU,CAACc,IAAK;MACxC,CAAC,EACD,GAAGN,cAAc,CACjB;IACF;IAEA,OAAOA,cAAc;EACtB,CAAC,EAAE,CAAET,OAAO,EAAEC,UAAU,CAAG,CAAC;EAE5B,OAAO;IAAEF,QAAQ;IAAES;EAAc,CAAC;AACnC"}
@@ -3,38 +3,22 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { __ } from '@wordpress/i18n';
6
- import { useMemo } from '@wordpress/element';
7
- import { useSelect, useDispatch } from '@wordpress/data';
8
- import { decodeEntities } from '@wordpress/html-entities';
6
+ import { useDispatch } from '@wordpress/data';
9
7
  import { SelectControl } from '@wordpress/components';
10
- import { store as coreStore } from '@wordpress/core-data';
11
8
 
12
9
  /**
13
10
  * Internal dependencies
14
11
  */
15
12
  import { store as editorStore } from '../../store';
16
- import { AUTHORS_QUERY } from './constants';
17
- function PostAuthorSelect() {
13
+ import { useAuthorsQuery } from './hook';
14
+ export default function PostAuthorSelect() {
18
15
  const {
19
16
  editPost
20
17
  } = useDispatch(editorStore);
21
18
  const {
22
- postAuthor,
23
- authors
24
- } = useSelect(select => {
25
- return {
26
- postAuthor: select(editorStore).getEditedPostAttribute('author'),
27
- authors: select(coreStore).getUsers(AUTHORS_QUERY)
28
- };
29
- }, []);
30
- const authorOptions = useMemo(() => {
31
- return (authors !== null && authors !== void 0 ? authors : []).map(author => {
32
- return {
33
- value: author.id,
34
- label: decodeEntities(author.name)
35
- };
36
- });
37
- }, [authors]);
19
+ authorId,
20
+ authorOptions
21
+ } = useAuthorsQuery();
38
22
  const setAuthorId = value => {
39
23
  const author = Number(value);
40
24
  editPost({
@@ -48,8 +32,7 @@ function PostAuthorSelect() {
48
32
  label: __('Author'),
49
33
  options: authorOptions,
50
34
  onChange: setAuthorId,
51
- value: postAuthor
35
+ value: authorId
52
36
  });
53
37
  }
54
- export default PostAuthorSelect;
55
38
  //# sourceMappingURL=select.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","useMemo","useSelect","useDispatch","decodeEntities","SelectControl","store","coreStore","editorStore","AUTHORS_QUERY","PostAuthorSelect","editPost","postAuthor","authors","select","getEditedPostAttribute","getUsers","authorOptions","map","author","value","id","label","name","setAuthorId","Number","createElement","__next40pxDefaultSize","__nextHasNoMarginBottom","className","options","onChange"],"sources":["@wordpress/editor/src/components/post-author/select.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { postAuthor, authors } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostAuthor:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'author' ),\n\t\t\tauthors: select( coreStore ).getUsers( AUTHORS_QUERY ),\n\t\t};\n\t}, [] );\n\n\tconst authorOptions = useMemo( () => {\n\t\treturn ( 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\t}, [ authors ] );\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ postAuthor }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorSelect;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,aAAa,QAAQ,aAAa;AAE3C,SAASC,gBAAgBA,CAAA,EAAG;EAC3B,MAAM;IAAEC;EAAS,CAAC,GAAGR,WAAW,CAAEK,WAAY,CAAC;EAC/C,MAAM;IAAEI,UAAU;IAAEC;EAAQ,CAAC,GAAGX,SAAS,CAAIY,MAAM,IAAM;IACxD,OAAO;MACNF,UAAU,EACTE,MAAM,CAAEN,WAAY,CAAC,CAACO,sBAAsB,CAAE,QAAS,CAAC;MACzDF,OAAO,EAAEC,MAAM,CAAEP,SAAU,CAAC,CAACS,QAAQ,CAAEP,aAAc;IACtD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMQ,aAAa,GAAGhB,OAAO,CAAE,MAAM;IACpC,OAAO,CAAEY,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,EAAGK,GAAG,CAAIC,MAAM,IAAM;MAC3C,OAAO;QACNC,KAAK,EAAED,MAAM,CAACE,EAAE;QAChBC,KAAK,EAAElB,cAAc,CAAEe,MAAM,CAACI,IAAK;MACpC,CAAC;IACF,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEV,OAAO,CAAG,CAAC;EAEhB,MAAMW,WAAW,GAAKJ,KAAK,IAAM;IAChC,MAAMD,MAAM,GAAGM,MAAM,CAAEL,KAAM,CAAC;IAC9BT,QAAQ,CAAE;MAAEQ;IAAO,CAAE,CAAC;EACvB,CAAC;EAED,OACCO,aAAA,CAACrB,aAAa;IACbsB,qBAAqB;IACrBC,uBAAuB;IACvBC,SAAS,EAAC,sBAAsB;IAChCP,KAAK,EAAGtB,EAAE,CAAE,QAAS,CAAG;IACxB8B,OAAO,EAAGb,aAAe;IACzBc,QAAQ,EAAGP,WAAa;IACxBJ,KAAK,EAAGR;EAAY,CACpB,CAAC;AAEJ;AAEA,eAAeF,gBAAgB"}
1
+ {"version":3,"names":["__","useDispatch","SelectControl","store","editorStore","useAuthorsQuery","PostAuthorSelect","editPost","authorId","authorOptions","setAuthorId","value","author","Number","createElement","__next40pxDefaultSize","__nextHasNoMarginBottom","className","label","options","onChange"],"sources":["@wordpress/editor/src/components/post-author/select.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { SelectControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { useAuthorsQuery } from './hook';\n\nexport default function PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { authorId, authorOptions } = useAuthorsQuery();\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ authorId }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,aAAa,QAAQ,uBAAuB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,eAAe,QAAQ,QAAQ;AAExC,eAAe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC;EAAS,CAAC,GAAGN,WAAW,CAAEG,WAAY,CAAC;EAC/C,MAAM;IAAEI,QAAQ;IAAEC;EAAc,CAAC,GAAGJ,eAAe,CAAC,CAAC;EAErD,MAAMK,WAAW,GAAKC,KAAK,IAAM;IAChC,MAAMC,MAAM,GAAGC,MAAM,CAAEF,KAAM,CAAC;IAC9BJ,QAAQ,CAAE;MAAEK;IAAO,CAAE,CAAC;EACvB,CAAC;EAED,OACCE,aAAA,CAACZ,aAAa;IACba,qBAAqB;IACrBC,uBAAuB;IACvBC,SAAS,EAAC,sBAAsB;IAChCC,KAAK,EAAGlB,EAAE,CAAE,QAAS,CAAG;IACxBmB,OAAO,EAAGV,aAAe;IACzBW,QAAQ,EAAGV,WAAa;IACxBC,KAAK,EAAGH;EAAU,CAClB,CAAC;AAEJ"}
@@ -2,7 +2,7 @@ import { createElement } from "react";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
- import { sprintf, _n } from '@wordpress/i18n';
5
+ import { sprintf, __ } from '@wordpress/i18n';
6
6
  import { Button } from '@wordpress/components';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { backup } from '@wordpress/icons';
@@ -32,9 +32,11 @@ function LastRevision() {
32
32
  revision: lastRevisionId
33
33
  }),
34
34
  className: "editor-post-last-revision__title",
35
- icon: backup
36
- }, sprintf( /* translators: %d: number of revisions */
37
- _n('%d Revision', '%d Revisions', revisionsCount), revisionsCount)));
35
+ icon: backup,
36
+ iconPosition: "right",
37
+ text: sprintf( /* translators: %s: number of revisions */
38
+ __('Revisions (%s)'), revisionsCount)
39
+ }));
38
40
  }
39
41
  export default LastRevision;
40
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sprintf","_n","Button","useSelect","backup","addQueryArgs","PostLastRevisionCheck","store","editorStore","LastRevision","lastRevisionId","revisionsCount","select","getCurrentPostLastRevisionId","getCurrentPostRevisionsCount","createElement","href","revision","className","icon"],"sources":["@wordpress/editor/src/components/post-last-revision/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, _n } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from './check';\nimport { store as editorStore } from '../../store';\n\nfunction LastRevision() {\n\tconst { lastRevisionId, revisionsCount } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<Button\n\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t} ) }\n\t\t\t\tclassName=\"editor-post-last-revision__title\"\n\t\t\t\ticon={ backup }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: %d: number of revisions */\n\t\t\t\t\t_n( '%d Revision', '%d Revisions', revisionsCount ),\n\t\t\t\t\trevisionsCount\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</PostLastRevisionCheck>\n\t);\n}\n\nexport default LastRevision;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,SAAS;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,SAASC,YAAYA,CAAA,EAAG;EACvB,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACnE,MAAM;MAAEC,4BAA4B;MAAEC;IAA6B,CAAC,GACnEF,MAAM,CAAEJ,WAAY,CAAC;IACtB,OAAO;MACNE,cAAc,EAAEG,4BAA4B,CAAC,CAAC;MAC9CF,cAAc,EAAEG,4BAA4B,CAAC;IAC9C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OACCC,aAAA,CAACT,qBAAqB,QACrBS,aAAA,CAACb,MAAM;IACNc,IAAI,EAAGX,YAAY,CAAE,cAAc,EAAE;MACpCY,QAAQ,EAAEP;IACX,CAAE,CAAG;IACLQ,SAAS,EAAC,kCAAkC;IAC5CC,IAAI,EAAGf;EAAQ,GAEbJ,OAAO,EACR;EACAC,EAAE,CAAE,aAAa,EAAE,cAAc,EAAEU,cAAe,CAAC,EACnDA,cACD,CACO,CACc,CAAC;AAE1B;AAEA,eAAeF,YAAY"}
1
+ {"version":3,"names":["sprintf","__","Button","useSelect","backup","addQueryArgs","PostLastRevisionCheck","store","editorStore","LastRevision","lastRevisionId","revisionsCount","select","getCurrentPostLastRevisionId","getCurrentPostRevisionsCount","createElement","href","revision","className","icon","iconPosition","text"],"sources":["@wordpress/editor/src/components/post-last-revision/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevisionCheck from './check';\nimport { store as editorStore } from '../../store';\n\nfunction LastRevision() {\n\tconst { lastRevisionId, revisionsCount } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tlastRevisionId: getCurrentPostLastRevisionId(),\n\t\t\trevisionsCount: getCurrentPostRevisionsCount(),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<Button\n\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t} ) }\n\t\t\t\tclassName=\"editor-post-last-revision__title\"\n\t\t\t\ticon={ backup }\n\t\t\t\ticonPosition=\"right\"\n\t\t\t\ttext={ sprintf(\n\t\t\t\t\t/* translators: %s: number of revisions */\n\t\t\t\t\t__( 'Revisions (%s)' ),\n\t\t\t\t\trevisionsCount\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostLastRevisionCheck>\n\t);\n}\n\nexport default LastRevision;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,EAAE,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,SAAS;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,SAASC,YAAYA,CAAA,EAAG;EACvB,MAAM;IAAEC,cAAc;IAAEC;EAAe,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACnE,MAAM;MAAEC,4BAA4B;MAAEC;IAA6B,CAAC,GACnEF,MAAM,CAAEJ,WAAY,CAAC;IACtB,OAAO;MACNE,cAAc,EAAEG,4BAA4B,CAAC,CAAC;MAC9CF,cAAc,EAAEG,4BAA4B,CAAC;IAC9C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OACCC,aAAA,CAACT,qBAAqB,QACrBS,aAAA,CAACb,MAAM;IACNc,IAAI,EAAGX,YAAY,CAAE,cAAc,EAAE;MACpCY,QAAQ,EAAEP;IACX,CAAE,CAAG;IACLQ,SAAS,EAAC,kCAAkC;IAC5CC,IAAI,EAAGf,MAAQ;IACfgB,YAAY,EAAC,OAAO;IACpBC,IAAI,EAAGrB,OAAO,EACb;IACAC,EAAE,CAAE,gBAAiB,CAAC,EACtBU,cACD;EAAG,CACH,CACqB,CAAC;AAE1B;AAEA,eAAeF,YAAY"}