@wordpress/editor 13.27.2 → 13.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/post-meta.js +1 -2
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/autocompleters/user.js +1 -2
  5. package/build/components/autocompleters/user.js.map +1 -1
  6. package/build/components/autosave-monitor/index.js +1 -2
  7. package/build/components/autosave-monitor/index.js.map +1 -1
  8. package/build/components/block-manager/category.js +1 -2
  9. package/build/components/block-manager/category.js.map +1 -1
  10. package/build/components/block-manager/checklist.js +1 -2
  11. package/build/components/block-manager/checklist.js.map +1 -1
  12. package/build/components/block-manager/index.js +1 -2
  13. package/build/components/block-manager/index.js.map +1 -1
  14. package/build/components/deprecated.js +52 -104
  15. package/build/components/deprecated.js.map +1 -1
  16. package/build/components/document-bar/index.js +5 -6
  17. package/build/components/document-bar/index.js.map +1 -1
  18. package/build/components/document-outline/check.js +1 -2
  19. package/build/components/document-outline/check.js.map +1 -1
  20. package/build/components/document-outline/index.js +1 -2
  21. package/build/components/document-outline/index.js.map +1 -1
  22. package/build/components/document-outline/item.js +1 -2
  23. package/build/components/document-outline/item.js.map +1 -1
  24. package/build/components/document-tools/index.js +1 -2
  25. package/build/components/document-tools/index.js.map +1 -1
  26. package/build/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  27. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  28. package/build/components/editor-canvas/index.js +14 -10
  29. package/build/components/editor-canvas/index.js.map +1 -1
  30. package/build/components/editor-help/add-blocks.native.js +1 -2
  31. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  32. package/build/components/editor-help/customize-blocks.native.js +1 -2
  33. package/build/components/editor-help/customize-blocks.native.js.map +1 -1
  34. package/build/components/editor-help/help-detail-navigation-screen.native.js +1 -2
  35. package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  36. package/build/components/editor-help/help-get-support-button.native.js +1 -2
  37. package/build/components/editor-help/help-get-support-button.native.js.map +1 -1
  38. package/build/components/editor-help/help-section-title.native.js +1 -2
  39. package/build/components/editor-help/help-section-title.native.js.map +1 -1
  40. package/build/components/editor-help/help-topic-row.native.js +1 -2
  41. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  42. package/build/components/editor-help/icon-move-blocks.native.js +1 -2
  43. package/build/components/editor-help/icon-move-blocks.native.js.map +1 -1
  44. package/build/components/editor-help/index.native.js +1 -2
  45. package/build/components/editor-help/index.native.js.map +1 -1
  46. package/build/components/editor-help/intro-to-blocks.native.js +1 -2
  47. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  48. package/build/components/editor-help/move-blocks.native.js +1 -2
  49. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  50. package/build/components/editor-help/remove-blocks.native.js +1 -2
  51. package/build/components/editor-help/remove-blocks.native.js.map +1 -1
  52. package/build/components/editor-history/redo.js +1 -2
  53. package/build/components/editor-history/redo.js.map +1 -1
  54. package/build/components/editor-history/undo.js +1 -2
  55. package/build/components/editor-history/undo.js.map +1 -1
  56. package/build/components/editor-notices/index.js +1 -2
  57. package/build/components/editor-notices/index.js.map +1 -1
  58. package/build/components/editor-snackbars/index.js +3 -1
  59. package/build/components/editor-snackbars/index.js.map +1 -1
  60. package/build/components/entities-saved-states/entity-record-item.js +1 -1
  61. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  62. package/build/components/entities-saved-states/entity-type-list.js +7 -7
  63. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  64. package/build/components/entities-saved-states/index.js +4 -1
  65. package/build/components/entities-saved-states/index.js.map +1 -1
  66. package/build/components/error-boundary/index.js +1 -2
  67. package/build/components/error-boundary/index.js.map +1 -1
  68. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -2
  69. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  70. package/build/components/index.js +4 -6
  71. package/build/components/index.js.map +1 -1
  72. package/build/components/list-view-sidebar/index.js +43 -36
  73. package/build/components/list-view-sidebar/index.js.map +1 -1
  74. package/build/components/local-autosave-monitor/index.js +1 -2
  75. package/build/components/local-autosave-monitor/index.js.map +1 -1
  76. package/build/components/media-categories/index.js +1 -2
  77. package/build/components/media-categories/index.js.map +1 -1
  78. package/build/components/offline-status/index.native.js +1 -2
  79. package/build/components/offline-status/index.native.js.map +1 -1
  80. package/build/components/page-attributes/check.js +1 -2
  81. package/build/components/page-attributes/check.js.map +1 -1
  82. package/build/components/page-attributes/panel.js +1 -2
  83. package/build/components/page-attributes/panel.js.map +1 -1
  84. package/build/components/page-attributes/parent.js +1 -2
  85. package/build/components/page-attributes/parent.js.map +1 -1
  86. package/build/components/post-author/combobox.js +6 -60
  87. package/build/components/post-author/combobox.js.map +1 -1
  88. package/build/components/post-author/constants.js +7 -5
  89. package/build/components/post-author/constants.js.map +1 -1
  90. package/build/components/post-author/hook.js +72 -0
  91. package/build/components/post-author/hook.js.map +1 -0
  92. package/build/components/post-author/index.js +1 -2
  93. package/build/components/post-author/index.js.map +1 -1
  94. package/build/components/post-author/panel.js +1 -2
  95. package/build/components/post-author/panel.js.map +1 -1
  96. package/build/components/post-author/select.js +6 -24
  97. package/build/components/post-author/select.js.map +1 -1
  98. package/build/components/post-comments/index.js +1 -2
  99. package/build/components/post-comments/index.js.map +1 -1
  100. package/build/components/post-discussion/panel.js +1 -2
  101. package/build/components/post-discussion/panel.js.map +1 -1
  102. package/build/components/post-excerpt/check.js +1 -2
  103. package/build/components/post-excerpt/check.js.map +1 -1
  104. package/build/components/post-excerpt/index.js +1 -2
  105. package/build/components/post-excerpt/index.js.map +1 -1
  106. package/build/components/post-excerpt/plugin.js +1 -2
  107. package/build/components/post-excerpt/plugin.js.map +1 -1
  108. package/build/components/post-featured-image/check.js +1 -2
  109. package/build/components/post-featured-image/check.js.map +1 -1
  110. package/build/components/post-featured-image/index.js +1 -2
  111. package/build/components/post-featured-image/index.js.map +1 -1
  112. package/build/components/post-featured-image/panel.js +1 -2
  113. package/build/components/post-featured-image/panel.js.map +1 -1
  114. package/build/components/post-format/check.js +1 -2
  115. package/build/components/post-format/check.js.map +1 -1
  116. package/build/components/post-format/index.js +1 -2
  117. package/build/components/post-format/index.js.map +1 -1
  118. package/build/components/post-last-revision/check.js +1 -2
  119. package/build/components/post-last-revision/check.js.map +1 -1
  120. package/build/components/post-last-revision/index.js +6 -5
  121. package/build/components/post-last-revision/index.js.map +1 -1
  122. package/build/components/post-last-revision/panel.js +1 -2
  123. package/build/components/post-last-revision/panel.js.map +1 -1
  124. package/build/components/post-panel-row/index.js +1 -2
  125. package/build/components/post-panel-row/index.js.map +1 -1
  126. package/build/components/post-pending-status/check.js +1 -2
  127. package/build/components/post-pending-status/check.js.map +1 -1
  128. package/build/components/post-pending-status/index.js +1 -2
  129. package/build/components/post-pending-status/index.js.map +1 -1
  130. package/build/components/post-pingbacks/index.js +1 -2
  131. package/build/components/post-pingbacks/index.js.map +1 -1
  132. package/build/components/post-publish-button/index.js +1 -2
  133. package/build/components/post-publish-button/index.js.map +1 -1
  134. package/build/components/post-publish-button/label.js +1 -2
  135. package/build/components/post-publish-button/label.js.map +1 -1
  136. package/build/components/post-publish-panel/index.js +1 -2
  137. package/build/components/post-publish-panel/index.js.map +1 -1
  138. package/build/components/post-publish-panel/maybe-category-panel.js +1 -2
  139. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  140. package/build/components/post-publish-panel/maybe-tags-panel.js +22 -26
  141. package/build/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  142. package/build/components/post-publish-panel/postpublish.js +1 -2
  143. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  144. package/build/components/post-publish-panel/prepublish.js +1 -2
  145. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  146. package/build/components/post-schedule/index.js +0 -1
  147. package/build/components/post-schedule/index.js.map +1 -1
  148. package/build/components/post-schedule/label.js +1 -1
  149. package/build/components/post-schedule/label.js.map +1 -1
  150. package/build/components/post-schedule/panel.js +1 -0
  151. package/build/components/post-schedule/panel.js.map +1 -1
  152. package/build/components/post-slug/index.js +1 -2
  153. package/build/components/post-slug/index.js.map +1 -1
  154. package/build/components/post-switch-to-draft-button/index.js +1 -0
  155. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  156. package/build/components/post-sync-status/index.js +1 -1
  157. package/build/components/post-sync-status/index.js.map +1 -1
  158. package/build/components/post-taxonomies/check.js +8 -15
  159. package/build/components/post-taxonomies/check.js.map +1 -1
  160. package/build/components/post-taxonomies/flat-term-selector.js +1 -2
  161. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  162. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  163. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  164. package/build/components/post-taxonomies/index.js +14 -15
  165. package/build/components/post-taxonomies/index.js.map +1 -1
  166. package/build/components/post-taxonomies/panel.js +1 -2
  167. package/build/components/post-taxonomies/panel.js.map +1 -1
  168. package/build/components/post-template/block-theme.js +12 -11
  169. package/build/components/post-template/block-theme.js.map +1 -1
  170. package/build/components/post-template/classic-theme.js +10 -11
  171. package/build/components/post-template/classic-theme.js.map +1 -1
  172. package/build/components/post-template/create-new-template-modal.js +4 -5
  173. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  174. package/build/components/post-template/panel.js +5 -1
  175. package/build/components/post-template/panel.js.map +1 -1
  176. package/build/components/post-title/constants.js +2 -4
  177. package/build/components/post-title/constants.js.map +1 -1
  178. package/build/components/post-title/index.js +2 -3
  179. package/build/components/post-title/index.js.map +1 -1
  180. package/build/components/post-title/index.native.js +1 -2
  181. package/build/components/post-title/index.native.js.map +1 -1
  182. package/build/components/post-title/post-title-raw.js +1 -2
  183. package/build/components/post-title/post-title-raw.js.map +1 -1
  184. package/build/components/post-trash/check.js +1 -2
  185. package/build/components/post-trash/check.js.map +1 -1
  186. package/build/components/post-trash/index.js +1 -0
  187. package/build/components/post-trash/index.js.map +1 -1
  188. package/build/components/post-type-support-check/index.js +1 -2
  189. package/build/components/post-type-support-check/index.js.map +1 -1
  190. package/build/components/post-url/panel.js +1 -0
  191. package/build/components/post-url/panel.js.map +1 -1
  192. package/build/components/post-visibility/utils.js +1 -2
  193. package/build/components/post-visibility/utils.js.map +1 -1
  194. package/build/components/preferences-modal/enable-panel.js +1 -2
  195. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  196. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +1 -2
  197. package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -1
  198. package/build/components/preferences-modal/index.js +0 -1
  199. package/build/components/preferences-modal/index.js.map +1 -1
  200. package/build/components/provider/constants.js +1 -2
  201. package/build/components/provider/constants.js.map +1 -1
  202. package/build/components/provider/index.js +12 -6
  203. package/build/components/provider/index.js.map +1 -1
  204. package/build/components/provider/index.native.js +4 -6
  205. package/build/components/provider/index.native.js.map +1 -1
  206. package/build/components/provider/use-block-editor-settings.js +2 -3
  207. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  208. package/build/components/provider/use-block-editor-settings.native.js +1 -2
  209. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  210. package/build/components/provider/with-registry-provider.js +1 -2
  211. package/build/components/provider/with-registry-provider.js.map +1 -1
  212. package/build/components/table-of-contents/index.js +1 -2
  213. package/build/components/table-of-contents/index.js.map +1 -1
  214. package/build/components/table-of-contents/panel.js +1 -2
  215. package/build/components/table-of-contents/panel.js.map +1 -1
  216. package/build/components/template-validation-notice/index.js +1 -2
  217. package/build/components/template-validation-notice/index.js.map +1 -1
  218. package/build/components/theme-support-check/index.js +1 -2
  219. package/build/components/theme-support-check/index.js.map +1 -1
  220. package/build/hooks/pattern-partial-syncing.js +9 -2
  221. package/build/hooks/pattern-partial-syncing.js.map +1 -1
  222. package/build/private-apis.js +1 -2
  223. package/build/private-apis.js.map +1 -1
  224. package/build/store/actions.js +31 -62
  225. package/build/store/actions.js.map +1 -1
  226. package/build/store/constants.js +7 -14
  227. package/build/store/constants.js.map +1 -1
  228. package/build/store/defaults.js +1 -2
  229. package/build/store/defaults.js.map +1 -1
  230. package/build/store/index.js +4 -6
  231. package/build/store/index.js.map +1 -1
  232. package/build/store/private-selectors.js +1 -2
  233. package/build/store/private-selectors.js.map +1 -1
  234. package/build/store/reducer.js +1 -2
  235. package/build/store/reducer.js.map +1 -1
  236. package/build/store/reducer.native.js +2 -4
  237. package/build/store/reducer.native.js.map +1 -1
  238. package/build/store/selectors.js +72 -144
  239. package/build/store/selectors.js.map +1 -1
  240. package/build/store/selectors.native.js +1 -2
  241. package/build/store/selectors.native.js.map +1 -1
  242. package/build-module/components/document-bar/index.js +5 -6
  243. package/build-module/components/document-bar/index.js.map +1 -1
  244. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +11 -18
  245. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  246. package/build-module/components/editor-canvas/index.js +13 -8
  247. package/build-module/components/editor-canvas/index.js.map +1 -1
  248. package/build-module/components/editor-snackbars/index.js +4 -1
  249. package/build-module/components/editor-snackbars/index.js.map +1 -1
  250. package/build-module/components/entities-saved-states/entity-record-item.js +1 -1
  251. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  252. package/build-module/components/entities-saved-states/entity-type-list.js +8 -8
  253. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  254. package/build-module/components/entities-saved-states/index.js +6 -3
  255. package/build-module/components/entities-saved-states/index.js.map +1 -1
  256. package/build-module/components/list-view-sidebar/index.js +44 -37
  257. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  258. package/build-module/components/post-author/combobox.js +8 -61
  259. package/build-module/components/post-author/combobox.js.map +1 -1
  260. package/build-module/components/post-author/constants.js +5 -2
  261. package/build-module/components/post-author/constants.js.map +1 -1
  262. package/build-module/components/post-author/hook.js +65 -0
  263. package/build-module/components/post-author/hook.js.map +1 -0
  264. package/build-module/components/post-author/select.js +7 -24
  265. package/build-module/components/post-author/select.js.map +1 -1
  266. package/build-module/components/post-last-revision/index.js +6 -4
  267. package/build-module/components/post-last-revision/index.js.map +1 -1
  268. package/build-module/components/post-publish-panel/maybe-tags-panel.js +24 -27
  269. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  270. package/build-module/components/post-schedule/index.js +0 -1
  271. package/build-module/components/post-schedule/index.js.map +1 -1
  272. package/build-module/components/post-schedule/label.js +1 -1
  273. package/build-module/components/post-schedule/label.js.map +1 -1
  274. package/build-module/components/post-schedule/panel.js +1 -0
  275. package/build-module/components/post-schedule/panel.js.map +1 -1
  276. package/build-module/components/post-switch-to-draft-button/index.js +1 -0
  277. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  278. package/build-module/components/post-sync-status/index.js +1 -1
  279. package/build-module/components/post-sync-status/index.js.map +1 -1
  280. package/build-module/components/post-taxonomies/check.js +9 -14
  281. package/build-module/components/post-taxonomies/check.js.map +1 -1
  282. package/build-module/components/post-taxonomies/index.js +15 -15
  283. package/build-module/components/post-taxonomies/index.js.map +1 -1
  284. package/build-module/components/post-template/block-theme.js +12 -11
  285. package/build-module/components/post-template/block-theme.js.map +1 -1
  286. package/build-module/components/post-template/classic-theme.js +9 -9
  287. package/build-module/components/post-template/classic-theme.js.map +1 -1
  288. package/build-module/components/post-template/create-new-template-modal.js +4 -5
  289. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  290. package/build-module/components/post-template/panel.js +5 -1
  291. package/build-module/components/post-template/panel.js.map +1 -1
  292. package/build-module/components/post-title/index.js +1 -2
  293. package/build-module/components/post-title/index.js.map +1 -1
  294. package/build-module/components/post-trash/index.js +1 -0
  295. package/build-module/components/post-trash/index.js.map +1 -1
  296. package/build-module/components/post-url/panel.js +1 -0
  297. package/build-module/components/post-url/panel.js.map +1 -1
  298. package/build-module/components/preferences-modal/index.js +0 -1
  299. package/build-module/components/preferences-modal/index.js.map +1 -1
  300. package/build-module/components/provider/index.js +10 -2
  301. package/build-module/components/provider/index.js.map +1 -1
  302. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  303. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  304. package/build-module/components/table-of-contents/panel.js +0 -1
  305. package/build-module/components/table-of-contents/panel.js.map +1 -1
  306. package/build-module/hooks/pattern-partial-syncing.js +9 -2
  307. package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
  308. package/build-style/style-rtl.css +28 -22
  309. package/build-style/style.css +28 -22
  310. package/package.json +32 -32
  311. package/src/components/document-bar/index.js +22 -17
  312. package/src/components/editor-canvas/edit-template-blocks-notification.js +31 -30
  313. package/src/components/editor-canvas/index.js +14 -4
  314. package/src/components/editor-snackbars/index.js +6 -3
  315. package/src/components/entities-saved-states/entity-record-item.js +1 -4
  316. package/src/components/entities-saved-states/entity-type-list.js +8 -8
  317. package/src/components/entities-saved-states/index.js +17 -4
  318. package/src/components/entities-saved-states/style.scss +5 -0
  319. package/src/components/list-view-sidebar/index.js +60 -47
  320. package/src/components/list-view-sidebar/style.scss +20 -20
  321. package/src/components/post-author/combobox.js +5 -61
  322. package/src/components/post-author/constants.js +6 -2
  323. package/src/components/post-author/hook.js +63 -0
  324. package/src/components/post-author/select.js +5 -25
  325. package/src/components/post-last-revision/index.js +6 -6
  326. package/src/components/post-last-revision/style.scss +3 -6
  327. package/src/components/post-panel-row/style.scss +3 -3
  328. package/src/components/post-publish-panel/maybe-tags-panel.js +27 -37
  329. package/src/components/post-publish-panel/style.scss +3 -1
  330. package/src/components/post-schedule/label.js +1 -1
  331. package/src/components/post-schedule/panel.js +1 -0
  332. package/src/components/post-schedule/test/label.js +19 -7
  333. package/src/components/post-switch-to-draft-button/index.js +1 -0
  334. package/src/components/post-sync-status/index.js +8 -2
  335. package/src/components/post-taxonomies/check.js +11 -15
  336. package/src/components/post-taxonomies/index.js +15 -22
  337. package/src/components/post-taxonomies/test/index.js +37 -51
  338. package/src/components/post-template/block-theme.js +29 -22
  339. package/src/components/post-template/classic-theme.js +10 -13
  340. package/src/components/post-template/create-new-template-modal.js +7 -9
  341. package/src/components/post-template/panel.js +5 -1
  342. package/src/components/post-trash/index.js +1 -0
  343. package/src/components/post-url/panel.js +1 -0
  344. package/src/components/provider/index.js +22 -2
  345. package/src/components/provider/use-block-editor-settings.js +1 -1
  346. package/src/hooks/pattern-partial-syncing.js +23 -4
@@ -57,7 +57,6 @@ export default function PostSchedule({
57
57
  .replace(/\\\\/g, '') // Replace "//" with empty strings.
58
58
  .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
59
59
  );
60
-
61
60
  return createElement(PublishDateTimePicker, {
62
61
  currentDate: postDate,
63
62
  onChange: onUpdateDate,
@@ -1 +1 @@
1
- {"version":3,"names":["parseISO","endOfMonth","startOfMonth","getSettings","useDispatch","useSelect","__experimentalPublishDateTimePicker","PublishDateTimePicker","useState","useMemo","store","coreStore","editorStore","PostSchedule","onClose","postDate","postType","select","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","date","previewedMonth","setPreviewedMonth","Date","eventsByPostType","getEntityRecords","status","after","toISOString","before","exclude","getCurrentPostId","per_page","_fields","events","map","eventDate","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join","createElement","currentDate","onChange","is12Hour","onMonthPreviewed"],"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { parseISO, endOfMonth, startOfMonth } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { getSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tstartOfMonth( new Date( postDate ) )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: startOfMonth( previewedMonth ).toISOString(),\n\t\t\t\tbefore: endOfMonth( previewedMonth ).toISOString(),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t\tper_page: 100,\n\t\t\t\t_fields: 'id,date',\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map( ( { date: eventDate } ) => ( {\n\t\t\t\tdate: new Date( eventDate ),\n\t\t\t} ) ),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = getSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ ( date ) =>\n\t\t\t\tsetPreviewedMonth( parseISO( date ) )\n\t\t\t}\n\t\t\tonClose={ onClose }\n\t\t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DC,MAAM,EAAE9B,UAAU,CAAEsB,cAAe,CAAC,CAACO,WAAW,CAAC,CAAC;IAClDE,OAAO,EAAE,CAAEf,MAAM,CAAEL,WAAY,CAAC,CAACqB,gBAAgB,CAAC,CAAC,CAAE;IACrDC,QAAQ,EAAE,GAAG;IACbC,OAAO,EAAE;EACV,CAAE,CAAC,EACJ,CAAEZ,cAAc,EAAEP,QAAQ,CAC3B,CAAC;EAED,MAAMoB,MAAM,GAAG3B,OAAO,CACrB,MACC,CAAEiB,gBAAgB,IAAI,EAAE,EAAGW,GAAG,CAAE,CAAE;IAAEf,IAAI,EAAEgB;EAAU,CAAC,MAAQ;IAC5DhB,IAAI,EAAE,IAAIG,IAAI,CAAEa,SAAU;EAC3B,CAAC,CAAG,CAAC,EACN,CAAEZ,gBAAgB,CACnB,CAAC;EAED,MAAMa,QAAQ,GAAGpC,WAAW,CAAC,CAAC;;EAE9B;EACA;EACA,MAAMqC,YAAY,GAAG,UAAU,CAACC,IAAI,CACnCF,QAAQ,CAACG,OAAO,CAACC,IAAI,CACnBC,WAAW,CAAC,CAAC,CAAC;EAAA,CACdC,OAAO,CAAE,OAAO,EAAE,EAAG,CAAC,CAAC;EAAA,CACvBC,KAAK,CAAE,EAAG,CAAC,CACXC,OAAO,CAAC,CAAC,CACTC,IAAI,CAAE,EAAG,CAAC,CAAC;EACd,CAAC;;EAED,OACCC,aAAA,CAAC1C,qBAAqB;IACrB2C,WAAW,EAAGnC,QAAU;IACxBoC,QAAQ,EAAG9B,YAAc;IACzB+B,QAAQ,EAAGZ,YAAc;IACzBJ,MAAM,EAAGA,MAAQ;IACjBiB,gBAAgB,EAAK/B,IAAI,IACxBE,iBAAiB,CAAExB,QAAQ,CAAEsB,IAAK,CAAE,CACpC;IACDR,OAAO,EAAGA;EAAS,CACnB,CAAC;AAEJ"}
1
+ {"version":3,"names":["parseISO","endOfMonth","startOfMonth","getSettings","useDispatch","useSelect","__experimentalPublishDateTimePicker","PublishDateTimePicker","useState","useMemo","store","coreStore","editorStore","PostSchedule","onClose","postDate","postType","select","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","date","previewedMonth","setPreviewedMonth","Date","eventsByPostType","getEntityRecords","status","after","toISOString","before","exclude","getCurrentPostId","per_page","_fields","events","map","eventDate","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join","createElement","currentDate","onChange","is12Hour","onMonthPreviewed"],"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { parseISO, endOfMonth, startOfMonth } from 'date-fns';\n\n/**\n * WordPress dependencies\n */\nimport { getSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tstartOfMonth( new Date( postDate ) )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: startOfMonth( previewedMonth ).toISOString(),\n\t\t\t\tbefore: endOfMonth( previewedMonth ).toISOString(),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t\tper_page: 100,\n\t\t\t\t_fields: 'id,date',\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map( ( { date: eventDate } ) => ( {\n\t\t\t\tdate: new Date( eventDate ),\n\t\t\t} ) ),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = getSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ ( date ) =>\n\t\t\t\tsetPreviewedMonth( parseISO( date ) )\n\t\t\t}\n\t\t\tonClose={ onClose }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,UAAU,EAAEC,YAAY,QAAQ,UAAU;;AAE7D;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,mCAAmC,IAAIC,qBAAqB,QAAQ,yBAAyB;AACtG,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,YAAYA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EACnD,MAAM;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGX,SAAS,CACrCY,MAAM,KAAQ;I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,CAAC,CAAC;;EAE9B;EACA;EACA,MAAMqC,YAAY,GAAG,UAAU,CAACC,IAAI,CACnCF,QAAQ,CAACG,OAAO,CAACC,IAAI,CACnBC,WAAW,CAAC,CAAC,CAAC;EAAA,CACdC,OAAO,CAAE,OAAO,EAAE,EAAG,CAAC,CAAC;EAAA,CACvBC,KAAK,CAAE,EAAG,CAAC,CACXC,OAAO,CAAC,CAAC,CACTC,IAAI,CAAE,EAAG,CAAC,CAAC;EACd,CAAC;EAED,OACCC,aAAA,CAAC1C,qBAAqB;IACrB2C,WAAW,EAAGnC,QAAU;IACxBoC,QAAQ,EAAG9B,YAAc;IACzB+B,QAAQ,EAAGZ,YAAc;IACzBJ,MAAM,EAAGA,MAAQ;IACjBiB,gBAAgB,EAAK/B,IAAI,IACxBE,iBAAiB,CAAExB,QAAQ,CAAEsB,IAAK,CAAE,CACpC;IACDR,OAAO,EAAGA;EAAS,CACnB,CAAC;AAEJ"}
@@ -81,7 +81,7 @@ function getTimezoneAbbreviation() {
81
81
  return timezone.abbr;
82
82
  }
83
83
  const symbol = timezone.offset < 0 ? '' : '+';
84
- return `UTC${symbol}${timezone.offset}`;
84
+ return `UTC${symbol}${timezone.offsetFormatted}`;
85
85
  }
86
86
  function isTimezoneSameAsSiteTimezone(date) {
87
87
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["__","_x","sprintf","isRTL","getSettings","getDate","dateI18n","useSelect","store","editorStore","PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getSettings, getDate, dateI18n } from '@wordpress/date';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostScheduleLabel( props ) {\n\treturn usePostScheduleLabel( props );\n}\n\nexport function usePostScheduleLabel( { full = false } = {} ) {\n\tconst { date, isFloating } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tisFloating: select( editorStore ).isEditedPostDateFloating(),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn full\n\t\t? getFullPostScheduleLabel( date )\n\t\t: getPostScheduleLabel( date, { isFloating } );\n}\n\nexport function getFullPostScheduleLabel( dateAttribute ) {\n\tconst date = getDate( dateAttribute );\n\n\tconst timezoneAbbreviation = getTimezoneAbbreviation();\n\tconst formattedDate = dateI18n(\n\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n\treturn isRTL()\n\t\t? `${ timezoneAbbreviation } ${ formattedDate }`\n\t\t: `${ formattedDate } ${ timezoneAbbreviation }`;\n}\n\nexport function getPostScheduleLabel(\n\tdateAttribute,\n\t{ isFloating = false, now = new Date() } = {}\n) {\n\tif ( ! dateAttribute || isFloating ) {\n\t\treturn __( 'Immediately' );\n\t}\n\n\t// If the user timezone does not equal the site timezone then using words\n\t// like 'tomorrow' is confusing, so show the full date.\n\tif ( ! isTimezoneSameAsSiteTimezone( now ) ) {\n\t\treturn getFullPostScheduleLabel( dateAttribute );\n\t}\n\n\tconst date = getDate( dateAttribute );\n\n\tif ( isSameDay( date, now ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Today at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tconst tomorrow = new Date( now );\n\ttomorrow.setDate( tomorrow.getDate() + 1 );\n\n\tif ( isSameDay( date, tomorrow ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Tomorrow at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tif ( date.getFullYear() === now.getFullYear() ) {\n\t\treturn dateI18n(\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\t_x( 'F j g:i\\xa0a', 'post schedule date format without year' ),\n\t\t\tdate\n\t\t);\n\t}\n\n\treturn dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n}\n\nfunction getTimezoneAbbreviation() {\n\tconst { timezone } = getSettings();\n\n\tif ( timezone.abbr && isNaN( Number( timezone.abbr ) ) ) {\n\t\treturn timezone.abbr;\n\t}\n\n\tconst symbol = timezone.offset < 0 ? '' : '+';\n\treturn `UTC${ symbol }${ timezone.offset }`;\n}\n\nfunction isTimezoneSameAsSiteTimezone( date ) {\n\tconst { timezone } = getSettings();\n\n\tconst siteOffset = Number( timezone.offset );\n\tconst dateOffset = -1 * ( date.getTimezoneOffset() / 60 );\n\treturn siteOffset === dateOffset;\n}\n\nfunction isSameDay( left, right ) {\n\treturn (\n\t\tleft.getDate() === right.getDate() &&\n\t\tleft.getMonth() === right.getMonth() &&\n\t\tleft.getFullYear() === right.getFullYear()\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,S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AOD,QAAQ,CAACC,IAAI;EACrB;EAEA,MAAMG,MAAM,GAAGJ,QAAQ,CAACK,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG;EAC7C,OAAQ,MAAMD,MAAQ,GAAGJ,QAAQ,CAACK,MAAQ,EAAC;AAC5C;AAEA,SAASV,4BAA4BA,CAAEb,IAAI,EAAG;EAC7C,MAAM;IAAEkB;EAAS,CAAC,GAAG5B,WAAW,CAAC,CAAC;EAElC,MAAMkC,UAAU,GAAGH,MAAM,CAAEH,QAAQ,CAACK,MAAO,CAAC;EAC5C,MAAME,UAAU,GAAG,CAAC,CAAC,IAAKzB,IAAI,CAAC0B,iBAAiB,CAAC,CAAC,GAAG,EAAE,CAAE;EACzD,OAAOF,UAAU,KAAKC,UAAU;AACjC;AAEA,SAASX,SAASA,CAAEa,IAAI,EAAEC,KAAK,EAAG;EACjC,OACCD,IAAI,CAACpC,OAAO,CAAC,CAAC,KAAKqC,KAAK,CAACrC,OAAO,CAAC,CAAC,IAClCoC,IAAI,CAACE,QAAQ,CAAC,CAAC,KAAKD,KAAK,CAACC,QAAQ,CAAC,CAAC,IACpCF,IAAI,CAACV,WAAW,CAAC,CAAC,KAAKW,KAAK,CAACX,WAAW,CAAC,CAAC;AAE5C"}
1
+ {"version":3,"names":["__","_x","sprintf","isRTL","getSettings","getDate","dateI18n","useSelect","store","editorStore","PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","offsetFormatted","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getSettings, getDate, dateI18n } from '@wordpress/date';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostScheduleLabel( props ) {\n\treturn usePostScheduleLabel( props );\n}\n\nexport function usePostScheduleLabel( { full = false } = {} ) {\n\tconst { date, isFloating } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tisFloating: select( editorStore ).isEditedPostDateFloating(),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn full\n\t\t? getFullPostScheduleLabel( date )\n\t\t: getPostScheduleLabel( date, { isFloating } );\n}\n\nexport function getFullPostScheduleLabel( dateAttribute ) {\n\tconst date = getDate( dateAttribute );\n\n\tconst timezoneAbbreviation = getTimezoneAbbreviation();\n\tconst formattedDate = dateI18n(\n\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n\treturn isRTL()\n\t\t? `${ timezoneAbbreviation } ${ formattedDate }`\n\t\t: `${ formattedDate } ${ timezoneAbbreviation }`;\n}\n\nexport function getPostScheduleLabel(\n\tdateAttribute,\n\t{ isFloating = false, now = new Date() } = {}\n) {\n\tif ( ! dateAttribute || isFloating ) {\n\t\treturn __( 'Immediately' );\n\t}\n\n\t// If the user timezone does not equal the site timezone then using words\n\t// like 'tomorrow' is confusing, so show the full date.\n\tif ( ! isTimezoneSameAsSiteTimezone( now ) ) {\n\t\treturn getFullPostScheduleLabel( dateAttribute );\n\t}\n\n\tconst date = getDate( dateAttribute );\n\n\tif ( isSameDay( date, now ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Today at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tconst tomorrow = new Date( now );\n\ttomorrow.setDate( tomorrow.getDate() + 1 );\n\n\tif ( isSameDay( date, tomorrow ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Tomorrow at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tif ( date.getFullYear() === now.getFullYear() ) {\n\t\treturn dateI18n(\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\t_x( 'F j g:i\\xa0a', 'post schedule date format without year' ),\n\t\t\tdate\n\t\t);\n\t}\n\n\treturn dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n}\n\nfunction getTimezoneAbbreviation() {\n\tconst { timezone } = getSettings();\n\n\tif ( timezone.abbr && isNaN( Number( timezone.abbr ) ) ) {\n\t\treturn timezone.abbr;\n\t}\n\n\tconst symbol = timezone.offset < 0 ? '' : '+';\n\treturn `UTC${ symbol }${ timezone.offsetFormatted }`;\n}\n\nfunction isTimezoneSameAsSiteTimezone( date ) {\n\tconst { timezone } = getSettings();\n\n\tconst siteOffset = Number( timezone.offset );\n\tconst dateOffset = -1 * ( date.getTimezoneOffset() / 60 );\n\treturn siteOffset === dateOffset;\n}\n\nfunction isSameDay( left, right ) {\n\treturn (\n\t\tleft.getDate() === right.getDate() &&\n\t\tleft.getMonth() === right.getMonth() &&\n\t\tleft.getFullYear() === right.getFullYear()\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACxD,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,SAAS,QAAQ,iBAAi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IAAI;EACrB;EAEA,MAAMG,MAAM,GAAGJ,QAAQ,CAACK,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG;EAC7C,OAAQ,MAAMD,MAAQ,GAAGJ,QAAQ,CAACM,eAAiB,EAAC;AACrD;AAEA,SAASX,4BAA4BA,CAAEb,IAAI,EAAG;EAC7C,MAAM;IAAEkB;EAAS,CAAC,GAAG5B,WAAW,CAAC,CAAC;EAElC,MAAMmC,UAAU,GAAGJ,MAAM,CAAEH,QAAQ,CAACK,MAAO,CAAC;EAC5C,MAAMG,UAAU,GAAG,CAAC,CAAC,IAAK1B,IAAI,CAAC2B,iBAAiB,CAAC,CAAC,GAAG,EAAE,CAAE;EACzD,OAAOF,UAAU,KAAKC,UAAU;AACjC;AAEA,SAASZ,SAASA,CAAEc,IAAI,EAAEC,KAAK,EAAG;EACjC,OACCD,IAAI,CAACrC,OAAO,CAAC,CAAC,KAAKsC,KAAK,CAACtC,OAAO,CAAC,CAAC,IAClCqC,IAAI,CAACE,QAAQ,CAAC,CAAC,KAAKD,KAAK,CAACC,QAAQ,CAAC,CAAC,IACpCF,IAAI,CAACX,WAAW,CAAC,CAAC,KAAKY,KAAK,CAACZ,WAAW,CAAC,CAAC;AAE5C"}
@@ -39,6 +39,7 @@ export default function PostSchedulePanel() {
39
39
  onToggle,
40
40
  isOpen
41
41
  }) => createElement(Button, {
42
+ __next40pxDefaultSize: true,
42
43
  className: "editor-post-schedule__dialog-toggle",
43
44
  variant: "tertiary",
44
45
  onClick: onToggle,
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Dropdown","__","sprintf","useState","useMemo","PostScheduleCheck","PostScheduleForm","usePostScheduleLabel","PostPanelRow","PostSchedulePanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","label","fullLabel","full","createElement","ref","focusOnMount","className","contentClassName","renderToggle","onToggle","isOpen","variant","onClick","showTooltip","renderContent","onClose"],"sources":["@wordpress/editor/src/components/post-schedule/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Dropdown } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleCheck from './check';\nimport PostScheduleForm from './index';\nimport { usePostScheduleLabel } from './label';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostSchedulePanel() {\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Change publish date' ),\n\t\t\tplacement: 'bottom-end',\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst label = usePostScheduleLabel();\n\tconst fullLabel = usePostScheduleLabel( { full: true } );\n\n\treturn (\n\t\t<PostScheduleCheck>\n\t\t\t<PostPanelRow label={ __( 'Publish' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\tclassName=\"editor-post-schedule__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-schedule__dialog\"\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"editor-post-schedule__dialog-toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post date.\n\t\t\t\t\t\t\t\t__( 'Change date: %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tlabel={ fullLabel }\n\t\t\t\t\t\t\tshowTooltip={ label !== fullLabel }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostScheduleForm onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostScheduleCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,SAAS;AACvC,OAAOC,gBAAgB,MAAM,SAAS;AACtC,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGR,QAAQ,CAAE,IAAK,CAAC;EAC5D;EACA,MAAMS,YAAY,GAAGR,OAAO,CAC3B,OAAQ;IACP;IACA;IACAS,MAAM,EAAEH,aAAa;IACrB,YAAY,EAAET,EAAE,CAAE,qBAAsB,CAAC;IACzCa,SAAS,EAAE;EACZ,CAAC,CAAE,EACH,CAAEJ,aAAa,CAChB,CAAC;EAED,MAAMK,KAAK,GAAGR,oBAAoB,CAAC,CAAC;EACpC,MAAMS,SAAS,GAAGT,oBAAoB,CAAE;IAAEU,IAAI,EAAE;EAAK,CAAE,CAAC;EAExD,OACCC,aAAA,CAACb,iBAAiB,QACjBa,aAAA,CAACV,YAAY;IAACO,KAAK,EAAGd,EAAE,CAAE,SAAU,CAAG;IAACkB,GAAG,EAAGR;EAAkB,GAC/DO,aAAA,CAAClB,QAAQ;IACRY,YAAY,EAAGA,YAAc;IAC7BQ,YAAY;IACZC,SAAS,EAAC,sCAAsC;IAChDC,gBAAgB,EAAC,8BAA8B;IAC/CC,YAAY,EAAGA,CAAE;MAAEC,QAAQ;MAAEC;IAAO,CAAC,KACpCP,aAAA,CAACnB,MAAM;MACNsB,SAAS,EAAC,qCAAqC;MAC/CK,OAAO,EAAC,UAAU;MAClBC,OAAO,EAAGH,QAAU;MACpB,cAAatB,OAAO;MACnB;MACAD,EAAE,CAAE,iBAAkB,CAAC,EACvBc,KACD,CAAG;MACHA,KAAK,EAAGC,SAAW;MACnBY,WAAW,EAAGb,KAAK,KAAKC,SAAW;MACnC,iBAAgBS;IAAQ,GAEtBV,KACK,CACN;IACHc,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,KAC5BZ,aAAA,CAACZ,gBAAgB;MAACwB,OAAO,EAAGA;IAAS,CAAE;EACrC,CACH,CACY,CACI,CAAC;AAEtB"}
1
+ {"version":3,"names":["Button","Dropdown","__","sprintf","useState","useMemo","PostScheduleCheck","PostScheduleForm","usePostScheduleLabel","PostPanelRow","PostSchedulePanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","label","fullLabel","full","createElement","ref","focusOnMount","className","contentClassName","renderToggle","onToggle","isOpen","__next40pxDefaultSize","variant","onClick","showTooltip","renderContent","onClose"],"sources":["@wordpress/editor/src/components/post-schedule/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Dropdown } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleCheck from './check';\nimport PostScheduleForm from './index';\nimport { usePostScheduleLabel } from './label';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostSchedulePanel() {\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\t'aria-label': __( 'Change publish date' ),\n\t\t\tplacement: 'bottom-end',\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst label = usePostScheduleLabel();\n\tconst fullLabel = usePostScheduleLabel( { full: true } );\n\n\treturn (\n\t\t<PostScheduleCheck>\n\t\t\t<PostPanelRow label={ __( 'Publish' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\tclassName=\"editor-post-schedule__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-schedule__dialog\"\n\t\t\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"editor-post-schedule__dialog-toggle\"\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Current post date.\n\t\t\t\t\t\t\t\t__( 'Change date: %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tlabel={ fullLabel }\n\t\t\t\t\t\t\tshowTooltip={ label !== fullLabel }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostScheduleForm onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostScheduleCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC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,KAAK,KAAKC,SAAW;MACnC,iBAAgBS;IAAQ,GAEtBV,KACK,CACN;IACHe,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,KAC5Bb,aAAA,CAACZ,gBAAgB;MAACyB,OAAO,EAAGA;IAAS,CAAE;EACrC,CACH,CACY,CACI,CAAC;AAEtB"}
@@ -48,6 +48,7 @@ export default function PostSwitchToDraftButton() {
48
48
  savePost();
49
49
  };
50
50
  return createElement(Fragment, null, createElement(Button, {
51
+ __next40pxDefaultSize: true,
51
52
  className: "editor-post-switch-to-draft",
52
53
  onClick: () => {
53
54
  if (!isDisabled) {
@@ -1 +1 @@
1
- {"version":3,"names":["Button","__experimentalConfirmDialog","ConfirmDialog","__","useDispatch","useSelect","useState","store","editorStore","PostSwitchToDraftButton","showConfirmDialog","setShowConfirmDialog","editPost","savePost","isSaving","isPublished","isScheduled","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","isDisabled","alertMessage","handleConfirm","status","createElement","Fragment","className","onClick","variant","style","flexGrow","justifyContent","isOpen","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSwitchToDraftButton() {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\tconst { isSaving, isPublished, isScheduled } = useSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t}, [] );\n\n\tconst isDisabled = isSaving || ( ! isPublished && ! isScheduled );\n\n\tlet alertMessage;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\teditPost( { status: 'draft' } );\n\t\tsavePost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( ! isDisabled ) {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { flexGrow: '1', justifyContent: 'center' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,uBAAuBA,CAAA,EAAG;EACjD,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGL,QAAQ,CAAE,KAAM,CAAC;EAErE,MAAM;IAAEM,QAAQ;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,MAAM,EAAGvB,iBAAmB;IAC5BwB,SAAS,EAAGX,aAAe;IAC3BY,QAAQ,EAAGA,CAAA,KAAMxB,oBAAoB,CAAE,KAAM;EAAG,GAE9CW,YACY,CACd,CAAC;AAEL"}
1
+ {"version":3,"names":["Button","__experimentalConfirmDialog","ConfirmDialog","__","useDispatch","useSelect","useState","store","editorStore","PostSwitchToDraftButton","showConfirmDialog","setShowConfirmDialog","editPost","savePost","isSaving","isPublished","isScheduled","select","isSavingPost","isCurrentPostPublished","isCurrentPostScheduled","isDisabled","alertMessage","handleConfirm","status","createElement","Fragment","__next40pxDefaultSize","className","onClick","variant","style","flexGrow","justifyContent","isOpen","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/post-switch-to-draft-button/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostSwitchToDraftButton() {\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tconst { editPost, savePost } = useDispatch( editorStore );\n\tconst { isSaving, isPublished, isScheduled } = useSelect( ( select ) => {\n\t\tconst { isSavingPost, isCurrentPostPublished, isCurrentPostScheduled } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisSaving: isSavingPost(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t}, [] );\n\n\tconst isDisabled = isSaving || ( ! isPublished && ! isScheduled );\n\n\tlet alertMessage;\n\tif ( isPublished ) {\n\t\talertMessage = __( 'Are you sure you want to unpublish this post?' );\n\t} else if ( isScheduled ) {\n\t\talertMessage = __( 'Are you sure you want to unschedule this post?' );\n\t}\n\n\tconst handleConfirm = () => {\n\t\tsetShowConfirmDialog( false );\n\t\teditPost( { status: 'draft' } );\n\t\tsavePost();\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"editor-post-switch-to-draft\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( ! isDisabled ) {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tstyle={ { flexGrow: '1', justifyContent: 'center' } }\n\t\t\t>\n\t\t\t\t{ __( 'Switch to draft' ) }\n\t\t\t</Button>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\tonConfirm={ handleConfirm }\n\t\t\t\tonCancel={ () => setShowConfirmDialog( false ) }\n\t\t\t>\n\t\t\t\t{ alertMessage }\n\t\t\t</ConfirmDialog>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,2BAA2B,IAAIC,aAAa,QACtC,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,uBAAuBA,CAAA,EAAG;EACjD,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGL,QAAQ,CAAE,KAAM,CAAC;EAErE,MAAM;IAAEM,QAAQ;IAAEC;EAAS,CAAC,GAAGT,WAAW,CAAEI,WAAY,CAAC;EACzD,MAAM;IAAEM,QAAQ;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAGX,SAAS,CAAIY,MAAM,IAAM;IACvE,MAAM;MAAEC,YAAY;MAAEC,sBAAsB;MAAEC;IAAuB,CAAC,GACr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: __('Sync status')
42
42
  }, createElement("div", {
43
43
  className: "editor-post-sync-status__value"
44
- }, syncStatus === 'unsynced' ? __('Not synced') : __('Fully synced')));
44
+ }, syncStatus === 'unsynced' ? _x('Not synced', 'Text that indicates that the pattern is not synchronized') : _x('Synced', 'Text that indicates that the pattern is synchronized')));
45
45
  }
46
46
  export function PostSyncStatusModal() {
47
47
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","__","_x","Modal","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","ToggleControl","useEffect","useState","privateApis","blockEditorPrivateApis","PostPanelRow","store","editorStore","unlock","ReusableBlocksRenameHint","PostSyncStatus","syncStatus","postType","select","getEditedPostAttribute","meta","currentSyncStatus","wp_pattern_sync_status","createElement","label","className","PostSyncStatusModal","editPost","isModalOpen","setIsModalOpen","syncType","setSyncType","undefined","isNewPost","isCleanNewPost","setSyncStatus","Fragment","title","onRequestClose","overlayClassName","onSubmit","event","preventDefault","spacing","help","checked","onChange","justify","variant","type"],"sources":["@wordpress/editor/src/components/post-sync-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tToggleControl,\n} from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { ReusableBlocksRenameHint } = unlock( blockEditorPrivateApis );\n\nexport default function PostSyncStatus() {\n\tconst { syncStatus, postType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst meta = getEditedPostAttribute( 'meta' );\n\n\t\t// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.\n\t\tconst currentSyncStatus =\n\t\t\tmeta?.wp_pattern_sync_status === 'unsynced'\n\t\t\t\t? 'unsynced'\n\t\t\t\t: getEditedPostAttribute( 'wp_pattern_sync_status' );\n\n\t\treturn {\n\t\t\tsyncStatus: currentSyncStatus,\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t};\n\t} );\n\n\tif ( postType !== 'wp_block' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Sync status' ) }>\n\t\t\t<div className=\"editor-post-sync-status__value\">\n\t\t\t\t{ syncStatus === 'unsynced'\n\t\t\t\t\t? __( 'Not synced' )\n\t\t\t\t\t: __( 'Fully synced' ) }\n\t\t\t</div>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport function PostSyncStatusModal() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst [ syncType, setSyncType ] = useState( undefined );\n\n\tconst { postType, isNewPost } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, isCleanNewPost } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisNewPost: isCleanNewPost(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isNewPost && postType === 'wp_block' ) {\n\t\t\tsetIsModalOpen( true );\n\t\t}\n\t\t// We only want the modal to open when the page is first loaded.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst setSyncStatus = () => {\n\t\teditPost( {\n\t\t\tmeta: {\n\t\t\t\twp_pattern_sync_status: syncType,\n\t\t\t},\n\t\t} );\n\t};\n\n\tif ( postType !== 'wp_block' || ! isNewPost ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Set pattern sync status' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"reusable-blocks-menu-items__convert-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form\n\t\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tsetSyncStatus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<ReusableBlocksRenameHint />\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Synced',\n\t\t\t\t\t\t\t\t\t'Option that makes an individual pattern synchronized'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Sync this pattern across multiple locations.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ ! syncType }\n\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\tsetSyncType(\n\t\t\t\t\t\t\t\t\t\t! syncType ? 'unsynced' : undefined\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</VStack>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,KAAK,EACLC,MAA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AAG,GAEHZ,aAAA,CAACnB,MAAM;IAACuC,OAAO,EAAC;EAAG,GAClBpB,aAAA,CAACT,wBAAwB,MAAE,CAAC,EAC5BS,aAAA,CAAClB,aAAa;IACbmB,KAAK,EAAG1B,EAAE,CACT,QAAQ,EACR,sDACD,CAAG;IACH8C,IAAI,EAAG/C,EAAE,CACR,8CACD,CAAG;IACHgD,OAAO,EAAG,CAAEf,QAAU;IACtBgB,QAAQ,EAAGA,CAAA,KAAM;MAChBf,WAAW,CACV,CAAED,QAAQ,GAAG,UAAU,GAAGE,SAC3B,CAAC;IACF;EAAG,CACH,CAAC,EACFT,aAAA,CAACrB,MAAM;IAAC6C,OAAO,EAAC;EAAO,GACtBxB,aAAA,CAACvB,MAAM;IAACgD,OAAO,EAAC,SAAS;IAACC,IAAI,EAAC;EAAQ,GACpCpD,EAAE,CAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAEP,CAAC;AAEL"}
1
+ {"version":3,"names":["useSelect","useDispatch","__","_x","Modal","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","ToggleControl","useEffect","useState","privateApis","blockEditorPrivateApis","PostPanelRow","store","editorStore","unlock","ReusableBlocksRenameHint","PostSyncStatus","syncStatus","postType","select","getEditedPostAttribute","meta","currentSyncStatus","wp_pattern_sync_status","createElement","label","className","PostSyncStatusModal","editPost","isModalOpen","setIsModalOpen","syncType","setSyncType","undefined","isNewPost","isCleanNewPost","setSyncStatus","Fragment","title","onRequestClose","overlayClassName","onSubmit","event","preventDefault","spacing","help","checked","onChange","justify","variant","type"],"sources":["@wordpress/editor/src/components/post-sync-status/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tToggleControl,\n} from '@wordpress/components';\nimport { useEffect, useState } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PostPanelRow from '../post-panel-row';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { ReusableBlocksRenameHint } = unlock( blockEditorPrivateApis );\n\nexport default function PostSyncStatus() {\n\tconst { syncStatus, postType } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst meta = getEditedPostAttribute( 'meta' );\n\n\t\t// When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.\n\t\tconst currentSyncStatus =\n\t\t\tmeta?.wp_pattern_sync_status === 'unsynced'\n\t\t\t\t? 'unsynced'\n\t\t\t\t: getEditedPostAttribute( 'wp_pattern_sync_status' );\n\n\t\treturn {\n\t\t\tsyncStatus: currentSyncStatus,\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t};\n\t} );\n\n\tif ( postType !== 'wp_block' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Sync status' ) }>\n\t\t\t<div className=\"editor-post-sync-status__value\">\n\t\t\t\t{ syncStatus === 'unsynced'\n\t\t\t\t\t? _x(\n\t\t\t\t\t\t\t'Not synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is not synchronized'\n\t\t\t\t\t )\n\t\t\t\t\t: _x(\n\t\t\t\t\t\t\t'Synced',\n\t\t\t\t\t\t\t'Text that indicates that the pattern is synchronized'\n\t\t\t\t\t ) }\n\t\t\t</div>\n\t\t</PostPanelRow>\n\t);\n}\n\nexport function PostSyncStatusModal() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst [ syncType, setSyncType ] = useState( undefined );\n\n\tconst { postType, isNewPost } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, isCleanNewPost } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tpostType: getEditedPostAttribute( 'type' ),\n\t\t\tisNewPost: isCleanNewPost(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( isNewPost && postType === 'wp_block' ) {\n\t\t\tsetIsModalOpen( true );\n\t\t}\n\t\t// We only want the modal to open when the page is first loaded.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst setSyncStatus = () => {\n\t\teditPost( {\n\t\t\tmeta: {\n\t\t\t\twp_pattern_sync_status: syncType,\n\t\t\t},\n\t\t} );\n\t};\n\n\tif ( postType !== 'wp_block' || ! isNewPost ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Set pattern sync status' ) }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName=\"reusable-blocks-menu-items__convert-modal\"\n\t\t\t\t>\n\t\t\t\t\t<form\n\t\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\t\tsetSyncStatus();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t\t\t<ReusableBlocksRenameHint />\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ _x(\n\t\t\t\t\t\t\t\t\t'Synced',\n\t\t\t\t\t\t\t\t\t'Option that makes an individual pattern synchronized'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t\t'Sync this pattern across multiple locations.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tchecked={ ! syncType }\n\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\tsetSyncType(\n\t\t\t\t\t\t\t\t\t\t! syncType ? 'unsynced' : undef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,EAAEQ;MACzB;IACD,CAAE,CAAC;EACJ,CAAC;EAED,IAAKb,QAAQ,KAAK,UAAU,IAAI,CAAEgB,SAAS,EAAG;IAC7C,OAAO,IAAI;EACZ;EAEA,OACCV,aAAA,CAAAa,QAAA,QACGR,WAAW,IACZL,aAAA,CAACxB,KAAK;IACLsC,KAAK,EAAGxC,EAAE,CAAE,yBAA0B,CAAG;IACzCyC,cAAc,EAAGA,CAAA,KAAM;MACtBT,cAAc,CAAE,KAAM,CAAC;IACxB,CAAG;IACHU,gBAAgB,EAAC;EAA2C,GAE5DhB,aAAA;IACCiB,QAAQ,EAAKC,KAAK,IAAM;MACvBA,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBb,cAAc,CAAE,KAAM,CAAC;MACvBM,aAAa,CAAC,CAAC;IAChB;EAAG,GAEHZ,aAAA,CAACnB,MAAM;IAACuC,OAAO,EAAC;EAAG,GAClBpB,aAAA,CAACT,wBAAwB,MAAE,CAAC,EAC5BS,aAAA,CAAClB,aAAa;IACbmB,KAAK,EAAG1B,EAAE,CACT,QAAQ,EACR,sDACD,CAAG;IACH8C,IAAI,EAAG/C,EAAE,CACR,8CACD,CAAG;IACHgD,OAAO,EAAG,CAAEf,QAAU;IACtBgB,QAAQ,EAAGA,CAAA,KAAM;MAChBf,WAAW,CACV,CAAED,QAAQ,GAAG,UAAU,GAAGE,SAC3B,CAAC;IACF;EAAG,CACH,CAAC,EACFT,aAAA,CAACrB,MAAM;IAAC6C,OAAO,EAAC;EAAO,GACtBxB,aAAA,CAACvB,MAAM;IAACgD,OAAO,EAAC,SAAS;IAACC,IAAI,EAAC;EAAQ,GACpCpD,EAAE,CAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAEP,CAAC;AAEL"}
@@ -1,31 +1,26 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { compose } from '@wordpress/compose';
5
- import { withSelect } from '@wordpress/data';
4
+ import { useSelect } from '@wordpress/data';
6
5
  import { store as coreStore } from '@wordpress/core-data';
7
6
 
8
7
  /**
9
8
  * Internal dependencies
10
9
  */
11
10
  import { store as editorStore } from '../../store';
12
- export function PostTaxonomiesCheck({
13
- postType,
14
- taxonomies,
11
+ export default function PostTaxonomiesCheck({
15
12
  children
16
13
  }) {
17
- const hasTaxonomies = taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
14
+ const hasTaxonomies = useSelect(select => {
15
+ const postType = select(editorStore).getCurrentPostType();
16
+ const taxonomies = select(coreStore).getTaxonomies({
17
+ per_page: -1
18
+ });
19
+ return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
20
+ }, []);
18
21
  if (!hasTaxonomies) {
19
22
  return null;
20
23
  }
21
24
  return children;
22
25
  }
23
- export default compose([withSelect(select => {
24
- return {
25
- postType: select(editorStore).getCurrentPostType(),
26
- taxonomies: select(coreStore).getTaxonomies({
27
- per_page: -1
28
- })
29
- };
30
- })])(PostTaxonomiesCheck);
31
26
  //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["compose","withSelect","store","coreStore","editorStore","PostTaxonomiesCheck","postType","taxonomies","children","hasTaxonomies","some","taxonomy","types","includes","select","getCurrentPostType","getTaxonomies","per_page"],"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function PostTaxonomiesCheck( { postType, taxonomies, children } ) {\n\tconst hasTaxonomies = taxonomies?.some( ( taxonomy ) =>\n\t\ttaxonomy.types.includes( postType )\n\t);\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomiesCheck );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,OAAO,SAASC,mBAAmBA,CAAE;EAAEC,QAAQ;EAAEC,UAAU;EAAEC;AAAS,CAAC,EAAG;EACzE,MAAMC,aAAa,GAAGF,UAAU,EAAEG,IAAI,CAAIC,QAAQ,IACjDA,QAAQ,CAACC,KAAK,CAACC,QAAQ,CAAEP,QAAS,CACnC,CAAC;EACD,IAAK,CAAEG,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB;AAEA,eAAeR,OAAO,CAAE,CACvBC,UAAU,CAAIa,MAAM,IAAM;EACzB,OAAO;IACNR,QAAQ,EAAEQ,MAAM,CAAEV,WAAY,CAAC,CAACW,kBAAkB,CAAC,CAAC;IACpDR,UAAU,EAAEO,MAAM,CAAEX,SAAU,CAAC,CAACa,aAAa,CAAE;MAAEC,QAAQ,EAAE,CAAC;IAAE,CAAE;EACjE,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEZ,mBAAoB,CAAC"}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","PostTaxonomiesCheck","children","hasTaxonomies","select","postType","getCurrentPostType","taxonomies","getTaxonomies","per_page","some","taxonomy","types","includes"],"sources":["@wordpress/editor/src/components/post-taxonomies/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostTaxonomiesCheck( { children } ) {\n\tconst hasTaxonomies = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst taxonomies = select( coreStore ).getTaxonomies( {\n\t\t\tper_page: -1,\n\t\t} );\n\t\treturn taxonomies?.some( ( taxonomy ) =>\n\t\t\ttaxonomy.types.includes( postType )\n\t\t);\n\t}, [] );\n\tif ( ! hasTaxonomies ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,mBAAmBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC3D,MAAMC,aAAa,GAAGN,SAAS,CAAIO,MAAM,IAAM;IAC9C,MAAMC,QAAQ,GAAGD,MAAM,CAAEJ,WAAY,CAAC,CAACM,kBAAkB,CAAC,CAAC;IAC3D,MAAMC,UAAU,GAAGH,MAAM,CAAEL,SAAU,CAAC,CAACS,aAAa,CAAE;MACrDC,QAAQ,EAAE,CAAC;IACZ,CAAE,CAAC;IACH,OAAOF,UAAU,EAAEG,IAAI,CAAIC,QAAQ,IAClCA,QAAQ,CAACC,KAAK,CAACC,QAAQ,CAAER,QAAS,CACnC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,IAAK,CAAEF,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB"}
@@ -3,8 +3,7 @@ import { createElement } from "react";
3
3
  * WordPress dependencies
4
4
  */
5
5
  import { Fragment } from '@wordpress/element';
6
- import { withSelect } from '@wordpress/data';
7
- import { compose } from '@wordpress/compose';
6
+ import { useSelect } from '@wordpress/data';
8
7
  import { store as coreStore } from '@wordpress/core-data';
9
8
 
10
9
  /**
@@ -15,15 +14,23 @@ import FlatTermSelector from './flat-term-selector';
15
14
  import { store as editorStore } from '../../store';
16
15
  const identity = x => x;
17
16
  export function PostTaxonomies({
18
- postType,
19
- taxonomies,
20
17
  taxonomyWrapper = identity
21
18
  }) {
22
- const availableTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy => taxonomy.types.includes(postType));
23
- const visibleTaxonomies = availableTaxonomies.filter(
19
+ const {
20
+ postType,
21
+ taxonomies
22
+ } = useSelect(select => {
23
+ return {
24
+ postType: select(editorStore).getCurrentPostType(),
25
+ taxonomies: select(coreStore).getTaxonomies({
26
+ per_page: -1
27
+ })
28
+ };
29
+ }, []);
30
+ const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
24
31
  // In some circumstances .visibility can end up as undefined so optional chaining operator required.
25
32
  // https://github.com/WordPress/gutenberg/issues/40326
26
- taxonomy => taxonomy.visibility?.show_ui);
33
+ taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
27
34
  return visibleTaxonomies.map(taxonomy => {
28
35
  const TaxonomyComponent = taxonomy.hierarchical ? HierarchicalTermSelector : FlatTermSelector;
29
36
  return createElement(Fragment, {
@@ -33,12 +40,5 @@ export function PostTaxonomies({
33
40
  }), taxonomy));
34
41
  });
35
42
  }
36
- export default compose([withSelect(select => {
37
- return {
38
- postType: select(editorStore).getCurrentPostType(),
39
- taxonomies: select(coreStore).getTaxonomies({
40
- per_page: -1
41
- })
42
- };
43
- })])(PostTaxonomies);
43
+ export default PostTaxonomies;
44
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Fragment","withSelect","compose","store","coreStore","HierarchicalTermSelector","FlatTermSelector","editorStore","identity","x","PostTaxonomies","postType","taxonomies","taxonomyWrapper","availableTaxonomies","filter","taxonomy","types","includes","visibleTaxonomies","visibility","show_ui","map","TaxonomyComponent","hierarchical","createElement","key","slug","select","getCurrentPostType","getTaxonomies","per_page"],"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( {\n\tpostType,\n\ttaxonomies,\n\ttaxonomyWrapper = identity,\n} ) {\n\tconst availableTaxonomies = ( taxonomies ?? [] ).filter( ( taxonomy ) =>\n\t\ttaxonomy.types.includes( postType )\n\t);\n\tconst visibleTaxonomies = availableTaxonomies.filter(\n\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t( taxonomy ) => taxonomy.visibility?.show_ui\n\t);\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomies );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,wBAAwB,MAAM,8BAA8B;AACnE,OAAOC,gBAAgB,MAAM,s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","identity","x","PostTaxonomies","taxonomyWrapper","postType","taxonomies","select","getCurrentPostType","getTaxonomies","per_page","visibleTaxonomies","filter","taxonomy","types","includes","visibility","show_ui","map","TaxonomyComponent","hierarchical","createElement","key","slug"],"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nconst identity = ( x ) => x;\n\nexport function PostTaxonomies( { taxonomyWrapper = identity } ) {\n\tconst { postType, taxonomies } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t}, [] );\n\tconst visibleTaxonomies = ( taxonomies ?? [] ).filter(\n\t\t( taxonomy ) =>\n\t\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t\ttaxonomy.types.includes( postType ) && taxonomy.visibility?.show_ui\n\t);\n\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default PostTaxonomies;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC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function BlockThemeControl({
27
27
  }) {
28
28
  const {
29
29
  isTemplateHidden,
30
- getPostLinkProps,
30
+ onNavigateToEntityRecord,
31
31
  getEditorSettings,
32
32
  hasGoBack
33
33
  } = useSelect(select => {
@@ -38,9 +38,9 @@ export default function BlockThemeControl({
38
38
  const editorSettings = _getEditorSettings();
39
39
  return {
40
40
  isTemplateHidden: getRenderingMode() === 'post-only',
41
- getPostLinkProps: editorSettings.getPostLinkProps,
41
+ onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
42
42
  getEditorSettings: _getEditorSettings,
43
- hasGoBack: editorSettings.hasOwnProperty('goBack')
43
+ hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
44
44
  };
45
45
  }, []);
46
46
  const {
@@ -53,23 +53,21 @@ export default function BlockThemeControl({
53
53
  const {
54
54
  setRenderingMode
55
55
  } = useDispatch(editorStore);
56
- const editTemplate = getPostLinkProps ? getPostLinkProps({
57
- postId: template.id,
58
- postType: 'wp_template'
59
- }) : {};
60
56
  if (!hasResolved) {
61
57
  return null;
62
58
  }
63
- // The site editor does not have a `goBack` setting as it uses its own routing
59
+
60
+ // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
64
61
  // and assigns its own backlink to focusMode pages.
65
62
  const notificationAction = hasGoBack ? [{
66
63
  label: __('Go back'),
67
- onClick: () => getEditorSettings().goBack()
64
+ onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
68
65
  }] : undefined;
69
66
  return createElement(DropdownMenu, {
70
67
  popoverProps: POPOVER_PROPS,
71
68
  focusOnMount: true,
72
69
  toggleProps: {
70
+ __next40pxDefaultSize: true,
73
71
  variant: 'tertiary'
74
72
  },
75
73
  label: __('Template options'),
@@ -78,8 +76,11 @@ export default function BlockThemeControl({
78
76
  }, ({
79
77
  onClose
80
78
  }) => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
81
- onClick: event => {
82
- editTemplate.onClick(event);
79
+ onClick: () => {
80
+ onNavigateToEntityRecord({
81
+ postId: template.id,
82
+ postType: 'wp_template'
83
+ });
83
84
  onClose();
84
85
  createSuccessNotice(__('Editing template. Changes made here affect all posts and pages that use the template.'), {
85
86
  type: 'snackbar',
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","check","store","noticesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","getPostLinkProps","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","editTemplate","postId","postType","notificationAction","label","onClick","goBack","undefined","createElement","popoverProps","focusOnMount","toggleProps","variant","text","title","icon","onClose","Fragment","event","type","actions","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst { isTemplateHidden, getPostLinkProps, getEditorSettings, hasGoBack } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\t\tunlock( select( editorStore ) );\n\t\t\tconst editorSettings = _getEditorSettings();\n\t\t\treturn {\n\t\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\t\tgetPostLinkProps: editorSettings.getPostLinkProps,\n\t\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\t\thasGoBack: editorSettings.hasOwnProperty( 'goBack' ),\n\t\t\t};\n\t\t}, [] );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\tconst editTemplate = getPostLinkProps\n\t\t? getPostLinkProps( {\n\t\t\t\tpostId: template.id,\n\t\t\t\tpostType: 'wp_template',\n\t\t } )\n\t\t: {};\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\t// The site editor does not have a `goBack` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () => getEditorSettings().goBack(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\teditTemplate.onClick( event );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tactions: notificationAction,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,KAAK,Q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aAAA,CAACtC,QAAQ;IACR6C,IAAI,EAAG,CAAE7B,gBAAgB,GAAGb,KAAK,GAAGkC,SAAW;IAC/Cc,UAAU,EAAG,CAAEnC,gBAAkB;IACjCoC,IAAI,EAAC,kBAAkB;IACvBjB,OAAO,EAAGA,CAAA,KAAM;MACfN,gBAAgB,CACfb,gBAAgB,GACb,iBAAiB,GACjB,WACJ,CAAC;IACF;EAAG,GAEDf,EAAE,CAAE,kBAAmB,CAChB,CACA,CACV,CAEU,CAAC;AAEjB"}
1
+ {"version":3,"names":["useSelect","useDispatch","decodeEntities","DropdownMenu","MenuGroup","MenuItem","__","useEntityRecord","check","store","noticesStore","editorStore","SwapTemplateButton","ResetDefaultTemplate","unlock","CreateNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","onNavigateToEntityRecord","getEditorSettings","hasGoBack","select","getRenderingMode","_getEditorSettings","editorSettings","hasOwnProperty","editedRecord","template","hasResolved","createSuccessNotice","setRenderingMode","notificationAction","label","onClick","onNavigateToPreviousEntityRecord","undefined","createElement","popoverProps","focusOnMount","toggleProps","__next40pxDefaultSize","variant","text","title","icon","onClose","Fragment","postId","postType","type","actions","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst {\n\t\tisTemplateHidden,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t\thasGoBack,\n\t} = useSelect( ( select ) => {\n\t\tconst { getRenderingMode, getEditorSettings: _getEditorSettings } =\n\t\t\tunlock( select( editorStore ) );\n\t\tconst editorSettings = _getEditorSettings();\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t\tonNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,\n\t\t\tgetEditorSettings: _getEditorSettings,\n\t\t\thasGoBack: editorSettings.hasOwnProperty(\n\t\t\t\t'onNavigateToPreviousEntityRecord'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\t// The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing\n\t// and assigns its own backlink to focusMode pages.\n\tconst notificationAction = hasGoBack\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t},\n\t\t ]\n\t\t: undefined;\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\t__next40pxDefaultSize: true,\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\t\tpostId: template.id,\n\t\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tactions: notificationAction,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t</MenuItem>\n\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n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AC5B,kBAAkB;IAACyB,OAAO,EAAGY;EAAS,CAAE,CAAC,EAC1CT,aAAA,CAAC3B,oBAAoB;IAACwB,OAAO,EAAGY;EAAS,CAAE,CAAC,EAC5CT,aAAA,CAACzB,iBAAiB;IAACsB,OAAO,EAAGY;EAAS,CAAE,CAC9B,CAAC,EACZT,aAAA,CAACpC,SAAS,QACToC,aAAA,CAACnC,QAAQ;IACR2C,IAAI,EAAG,CAAE3B,gBAAgB,GAAGb,KAAK,GAAG+B,SAAW;IAC/CgB,UAAU,EAAG,CAAElC,gBAAkB;IACjCmC,IAAI,EAAC,kBAAkB;IACvBnB,OAAO,EAAGA,CAAA,KAAM;MACfH,gBAAgB,CACfb,gBAAgB,GACb,iBAAiB,GACjB,WACJ,CAAC;IACF;EAAG,GAEDf,EAAE,CAAE,kBAAmB,CAChB,CACA,CACV,CAEU,CAAC;AAEjB"}
@@ -38,6 +38,7 @@ function PostTemplateToggle({
38
38
  return template?.title || template?.slug || availableTemplates?.[templateSlug];
39
39
  }, []);
40
40
  return createElement(Button, {
41
+ __next40pxDefaultSize: true,
41
42
  className: "edit-post-post-template__toggle",
42
43
  variant: "tertiary",
43
44
  "aria-expanded": isOpen,
@@ -57,7 +58,7 @@ function PostTemplateDropdownContent({
57
58
  canCreate,
58
59
  canEdit,
59
60
  currentTemplateId,
60
- getPostLinkProps,
61
+ onNavigateToEntityRecord,
61
62
  getEditorSettings
62
63
  } = useSelect(select => {
63
64
  const {
@@ -77,14 +78,10 @@ function PostTemplateDropdownContent({
77
78
  canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
78
79
  canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
79
80
  currentTemplateId: _currentTemplateId,
80
- getPostLinkProps: editorSettings.getPostLinkProps,
81
+ onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
81
82
  getEditorSettings: select(editorStore).getEditorSettings
82
83
  };
83
84
  }, [allowSwitchingTemplate]);
84
- const editTemplate = getPostLinkProps && currentTemplateId ? getPostLinkProps({
85
- postId: currentTemplateId,
86
- postType: 'wp_template'
87
- }) : {};
88
85
  const options = useMemo(() => Object.entries({
89
86
  ...availableTemplates,
90
87
  ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
@@ -128,16 +125,19 @@ function PostTemplateDropdownContent({
128
125
  onChange: slug => editPost({
129
126
  template: slug || ''
130
127
  })
131
- }), canEdit && createElement("p", null, createElement(Button, {
128
+ }), canEdit && onNavigateToEntityRecord && createElement("p", null, createElement(Button, {
132
129
  variant: "link",
133
130
  onClick: () => {
134
- editTemplate.onClick();
131
+ onNavigateToEntityRecord({
132
+ postId: currentTemplateId,
133
+ postType: 'wp_template'
134
+ });
135
135
  onClose();
136
136
  createSuccessNotice(__('Editing template. Changes made here affect all posts and pages that use the template.'), {
137
137
  type: 'snackbar',
138
138
  actions: [{
139
139
  label: __('Go back'),
140
- onClick: () => getEditorSettings().goBack()
140
+ onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
141
141
  }]
142
142
  });
143
143
  }
@@ -1 +1 @@
1
- {"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","createElement","variant","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","getPostLinkProps","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","editTemplate","postId","postType","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__next40pxDefaultSize","__nextHasNoMarginBottom","hideLabelFromVision","onChange","type","goBack","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tgetPostLinkProps,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tgetPostLinkProps: editorSettings.getPostLinkProps,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst editTemplate =\n\t\tgetPostLinkProps && currentTemplateId\n\t\t\t? getPostLinkProps( {\n\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t } )\n\t\t\t: {};\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\teditTemplate.onClick();\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().goBack(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default ClassicThemeControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,uBAAuB;AAC/E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASN,KAAK,IAAIO,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,0BAA0B,QAAQ,SAAS;AAEpD,MAAMC,aAAa,GAAG;EACrBC,SAAS,EAAE,gCAAgC;EAC3CC,SAAS,EAAE;AACZ,CAAC;AAED,SAASC,kBAAkBA,CAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAG;EAClD,MAAMC,aAAa,GAAGnB,SAAS,CAAIoB,MAAM,IAAM;IAC9C,MAAMC,YAAY,GACjBD,MAAM,CAAEV,WAAY,CAAC,CAACY,sBAAs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AAEoE;IAAS,CAAC,KACpCtD,aAAA,CAACf,kBAAkB;MAACC,MAAM,EAAGA,MAAQ;MAACC,OAAO,EAAGmE;IAAU,CAAE,CAC1D;IACHC,aAAa,EAAGA,CAAE;MAAEpD;IAAQ,CAAC,KAC5BH,aAAA,CAACE,2BAA2B;MAACC,OAAO,EAAGA;IAAS,CAAE;EAChD,CACH,CAAC;AAEJ;AAEA,eAAe+C,mBAAmB"}
1
+ {"version":3,"names":["__","SelectControl","Dropdown","Button","Notice","useSelect","useDispatch","store","coreStore","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","useState","useMemo","addTemplate","noticesStore","editorStore","CreateNewTemplateModal","useAllowSwitchingTemplates","POPOVER_PROPS","className","placement","PostTemplateToggle","isOpen","onClick","templateTitle","select","templateSlug","getEditedPostAttribute","supportsTemplateMode","availableTemplates","getEditorSettings","template","canUser","getCurrentTemplateId","title","slug","createElement","__next40pxDefaultSize","variant","PostTemplateDropdownContent","onClose","_options$find","_selectedOption$value","allowSwitchingTemplate","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","currentTemplateId","onNavigateToEntityRecord","getEntityRecords","editorSettings","canCreateTemplates","_currentTemplateId","post_type","getCurrentPostType","per_page","undefined","options","Object","entries","fromEntries","map","rendered","value","label","selectedOption","find","option","editPost","createSuccessNotice","isCreateModalOpen","setIsCreateModalOpen","help","actions","icon","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","postId","postType","type","onNavigateToPreviousEntityRecord","ClassicThemeControl","popoverProps","focusOnMount","renderToggle","onToggle","renderContent"],"sources":["@wordpress/editor/src/components/post-template/classic-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { SelectControl, Dropdown, Button, Notice } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { addTemplate } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport CreateNewTemplateModal from './create-new-template-modal';\nimport { useAllowSwitchingTemplates } from './hooks';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={ __( 'Template options' ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n\nfunction PostTemplateDropdownContent( { onClose } ) {\n\tconst allowSwitchingTemplate = useAllowSwitchingTemplates();\n\tconst {\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t\tcurrentTemplateId,\n\t\tonNavigateToEntityRecord,\n\t\tgetEditorSettings,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getEntityRecords } = select( coreStore );\n\t\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\t\t\tconst _currentTemplateId =\n\t\t\t\tselect( editorStore ).getCurrentTemplateId();\n\t\t\treturn {\n\t\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\t\tpost_type:\n\t\t\t\t\t\t\t\tselect( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: undefined,\n\t\t\t\tselectedTemplateSlug:\n\t\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\t\tcanCreate:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\t\tcanEdit:\n\t\t\t\t\tallowSwitchingTemplate &&\n\t\t\t\t\tcanCreateTemplates &&\n\t\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t\t!! _currentTemplateId,\n\t\t\t\tcurrentTemplateId: _currentTemplateId,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\teditorSettings.onNavigateToEntityRecord,\n\t\t\t\tgetEditorSettings: select( editorStore ).getEditorSettings,\n\t\t\t};\n\t\t},\n\t\t[ allowSwitchingTemplate ]\n\t);\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"editor-post-template__classic-theme-dropdown\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ ! allowSwitchingTemplate ? (\n\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && onNavigateToEntityRecord && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\t\tpostId: currentTemplateId,\n\t\t\t\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord(),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<CreateNewTemplateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction ClassicThemeControl() {\n\treturn (\n\t\t<Dropdown\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<PostTemplateToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t) }\n\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t<PostTemplateDropdownContent onClose={ onClose } />\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default Class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