@wordpress/edit-site 5.22.0 → 5.24.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 (524) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/actions/index.js +115 -15
  3. package/build/components/actions/index.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +0 -7
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/block-editor/site-editor-canvas.js +7 -2
  7. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  8. package/build/components/block-editor/use-site-editor-settings.js +54 -63
  9. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  10. package/build/components/dataviews/add-filter.js +91 -0
  11. package/build/components/dataviews/add-filter.js.map +1 -0
  12. package/build/components/dataviews/constants.js +14 -0
  13. package/build/components/dataviews/constants.js.map +1 -0
  14. package/build/components/dataviews/dataviews.js +30 -9
  15. package/build/components/dataviews/dataviews.js.map +1 -1
  16. package/build/components/dataviews/filter-summary.js +62 -0
  17. package/build/components/dataviews/filter-summary.js.map +1 -0
  18. package/build/components/dataviews/filters.js +37 -48
  19. package/build/components/dataviews/filters.js.map +1 -1
  20. package/build/components/dataviews/index.js +9 -2
  21. package/build/components/dataviews/index.js.map +1 -1
  22. package/build/components/dataviews/item-actions.js +139 -17
  23. package/build/components/dataviews/item-actions.js.map +1 -1
  24. package/build/components/dataviews/pagination.js +7 -2
  25. package/build/components/dataviews/pagination.js.map +1 -1
  26. package/build/components/dataviews/reset-filters.js +33 -0
  27. package/build/components/dataviews/reset-filters.js.map +1 -0
  28. package/build/components/dataviews/search.js +1 -0
  29. package/build/components/dataviews/search.js.map +1 -1
  30. package/build/components/dataviews/view-actions.js +49 -32
  31. package/build/components/dataviews/view-actions.js.map +1 -1
  32. package/build/components/dataviews/view-grid.js +48 -25
  33. package/build/components/dataviews/view-grid.js.map +1 -1
  34. package/build/components/dataviews/view-list.js +130 -14
  35. package/build/components/dataviews/view-list.js.map +1 -1
  36. package/build/components/dataviews/view-side-by-side.js +20 -0
  37. package/build/components/dataviews/view-side-by-side.js.map +1 -0
  38. package/build/components/editor/index.js +52 -56
  39. package/build/components/editor/index.js.map +1 -1
  40. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  41. package/build/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
  42. package/build/components/global-styles/font-library-modal/utils/index.js +15 -2
  43. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  44. package/build/components/global-styles/header.js +4 -2
  45. package/build/components/global-styles/header.js.map +1 -1
  46. package/build/components/global-styles/screen-block-list.js +22 -16
  47. package/build/components/global-styles/screen-block-list.js.map +1 -1
  48. package/build/components/global-styles/screen-revisions/index.js +66 -24
  49. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  50. package/build/components/global-styles/screen-revisions/revisions-buttons.js +52 -24
  51. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  52. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
  53. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  54. package/build/components/global-styles/screen-root.js +3 -3
  55. package/build/components/global-styles/screen-root.js.map +1 -1
  56. package/build/components/global-styles/ui.js +31 -39
  57. package/build/components/global-styles/ui.js.map +1 -1
  58. package/build/components/global-styles-renderer/index.js +1 -1
  59. package/build/components/global-styles-renderer/index.js.map +1 -1
  60. package/build/components/header-edit-mode/document-actions/index.js +21 -16
  61. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  62. package/build/components/header-edit-mode/document-tools/index.js +160 -0
  63. package/build/components/header-edit-mode/document-tools/index.js.map +1 -0
  64. package/build/components/header-edit-mode/index.js +50 -117
  65. package/build/components/header-edit-mode/index.js.map +1 -1
  66. package/build/components/header-edit-mode/more-menu/index.js +1 -1
  67. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  68. package/build/components/header-edit-mode/more-menu/site-export.js +2 -6
  69. package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -1
  70. package/build/components/layout/index.js +4 -19
  71. package/build/components/layout/index.js.map +1 -1
  72. package/build/components/list/added-by.js +44 -54
  73. package/build/components/list/added-by.js.map +1 -1
  74. package/build/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +11 -15
  75. package/build/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
  76. package/build/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  77. package/build/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
  78. package/build/components/page-content-focus-notifications/index.js +22 -0
  79. package/build/components/page-content-focus-notifications/index.js.map +1 -0
  80. package/build/components/page-main/index.js +2 -1
  81. package/build/components/page-main/index.js.map +1 -1
  82. package/build/components/page-pages/index.js +137 -88
  83. package/build/components/page-pages/index.js.map +1 -1
  84. package/build/components/page-pages/side-editor.js +25 -0
  85. package/build/components/page-pages/side-editor.js.map +1 -0
  86. package/build/components/page-patterns/grid-item.js +2 -2
  87. package/build/components/page-patterns/grid-item.js.map +1 -1
  88. package/build/components/page-patterns/patterns-list.js +3 -3
  89. package/build/components/page-patterns/patterns-list.js.map +1 -1
  90. package/build/components/page-patterns/use-patterns.js +2 -2
  91. package/build/components/page-patterns/use-patterns.js.map +1 -1
  92. package/build/components/page-templates/dataviews-templates.js +316 -0
  93. package/build/components/page-templates/dataviews-templates.js.map +1 -0
  94. package/build/components/page-templates/template-actions.js +168 -0
  95. package/build/components/page-templates/template-actions.js.map +1 -0
  96. package/build/components/preferences-modal/index.js +1 -1
  97. package/build/components/preferences-modal/index.js.map +1 -1
  98. package/build/components/save-button/index.js +9 -6
  99. package/build/components/save-button/index.js.map +1 -1
  100. package/build/components/save-hub/index.js +14 -0
  101. package/build/components/save-hub/index.js.map +1 -1
  102. package/build/components/sidebar/index.js +1 -2
  103. package/build/components/sidebar/index.js.map +1 -1
  104. package/build/components/sidebar-dataviews/add-new-view.js +124 -0
  105. package/build/components/sidebar-dataviews/add-new-view.js.map +1 -0
  106. package/build/components/sidebar-dataviews/custom-dataviews-list.js +191 -0
  107. package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
  108. package/build/components/sidebar-dataviews/dataview-item.js +71 -0
  109. package/build/components/sidebar-dataviews/dataview-item.js.map +1 -0
  110. package/build/components/sidebar-dataviews/default-views.js +65 -0
  111. package/build/components/sidebar-dataviews/default-views.js.map +1 -0
  112. package/build/components/sidebar-dataviews/index.js +21 -38
  113. package/build/components/sidebar-dataviews/index.js.map +1 -1
  114. package/build/components/sidebar-edit-mode/default-sidebar.js +2 -6
  115. package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  116. package/build/components/sidebar-edit-mode/index.js +6 -5
  117. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  118. package/build/components/sidebar-edit-mode/page-panels/edit-template.js +18 -29
  119. package/build/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
  120. package/build/components/sidebar-edit-mode/page-panels/hooks.js +22 -8
  121. package/build/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
  122. package/build/components/sidebar-edit-mode/page-panels/page-status.js +8 -5
  123. package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  124. package/build/components/sidebar-edit-mode/page-panels/page-summary.js +5 -8
  125. package/build/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
  126. package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js +6 -14
  127. package/build/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
  128. package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js +4 -12
  129. package/build/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
  130. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
  131. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  132. package/build/components/sidebar-edit-mode/settings-header/index.js +10 -6
  133. package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  134. package/build/components/sidebar-edit-mode/template-panel/hooks.js +3 -3
  135. package/build/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
  136. package/build/components/sidebar-navigation-screen-global-styles/index.js +1 -1
  137. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  138. package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
  139. package/build/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
  140. package/build/components/sidebar-navigation-screen-page/index.js +23 -4
  141. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
  142. package/build/components/sidebar-navigation-screen-page/page-details.js +3 -11
  143. package/build/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
  144. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
  145. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  146. package/build/components/site-hub/index.js +18 -6
  147. package/build/components/site-hub/index.js.map +1 -1
  148. package/build/components/start-template-options/index.js +12 -16
  149. package/build/components/start-template-options/index.js.map +1 -1
  150. package/build/components/style-book/index.js +22 -12
  151. package/build/components/style-book/index.js.map +1 -1
  152. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +150 -55
  153. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  154. package/build/components/template-part-converter/convert-to-regular.js +1 -1
  155. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  156. package/build/components/welcome-guide/page.js +2 -2
  157. package/build/components/welcome-guide/page.js.map +1 -1
  158. package/build/components/welcome-guide/template.js +6 -3
  159. package/build/components/welcome-guide/template.js.map +1 -1
  160. package/build/hooks/commands/use-edit-mode-commands.js +24 -14
  161. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  162. package/build/hooks/push-changes-to-global-styles/index.js +3 -1
  163. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  164. package/build/hooks/template-part-edit.js +6 -2
  165. package/build/hooks/template-part-edit.js.map +1 -1
  166. package/build/index.js +0 -3
  167. package/build/index.js.map +1 -1
  168. package/build/store/actions.js +39 -83
  169. package/build/store/actions.js.map +1 -1
  170. package/build/store/private-actions.js +2 -27
  171. package/build/store/private-actions.js.map +1 -1
  172. package/build/store/private-selectors.js +0 -23
  173. package/build/store/private-selectors.js.map +1 -1
  174. package/build/store/reducer.js +1 -40
  175. package/build/store/reducer.js.map +1 -1
  176. package/build/store/selectors.js +33 -67
  177. package/build/store/selectors.js.map +1 -1
  178. package/build/utils/constants.js +3 -14
  179. package/build/utils/constants.js.map +1 -1
  180. package/build-module/components/actions/index.js +113 -14
  181. package/build-module/components/actions/index.js.map +1 -1
  182. package/build-module/components/add-new-template/new-template.js +0 -7
  183. package/build-module/components/add-new-template/new-template.js.map +1 -1
  184. package/build-module/components/block-editor/site-editor-canvas.js +7 -2
  185. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  186. package/build-module/components/block-editor/use-site-editor-settings.js +54 -62
  187. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  188. package/build-module/components/dataviews/add-filter.js +84 -0
  189. package/build-module/components/dataviews/add-filter.js.map +1 -0
  190. package/build-module/components/dataviews/constants.js +6 -0
  191. package/build-module/components/dataviews/constants.js.map +1 -0
  192. package/build-module/components/dataviews/dataviews.js +29 -9
  193. package/build-module/components/dataviews/dataviews.js.map +1 -1
  194. package/build-module/components/dataviews/filter-summary.js +55 -0
  195. package/build-module/components/dataviews/filter-summary.js.map +1 -0
  196. package/build-module/components/dataviews/filters.js +37 -48
  197. package/build-module/components/dataviews/filters.js.map +1 -1
  198. package/build-module/components/dataviews/index.js +1 -1
  199. package/build-module/components/dataviews/index.js.map +1 -1
  200. package/build-module/components/dataviews/item-actions.js +142 -20
  201. package/build-module/components/dataviews/item-actions.js.map +1 -1
  202. package/build-module/components/dataviews/pagination.js +7 -2
  203. package/build-module/components/dataviews/pagination.js.map +1 -1
  204. package/build-module/components/dataviews/reset-filters.js +26 -0
  205. package/build-module/components/dataviews/reset-filters.js.map +1 -0
  206. package/build-module/components/dataviews/search.js +1 -0
  207. package/build-module/components/dataviews/search.js.map +1 -1
  208. package/build-module/components/dataviews/view-actions.js +50 -33
  209. package/build-module/components/dataviews/view-actions.js.map +1 -1
  210. package/build-module/components/dataviews/view-grid.js +49 -26
  211. package/build-module/components/dataviews/view-grid.js.map +1 -1
  212. package/build-module/components/dataviews/view-list.js +132 -16
  213. package/build-module/components/dataviews/view-list.js.map +1 -1
  214. package/build-module/components/dataviews/view-side-by-side.js +12 -0
  215. package/build-module/components/dataviews/view-side-by-side.js.map +1 -0
  216. package/build-module/components/editor/index.js +55 -59
  217. package/build-module/components/editor/index.js.map +1 -1
  218. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  219. package/build-module/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js.map +1 -1
  220. package/build-module/components/global-styles/font-library-modal/utils/index.js +14 -2
  221. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  222. package/build-module/components/global-styles/header.js +4 -2
  223. package/build-module/components/global-styles/header.js.map +1 -1
  224. package/build-module/components/global-styles/screen-block-list.js +23 -17
  225. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  226. package/build-module/components/global-styles/screen-revisions/index.js +67 -25
  227. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  228. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +51 -24
  229. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  230. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +9 -3
  231. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  232. package/build-module/components/global-styles/screen-root.js +3 -3
  233. package/build-module/components/global-styles/screen-root.js.map +1 -1
  234. package/build-module/components/global-styles/ui.js +31 -39
  235. package/build-module/components/global-styles/ui.js.map +1 -1
  236. package/build-module/components/global-styles-renderer/index.js +1 -1
  237. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  238. package/build-module/components/header-edit-mode/document-actions/index.js +21 -16
  239. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  240. package/build-module/components/header-edit-mode/document-tools/index.js +152 -0
  241. package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -0
  242. package/build-module/components/header-edit-mode/index.js +54 -121
  243. package/build-module/components/header-edit-mode/index.js.map +1 -1
  244. package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
  245. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  246. package/build-module/components/header-edit-mode/more-menu/site-export.js +2 -6
  247. package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -1
  248. package/build-module/components/layout/index.js +5 -20
  249. package/build-module/components/layout/index.js.map +1 -1
  250. package/build-module/components/list/added-by.js +45 -56
  251. package/build-module/components/list/added-by.js.map +1 -1
  252. package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +11 -15
  253. package/build-module/components/page-content-focus-notifications/back-to-page-notification.js.map +1 -0
  254. package/build-module/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  255. package/build-module/components/page-content-focus-notifications/edit-template-notification.js.map +1 -0
  256. package/build-module/components/page-content-focus-notifications/index.js +14 -0
  257. package/build-module/components/page-content-focus-notifications/index.js.map +1 -0
  258. package/build-module/components/page-main/index.js +2 -1
  259. package/build-module/components/page-main/index.js.map +1 -1
  260. package/build-module/components/page-pages/index.js +141 -90
  261. package/build-module/components/page-pages/index.js.map +1 -1
  262. package/build-module/components/page-pages/side-editor.js +17 -0
  263. package/build-module/components/page-pages/side-editor.js.map +1 -0
  264. package/build-module/components/page-patterns/grid-item.js +2 -2
  265. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  266. package/build-module/components/page-patterns/patterns-list.js +4 -4
  267. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  268. package/build-module/components/page-patterns/use-patterns.js +3 -3
  269. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  270. package/build-module/components/page-templates/dataviews-templates.js +308 -0
  271. package/build-module/components/page-templates/dataviews-templates.js.map +1 -0
  272. package/build-module/components/page-templates/template-actions.js +157 -0
  273. package/build-module/components/page-templates/template-actions.js.map +1 -0
  274. package/build-module/components/preferences-modal/index.js +1 -1
  275. package/build-module/components/preferences-modal/index.js.map +1 -1
  276. package/build-module/components/save-button/index.js +11 -8
  277. package/build-module/components/save-button/index.js.map +1 -1
  278. package/build-module/components/save-hub/index.js +14 -0
  279. package/build-module/components/save-hub/index.js.map +1 -1
  280. package/build-module/components/sidebar/index.js +1 -2
  281. package/build-module/components/sidebar/index.js.map +1 -1
  282. package/build-module/components/sidebar-dataviews/add-new-view.js +116 -0
  283. package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -0
  284. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +182 -0
  285. package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -0
  286. package/build-module/components/sidebar-dataviews/dataview-item.js +63 -0
  287. package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -0
  288. package/build-module/components/sidebar-dataviews/default-views.js +57 -0
  289. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -0
  290. package/build-module/components/sidebar-dataviews/index.js +22 -39
  291. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  292. package/build-module/components/sidebar-edit-mode/default-sidebar.js +2 -6
  293. package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  294. package/build-module/components/sidebar-edit-mode/index.js +6 -5
  295. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  296. package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js +20 -31
  297. package/build-module/components/sidebar-edit-mode/page-panels/edit-template.js.map +1 -1
  298. package/build-module/components/sidebar-edit-mode/page-panels/hooks.js +21 -7
  299. package/build-module/components/sidebar-edit-mode/page-panels/hooks.js.map +1 -1
  300. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +9 -6
  301. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  302. package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js +6 -8
  303. package/build-module/components/sidebar-edit-mode/page-panels/page-summary.js.map +1 -1
  304. package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js +8 -16
  305. package/build-module/components/sidebar-edit-mode/page-panels/reset-default-template.js.map +1 -1
  306. package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js +5 -13
  307. package/build-module/components/sidebar-edit-mode/page-panels/swap-template-button.js.map +1 -1
  308. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +2 -6
  309. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  310. package/build-module/components/sidebar-edit-mode/settings-header/index.js +10 -6
  311. package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  312. package/build-module/components/sidebar-edit-mode/template-panel/hooks.js +4 -4
  313. package/build-module/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -1
  314. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +1 -1
  315. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  316. package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
  317. package/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js.map +1 -1
  318. package/build-module/components/sidebar-navigation-screen-page/index.js +23 -4
  319. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
  320. package/build-module/components/sidebar-navigation-screen-page/page-details.js +3 -11
  321. package/build-module/components/sidebar-navigation-screen-page/page-details.js.map +1 -1
  322. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
  323. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  324. package/build-module/components/site-hub/index.js +19 -7
  325. package/build-module/components/site-hub/index.js.map +1 -1
  326. package/build-module/components/start-template-options/index.js +13 -16
  327. package/build-module/components/start-template-options/index.js.map +1 -1
  328. package/build-module/components/style-book/index.js +22 -12
  329. package/build-module/components/style-book/index.js.map +1 -1
  330. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +150 -56
  331. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  332. package/build-module/components/template-part-converter/convert-to-regular.js +1 -1
  333. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  334. package/build-module/components/welcome-guide/page.js +2 -2
  335. package/build-module/components/welcome-guide/page.js.map +1 -1
  336. package/build-module/components/welcome-guide/template.js +6 -3
  337. package/build-module/components/welcome-guide/template.js.map +1 -1
  338. package/build-module/hooks/commands/use-edit-mode-commands.js +24 -14
  339. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  340. package/build-module/hooks/push-changes-to-global-styles/index.js +4 -2
  341. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  342. package/build-module/hooks/template-part-edit.js +6 -2
  343. package/build-module/hooks/template-part-edit.js.map +1 -1
  344. package/build-module/index.js +0 -3
  345. package/build-module/index.js.map +1 -1
  346. package/build-module/store/actions.js +37 -80
  347. package/build-module/store/actions.js.map +1 -1
  348. package/build-module/store/private-actions.js +1 -25
  349. package/build-module/store/private-actions.js.map +1 -1
  350. package/build-module/store/private-selectors.js +0 -22
  351. package/build-module/store/private-selectors.js.map +1 -1
  352. package/build-module/store/reducer.js +1 -38
  353. package/build-module/store/reducer.js.map +1 -1
  354. package/build-module/store/selectors.js +27 -62
  355. package/build-module/store/selectors.js.map +1 -1
  356. package/build-module/utils/constants.js +1 -11
  357. package/build-module/utils/constants.js.map +1 -1
  358. package/build-style/style-rtl.css +221 -181
  359. package/build-style/style.css +221 -181
  360. package/package.json +41 -41
  361. package/src/components/actions/index.js +150 -14
  362. package/src/components/add-new-template/new-template.js +0 -5
  363. package/src/components/block-editor/site-editor-canvas.js +8 -2
  364. package/src/components/block-editor/style.scss +0 -87
  365. package/src/components/block-editor/use-site-editor-settings.js +68 -89
  366. package/src/components/dataviews/README.md +80 -83
  367. package/src/components/dataviews/add-filter.js +108 -0
  368. package/src/components/dataviews/constants.js +5 -0
  369. package/src/components/dataviews/dataviews.js +28 -10
  370. package/src/components/dataviews/filter-summary.js +79 -0
  371. package/src/components/dataviews/filters.js +48 -58
  372. package/src/components/dataviews/index.js +1 -1
  373. package/src/components/dataviews/item-actions.js +169 -30
  374. package/src/components/dataviews/pagination.js +9 -4
  375. package/src/components/dataviews/reset-filters.js +26 -0
  376. package/src/components/dataviews/search.js +1 -0
  377. package/src/components/dataviews/style.scss +89 -9
  378. package/src/components/dataviews/view-actions.js +77 -49
  379. package/src/components/dataviews/view-grid.js +63 -38
  380. package/src/components/dataviews/view-list.js +182 -18
  381. package/src/components/dataviews/view-side-by-side.js +9 -0
  382. package/src/components/editor/index.js +135 -123
  383. package/src/components/global-styles/font-library-modal/utils/get-intersecting-font-faces.js +1 -1
  384. package/src/components/global-styles/font-library-modal/utils/index.js +20 -9
  385. package/src/components/global-styles/font-library-modal/utils/test/getIntersectingFontFaces.spec.js +46 -15
  386. package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +28 -0
  387. package/src/components/global-styles/header.js +2 -1
  388. package/src/components/global-styles/screen-block-list.js +37 -26
  389. package/src/components/global-styles/screen-revisions/index.js +91 -35
  390. package/src/components/global-styles/screen-revisions/revisions-buttons.js +65 -45
  391. package/src/components/global-styles/screen-revisions/style.scss +52 -28
  392. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -6
  393. package/src/components/global-styles/screen-root.js +2 -1
  394. package/src/components/global-styles/style.scss +0 -11
  395. package/src/components/global-styles/ui.js +60 -75
  396. package/src/components/global-styles-renderer/index.js +1 -1
  397. package/src/components/header-edit-mode/document-actions/index.js +20 -18
  398. package/src/components/header-edit-mode/document-tools/index.js +201 -0
  399. package/src/components/header-edit-mode/index.js +87 -184
  400. package/src/components/header-edit-mode/more-menu/index.js +1 -1
  401. package/src/components/header-edit-mode/more-menu/site-export.js +2 -6
  402. package/src/components/header-edit-mode/style.scss +35 -2
  403. package/src/components/layout/index.js +4 -11
  404. package/src/components/layout/style.scss +6 -18
  405. package/src/components/list/added-by.js +24 -64
  406. package/src/components/list/style.scss +11 -13
  407. package/src/components/{page-content-focus-manager → page-content-focus-notifications}/back-to-page-notification.js +10 -22
  408. package/src/components/{page-content-focus-manager → page-content-focus-notifications}/edit-template-notification.js +9 -13
  409. package/src/components/page-content-focus-notifications/index.js +14 -0
  410. package/src/components/page-main/index.js +6 -1
  411. package/src/components/page-pages/index.js +167 -91
  412. package/src/components/page-pages/side-editor.js +14 -0
  413. package/src/components/page-patterns/grid-item.js +3 -3
  414. package/src/components/page-patterns/patterns-list.js +10 -4
  415. package/src/components/page-patterns/use-patterns.js +4 -3
  416. package/src/components/page-templates/dataviews-templates.js +345 -0
  417. package/src/components/page-templates/style.scss +13 -0
  418. package/src/components/page-templates/template-actions.js +209 -0
  419. package/src/components/preferences-modal/index.js +1 -1
  420. package/src/components/save-button/index.js +37 -24
  421. package/src/components/save-hub/index.js +15 -0
  422. package/src/components/save-hub/style.scss +7 -0
  423. package/src/components/sidebar/index.js +1 -2
  424. package/src/components/sidebar-dataviews/add-new-view.js +141 -0
  425. package/src/components/sidebar-dataviews/custom-dataviews-list.js +229 -0
  426. package/src/components/sidebar-dataviews/dataview-item.js +67 -0
  427. package/src/components/sidebar-dataviews/default-views.js +59 -0
  428. package/src/components/sidebar-dataviews/index.js +36 -45
  429. package/src/components/sidebar-dataviews/style.scss +29 -0
  430. package/src/components/sidebar-edit-mode/default-sidebar.js +6 -6
  431. package/src/components/sidebar-edit-mode/index.js +13 -9
  432. package/src/components/sidebar-edit-mode/page-panels/edit-template.js +31 -57
  433. package/src/components/sidebar-edit-mode/page-panels/hooks.js +20 -9
  434. package/src/components/sidebar-edit-mode/page-panels/page-status.js +6 -6
  435. package/src/components/sidebar-edit-mode/page-panels/page-summary.js +10 -8
  436. package/src/components/sidebar-edit-mode/page-panels/reset-default-template.js +13 -12
  437. package/src/components/sidebar-edit-mode/page-panels/style.scss +14 -19
  438. package/src/components/sidebar-edit-mode/page-panels/swap-template-button.js +10 -9
  439. package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +6 -6
  440. package/src/components/sidebar-edit-mode/settings-header/index.js +8 -9
  441. package/src/components/sidebar-edit-mode/template-panel/hooks.js +11 -7
  442. package/src/components/sidebar-navigation-screen/style.scss +1 -0
  443. package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -1
  444. package/src/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js +1 -1
  445. package/src/components/sidebar-navigation-screen-page/index.js +24 -3
  446. package/src/components/sidebar-navigation-screen-page/page-details.js +4 -17
  447. package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -2
  448. package/src/components/sidebar-navigation-screen-template/style.scss +6 -1
  449. package/src/components/site-hub/index.js +9 -8
  450. package/src/components/start-template-options/index.js +14 -12
  451. package/src/components/style-book/index.js +48 -35
  452. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +182 -63
  453. package/src/components/template-part-converter/convert-to-regular.js +1 -1
  454. package/src/components/welcome-guide/page.js +2 -2
  455. package/src/components/welcome-guide/template.js +4 -2
  456. package/src/hooks/commands/use-edit-mode-commands.js +22 -16
  457. package/src/hooks/push-changes-to-global-styles/index.js +13 -6
  458. package/src/hooks/template-part-edit.js +4 -2
  459. package/src/index.js +0 -8
  460. package/src/store/actions.js +42 -96
  461. package/src/store/private-actions.js +1 -24
  462. package/src/store/private-selectors.js +0 -22
  463. package/src/store/reducer.js +0 -39
  464. package/src/store/selectors.js +43 -95
  465. package/src/store/test/actions.js +14 -169
  466. package/src/store/test/reducer.js +0 -62
  467. package/src/store/test/selectors.js +0 -117
  468. package/src/style.scss +2 -0
  469. package/src/utils/constants.js +1 -11
  470. package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -77
  471. package/build/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
  472. package/build/components/block-editor/block-editor-provider/index.js +0 -31
  473. package/build/components/block-editor/block-editor-provider/index.js.map +0 -1
  474. package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -110
  475. package/build/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
  476. package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -84
  477. package/build/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
  478. package/build/components/block-editor/index.js +0 -30
  479. package/build/components/block-editor/index.js.map +0 -1
  480. package/build/components/dataviews/in-filter.js +0 -49
  481. package/build/components/dataviews/in-filter.js.map +0 -1
  482. package/build/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
  483. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -50
  484. package/build/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
  485. package/build/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
  486. package/build/components/page-content-focus-manager/index.js +0 -61
  487. package/build/components/page-content-focus-manager/index.js.map +0 -1
  488. package/build/components/page-pages/default-views.js +0 -62
  489. package/build/components/page-pages/default-views.js.map +0 -1
  490. package/build/components/sidebar-edit-mode/page-panels/publish-date.js +0 -87
  491. package/build/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
  492. package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -69
  493. package/build-module/components/block-editor/block-editor-provider/default-block-editor-provider.js.map +0 -1
  494. package/build-module/components/block-editor/block-editor-provider/index.js +0 -23
  495. package/build-module/components/block-editor/block-editor-provider/index.js.map +0 -1
  496. package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -102
  497. package/build-module/components/block-editor/block-editor-provider/navigation-block-editor-provider.js.map +0 -1
  498. package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -78
  499. package/build-module/components/block-editor/block-editor-provider/use-page-content-blocks.js.map +0 -1
  500. package/build-module/components/block-editor/index.js +0 -22
  501. package/build-module/components/block-editor/index.js.map +0 -1
  502. package/build-module/components/dataviews/in-filter.js +0 -41
  503. package/build-module/components/dataviews/in-filter.js.map +0 -1
  504. package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +0 -1
  505. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -43
  506. package/build-module/components/page-content-focus-manager/disable-non-page-content-blocks.js.map +0 -1
  507. package/build-module/components/page-content-focus-manager/edit-template-notification.js.map +0 -1
  508. package/build-module/components/page-content-focus-manager/index.js +0 -52
  509. package/build-module/components/page-content-focus-manager/index.js.map +0 -1
  510. package/build-module/components/page-pages/default-views.js +0 -55
  511. package/build-module/components/page-pages/default-views.js.map +0 -1
  512. package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js +0 -80
  513. package/build-module/components/sidebar-edit-mode/page-panels/publish-date.js.map +0 -1
  514. package/src/components/block-editor/block-editor-provider/default-block-editor-provider.js +0 -75
  515. package/src/components/block-editor/block-editor-provider/index.js +0 -29
  516. package/src/components/block-editor/block-editor-provider/navigation-block-editor-provider.js +0 -114
  517. package/src/components/block-editor/block-editor-provider/test/use-page-content-blocks.js +0 -116
  518. package/src/components/block-editor/block-editor-provider/use-page-content-blocks.js +0 -90
  519. package/src/components/block-editor/index.js +0 -28
  520. package/src/components/dataviews/in-filter.js +0 -45
  521. package/src/components/page-content-focus-manager/disable-non-page-content-blocks.js +0 -52
  522. package/src/components/page-content-focus-manager/index.js +0 -51
  523. package/src/components/page-pages/default-views.js +0 -60
  524. package/src/components/sidebar-edit-mode/page-panels/publish-date.js +0 -94
@@ -14,7 +14,8 @@ var _icons = require("@wordpress/icons");
14
14
 
15
15
  function ScreenHeader({
16
16
  title,
17
- description
17
+ description,
18
+ onBack
18
19
  }) {
19
20
  return (0, _react.createElement)(_components.__experimentalVStack, {
20
21
  spacing: 0
@@ -34,7 +35,8 @@ function ScreenHeader({
34
35
  },
35
36
  icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
36
37
  isSmall: true,
37
- "aria-label": (0, _i18n.__)('Navigate to the previous view')
38
+ "aria-label": (0, _i18n.__)('Navigate to the previous view'),
39
+ onClick: onBack
38
40
  }), (0, _react.createElement)(_components.__experimentalSpacer, null, (0, _react.createElement)(_components.__experimentalHeading, {
39
41
  className: "edit-site-global-styles-header",
40
42
  level: 2,
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_icons","ScreenHeader","title","description","_react","createElement","__experimentalVStack","spacing","__experimentalView","__experimentalSpacer","marginBottom","paddingX","paddingY","__experimentalHStack","__experimentalNavigatorToParentButton","style","minWidth","padding","icon","isRTL","chevronRight","chevronLeft","isSmall","__","__experimentalHeading","className","level","size","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\nfunction ScreenHeader( { title, description } ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\taria-label={ __( 'Navigate to the previous view' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"edit-site-global-styles-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default ScreenHeader;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAZA;AACA;AACA;;AAYA,SAASG,YAAYA,CAAE;EAAEC,KAAK;EAAEC;AAAY,CAAC,EAAG;EAC/C,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAS,oBAAM;IAACC,OAAO,EAAG;EAAG,GACpB,IAAAH,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAW,kBAAI,QACJ,IAAAJ,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAY,oBAAM;IAACC,YAAY,EAAG,CAAG;IAACC,QAAQ,EAAG,CAAG;IAACC,QAAQ,EAAG;EAAG,GACvD,IAAAR,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAgB,oBAAM;IAACN,OAAO,EAAG;EAAG,GACpB,IAAAH,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAiB,qCAAuB;IACvBC,KAAK;IACJ;IACA;IACA;MAAEC,QAAQ,EAAE,EAAE;MAAEC,OAAO,EAAE;IAAE,CAC3B;IACDC,IAAI,EAAG,IAAAC,WAAK,EAAC,CAAC,GAAGC,mBAAY,GAAGC,kBAAa;IAC7CC,OAAO;IACP,cAAa,IAAAC,QAAE,EAAE,+BAAgC;EAAG,CACpD,CAAC,EACF,IAAAnB,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAAY,oBAAM,QACN,IAAAL,MAAA,CAAAC,aAAA,EAACR,WAAA,CAAA2B,qBAAO;IACPC,SAAS,EAAC,gCAAgC;IAC1CC,KAAK,EAAG,CAAG;IACXC,IAAI,EAAG;EAAI,GAETzB,KACM,CACF,CACD,CACD,CACH,CAAC,EACLC,WAAW,IACZ,IAAAC,MAAA,CAAAC,aAAA;IAAGoB,SAAS,EAAC;EAA6C,GACvDtB,WACA,CAEG,CAAC;AAEX;AAAC,IAAAyB,QAAA,GAEc3B,YAAY;AAAA4B,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_components","require","_i18n","_icons","ScreenHeader","title","description","onBack","_react","createElement","__experimentalVStack","spacing","__experimentalView","__experimentalSpacer","marginBottom","paddingX","paddingY","__experimentalHStack","__experimentalNavigatorToParentButton","style","minWidth","padding","icon","isRTL","chevronRight","chevronLeft","isSmall","__","onClick","__experimentalHeading","className","level","size","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/global-styles/header.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHeading as Heading,\n\t__experimentalView as View,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\nfunction ScreenHeader( { title, description, onBack } ) {\n\treturn (\n\t\t<VStack spacing={ 0 }>\n\t\t\t<View>\n\t\t\t\t<Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>\n\t\t\t\t\t<HStack spacing={ 2 }>\n\t\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\taria-label={ __( 'Navigate to the previous view' ) }\n\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Spacer>\n\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</HStack>\n\t\t\t\t</Spacer>\n\t\t\t</View>\n\t\t\t{ description && (\n\t\t\t\t<p className=\"edit-site-global-styles-header__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default ScreenHeader;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAZA;AACA;AACA;;AAYA,SAASG,YAAYA,CAAE;EAAEC,KAAK;EAAEC,WAAW;EAAEC;AAAO,CAAC,EAAG;EACvD,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAU,oBAAM;IAACC,OAAO,EAAG;EAAG,GACpB,IAAAH,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAY,kBAAI,QACJ,IAAAJ,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAa,oBAAM;IAACC,YAAY,EAAG,CAAG;IAACC,QAAQ,EAAG,CAAG;IAACC,QAAQ,EAAG;EAAG,GACvD,IAAAR,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAiB,oBAAM;IAACN,OAAO,EAAG;EAAG,GACpB,IAAAH,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAkB,qCAAuB;IACvBC,KAAK;IACJ;IACA;IACA;MAAEC,QAAQ,EAAE,EAAE;MAAEC,OAAO,EAAE;IAAE,CAC3B;IACDC,IAAI,EAAG,IAAAC,WAAK,EAAC,CAAC,GAAGC,mBAAY,GAAGC,kBAAa;IAC7CC,OAAO;IACP,cAAa,IAAAC,QAAE,EAAE,+BAAgC,CAAG;IACpDC,OAAO,EAAGrB;EAAQ,CAClB,CAAC,EACF,IAAAC,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAa,oBAAM,QACN,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAA6B,qBAAO;IACPC,SAAS,EAAC,gCAAgC;IAC1CC,KAAK,EAAG,CAAG;IACXC,IAAI,EAAG;EAAI,GAET3B,KACM,CACF,CACD,CACD,CACH,CAAC,EACLC,WAAW,IACZ,IAAAE,MAAA,CAAAC,aAAA;IAAGqB,SAAS,EAAC;EAA6C,GACvDxB,WACA,CAEG,CAAC;AAEX;AAAC,IAAA2B,QAAA,GAEc7B,YAAY;AAAA8B,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -91,17 +91,15 @@ function BlockMenuItem({
91
91
  icon: block.icon
92
92
  }), (0, _react.createElement)(_components.FlexItem, null, block.title)));
93
93
  }
94
- function ScreenBlockList() {
94
+ function BlockList({
95
+ filterValue
96
+ }) {
95
97
  const sortedBlockTypes = useSortedBlockTypes();
96
- const [filterValue, setFilterValue] = (0, _element.useState)('');
97
98
  const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
98
- const isMatchingSearchTerm = (0, _data.useSelect)(select => select(_blocks.store).isMatchingSearchTerm, []);
99
- const filteredBlockTypes = (0, _element.useMemo)(() => {
100
- if (!filterValue) {
101
- return sortedBlockTypes;
102
- }
103
- return sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
104
- }, [filterValue, sortedBlockTypes, isMatchingSearchTerm]);
99
+ const {
100
+ isMatchingSearchTerm
101
+ } = (0, _data.useSelect)(_blocks.store);
102
+ const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue));
105
103
  const blockTypesListRef = (0, _element.useRef)();
106
104
 
107
105
  // Announce search results on change
@@ -122,6 +120,18 @@ function ScreenBlockList() {
122
120
  (0, _i18n._n)('%d result found.', '%d results found.', count), count);
123
121
  debouncedSpeak(resultsFoundMessage, count);
124
122
  }, [filterValue, debouncedSpeak]);
123
+ return (0, _react.createElement)("div", {
124
+ ref: blockTypesListRef,
125
+ className: "edit-site-block-types-item-list"
126
+ }, filteredBlockTypes.map(block => (0, _react.createElement)(BlockMenuItem, {
127
+ block: block,
128
+ key: 'menu-itemblock-' + block.name
129
+ })));
130
+ }
131
+ const MemoizedBlockList = (0, _element.memo)(BlockList);
132
+ function ScreenBlockList() {
133
+ const [filterValue, setFilterValue] = (0, _element.useState)('');
134
+ const deferredFilterValue = (0, _element.useDeferredValue)(filterValue);
125
135
  return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_header.default, {
126
136
  title: (0, _i18n.__)('Blocks'),
127
137
  description: (0, _i18n.__)('Customize the appearance of specific blocks and for the whole site.')
@@ -132,13 +142,9 @@ function ScreenBlockList() {
132
142
  value: filterValue,
133
143
  label: (0, _i18n.__)('Search for blocks'),
134
144
  placeholder: (0, _i18n.__)('Search')
135
- }), (0, _react.createElement)("div", {
136
- ref: blockTypesListRef,
137
- className: "edit-site-block-types-item-list"
138
- }, filteredBlockTypes.map(block => (0, _react.createElement)(BlockMenuItem, {
139
- block: block,
140
- key: 'menu-itemblock-' + block.name
141
- }))));
145
+ }), (0, _react.createElement)(MemoizedBlockList, {
146
+ filterValue: deferredFilterValue
147
+ }));
142
148
  }
143
149
  var _default = ScreenBlockList;
144
150
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_i18n","_components","_data","_element","_blockEditor","_compose","_a11y","_variationsPanel","_header","_interopRequireDefault","_navigationButton","_lockUnlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","unlock","blockEditorPrivateApis","useSortedBlockTypes","blockItems","useSelect","select","blocksStore","getBlockTypes","groupByType","blocks","block","core","noncore","type","name","startsWith","push","coreItems","nonCoreItems","reduce","useBlockHasGlobalStyles","blockName","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","useBlockVariations","length","hasGlobalStyles","BlockMenuItem","hasBlockMenuItem","navigationButtonLabel","sprintf","__","title","_react","createElement","NavigationButtonAsItem","path","encodeURIComponent","__experimentalHStack","justify","BlockIcon","icon","FlexItem","ScreenBlockList","sortedBlockTypes","filterValue","setFilterValue","useState","debouncedSpeak","useDebounce","speak","isMatchingSearchTerm","filteredBlockTypes","useMemo","filter","blockType","blockTypesListRef","useRef","useEffect","count","current","childElementCount","resultsFoundMessage","_n","Fragment","default","description","SearchControl","__nextHasNoMarginBottom","className","onChange","value","label","placeholder","ref","map","key","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport {\n\tFlexItem,\n\tSearchControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useState, useMemo, useEffect, useRef } from '@wordpress/element';\nimport {\n\tBlockIcon,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { useBlockVariations } from './variations-panel';\nimport ScreenHeader from './header';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction useSortedBlockTypes() {\n\tconst blockItems = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\t// Ensure core blocks are prioritized in the returned results,\n\t// because third party blocks can be registered earlier than\n\t// the core blocks (usually by using the `init` action),\n\t// thus affecting the display order.\n\t// We don't sort reusable blocks as they are handled differently.\n\tconst groupByType = ( blocks, block ) => {\n\t\tconst { core, noncore } = blocks;\n\t\tconst type = block.name.startsWith( 'core/' ) ? core : noncore;\n\t\ttype.push( block );\n\t\treturn blocks;\n\t};\n\tconst { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(\n\t\tgroupByType,\n\t\t{ core: [], noncore: [] }\n\t);\n\treturn [ ...coreItems, ...nonCoreItems ];\n}\n\nexport function useBlockHasGlobalStyles( blockName ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', blockName );\n\tconst settings = useSettingsForBlockElement( rawSettings, blockName );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\tconst hasVariationsPanel = !! useBlockVariations( blockName )?.length;\n\tconst hasGlobalStyles =\n\t\thasTypographyPanel ||\n\t\thasColorPanel ||\n\t\thasLayoutPanel ||\n\t\thasVariationsPanel;\n\treturn hasGlobalStyles;\n}\n\nfunction BlockMenuItem( { block } ) {\n\tconst hasBlockMenuItem = useBlockHasGlobalStyles( block.name );\n\tif ( ! hasBlockMenuItem ) {\n\t\treturn null;\n\t}\n\n\tconst navigationButtonLabel = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t__( '%s block styles' ),\n\t\tblock.title\n\t);\n\n\treturn (\n\t\t<NavigationButtonAsItem\n\t\t\tpath={ '/blocks/' + encodeURIComponent( block.name ) }\n\t\t\taria-label={ navigationButtonLabel }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ block.icon } />\n\t\t\t\t<FlexItem>{ block.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</NavigationButtonAsItem>\n\t);\n}\n\nfunction ScreenBlockList() {\n\tconst sortedBlockTypes = useSortedBlockTypes();\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst isMatchingSearchTerm = useSelect(\n\t\t( select ) => select( blocksStore ).isMatchingSearchTerm,\n\t\t[]\n\t);\n\tconst filteredBlockTypes = useMemo( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn sortedBlockTypes;\n\t\t}\n\t\treturn sortedBlockTypes.filter( ( blockType ) =>\n\t\t\tisMatchingSearchTerm( blockType, filterValue )\n\t\t);\n\t}, [ filterValue, sortedBlockTypes, isMatchingSearchTerm ] );\n\n\tconst blockTypesListRef = useRef();\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\t// We extract the results from the wrapper div's `ref` because\n\t\t// filtered items can contain items that will eventually not\n\t\t// render and there is no reliable way to detect when a child\n\t\t// will return `null`.\n\t\t// TODO: We should find a better way of handling this as it's\n\t\t// fragile and depends on the number of rendered elements of `BlockMenuItem`,\n\t\t// which is now one.\n\t\t// @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116\n\t\tconst count = blockTypesListRef.current.childElementCount;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage, count );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Blocks' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Customize the appearance of specific blocks and for the whole site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tclassName=\"edit-site-block-types-search\"\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for blocks' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t\t<div\n\t\t\t\tref={ blockTypesListRef }\n\t\t\t\tclassName=\"edit-site-block-types-item-list\"\n\t\t\t>\n\t\t\t\t{ filteredBlockTypes.map( ( block ) => (\n\t\t\t\t\t<BlockMenuItem\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tkey={ 'menu-itemblock-' + block.name }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ScreenBlockList;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAIA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAKA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,iBAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAzBA;AACA;AACA;;AAiBA;AACA;AACA;;AAMA,MAAM;EACLa,qB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,aAAa;IACbC,uBAAuB;IACvBC,SAAS,EAAC,8BAA8B;IACxCC,QAAQ,EAAGxB,cAAgB;IAC3ByB,KAAK,EAAG1B,WAAa;IACrB2B,KAAK,EAAG,IAAAzC,QAAE,EAAE,mBAAoB,CAAG;IACnC0C,WAAW,EAAG,IAAA1C,QAAE,EAAE,QAAS;EAAG,CAC9B,CAAC,EACF,IAAAE,MAAA,CAAAC,aAAA;IACCwC,GAAG,EAAGlB,iBAAmB;IACzBa,SAAS,EAAC;EAAiC,GAEzCjB,kBAAkB,CAACuB,GAAG,CAAIvE,KAAK,IAChC,IAAA6B,MAAA,CAAAC,aAAA,EAACP,aAAa;IACbvB,KAAK,EAAGA,KAAO;IACfwE,GAAG,EAAG,iBAAiB,GAAGxE,KAAK,CAACI;EAAM,CACtC,CACA,CACE,CACJ,CAAC;AAEL;AAAC,IAAAqE,QAAA,GAEclC,eAAe;AAAAmC,OAAA,CAAAb,OAAA,GAAAY,QAAA"}
1
+ {"version":3,"names":["_blocks","require","_i18n","_components","_data","_element","_blockEditor","_compose","_a11y","_variationsPanel","_header","_interopRequireDefault","_navigationButton","_lockUnlock","useHasDimensionsPanel","useHasTypographyPanel","useHasBorderPanel","useGlobalSetting","useSettingsForBlockElement","useHasColorPanel","unlock","blockEditorPrivateApis","useSortedBlockTypes","blockItems","useSelect","select","blocksStore","getBlockTypes","groupByType","blocks","block","core","noncore","type","name","startsWith","push","coreItems","nonCoreItems","reduce","useBlockHasGlobalStyles","blockName","rawSettings","settings","hasTypographyPanel","hasColorPanel","hasBorderPanel","hasDimensionsPanel","hasLayoutPanel","hasVariationsPanel","useBlockVariations","length","hasGlobalStyles","BlockMenuItem","hasBlockMenuItem","navigationButtonLabel","sprintf","__","title","_react","createElement","NavigationButtonAsItem","path","encodeURIComponent","__experimentalHStack","justify","BlockIcon","icon","FlexItem","BlockList","filterValue","sortedBlockTypes","debouncedSpeak","useDebounce","speak","isMatchingSearchTerm","filteredBlockTypes","filter","blockType","blockTypesListRef","useRef","useEffect","count","current","childElementCount","resultsFoundMessage","_n","ref","className","map","key","MemoizedBlockList","memo","ScreenBlockList","setFilterValue","useState","deferredFilterValue","useDeferredValue","Fragment","default","description","SearchControl","__nextHasNoMarginBottom","onChange","value","label","placeholder","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-block-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport {\n\tFlexItem,\n\tSearchControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tuseDeferredValue,\n\tmemo,\n} from '@wordpress/element';\nimport {\n\tBlockIcon,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { useBlockVariations } from './variations-panel';\nimport ScreenHeader from './header';\nimport { NavigationButtonAsItem } from './navigation-button';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tuseHasDimensionsPanel,\n\tuseHasTypographyPanel,\n\tuseHasBorderPanel,\n\tuseGlobalSetting,\n\tuseSettingsForBlockElement,\n\tuseHasColorPanel,\n} = unlock( blockEditorPrivateApis );\n\nfunction useSortedBlockTypes() {\n\tconst blockItems = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\t// Ensure core blocks are prioritized in the returned results,\n\t// because third party blocks can be registered earlier than\n\t// the core blocks (usually by using the `init` action),\n\t// thus affecting the display order.\n\t// We don't sort reusable blocks as they are handled differently.\n\tconst groupByType = ( blocks, block ) => {\n\t\tconst { core, noncore } = blocks;\n\t\tconst type = block.name.startsWith( 'core/' ) ? core : noncore;\n\t\ttype.push( block );\n\t\treturn blocks;\n\t};\n\tconst { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(\n\t\tgroupByType,\n\t\t{ core: [], noncore: [] }\n\t);\n\treturn [ ...coreItems, ...nonCoreItems ];\n}\n\nexport function useBlockHasGlobalStyles( blockName ) {\n\tconst [ rawSettings ] = useGlobalSetting( '', blockName );\n\tconst settings = useSettingsForBlockElement( rawSettings, blockName );\n\tconst hasTypographyPanel = useHasTypographyPanel( settings );\n\tconst hasColorPanel = useHasColorPanel( settings );\n\tconst hasBorderPanel = useHasBorderPanel( settings );\n\tconst hasDimensionsPanel = useHasDimensionsPanel( settings );\n\tconst hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;\n\tconst hasVariationsPanel = !! useBlockVariations( blockName )?.length;\n\tconst hasGlobalStyles =\n\t\thasTypographyPanel ||\n\t\thasColorPanel ||\n\t\thasLayoutPanel ||\n\t\thasVariationsPanel;\n\treturn hasGlobalStyles;\n}\n\nfunction BlockMenuItem( { block } ) {\n\tconst hasBlockMenuItem = useBlockHasGlobalStyles( block.name );\n\tif ( ! hasBlockMenuItem ) {\n\t\treturn null;\n\t}\n\n\tconst navigationButtonLabel = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Table'.\n\t\t__( '%s block styles' ),\n\t\tblock.title\n\t);\n\n\treturn (\n\t\t<NavigationButtonAsItem\n\t\t\tpath={ '/blocks/' + encodeURIComponent( block.name ) }\n\t\t\taria-label={ navigationButtonLabel }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<BlockIcon icon={ block.icon } />\n\t\t\t\t<FlexItem>{ block.title }</FlexItem>\n\t\t\t</HStack>\n\t\t</NavigationButtonAsItem>\n\t);\n}\n\nfunction BlockList( { filterValue } ) {\n\tconst sortedBlockTypes = useSortedBlockTypes();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst { isMatchingSearchTerm } = useSelect( blocksStore );\n\n\tconst filteredBlockTypes = ! filterValue\n\t\t? sortedBlockTypes\n\t\t: sortedBlockTypes.filter( ( blockType ) =>\n\t\t\t\tisMatchingSearchTerm( blockType, filterValue )\n\t\t );\n\n\tconst blockTypesListRef = useRef();\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\t// We extract the results from the wrapper div's `ref` because\n\t\t// filtered items can contain items that will eventually not\n\t\t// render and there is no reliable way to detect when a child\n\t\t// will return `null`.\n\t\t// TODO: We should find a better way of handling this as it's\n\t\t// fragile and depends on the number of rendered elements of `BlockMenuItem`,\n\t\t// which is now one.\n\t\t// @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116\n\t\tconst count = blockTypesListRef.current.childElementCount;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage, count );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ blockTypesListRef }\n\t\t\tclassName=\"edit-site-block-types-item-list\"\n\t\t>\n\t\t\t{ filteredBlockTypes.map( ( block ) => (\n\t\t\t\t<BlockMenuItem\n\t\t\t\t\tblock={ block }\n\t\t\t\t\tkey={ 'menu-itemblock-' + block.name }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n\nconst MemoizedBlockList = memo( BlockList );\n\nfunction ScreenBlockList() {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst deferredFilterValue = useDeferredValue( filterValue );\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Blocks' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Customize the appearance of specific blocks and for the whole site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tclassName=\"edit-site-block-types-search\"\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for blocks' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t\t<MemoizedBlockList filterValue={ deferredFilterValue } />\n\t\t</>\n\t);\n}\n\nexport default ScreenBlockList;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAOA,IAAAK,YAAA,GAAAL,OAAA;AAIA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAKA,IAAAQ,gBAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,iBAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AA/BA;AACA;AACA;;AAuBA;AACA;AACA;;AAMA,MAAM;EACLa,qBAAqB;EACrBC,qBAAqB;EACrBC,iBAAiB;EACjBC,gBAAgB;EAChBC,0BAA0B;EAC1BC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAEpC,SAASC,mBAAmBA,CAAA,EAAG;EAC9B,MAAMC,UAAU,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAMA,MAAM,CAAEC,aAAY,CAAC,CAACC,aAAa,CAAC,CAAC,EACnD,EACD,CAAC;EACD;EACA;EACA;EACA;EACA;EACA,MAAMC,WAAW,GAAGA,CAAEC,MAAM,EAAEC,KAAK,KAAM;IACxC,MAAM;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAGH,MAAM;IAChC,MAAMI,IAAI,GAAGH,KAAK,CAACI,IAAI,CAACC,UAAU,CAAE,OAAQ,CAAC,GAAGJ,IAAI,GAAGC,OAAO;IAC9DC,IAAI,CAACG,IAAI,CAAEN,KAAM,CAAC;IAClB,OAAOD,MAA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,CAAE,CACvD,CAAC;AAEL;AAAC,IAAAW,QAAA,GAEcd,eAAe;AAAAe,OAAA,CAAAT,OAAA,GAAAQ,QAAA"}
@@ -9,6 +9,7 @@ var _react = require("react");
9
9
  var _i18n = require("@wordpress/i18n");
10
10
  var _components = require("@wordpress/components");
11
11
  var _data = require("@wordpress/data");
12
+ var _coreData = require("@wordpress/core-data");
12
13
  var _element = require("@wordpress/element");
13
14
  var _blockEditor = require("@wordpress/block-editor");
14
15
  var _header = _interopRequireDefault(require("../header"));
@@ -32,19 +33,36 @@ const {
32
33
  } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
33
34
  function ScreenRevisions() {
34
35
  const {
35
- goBack
36
+ goTo
36
37
  } = (0, _components.__experimentalUseNavigator)();
37
38
  const {
38
- user: userConfig,
39
+ user: currentEditorGlobalStyles,
39
40
  setUserConfig
40
41
  } = (0, _element.useContext)(GlobalStylesContext);
41
42
  const {
42
43
  blocks,
43
- editorCanvasContainerView
44
+ editorCanvasContainerView,
45
+ revisionsCount
44
46
  } = (0, _data.useSelect)(select => {
47
+ const {
48
+ getEntityRecord,
49
+ __experimentalGetCurrentGlobalStylesId,
50
+ __experimentalGetDirtyEntityRecords
51
+ } = select(_coreData.store);
52
+ const isDirty = __experimentalGetDirtyEntityRecords().length > 0;
53
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
54
+ const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
55
+ let _revisionsCount = globalStyles?._links?.['version-history']?.[0]?.count || 0;
56
+ // one for the reset item.
57
+ _revisionsCount++;
58
+ // one for any dirty changes (unsaved).
59
+ if (isDirty) {
60
+ _revisionsCount++;
61
+ }
45
62
  return {
46
63
  editorCanvasContainerView: (0, _lockUnlock.unlock)(select(_store.store)).getEditorCanvasContainerView(),
47
- blocks: select(_blockEditor.store).getBlocks()
64
+ blocks: select(_blockEditor.store).getBlocks(),
65
+ revisionsCount: _revisionsCount
48
66
  };
49
67
  }, []);
50
68
  const {
@@ -52,20 +70,15 @@ function ScreenRevisions() {
52
70
  isLoading,
53
71
  hasUnsavedChanges
54
72
  } = (0, _useGlobalStylesRevisions.default)();
55
- const [selectedRevisionId, setSelectedRevisionId] = (0, _element.useState)();
56
- const [globalStylesRevision, setGlobalStylesRevision] = (0, _element.useState)(userConfig);
73
+ const [currentlySelectedRevision, setCurrentlySelectedRevision] = (0, _element.useState)(currentEditorGlobalStyles);
57
74
  const [isLoadingRevisionWithUnsavedChanges, setIsLoadingRevisionWithUnsavedChanges] = (0, _element.useState)(false);
58
75
  const {
59
76
  setEditorCanvasContainerView
60
77
  } = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
61
- (0, _element.useEffect)(() => {
62
- if (editorCanvasContainerView !== 'global-styles-revisions') {
63
- goBack();
64
- setEditorCanvasContainerView(editorCanvasContainerView);
65
- }
66
- }, [editorCanvasContainerView]);
78
+ const selectedRevisionMatchesEditorStyles = areGlobalStyleConfigsEqual(currentlySelectedRevision, currentEditorGlobalStyles);
67
79
  const onCloseRevisions = () => {
68
- goBack();
80
+ goTo('/'); // Return to global styles main panel.
81
+ setEditorCanvasContainerView(undefined);
69
82
  };
70
83
  const restoreRevision = revision => {
71
84
  setUserConfig(() => ({
@@ -76,45 +89,74 @@ function ScreenRevisions() {
76
89
  onCloseRevisions();
77
90
  };
78
91
  const selectRevision = revision => {
79
- setGlobalStylesRevision({
92
+ setCurrentlySelectedRevision({
80
93
  styles: revision?.styles || {},
81
94
  settings: revision?.settings || {},
82
95
  id: revision?.id
83
96
  });
84
- setSelectedRevisionId(revision?.id);
85
97
  };
86
- const isLoadButtonEnabled = !!globalStylesRevision?.id && !areGlobalStyleConfigsEqual(globalStylesRevision, userConfig);
98
+ (0, _element.useEffect)(() => {
99
+ if (editorCanvasContainerView !== 'global-styles-revisions') {
100
+ goTo('/'); // Return to global styles main panel.
101
+ setEditorCanvasContainerView(editorCanvasContainerView);
102
+ }
103
+ }, [editorCanvasContainerView]);
104
+ const firstRevision = revisions[0];
105
+ const currentlySelectedRevisionId = currentlySelectedRevision?.id;
106
+ const shouldSelectFirstItem = !!firstRevision?.id && !selectedRevisionMatchesEditorStyles && !currentlySelectedRevisionId;
107
+ (0, _element.useEffect)(() => {
108
+ /*
109
+ * Ensure that the first item is selected and loaded into the preview pane
110
+ * when no revision is selected and the selected styles don't match the current editor styles.
111
+ * This is required in case editor styles are changed outside the revisions panel,
112
+ * e.g., via the reset styles function of useGlobalStylesReset().
113
+ * See: https://github.com/WordPress/gutenberg/issues/55866
114
+ */
115
+ if (shouldSelectFirstItem) {
116
+ setCurrentlySelectedRevision({
117
+ styles: firstRevision?.styles || {},
118
+ settings: firstRevision?.settings || {},
119
+ id: firstRevision?.id
120
+ });
121
+ }
122
+ }, [shouldSelectFirstItem, firstRevision]);
123
+
124
+ // Only display load button if there is a revision to load and it is different from the current editor styles.
125
+ const isLoadButtonEnabled = !!currentlySelectedRevisionId && !selectedRevisionMatchesEditorStyles;
87
126
  const shouldShowRevisions = !isLoading && revisions.length;
88
127
  return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_header.default, {
89
- title: (0, _i18n.__)('Revisions'),
90
- description: (0, _i18n.__)('Revisions are added to the timeline when style changes are saved.')
128
+ title: revisionsCount &&
129
+ // translators: %s: number of revisions.
130
+ (0, _i18n.sprintf)((0, _i18n.__)('Revisions (%s)'), revisionsCount),
131
+ description: (0, _i18n.__)('Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you\'re ready, use the Save button to save your changes.'),
132
+ onBack: onCloseRevisions
91
133
  }), isLoading && (0, _react.createElement)(_components.Spinner, {
92
134
  className: "edit-site-global-styles-screen-revisions__loading"
93
135
  }), shouldShowRevisions ? (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_revisions.default, {
94
136
  blocks: blocks,
95
- userConfig: globalStylesRevision,
137
+ userConfig: currentlySelectedRevision,
96
138
  onClose: onCloseRevisions
97
139
  }), (0, _react.createElement)("div", {
98
140
  className: "edit-site-global-styles-screen-revisions"
99
141
  }, (0, _react.createElement)(_revisionsButtons.default, {
100
142
  onChange: selectRevision,
101
- selectedRevisionId: selectedRevisionId,
143
+ selectedRevisionId: currentlySelectedRevisionId,
102
144
  userRevisions: revisions
103
145
  }), isLoadButtonEnabled && (0, _react.createElement)(_sidebarFixedBottom.default, null, (0, _react.createElement)(_components.Button, {
104
146
  variant: "primary",
105
147
  className: "edit-site-global-styles-screen-revisions__button",
106
- disabled: !globalStylesRevision?.id || globalStylesRevision?.id === 'unsaved',
148
+ disabled: !currentlySelectedRevisionId || currentlySelectedRevisionId === 'unsaved',
107
149
  onClick: () => {
108
150
  if (hasUnsavedChanges) {
109
151
  setIsLoadingRevisionWithUnsavedChanges(true);
110
152
  } else {
111
- restoreRevision(globalStylesRevision);
153
+ restoreRevision(currentlySelectedRevision);
112
154
  }
113
155
  }
114
- }, globalStylesRevision?.id === 'parent' ? (0, _i18n.__)('Reset to defaults') : (0, _i18n.__)('Apply')))), isLoadingRevisionWithUnsavedChanges && (0, _react.createElement)(_components.__experimentalConfirmDialog, {
156
+ }, currentlySelectedRevisionId === 'parent' ? (0, _i18n.__)('Reset to defaults') : (0, _i18n.__)('Apply')))), isLoadingRevisionWithUnsavedChanges && (0, _react.createElement)(_components.__experimentalConfirmDialog, {
115
157
  isOpen: isLoadingRevisionWithUnsavedChanges,
116
158
  confirmButtonText: (0, _i18n.__)('Apply'),
117
- onConfirm: () => restoreRevision(globalStylesRevision),
159
+ onConfirm: () => restoreRevision(currentlySelectedRevision),
118
160
  onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false)
119
161
  }, (0, _i18n.__)('Any unsaved changes will be lost when you apply this revision.'))) : (0, _react.createElement)(_components.__experimentalSpacer, {
120
162
  marginX: 4,
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_data","_element","_blockEditor","_header","_interopRequireDefault","_lockUnlock","_revisions","_sidebarFixedBottom","_store","_useGlobalStylesRevisions","_revisionsButtons","GlobalStylesContext","areGlobalStyleConfigsEqual","unlock","blockEditorPrivateApis","ScreenRevisions","goBack","useNavigator","user","userConfig","setUserConfig","useContext","blocks","editorCanvasContainerView","useSelect","select","editSiteStore","getEditorCanvasContainerView","blockEditorStore","getBlocks","revisions","isLoading","hasUnsavedChanges","useGlobalStylesRevisions","selectedRevisionId","setSelectedRevisionId","useState","globalStylesRevision","setGlobalStylesRevision","isLoadingRevisionWithUnsavedChanges","setIsLoadingRevisionWithUnsavedChanges","setEditorCanvasContainerView","useDispatch","useEffect","onCloseRevisions","restoreRevision","revision","styles","settings","selectRevision","id","isLoadButtonEnabled","shouldShowRevisions","length","_react","createElement","Fragment","default","title","__","description","Spinner","className","onClose","onChange","userRevisions","Button","variant","disabled","onClick","__experimentalConfirmDialog","isOpen","confirmButtonText","onConfirm","onCancel","__experimentalSpacer","marginX","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-revisions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalUseNavigator as useNavigator,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tSpinner,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useContext, useState, useEffect } from '@wordpress/element';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ScreenHeader from '../header';\nimport { unlock } from '../../../lock-unlock';\nimport Revisions from '../../revisions';\nimport SidebarFixedBottom from '../../sidebar-edit-mode/sidebar-fixed-bottom';\nimport { store as editSiteStore } from '../../../store';\nimport useGlobalStylesRevisions from './use-global-styles-revisions';\nimport RevisionsButtons from './revisions-buttons';\n\nconst { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction ScreenRevisions() {\n\tconst { goBack } = useNavigator();\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\tconst { blocks, editorCanvasContainerView } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\teditorCanvasContainerView: unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t).getEditorCanvasContainerView(),\n\t\t\tblocks: select( blockEditorStore ).getBlocks(),\n\t\t};\n\t}, [] );\n\tconst { revisions, isLoading, hasUnsavedChanges } =\n\t\tuseGlobalStylesRevisions();\n\tconst [ selectedRevisionId, setSelectedRevisionId ] = useState();\n\tconst [ globalStylesRevision, setGlobalStylesRevision ] =\n\t\tuseState( userConfig );\n\tconst [\n\t\tisLoadingRevisionWithUnsavedChanges,\n\t\tsetIsLoadingRevisionWithUnsavedChanges,\n\t] = useState( false );\n\tconst { setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\tuseEffect( () => {\n\t\tif ( editorCanvasContainerView !== 'global-styles-revisions' ) {\n\t\t\tgoBack();\n\t\t\tsetEditorCanvasContainerView( editorCanvasContainerView );\n\t\t}\n\t}, [ editorCanvasContainerView ] );\n\n\tconst onCloseRevisions = () => {\n\t\tgoBack();\n\t};\n\n\tconst restoreRevision = ( revision ) => {\n\t\tsetUserConfig( () => ( {\n\t\t\tstyles: revision?.styles,\n\t\t\tsettings: revision?.settings,\n\t\t} ) );\n\t\tsetIsLoadingRevisionWithUnsavedChanges( false );\n\t\tonCloseRevisions();\n\t};\n\n\tconst selectRevision = ( revision ) => {\n\t\tsetGlobalStylesRevision( {\n\t\t\tstyles: revision?.styles || {},\n\t\t\tsettings: revision?.settings || {},\n\t\t\tid: revision?.id,\n\t\t} );\n\t\tsetSelectedRevisionId( revision?.id );\n\t};\n\n\tconst isLoadButtonEnabled =\n\t\t!! globalStylesRevision?.id &&\n\t\t! areGlobalStyleConfigsEqual( globalStylesRevision, userConfig );\n\tconst shouldShowRevisions = ! isLoading && revisions.length;\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Revisions' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Revisions are added to the timeline when style changes are saved.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ isLoading && (\n\t\t\t\t<Spinner className=\"edit-site-global-styles-screen-revisions__loading\" />\n\t\t\t) }\n\t\t\t{ shouldShowRevisions ? (\n\t\t\t\t<>\n\t\t\t\t\t<Revisions\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tuserConfig={ globalStylesRevision }\n\t\t\t\t\t\tonClose={ onCloseRevisions }\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"edit-site-global-styles-screen-revisions\">\n\t\t\t\t\t\t<RevisionsButtons\n\t\t\t\t\t\t\tonChange={ selectRevision }\n\t\t\t\t\t\t\tselectedRevisionId={ selectedRevisionId }\n\t\t\t\t\t\t\tuserRevisions={ revisions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isLoadButtonEnabled && (\n\t\t\t\t\t\t\t<SidebarFixedBottom>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-revisions__button\"\n\t\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\t\t! globalStylesRevision?.id ||\n\t\t\t\t\t\t\t\t\t\tglobalStylesRevision?.id === 'unsaved'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( hasUnsavedChanges ) {\n\t\t\t\t\t\t\t\t\t\t\tsetIsLoadingRevisionWithUnsavedChanges(\n\t\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\trestoreRevision(\n\t\t\t\t\t\t\t\t\t\t\t\tglobalStylesRevision\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ globalStylesRevision?.id === 'parent'\n\t\t\t\t\t\t\t\t\t\t? __( 'Reset to defaults' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Apply' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</SidebarFixedBottom>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ isLoadingRevisionWithUnsavedChanges && (\n\t\t\t\t\t\t<ConfirmDialog\n\t\t\t\t\t\t\tisOpen={ isLoadingRevisionWithUnsavedChanges }\n\t\t\t\t\t\t\tconfirmButtonText={ __( 'Apply' ) }\n\t\t\t\t\t\t\tonConfirm={ () =>\n\t\t\t\t\t\t\t\trestoreRevision( globalStylesRevision )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonCancel={ () =>\n\t\t\t\t\t\t\t\tsetIsLoadingRevisionWithUnsavedChanges( false )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Any unsaved changes will be lost when you apply this revision.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ConfirmDialog>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<Spacer marginX={ 4 } data-testid=\"global-styles-no-revisions\">\n\t\t\t\t\t{\n\t\t\t\t\t\t// Adding an existing translation here in case these changes are shipped to WordPress 6.3.\n\t\t\t\t\t\t// Later we could update to something better, e.g., \"There are currently no style revisions.\".\n\t\t\t\t\t\t__( 'No results found.' )\n\t\t\t\t\t}\n\t\t\t\t</Spacer>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ScreenRevisions;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAA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BACD,CAAC;MACF;IACD;EAAG,GAEDA,oBAAoB,EAAEa,EAAE,KAAK,QAAQ,GACpC,IAAAS,QAAE,EAAE,mBAAoB,CAAC,GACzB,IAAAA,QAAE,EAAE,OAAQ,CACR,CACW,CAEjB,CAAC,EACJpB,mCAAmC,IACpC,IAAAe,MAAA,CAAAC,aAAA,EAACxD,WAAA,CAAAuE,2BAAa;IACbC,MAAM,EAAGhC,mCAAqC;IAC9CiC,iBAAiB,EAAG,IAAAb,QAAE,EAAE,OAAQ,CAAG;IACnCc,SAAS,EAAGA,CAAA,KACX5B,eAAe,CAAER,oBAAqB,CACtC;IACDqC,QAAQ,EAAGA,CAAA,KACVlC,sCAAsC,CAAE,KAAM;EAC9C,GAEC,IAAAmB,QAAE,EACH,gEACD,CACc,CAEf,CAAC,GAEH,IAAAL,MAAA,CAAAC,aAAA,EAACxD,WAAA,CAAA4E,oBAAM;IAACC,OAAO,EAAG,CAAG;IAAC,eAAY;EAA4B;EAE5D;EACA;EACA,IAAAjB,QAAE,EAAE,mBAAoB,CAElB,CAER,CAAC;AAEL;AAAC,IAAAkB,QAAA,GAEc9D,eAAe;AAAA+D,OAAA,CAAArB,OAAA,GAAAoB,QAAA"}
1
+ {"version":3,"names":["_i18n","require","_components","_data","_coreData","_element","_blockEditor","_header","_interopRequireDefault","_lockUnlock","_revisions","_sidebarFixedBottom","_store","_useGlobalStylesRevisions","_revisionsButtons","GlobalStylesContext","areGlobalStyleConfigsEqual","unlock","blockEditorPrivateApis","ScreenRevisions","goTo","useNavigator","user","currentEditorGlobalStyles","setUserConfig","useContext","blocks","editorCanvasContainerView","revisionsCount","useSelect","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","__experimentalGetDirtyEntityRecords","coreStore","isDirty","length","globalStylesId","globalStyles","undefined","_revisionsCount","_links","count","editSiteStore","getEditorCanvasContainerView","blockEditorStore","getBlocks","revisions","isLoading","hasUnsavedChanges","useGlobalStylesRevisions","currentlySelectedRevision","setCurrentlySelectedRevision","useState","isLoadingRevisionWithUnsavedChanges","setIsLoadingRevisionWithUnsavedChanges","setEditorCanvasContainerView","useDispatch","selectedRevisionMatchesEditorStyles","onCloseRevisions","restoreRevision","revision","styles","settings","selectRevision","id","useEffect","firstRevision","currentlySelectedRevisionId","shouldSelectFirstItem","isLoadButtonEnabled","shouldShowRevisions","_react","createElement","Fragment","default","title","sprintf","__","description","onBack","Spinner","className","userConfig","onClose","onChange","selectedRevisionId","userRevisions","Button","variant","disabled","onClick","__experimentalConfirmDialog","isOpen","confirmButtonText","onConfirm","onCancel","__experimentalSpacer","marginX","_default","exports"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-revisions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalUseNavigator as useNavigator,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tSpinner,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useContext, useState, useEffect } from '@wordpress/element';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ScreenHeader from '../header';\nimport { unlock } from '../../../lock-unlock';\nimport Revisions from '../../revisions';\nimport SidebarFixedBottom from '../../sidebar-edit-mode/sidebar-fixed-bottom';\nimport { store as editSiteStore } from '../../../store';\nimport useGlobalStylesRevisions from './use-global-styles-revisions';\nimport RevisionsButtons from './revisions-buttons';\n\nconst { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(\n\tblockEditorPrivateApis\n);\n\nfunction ScreenRevisions() {\n\tconst { goTo } = useNavigator();\n\tconst { user: currentEditorGlobalStyles, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\tconst { blocks, editorCanvasContainerView, revisionsCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEntityRecord,\n\t\t\t\t__experimentalGetCurrentGlobalStylesId,\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t} = select( coreStore );\n\t\t\tconst isDirty = __experimentalGetDirtyEntityRecords().length > 0;\n\t\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\t\tconst globalStyles = globalStylesId\n\t\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t\t: undefined;\n\t\t\tlet _revisionsCount =\n\t\t\t\tglobalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count || 0;\n\t\t\t// one for the reset item.\n\t\t\t_revisionsCount++;\n\t\t\t// one for any dirty changes (unsaved).\n\t\t\tif ( isDirty ) {\n\t\t\t\t_revisionsCount++;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\teditorCanvasContainerView: unlock(\n\t\t\t\t\tselect( editSiteStore )\n\t\t\t\t).getEditorCanvasContainerView(),\n\t\t\t\tblocks: select( blockEditorStore ).getBlocks(),\n\t\t\t\trevisionsCount: _revisionsCount,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { revisions, isLoading, hasUnsavedChanges } =\n\t\tuseGlobalStylesRevisions();\n\tconst [ currentlySelectedRevision, setCurrentlySelectedRevision ] =\n\t\tuseState( currentEditorGlobalStyles );\n\tconst [\n\t\tisLoadingRevisionWithUnsavedChanges,\n\t\tsetIsLoadingRevisionWithUnsavedChanges,\n\t] = useState( false );\n\tconst { setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst selectedRevisionMatchesEditorStyles = areGlobalStyleConfigsEqual(\n\t\tcurrentlySelectedRevision,\n\t\tcurrentEditorGlobalStyles\n\t);\n\n\tconst onCloseRevisions = () => {\n\t\tgoTo( '/' ); // Return to global styles main panel.\n\t\tsetEditorCanvasContainerView( undefined );\n\t};\n\n\tconst restoreRevision = ( revision ) => {\n\t\tsetUserConfig( () => ( {\n\t\t\tstyles: revision?.styles,\n\t\t\tsettings: revision?.settings,\n\t\t} ) );\n\t\tsetIsLoadingRevisionWithUnsavedChanges( false );\n\t\tonCloseRevisions();\n\t};\n\n\tconst selectRevision = ( revision ) => {\n\t\tsetCurrentlySelectedRevision( {\n\t\t\tstyles: revision?.styles || {},\n\t\t\tsettings: revision?.settings || {},\n\t\t\tid: revision?.id,\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( editorCanvasContainerView !== 'global-styles-revisions' ) {\n\t\t\tgoTo( '/' ); // Return to global styles main panel.\n\t\t\tsetEditorCanvasContainerView( editorCanvasContainerView );\n\t\t}\n\t}, [ editorCanvasContainerView ] );\n\n\tconst firstRevision = revisions[ 0 ];\n\tconst currentlySelectedRevisionId = currentlySelectedRevision?.id;\n\tconst shouldSelectFirstItem =\n\t\t!! firstRevision?.id &&\n\t\t! selectedRevisionMatchesEditorStyles &&\n\t\t! currentlySelectedRevisionId;\n\n\tuseEffect( () => {\n\t\t/*\n\t\t * Ensure that the first item is selected and loaded into the preview pane\n\t\t * when no revision is selected and the selected styles don't match the current editor styles.\n\t\t * This is required in case editor styles are changed outside the revisions panel,\n\t\t * e.g., via the reset styles function of useGlobalStylesReset().\n\t\t * See: https://github.com/WordPress/gutenberg/issues/55866\n\t\t */\n\t\tif ( shouldSelectFirstItem ) {\n\t\t\tsetCurrentlySelectedRevision( {\n\t\t\t\tstyles: firstRevision?.styles || {},\n\t\t\t\tsettings: firstRevision?.settings || {},\n\t\t\t\tid: firstRevision?.id,\n\t\t\t} );\n\t\t}\n\t}, [ shouldSelectFirstItem, firstRevision ] );\n\n\t// Only display load button if there is a revision to load and it is different from the current editor styles.\n\tconst isLoadButtonEnabled =\n\t\t!! currentlySelectedRevisionId && ! selectedRevisionMatchesEditorStyles;\n\tconst shouldShowRevisions = ! isLoading && revisions.length;\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={\n\t\t\t\t\trevisionsCount &&\n\t\t\t\t\t// translators: %s: number of revisions.\n\t\t\t\t\tsprintf( __( 'Revisions (%s)' ), revisionsCount )\n\t\t\t\t}\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Click on previously saved styles to preview them. To restore a selected version to the editor, hit \"Apply.\" When you\\'re ready, use the Save button to save your changes.'\n\t\t\t\t) }\n\t\t\t\tonBack={ onCloseRevisions }\n\t\t\t/>\n\t\t\t{ isLoading && (\n\t\t\t\t<Spinner className=\"edit-site-global-styles-screen-revisions__loading\" />\n\t\t\t) }\n\t\t\t{ shouldShowRevisions ? (\n\t\t\t\t<>\n\t\t\t\t\t<Revisions\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tuserConfig={ currentlySelectedRevision }\n\t\t\t\t\t\tonClose={ onCloseRevisions }\n\t\t\t\t\t/>\n\t\t\t\t\t<div className=\"edit-site-global-styles-screen-revisions\">\n\t\t\t\t\t\t<RevisionsButtons\n\t\t\t\t\t\t\tonChange={ selectRevision }\n\t\t\t\t\t\t\tselectedRevisionId={ currentlySelectedRevisionId }\n\t\t\t\t\t\t\tuserRevisions={ revisions }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isLoadButtonEnabled && (\n\t\t\t\t\t\t\t<SidebarFixedBottom>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-revisions__button\"\n\t\t\t\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\t\t\t\t! currentlySelectedRevisionId ||\n\t\t\t\t\t\t\t\t\t\tcurrentlySelectedRevisionId ===\n\t\t\t\t\t\t\t\t\t\t\t'unsaved'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( hasUnsavedChanges ) {\n\t\t\t\t\t\t\t\t\t\t\tsetIsLoadingRevisionWithUnsavedChanges(\n\t\t\t\t\t\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\trestoreRevision(\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentlySelectedRevision\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ currentlySelectedRevisionId === 'parent'\n\t\t\t\t\t\t\t\t\t\t? __( 'Reset to defaults' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Apply' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</SidebarFixedBottom>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ isLoadingRevisionWithUnsavedChanges && (\n\t\t\t\t\t\t<ConfirmDialog\n\t\t\t\t\t\t\tisOpen={ isLoadingRevisionWithUnsavedChanges }\n\t\t\t\t\t\t\tconfirmButtonText={ __( 'Apply' ) }\n\t\t\t\t\t\t\tonConfirm={ () =>\n\t\t\t\t\t\t\t\trestoreRevision( currentlySelectedRevision )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonCancel={ () =>\n\t\t\t\t\t\t\t\tsetIsLoadingRevisionWithUnsavedChanges( false )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Any unsaved changes will be lost when you apply this revision.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ConfirmDialog>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<Spacer marginX={ 4 } data-testid=\"global-styles-no-revisions\">\n\t\t\t\t\t{\n\t\t\t\t\t\t// Adding an existing translation here in case these changes are shipped to WordPress 6.3.\n\t\t\t\t\t\t// Later we could update to something better, e.g., \"There are currently no style revisions.\".\n\t\t\t\t\t\t__( 'No results found.' )\n\t\t\t\t\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f,IAAK1C,iBAAiB,EAAG;QACxBM,sCAAsC,CACrC,IACD,CAAC;MACF,CAAC,MAAM;QACNK,eAAe,CACdT,yBACD,CAAC;MACF;IACD;EAAG,GAEDiB,2BAA2B,KAAK,QAAQ,GACvC,IAAAU,QAAE,EAAE,mBAAoB,CAAC,GACzB,IAAAA,QAAE,EAAE,OAAQ,CACR,CACW,CAEjB,CAAC,EACJxB,mCAAmC,IACpC,IAAAkB,MAAA,CAAAC,aAAA,EAACvE,WAAA,CAAA0F,2BAAa;IACbC,MAAM,EAAGvC,mCAAqC;IAC9CwC,iBAAiB,EAAG,IAAAhB,QAAE,EAAE,OAAQ,CAAG;IACnCiB,SAAS,EAAGA,CAAA,KACXnC,eAAe,CAAET,yBAA0B,CAC3C;IACD6C,QAAQ,EAAGA,CAAA,KACVzC,sCAAsC,CAAE,KAAM;EAC9C,GAEC,IAAAuB,QAAE,EACH,gEACD,CACc,CAEf,CAAC,GAEH,IAAAN,MAAA,CAAAC,aAAA,EAACvE,WAAA,CAAA+F,oBAAM;IAACC,OAAO,EAAG,CAAG;IAAC,eAAY;EAA4B;EAE5D;EACA;EACA,IAAApB,QAAE,EAAE,mBAAoB,CAElB,CAER,CAAC;AAEL;AAAC,IAAAqB,QAAA,GAEchF,eAAe;AAAAiF,OAAA,CAAAzB,OAAA,GAAAwB,QAAA"}
@@ -20,25 +20,28 @@ var _data = require("@wordpress/data");
20
20
  * WordPress dependencies
21
21
  */
22
22
 
23
+ const DAY_IN_MILLISECONDS = 60 * 60 * 1000 * 24;
24
+
23
25
  /**
24
26
  * Returns a button label for the revision.
25
27
  *
26
- * @param {Object} revision A revision object.
28
+ * @param {string|number} id A revision object.
29
+ * @param {boolean} isLatest Whether the revision is the most current.
30
+ * @param {string} authorDisplayName Author name.
31
+ * @param {string} formattedModifiedDate Revision modified date formatted.
27
32
  * @return {string} Translated label.
28
33
  */
29
- function getRevisionLabel(revision) {
30
- const authorDisplayName = revision?.author?.name || (0, _i18n.__)('User');
31
- if ('parent' === revision?.id) {
34
+ function getRevisionLabel(id, isLatest, authorDisplayName, formattedModifiedDate) {
35
+ if ('parent' === id) {
32
36
  return (0, _i18n.__)('Reset the styles to the theme defaults');
33
37
  }
34
- if ('unsaved' === revision?.id) {
38
+ if ('unsaved' === id) {
35
39
  return (0, _i18n.sprintf)( /* translators: %s author display name */
36
40
  (0, _i18n.__)('Unsaved changes by %s'), authorDisplayName);
37
41
  }
38
- const formattedDate = (0, _date.dateI18n)((0, _date.getSettings)().formats.datetimeAbbreviated, (0, _date.getDate)(revision?.modified));
39
- return revision?.isLatest ? (0, _i18n.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */
40
- (0, _i18n.__)('Changes saved by %1$s on %2$s (current)'), authorDisplayName, formattedDate) : (0, _i18n.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */
41
- (0, _i18n.__)('Changes saved by %1$s on %2$s'), authorDisplayName, formattedDate);
42
+ return isLatest ? (0, _i18n.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */
43
+ (0, _i18n.__)('Changes saved by %1$s on %2$s (current)'), authorDisplayName, formattedModifiedDate) : (0, _i18n.sprintf)( /* translators: %1$s author display name, %2$s: revision creation date */
44
+ (0, _i18n.__)('Changes saved by %1$s on %2$s'), authorDisplayName, formattedModifiedDate);
42
45
  }
43
46
 
44
47
  /**
@@ -57,7 +60,25 @@ function RevisionsButtons({
57
60
  selectedRevisionId,
58
61
  onChange
59
62
  }) {
60
- const currentTheme = (0, _data.useSelect)(select => select(_coreData.store).getCurrentTheme(), []);
63
+ const {
64
+ currentThemeName,
65
+ currentUser
66
+ } = (0, _data.useSelect)(select => {
67
+ const {
68
+ getCurrentTheme,
69
+ getCurrentUser
70
+ } = select(_coreData.store);
71
+ const currentTheme = getCurrentTheme();
72
+ return {
73
+ currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet,
74
+ currentUser: getCurrentUser()
75
+ };
76
+ }, []);
77
+ const dateNowInMs = (0, _date.getDate)().getTime();
78
+ const {
79
+ date: dateFormat,
80
+ datetimeAbbreviated
81
+ } = (0, _date.getSettings)().formats;
61
82
  return (0, _react.createElement)("ol", {
62
83
  className: "edit-site-global-styles-screen-revisions__revisions-list",
63
84
  "aria-label": (0, _i18n.__)('Global styles revisions'),
@@ -65,14 +86,20 @@ function RevisionsButtons({
65
86
  }, userRevisions.map((revision, index) => {
66
87
  const {
67
88
  id,
89
+ isLatest,
68
90
  author,
69
91
  modified
70
92
  } = revision;
71
- const authorDisplayName = author?.name || (0, _i18n.__)('User');
72
- const authorAvatar = author?.avatar_urls?.['48'];
73
- const isUnsaved = 'unsaved' === revision?.id;
74
- const isSelected = selectedRevisionId ? selectedRevisionId === revision?.id : index === 0;
75
- const isReset = 'parent' === revision?.id;
93
+ const isUnsaved = 'unsaved' === id;
94
+ // Unsaved changes are created by the current user.
95
+ const revisionAuthor = isUnsaved ? currentUser : author;
96
+ const authorDisplayName = revisionAuthor?.name || (0, _i18n.__)('User');
97
+ const authorAvatar = revisionAuthor?.avatar_urls?.['48'];
98
+ const isSelected = selectedRevisionId ? selectedRevisionId === id : index === 0;
99
+ const isReset = 'parent' === id;
100
+ const modifiedDate = (0, _date.getDate)(modified);
101
+ const displayDate = modified && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0, _date.dateI18n)(dateFormat, modifiedDate) : (0, _date.humanTimeDiff)(modified);
102
+ const revisionLabel = getRevisionLabel(id, isLatest, authorDisplayName, (0, _date.dateI18n)(datetimeAbbreviated, modifiedDate));
76
103
  return (0, _react.createElement)("li", {
77
104
  className: (0, _classnames.default)('edit-site-global-styles-screen-revisions__revision-item', {
78
105
  'is-selected': isSelected,
@@ -85,23 +112,24 @@ function RevisionsButtons({
85
112
  onClick: () => {
86
113
  onChange(revision);
87
114
  },
88
- label: getRevisionLabel(revision)
115
+ label: revisionLabel
89
116
  }, isReset ? (0, _react.createElement)("span", {
90
117
  className: "edit-site-global-styles-screen-revisions__description"
91
118
  }, (0, _i18n.__)('Default styles'), (0, _react.createElement)("span", {
92
119
  className: "edit-site-global-styles-screen-revisions__meta"
93
- }, currentTheme?.name?.rendered || currentTheme?.stylesheet)) : (0, _react.createElement)("span", {
120
+ }, currentThemeName)) : (0, _react.createElement)("span", {
94
121
  className: "edit-site-global-styles-screen-revisions__description"
95
- }, (0, _react.createElement)("time", {
122
+ }, isUnsaved ? (0, _react.createElement)("span", {
123
+ className: "edit-site-global-styles-screen-revisions__date"
124
+ }, (0, _i18n.__)('(Unsaved)')) : (0, _react.createElement)("time", {
125
+ className: "edit-site-global-styles-screen-revisions__date",
96
126
  dateTime: modified
97
- }, (0, _date.humanTimeDiff)(modified)), (0, _react.createElement)("span", {
127
+ }, displayDate), (0, _react.createElement)("span", {
98
128
  className: "edit-site-global-styles-screen-revisions__meta"
99
- }, isUnsaved ? (0, _i18n.sprintf)( /* translators: %s author display name */
100
- (0, _i18n.__)('Unsaved changes by %s'), authorDisplayName) : (0, _i18n.sprintf)( /* translators: %s author display name */
101
- (0, _i18n.__)('Changes saved by %s'), authorDisplayName), (0, _react.createElement)("img", {
102
- alt: author?.name,
129
+ }, (0, _react.createElement)("img", {
130
+ alt: authorDisplayName,
103
131
  src: authorAvatar
104
- })))));
132
+ }), authorDisplayName))));
105
133
  }));
106
134
  }
107
135
  var _default = RevisionsButtons;
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_date","_coreData","_data","getRevisionLabel","revision","authorDisplayName","author","name","__","id","sprintf","formattedDate","dateI18n","getSettings","formats","datetimeAbbreviated","getDate","modified","isLatest","RevisionsButtons","userRevisions","selectedRevisionId","onChange","currentTheme","useSelect","select","coreStore","getCurrentTheme","_react","createElement","className","role","map","index","authorAvatar","avatar_urls","isUnsaved","isSelected","isReset","classnames","key","Button","disabled","onClick","label","rendered","stylesheet","dateTime","humanTimeDiff","alt","src","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Returns a button label for the revision.\n *\n * @param {Object} revision A revision object.\n * @return {string} Translated label.\n */\nfunction getRevisionLabel( revision ) {\n\tconst authorDisplayName = revision?.author?.name || __( 'User' );\n\n\tif ( 'parent' === revision?.id ) {\n\t\treturn __( 'Reset the styles to the theme defaults' );\n\t}\n\n\tif ( 'unsaved' === revision?.id ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s author display name */\n\t\t\t__( 'Unsaved changes by %s' ),\n\t\t\tauthorDisplayName\n\t\t);\n\t}\n\n\tconst formattedDate = dateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( revision?.modified )\n\t);\n\n\treturn revision?.isLatest\n\t\t? sprintf(\n\t\t\t\t/* translators: %1$s author display name, %2$s: revision creation date */\n\t\t\t\t__( 'Changes saved by %1$s on %2$s (current)' ),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedDate\n\t\t )\n\t\t: sprintf(\n\t\t\t\t/* translators: %1$s author display name, %2$s: revision creation date */\n\t\t\t\t__( 'Changes saved by %1$s on %2$s' ),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedDate\n\t\t );\n}\n\n/**\n * Returns a rendered list of revisions buttons.\n *\n * @typedef {Object} props\n * @property {Array<Object>} userRevisions A collection of user revisions.\n * @property {number} selectedRevisionId The id of the currently-selected revision.\n * @property {Function} onChange Callback fired when a revision is selected.\n *\n * @param {props} Component props.\n * @return {JSX.Element} The modal component.\n */\nfunction RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme(),\n\t\t[]\n\t);\n\treturn (\n\t\t<ol\n\t\t\tclassName=\"edit-site-global-styles-screen-revisions__revisions-list\"\n\t\t\taria-label={ __( 'Global styles revisions' ) }\n\t\t\trole=\"group\"\n\t\t>\n\t\t\t{ userRevisions.map( ( revision, index ) => {\n\t\t\t\tconst { id, author, modified } = revision;\n\t\t\t\tconst authorDisplayName = author?.name || __( 'User' );\n\t\t\t\tconst authorAvatar = author?.avatar_urls?.[ '48' ];\n\t\t\t\tconst isUnsaved = 'unsaved' === revision?.id;\n\t\t\t\tconst isSelected = selectedRevisionId\n\t\t\t\t\t? selectedRevisionId === revision?.id\n\t\t\t\t\t: index === 0;\n\t\t\t\tconst isReset = 'parent' === revision?.id;\n\n\t\t\t\treturn (\n\t\t\t\t\t<li\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-global-styles-screen-revisions__revision-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t\t\t\t'is-reset': isReset,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-revisions__revision-button\"\n\t\t\t\t\t\t\tdisabled={ isSelected }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonChange( revision );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ getRevisionLabel( revision ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ isReset ? (\n\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t{ __( 'Default styles' ) }\n\t\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t{ currentTheme?.name?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\tcurrentTheme?.stylesheet }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t<time dateTime={ modified }>\n\t\t\t\t\t\t\t\t\t\t{ humanTimeDiff( modified ) }\n\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t{ isUnsaved\n\t\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s author display name */\n\t\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Unsaved changes by %s'\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\tauthorDisplayName\n\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s author display name */\n\t\t\t\t\t\t\t\t\t\t\t\t\t__( 'Changes saved by %s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\tauthorDisplayName\n\t\t\t\t\t\t\t\t\t\t\t ) }\n\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\talt={ author?.name }\n\t\t\t\t\t\t\t\t\t\t\tsrc={ authorAvatar }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ol>\n\t);\n}\n\nexport default RevisionsButtons;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,G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,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAgD,GAC7DP,YAAY,EAAEhB,IAAI,EAAEsC,QAAQ,IAC7BtB,YAAY,EAAEuB,UACV,CACD,CAAC,GAEP,IAAAlB,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAuD,GACtE,IAAAF,MAAA,CAAAC,aAAA;MAAMkB,QAAQ,EAAG9B;IAAU,GACxB,IAAA+B,mBAAa,EAAE/B,QAAS,CACrB,CAAC,EACP,IAAAW,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAgD,GAC7DM,SAAS,GACR,IAAA1B,aAAO,GACP;IACA,IAAAF,QAAE,EACD,uBACD,CAAC,EACDH,iBACA,CAAC,GACD,IAAAK,aAAO,GACP;IACA,IAAAF,QAAE,EAAE,qBAAsB,CAAC,EAC3BH,iBACA,CAAC,EAEJ,IAAAuB,MAAA,CAAAC,aAAA;MACCoB,GAAG,EAAG3C,MAAM,EAAEC,IAAM;MACpB2C,GAAG,EAAGhB;IAAc,CACpB,CACI,CACD,CAEA,CACL,CAAC;EAEP,CAAE,CACC,CAAC;AAEP;AAAC,IAAAiB,QAAA,GAEchC,gBAAgB;AAAAiC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_components","_date","_coreData","_data","DAY_IN_MILLISECONDS","getRevisionLabel","id","isLatest","authorDisplayName","formattedModifiedDate","__","sprintf","RevisionsButtons","userRevisions","selectedRevisionId","onChange","currentThemeName","currentUser","useSelect","select","getCurrentTheme","getCurrentUser","coreStore","currentTheme","name","rendered","stylesheet","dateNowInMs","getDate","getTime","date","dateFormat","datetimeAbbreviated","getSettings","formats","_react","createElement","className","role","map","revision","index","author","modified","isUnsaved","revisionAuthor","authorAvatar","avatar_urls","isSelected","isReset","modifiedDate","displayDate","dateI18n","humanTimeDiff","revisionLabel","classnames","key","Button","disabled","onClick","label","dateTime","alt","src","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-revisions/revisions-buttons.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\nconst DAY_IN_MILLISECONDS = 60 * 60 * 1000 * 24;\n\n/**\n * Returns a button label for the revision.\n *\n * @param {string|number} id A revision object.\n * @param {boolean} isLatest Whether the revision is the most current.\n * @param {string} authorDisplayName Author name.\n * @param {string} formattedModifiedDate Revision modified date formatted.\n * @return {string} Translated label.\n */\nfunction getRevisionLabel(\n\tid,\n\tisLatest,\n\tauthorDisplayName,\n\tformattedModifiedDate\n) {\n\tif ( 'parent' === id ) {\n\t\treturn __( 'Reset the styles to the theme defaults' );\n\t}\n\n\tif ( 'unsaved' === id ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %s author display name */\n\t\t\t__( 'Unsaved changes by %s' ),\n\t\t\tauthorDisplayName\n\t\t);\n\t}\n\n\treturn isLatest\n\t\t? sprintf(\n\t\t\t\t/* translators: %1$s author display name, %2$s: revision creation date */\n\t\t\t\t__( 'Changes saved by %1$s on %2$s (current)' ),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedModifiedDate\n\t\t )\n\t\t: sprintf(\n\t\t\t\t/* translators: %1$s author display name, %2$s: revision creation date */\n\t\t\t\t__( 'Changes saved by %1$s on %2$s' ),\n\t\t\t\tauthorDisplayName,\n\t\t\t\tformattedModifiedDate\n\t\t );\n}\n\n/**\n * Returns a rendered list of revisions buttons.\n *\n * @typedef {Object} props\n * @property {Array<Object>} userRevisions A collection of user revisions.\n * @property {number} selectedRevisionId The id of the currently-selected revision.\n * @property {Function} onChange Callback fired when a revision is selected.\n *\n * @param {props} Component props.\n * @return {JSX.Element} The modal component.\n */\nfunction RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {\n\tconst { currentThemeName, currentUser } = useSelect( ( select ) => {\n\t\tconst { getCurrentTheme, getCurrentUser } = select( coreStore );\n\t\tconst currentTheme = getCurrentTheme();\n\t\treturn {\n\t\t\tcurrentThemeName:\n\t\t\t\tcurrentTheme?.name?.rendered || currentTheme?.stylesheet,\n\t\t\tcurrentUser: getCurrentUser(),\n\t\t};\n\t}, [] );\n\tconst dateNowInMs = getDate().getTime();\n\tconst { date: dateFormat, datetimeAbbreviated } = getSettings().formats;\n\n\treturn (\n\t\t<ol\n\t\t\tclassName=\"edit-site-global-styles-screen-revisions__revisions-list\"\n\t\t\taria-label={ __( 'Global styles revisions' ) }\n\t\t\trole=\"group\"\n\t\t>\n\t\t\t{ userRevisions.map( ( revision, index ) => {\n\t\t\t\tconst { id, isLatest, author, modified } = revision;\n\t\t\t\tconst isUnsaved = 'unsaved' === id;\n\t\t\t\t// Unsaved changes are created by the current user.\n\t\t\t\tconst revisionAuthor = isUnsaved ? currentUser : author;\n\t\t\t\tconst authorDisplayName = revisionAuthor?.name || __( 'User' );\n\t\t\t\tconst authorAvatar = revisionAuthor?.avatar_urls?.[ '48' ];\n\t\t\t\tconst isSelected = selectedRevisionId\n\t\t\t\t\t? selectedRevisionId === id\n\t\t\t\t\t: index === 0;\n\t\t\t\tconst isReset = 'parent' === id;\n\t\t\t\tconst modifiedDate = getDate( modified );\n\t\t\t\tconst displayDate =\n\t\t\t\t\tmodified &&\n\t\t\t\t\tdateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS\n\t\t\t\t\t\t? dateI18n( dateFormat, modifiedDate )\n\t\t\t\t\t\t: humanTimeDiff( modified );\n\t\t\t\tconst revisionLabel = getRevisionLabel(\n\t\t\t\t\tid,\n\t\t\t\t\tisLatest,\n\t\t\t\t\tauthorDisplayName,\n\t\t\t\t\tdateI18n( datetimeAbbreviated, modifiedDate )\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<li\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'edit-site-global-styles-screen-revisions__revision-item',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t\t\t\t\t'is-reset': isReset,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tkey={ id }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-revisions__revision-button\"\n\t\t\t\t\t\t\tdisabled={ isSelected }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonChange( revision );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ revisionLabel }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ isReset ? (\n\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t{ __( 'Default styles' ) }\n\t\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t{ currentThemeName }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__description\">\n\t\t\t\t\t\t\t\t\t{ isUnsaved ? (\n\t\t\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__date\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( '(Unsaved)' ) }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<time\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-screen-revisions__date\"\n\t\t\t\t\t\t\t\t\t\t\tdateTime={ modified }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ displayDate }\n\t\t\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<span className=\"edit-site-global-styles-screen-revisions__meta\">\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\talt={ authorDisplayName }\n\t\t\t\t\t\t\t\t\t\t\tsrc={ authorAvatar }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{ authorDisplayName }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</li>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ol>\n\t);\n}\n\nexport default RevisionsButtons;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAGA;AACA;AACA;;AAOA,MAAMM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACxBC,EAAE,EACFC,QAAQ,EACRC,iBAAiB,EACjBC,qBAAqB,EACpB;EACD,IAAK,QAAQ,KAAKH,EAAE,EAAG;IACtB,OAAO,IAAAI,QAAE,EAAE,wCAAyC,CAAC;EACtD;EAEA,IAAK,SAAS,KAAKJ,EAAE,EAAG;IACvB,OAAO,IAAAK,aAAO,GACb;IACA,IAAAD,QAAE,EAAE,uBAAwB,CAAC,EAC7BF,iBACD,CAAC;EACF;EAEA,OAAOD,QAAQ,GACZ,IAAAI,aAAO,GACP;EACA,IAAAD,QAAE,EAAE,yCAA0C,CAA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B,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAgD,GAC7DrB,gBACG,CACD,CAAC,GAEP,IAAAmB,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAuD,GACpEO,SAAS,GACV,IAAAT,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAgD,GAC7D,IAAA3B,QAAE,EAAE,WAAY,CACb,CAAC,GAEP,IAAAyB,MAAA,CAAAC,aAAA;MACCC,SAAS,EAAC,gDAAgD;MAC1DwB,QAAQ,EAAGlB;IAAU,GAEnBQ,WACG,CACN,EACD,IAAAhB,MAAA,CAAAC,aAAA;MAAMC,SAAS,EAAC;IAAgD,GAC/D,IAAAF,MAAA,CAAAC,aAAA;MACC0B,GAAG,EAAGtD,iBAAmB;MACzBuD,GAAG,EAAGjB;IAAc,CACpB,CAAC,EACAtC,iBACG,CACD,CAEA,CACL,CAAC;EAEP,CAAE,CACC,CAAC;AAEP;AAAC,IAAAwD,QAAA,GAEcpD,gBAAgB;AAAAqD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -42,20 +42,26 @@ function useGlobalStylesRevisions() {
42
42
  __experimentalGetDirtyEntityRecords,
43
43
  getCurrentUser,
44
44
  getUsers,
45
- getCurrentThemeGlobalStylesRevisions,
45
+ getRevisions,
46
+ __experimentalGetCurrentGlobalStylesId,
46
47
  isResolving
47
48
  } = select(_coreData.store);
48
49
  const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
49
50
  const _currentUser = getCurrentUser();
50
51
  const _isDirty = dirtyEntityRecords.length > 0;
51
- const globalStylesRevisions = getCurrentThemeGlobalStylesRevisions() || EMPTY_ARRAY;
52
+ const query = {
53
+ per_page: 100
54
+ };
55
+ const globalStylesId = __experimentalGetCurrentGlobalStylesId();
56
+ const globalStylesRevisions = getRevisions('root', 'globalStyles', globalStylesId, query) || EMPTY_ARRAY;
52
57
  const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || EMPTY_ARRAY;
58
+ const _isResolving = isResolving('getRevisions', ['root', 'globalStyles', globalStylesId, query]);
53
59
  return {
54
60
  authors: _authors,
55
61
  currentUser: _currentUser,
56
62
  isDirty: _isDirty,
57
63
  revisions: globalStylesRevisions,
58
- isLoadingGlobalStylesRevisions: isResolving('getCurrentThemeGlobalStylesRevisions')
64
+ isLoadingGlobalStylesRevisions: _isResolving
59
65
  };
60
66
  }, []);
61
67
  return (0, _element.useMemo)(() => {