@wordpress/edit-site 5.4.0 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template-part.js +8 -7
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +19 -16
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/app/index.js +4 -2
  9. package/build/components/app/index.js.map +1 -1
  10. package/build/components/block-editor/editor-canvas.js +2 -1
  11. package/build/components/block-editor/editor-canvas.js.map +1 -1
  12. package/build/components/editor/index.js +5 -7
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/border-panel.js +20 -159
  15. package/build/components/global-styles/border-panel.js.map +1 -1
  16. package/build/components/global-styles/context-menu.js +13 -11
  17. package/build/components/global-styles/context-menu.js.map +1 -1
  18. package/build/components/global-styles/dimensions-panel.js +41 -487
  19. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  20. package/build/components/global-styles/duotone-panel.js +78 -0
  21. package/build/components/global-styles/duotone-panel.js.map +1 -0
  22. package/build/components/global-styles/filter-utils.js +17 -0
  23. package/build/components/global-styles/filter-utils.js.map +1 -0
  24. package/build/components/global-styles/hooks.js +11 -26
  25. package/build/components/global-styles/hooks.js.map +1 -1
  26. package/build/components/global-styles/preview.js +9 -5
  27. package/build/components/global-styles/preview.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +6 -11
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-border.js +14 -6
  31. package/build/components/global-styles/screen-border.js.map +1 -1
  32. package/build/components/global-styles/screen-filters.js +46 -0
  33. package/build/components/global-styles/screen-filters.js.map +1 -0
  34. package/build/components/global-styles/screen-layout.js +13 -5
  35. package/build/components/global-styles/screen-layout.js.map +1 -1
  36. package/build/components/global-styles/screen-root.js +2 -1
  37. package/build/components/global-styles/screen-root.js.map +1 -1
  38. package/build/components/global-styles/screen-style-variations.js +2 -1
  39. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  40. package/build/components/global-styles/screen-variations.js +1 -1
  41. package/build/components/global-styles/screen-variations.js.map +1 -1
  42. package/build/components/global-styles/shadow-panel.js +6 -4
  43. package/build/components/global-styles/shadow-panel.js.map +1 -1
  44. package/build/components/global-styles/typography-panel.js +2 -5
  45. package/build/components/global-styles/typography-panel.js.map +1 -1
  46. package/build/components/global-styles/ui.js +7 -1
  47. package/build/components/global-styles/ui.js.map +1 -1
  48. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  49. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  50. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  51. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  52. package/build/components/keyboard-shortcuts/global.js +48 -0
  53. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  54. package/build/components/keyboard-shortcuts/index.js +67 -0
  55. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  56. package/build/components/keyboard-shortcuts/register.js +153 -0
  57. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  58. package/build/components/layout/index.js +12 -1
  59. package/build/components/layout/index.js.map +1 -1
  60. package/build/components/list/added-by.js +127 -136
  61. package/build/components/list/added-by.js.map +1 -1
  62. package/build/components/list/index.js +2 -1
  63. package/build/components/list/index.js.map +1 -1
  64. package/build/components/list/table.js +9 -7
  65. package/build/components/list/table.js.map +1 -1
  66. package/build/components/routes/link.js +4 -1
  67. package/build/components/routes/link.js.map +1 -1
  68. package/build/components/save-hub/index.js +82 -0
  69. package/build/components/save-hub/index.js.map +1 -0
  70. package/build/components/save-panel/index.js +11 -1
  71. package/build/components/save-panel/index.js.map +1 -1
  72. package/build/components/sidebar/index.js +27 -17
  73. package/build/components/sidebar/index.js.map +1 -1
  74. package/build/components/sidebar-button/index.js +30 -0
  75. package/build/components/sidebar-button/index.js.map +1 -0
  76. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  77. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  78. package/build/components/sidebar-navigation-screen/index.js +14 -11
  79. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-screen-main/index.js +16 -16
  81. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  82. package/build/components/sidebar-navigation-screen-navigation-item/index.js +22 -26
  83. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  84. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +97 -14
  85. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  86. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  87. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  88. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  89. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  90. package/build/components/sidebar-navigation-screen-template/index.js +66 -27
  91. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  92. package/build/components/sidebar-navigation-screen-templates/index.js +30 -17
  93. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  94. package/build/components/sidebar-navigation-screen-templates-browse/index.js +14 -10
  95. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  96. package/build/components/site-hub/index.js +3 -1
  97. package/build/components/site-hub/index.js.map +1 -1
  98. package/build/components/style-book/index.js +151 -21
  99. package/build/components/style-book/index.js.map +1 -1
  100. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  101. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  102. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  103. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  104. package/build/components/sync-state-with-url/use-sync-path-with-url.js +67 -18
  105. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  106. package/build/components/template-details/index.js +5 -10
  107. package/build/components/template-details/index.js.map +1 -1
  108. package/build/components/template-part-converter/convert-to-regular.js +8 -12
  109. package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
  110. package/build/components/template-part-converter/convert-to-template-part.js +2 -2
  111. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  112. package/build/components/template-part-converter/index.js +19 -14
  113. package/build/components/template-part-converter/index.js.map +1 -1
  114. package/build/components/use-edited-entity-record/index.js +6 -6
  115. package/build/components/use-edited-entity-record/index.js.map +1 -1
  116. package/build/index.js +13 -22
  117. package/build/index.js.map +1 -1
  118. package/build/store/actions.js +2 -2
  119. package/build/store/actions.js.map +1 -1
  120. package/build/utils/get-is-list-page.js +1 -1
  121. package/build/utils/get-is-list-page.js.map +1 -1
  122. package/build/utils/history.js +8 -2
  123. package/build/utils/history.js.map +1 -1
  124. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  125. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  126. package/build-module/components/add-new-template/new-template-part.js +8 -7
  127. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  128. package/build-module/components/add-new-template/new-template.js +21 -17
  129. package/build-module/components/add-new-template/new-template.js.map +1 -1
  130. package/build-module/components/app/index.js +3 -2
  131. package/build-module/components/app/index.js.map +1 -1
  132. package/build-module/components/block-editor/editor-canvas.js +2 -1
  133. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  134. package/build-module/components/editor/index.js +5 -6
  135. package/build-module/components/editor/index.js.map +1 -1
  136. package/build-module/components/global-styles/border-panel.js +21 -157
  137. package/build-module/components/global-styles/border-panel.js.map +1 -1
  138. package/build-module/components/global-styles/context-menu.js +14 -11
  139. package/build-module/components/global-styles/context-menu.js.map +1 -1
  140. package/build-module/components/global-styles/dimensions-panel.js +43 -480
  141. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  142. package/build-module/components/global-styles/duotone-panel.js +67 -0
  143. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  144. package/build-module/components/global-styles/filter-utils.js +9 -0
  145. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  146. package/build-module/components/global-styles/hooks.js +11 -26
  147. package/build-module/components/global-styles/hooks.js.map +1 -1
  148. package/build-module/components/global-styles/preview.js +10 -6
  149. package/build-module/components/global-styles/preview.js.map +1 -1
  150. package/build-module/components/global-styles/screen-block-list.js +6 -8
  151. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  152. package/build-module/components/global-styles/screen-border.js +12 -3
  153. package/build-module/components/global-styles/screen-border.js.map +1 -1
  154. package/build-module/components/global-styles/screen-filters.js +33 -0
  155. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  156. package/build-module/components/global-styles/screen-layout.js +11 -2
  157. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  158. package/build-module/components/global-styles/screen-root.js +2 -1
  159. package/build-module/components/global-styles/screen-root.js.map +1 -1
  160. package/build-module/components/global-styles/screen-style-variations.js +2 -1
  161. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  162. package/build-module/components/global-styles/screen-variations.js +1 -1
  163. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  164. package/build-module/components/global-styles/shadow-panel.js +6 -4
  165. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  166. package/build-module/components/global-styles/typography-panel.js +2 -5
  167. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  168. package/build-module/components/global-styles/ui.js +6 -1
  169. package/build-module/components/global-styles/ui.js.map +1 -1
  170. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  172. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  173. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  174. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  175. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  176. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  177. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  178. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  179. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  180. package/build-module/components/layout/index.js +10 -1
  181. package/build-module/components/layout/index.js.map +1 -1
  182. package/build-module/components/list/added-by.js +126 -138
  183. package/build-module/components/list/added-by.js.map +1 -1
  184. package/build-module/components/list/index.js +2 -1
  185. package/build-module/components/list/index.js.map +1 -1
  186. package/build-module/components/list/table.js +9 -7
  187. package/build-module/components/list/table.js.map +1 -1
  188. package/build-module/components/routes/link.js +5 -2
  189. package/build-module/components/routes/link.js.map +1 -1
  190. package/build-module/components/save-hub/index.js +68 -0
  191. package/build-module/components/save-hub/index.js.map +1 -0
  192. package/build-module/components/save-panel/index.js +8 -1
  193. package/build-module/components/save-panel/index.js.map +1 -1
  194. package/build-module/components/sidebar/index.js +24 -19
  195. package/build-module/components/sidebar/index.js.map +1 -1
  196. package/build-module/components/sidebar-button/index.js +18 -0
  197. package/build-module/components/sidebar-button/index.js.map +1 -0
  198. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  199. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  200. package/build-module/components/sidebar-navigation-screen/index.js +12 -12
  201. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  202. package/build-module/components/sidebar-navigation-screen-main/index.js +16 -16
  203. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  204. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +24 -30
  205. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  206. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +91 -14
  207. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  208. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  209. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  210. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  211. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  212. package/build-module/components/sidebar-navigation-screen-template/index.js +67 -30
  213. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  214. package/build-module/components/sidebar-navigation-screen-templates/index.js +28 -18
  215. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  216. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +13 -10
  217. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  218. package/build-module/components/site-hub/index.js +3 -1
  219. package/build-module/components/site-hub/index.js.map +1 -1
  220. package/build-module/components/style-book/index.js +152 -25
  221. package/build-module/components/style-book/index.js.map +1 -1
  222. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  223. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  224. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  225. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  226. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
  227. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  228. package/build-module/components/template-details/index.js +5 -9
  229. package/build-module/components/template-details/index.js.map +1 -1
  230. package/build-module/components/template-part-converter/convert-to-regular.js +9 -13
  231. package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
  232. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -3
  233. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  234. package/build-module/components/template-part-converter/index.js +20 -15
  235. package/build-module/components/template-part-converter/index.js.map +1 -1
  236. package/build-module/components/use-edited-entity-record/index.js +6 -6
  237. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  238. package/build-module/index.js +16 -23
  239. package/build-module/index.js.map +1 -1
  240. package/build-module/store/actions.js +2 -2
  241. package/build-module/store/actions.js.map +1 -1
  242. package/build-module/utils/get-is-list-page.js +1 -1
  243. package/build-module/utils/get-is-list-page.js.map +1 -1
  244. package/build-module/utils/history.js +9 -3
  245. package/build-module/utils/history.js.map +1 -1
  246. package/build-style/style-rtl.css +203 -143
  247. package/build-style/style.css +203 -143
  248. package/package.json +31 -31
  249. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  250. package/src/components/add-new-template/new-template-part.js +7 -9
  251. package/src/components/add-new-template/new-template.js +60 -38
  252. package/src/components/add-new-template/style.scss +12 -6
  253. package/src/components/app/index.js +9 -6
  254. package/src/components/block-editor/editor-canvas.js +2 -1
  255. package/src/components/block-editor/style.scss +1 -1
  256. package/src/components/editor/index.js +62 -65
  257. package/src/components/editor/style.scss +0 -6
  258. package/src/components/global-styles/border-panel.js +24 -199
  259. package/src/components/global-styles/context-menu.js +18 -12
  260. package/src/components/global-styles/dimensions-panel.js +43 -577
  261. package/src/components/global-styles/duotone-panel.js +82 -0
  262. package/src/components/global-styles/filter-utils.js +9 -0
  263. package/src/components/global-styles/hooks.js +12 -36
  264. package/src/components/global-styles/preview.js +155 -140
  265. package/src/components/global-styles/screen-block-list.js +6 -11
  266. package/src/components/global-styles/screen-border.js +10 -3
  267. package/src/components/global-styles/screen-filters.js +27 -0
  268. package/src/components/global-styles/screen-layout.js +9 -2
  269. package/src/components/global-styles/screen-root.js +1 -1
  270. package/src/components/global-styles/screen-style-variations.js +5 -1
  271. package/src/components/global-styles/screen-variations.js +0 -1
  272. package/src/components/global-styles/shadow-panel.js +4 -3
  273. package/src/components/global-styles/style.scss +10 -0
  274. package/src/components/global-styles/typography-panel.js +5 -7
  275. package/src/components/global-styles/ui.js +6 -1
  276. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  277. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  278. package/src/components/keyboard-shortcuts/global.js +35 -0
  279. package/src/components/keyboard-shortcuts/index.js +70 -0
  280. package/src/components/keyboard-shortcuts/register.js +157 -0
  281. package/src/components/layout/index.js +19 -0
  282. package/src/components/layout/style.scss +9 -4
  283. package/src/components/list/added-by.js +152 -155
  284. package/src/components/list/index.js +3 -1
  285. package/src/components/list/style.scss +5 -13
  286. package/src/components/list/table.js +11 -9
  287. package/src/components/routes/link.js +9 -2
  288. package/src/components/save-hub/index.js +78 -0
  289. package/src/components/save-hub/style.scss +15 -0
  290. package/src/components/save-panel/index.js +8 -1
  291. package/src/components/sidebar/index.js +33 -16
  292. package/src/components/sidebar/style.scss +4 -3
  293. package/src/components/sidebar-button/index.js +21 -0
  294. package/src/components/sidebar-button/style.scss +24 -0
  295. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
  296. package/src/components/sidebar-edit-mode/style.scss +16 -0
  297. package/src/components/sidebar-navigation-item/style.scss +1 -23
  298. package/src/components/sidebar-navigation-screen/index.js +37 -38
  299. package/src/components/sidebar-navigation-screen/style.scss +16 -9
  300. package/src/components/sidebar-navigation-screen-main/index.js +24 -11
  301. package/src/components/sidebar-navigation-screen-navigation-item/index.js +39 -26
  302. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +99 -12
  303. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  304. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  305. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +108 -1
  306. package/src/components/sidebar-navigation-screen-template/index.js +89 -30
  307. package/src/components/sidebar-navigation-screen-template/style.scss +25 -0
  308. package/src/components/sidebar-navigation-screen-templates/index.js +29 -14
  309. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  310. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -6
  311. package/src/components/site-hub/index.js +5 -1
  312. package/src/components/site-hub/style.scss +5 -1
  313. package/src/components/style-book/index.js +234 -55
  314. package/src/components/style-book/style.scss +1 -45
  315. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
  316. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  317. package/src/components/sync-state-with-url/use-sync-path-with-url.js +77 -17
  318. package/src/components/template-details/index.js +4 -8
  319. package/src/components/template-part-converter/convert-to-regular.js +10 -17
  320. package/src/components/template-part-converter/convert-to-template-part.js +9 -16
  321. package/src/components/template-part-converter/index.js +28 -12
  322. package/src/components/use-edited-entity-record/index.js +26 -18
  323. package/src/index.js +11 -22
  324. package/src/store/actions.js +2 -2
  325. package/src/store/test/actions.js +0 -2
  326. package/src/style.scss +3 -1
  327. package/src/utils/get-is-list-page.js +1 -1
  328. package/src/utils/history.js +13 -9
  329. package/build/components/navigation-inspector/index.js +0 -161
  330. package/build/components/navigation-inspector/index.js.map +0 -1
  331. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  332. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  333. package/build-module/components/navigation-inspector/index.js +0 -146
  334. package/build-module/components/navigation-inspector/index.js.map +0 -1
  335. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  336. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  337. package/src/components/navigation-inspector/index.js +0 -191
  338. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  339. package/src/components/navigation-inspector/style.scss +0 -46
@@ -4,37 +4,114 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
- import { useCallback } from '@wordpress/element';
7
+ import { useCallback, useMemo } from '@wordpress/element';
8
+ import { useSelect } from '@wordpress/data';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { BlockEditorProvider } from '@wordpress/block-editor';
11
+ import { createBlock } from '@wordpress/blocks';
8
12
  /**
9
13
  * Internal dependencies
10
14
  */
11
15
 
12
16
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
13
- import NavigationInspector from '../navigation-inspector';
14
17
  import { useHistory } from '../routes';
18
+ import NavigationMenuContent from './navigation-menu-content';
19
+ import { NavigationMenuLoader } from './loader';
20
+ import { unlock } from '../../private-apis';
21
+ import { store as editSiteStore } from '../../store';
22
+
23
+ const noop = () => {};
24
+
25
+ const NAVIGATION_MENUS_QUERY = {
26
+ per_page: 1,
27
+ status: 'publish',
28
+ order: 'desc',
29
+ orderby: 'date'
30
+ };
31
+
32
+ function SidebarNavigationScreenWrapper(_ref) {
33
+ let {
34
+ children,
35
+ actions
36
+ } = _ref;
37
+ return createElement(SidebarNavigationScreen, {
38
+ title: __('Navigation'),
39
+ actions: actions,
40
+ description: __('Browse your site, edit pages, and manage your primary navigation menu.'),
41
+ content: children
42
+ });
43
+ }
44
+
15
45
  export default function SidebarNavigationScreenNavigationMenus() {
46
+ var _navigationMenus$;
47
+
16
48
  const history = useHistory();
49
+ const {
50
+ navigationMenus,
51
+ hasResolvedNavigationMenus,
52
+ storedSettings
53
+ } = useSelect(select => {
54
+ const {
55
+ getSettings
56
+ } = unlock(select(editSiteStore));
57
+ const {
58
+ getEntityRecords,
59
+ hasFinishedResolution
60
+ } = select(coreStore);
61
+ const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY];
62
+ return {
63
+ storedSettings: getSettings(false),
64
+ navigationMenus: getEntityRecords(...navigationMenusQuery),
65
+ hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
66
+ };
67
+ }, []);
68
+ const firstNavigationMenu = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id;
69
+ const blocks = useMemo(() => {
70
+ return [createBlock('core/navigation', {
71
+ ref: firstNavigationMenu
72
+ })];
73
+ }, [firstNavigationMenu]);
74
+ const isLoading = !hasResolvedNavigationMenus;
75
+ const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
17
76
  const onSelect = useCallback(selectedBlock => {
18
77
  const {
19
- attributes
78
+ attributes,
79
+ name
20
80
  } = selectedBlock;
21
81
 
22
82
  if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) {
23
83
  history.push({
24
84
  postType: attributes.type,
25
- postId: attributes.id,
26
- path: '/navigation/single'
85
+ postId: attributes.id
86
+ });
87
+ }
88
+
89
+ if (name === 'core/page-list-item' && attributes.id && history) {
90
+ history.push({
91
+ postType: 'page',
92
+ postId: attributes.id
27
93
  });
28
94
  }
29
95
  }, [history]);
30
- return createElement(SidebarNavigationScreen, {
31
- path: "/navigation",
32
- title: __('Navigation'),
33
- content: createElement("div", {
34
- className: "edit-site-sidebar-navigation-screen-navigation-menus"
35
- }, createElement(NavigationInspector, {
36
- onSelect: onSelect
37
- }))
38
- });
96
+
97
+ if (hasResolvedNavigationMenus && !hasNavigationMenus) {
98
+ return createElement(SidebarNavigationScreenWrapper, null, __('There are no Navigation Menus.'));
99
+ }
100
+
101
+ if (!hasResolvedNavigationMenus || isLoading) {
102
+ return createElement(SidebarNavigationScreenWrapper, null, createElement(NavigationMenuLoader, null));
103
+ }
104
+
105
+ return createElement(BlockEditorProvider, {
106
+ settings: storedSettings,
107
+ value: blocks,
108
+ onChange: noop,
109
+ onInput: noop
110
+ }, createElement(SidebarNavigationScreenWrapper, null, createElement("div", {
111
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__content"
112
+ }, createElement(NavigationMenuContent, {
113
+ rootClientId: blocks[0].clientId,
114
+ onSelect: onSelect
115
+ }))));
39
116
  }
40
117
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["__","useCallback","SidebarNavigationScreen","NavigationInspector","useHistory","SidebarNavigationScreenNavigationMenus","history","onSelect","selectedBlock","attributes","kind","id","type","push","postType","postId","path"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,UAAT,QAA2B,WAA3B;AAEA,eAAe,SAASC,sCAAT,GAAkD;AAChE,QAAMC,OAAO,GAAGF,UAAU,EAA1B;AACA,QAAMG,QAAQ,GAAGN,WAAW,CACzBO,aAAF,IAAqB;AACpB,UAAM;AAAEC,MAAAA;AAAF,QAAiBD,aAAvB;;AACA,QACCC,UAAU,CAACC,IAAX,KAAoB,WAApB,IACAD,UAAU,CAACE,EADX,IAEAF,UAAU,CAACG,IAFX,IAGAN,OAJD,EAKE;AACDA,MAAAA,OAAO,CAACO,IAAR,CAAc;AACbC,QAAAA,QAAQ,EAAEL,UAAU,CAACG,IADR;AAEbG,QAAAA,MAAM,EAAEN,UAAU,CAACE,EAFN;AAGbK,QAAAA,IAAI,EAAE;AAHO,OAAd;AAKA;AACD,GAf0B,EAgB3B,CAAEV,OAAF,CAhB2B,CAA5B;AAkBA,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAC,aADN;AAEC,IAAA,KAAK,EAAGN,EAAE,CAAE,YAAF,CAFX;AAGC,IAAA,OAAO,EACN;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,mBAAD;AAAqB,MAAA,QAAQ,EAAGO;AAAhC,MADD;AAJF,IADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport NavigationInspector from '../navigation-inspector';\nimport { useHistory } from '../routes';\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst history = useHistory();\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\tpath: '/navigation/single',\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath=\"/navigation\"\n\t\t\ttitle={ __( 'Navigation' ) }\n\t\t\tcontent={\n\t\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus\">\n\t\t\t\t\t<NavigationInspector onSelect={ onSelect } />\n\t\t\t\t</div>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["__","useCallback","useMemo","useSelect","store","coreStore","BlockEditorProvider","createBlock","SidebarNavigationScreen","useHistory","NavigationMenuContent","NavigationMenuLoader","unlock","editSiteStore","noop","NAVIGATION_MENUS_QUERY","per_page","status","order","orderby","SidebarNavigationScreenWrapper","children","actions","SidebarNavigationScreenNavigationMenus","history","navigationMenus","hasResolvedNavigationMenus","storedSettings","select","getSettings","getEntityRecords","hasFinishedResolution","navigationMenusQuery","firstNavigationMenu","id","blocks","ref","isLoading","hasNavigationMenus","length","onSelect","selectedBlock","attributes","name","kind","type","push","postType","postId","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,mBAAT,QAAoC,yBAApC;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,UAAT,QAA2B,WAA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0D;AACzD,WACC,cAAC,8BAAD,QACGtC,EAAE,CAAE,gCAAF,CADL,CADD;AAKA;;AAED,MAAK,CAAE0B,0BAAF,IAAgCW,SAArC,EAAiD;AAChD,WACC,cAAC,8BAAD,QACC,cAAC,oBAAD,OADD,CADD;AAKA;;AAED,SACC,cAAC,mBAAD;AACC,IAAA,QAAQ,EAAGV,cADZ;AAEC,IAAA,KAAK,EAAGQ,MAFT;AAGC,IAAA,QAAQ,EAAGrB,IAHZ;AAIC,IAAA,OAAO,EAAGA;AAJX,KAMC,cAAC,8BAAD,QACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,qBAAD;AACC,IAAA,YAAY,EAAGqB,MAAM,CAAE,CAAF,CAAN,CAAYc,QAD5B;AAEC,IAAA,QAAQ,EAAGT;AAFZ,IADD,CADD,CAND,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { BlockEditorProvider } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useHistory } from '../routes';\nimport NavigationMenuContent from './navigation-menu-content';\nimport { NavigationMenuLoader } from './loader';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nconst noop = () => {};\nconst NAVIGATION_MENUS_QUERY = {\n\tper_page: 1,\n\tstatus: 'publish',\n\torder: 'desc',\n\torderby: 'date',\n};\n\nfunction SidebarNavigationScreenWrapper( { children, actions } ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Navigation' ) }\n\t\t\tactions={ actions }\n\t\t\tdescription={ __(\n\t\t\t\t'Browse your site, edit pages, and manage your primary navigation menu.'\n\t\t\t) }\n\t\t\tcontent={ children }\n\t\t/>\n\t);\n}\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst history = useHistory();\n\tconst { navigationMenus, hasResolvedNavigationMenus, storedSettings } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst navigationMenusQuery = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tNAVIGATION_MENUS_QUERY,\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( false ),\n\t\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tnavigationMenusQuery\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\tconst firstNavigationMenu = navigationMenus?.[ 0 ]?.id;\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock( 'core/navigation', { ref: firstNavigationMenu } ),\n\t\t];\n\t}, [ firstNavigationMenu ] );\n\n\tconst isLoading = ! hasResolvedNavigationMenus;\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tif ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\tif ( ! hasResolvedNavigationMenus || isLoading ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t<NavigationMenuLoader />\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ storedSettings }\n\t\t\tvalue={ blocks }\n\t\t\tonChange={ noop }\n\t\t\tonInput={ noop }\n\t\t>\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__content\">\n\t\t\t\t\t<NavigationMenuContent\n\t\t\t\t\t\trootClientId={ blocks[ 0 ].clientId }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { createElement, Fragment } from "@wordpress/element";
2
+ export function NavigationMenuLoader() {
3
+ return createElement(Fragment, null, createElement("div", {
4
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__placeholder"
5
+ }), createElement("div", {
6
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__placeholder"
7
+ }), createElement("div", {
8
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__placeholder"
9
+ }));
10
+ }
11
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/loader.js"],"names":["NavigationMenuLoader"],"mappings":";AAAA,OAAO,SAASA,oBAAT,GAAgC;AACtC,SACC,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,CADD;AAOA","sourcesContent":["export function NavigationMenuLoader() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__placeholder\" />\n\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__placeholder\" />\n\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__placeholder\" />\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,66 @@
1
+ import { createElement, Fragment } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { privateApis as blockEditorPrivateApis, store as blockEditorStore, BlockList, BlockTools } from '@wordpress/block-editor';
7
+ import { useDispatch, useSelect } from '@wordpress/data';
8
+ import { createBlock } from '@wordpress/blocks';
9
+ import { useCallback } from '@wordpress/element';
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+
14
+ import { unlock } from '../../private-apis';
15
+ import { NavigationMenuLoader } from './loader';
16
+ export default function NavigationMenuContent(_ref) {
17
+ let {
18
+ rootClientId,
19
+ onSelect
20
+ } = _ref;
21
+ const {
22
+ clientIdsTree,
23
+ isLoading
24
+ } = useSelect(select => {
25
+ const {
26
+ __unstableGetClientIdsTree,
27
+ areInnerBlocksControlled
28
+ } = select(blockEditorStore);
29
+ return {
30
+ clientIdsTree: __unstableGetClientIdsTree(rootClientId),
31
+ // This is a small hack to wait for the navigation block
32
+ // to actually load its inner blocks.
33
+ isLoading: !areInnerBlocksControlled(rootClientId)
34
+ };
35
+ }, [rootClientId]);
36
+ const {
37
+ replaceBlock,
38
+ __unstableMarkNextChangeAsNotPersistent
39
+ } = useDispatch(blockEditorStore);
40
+ const {
41
+ OffCanvasEditor,
42
+ LeafMoreMenu
43
+ } = unlock(blockEditorPrivateApis);
44
+ const offCanvasOnselect = useCallback(block => {
45
+ if (block.name === 'core/navigation-link' && !block.attributes.url) {
46
+ __unstableMarkNextChangeAsNotPersistent();
47
+
48
+ replaceBlock(block.clientId, createBlock('core/navigation-link', block.attributes));
49
+ } else {
50
+ onSelect(block);
51
+ }
52
+ }, [onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock]); // The hidden block is needed because it makes block edit side effects trigger.
53
+ // For example a navigation page list load its items has an effect on edit to load its items.
54
+
55
+ return createElement(Fragment, null, isLoading && createElement(NavigationMenuLoader, null), !isLoading && createElement(OffCanvasEditor, {
56
+ blocks: clientIdsTree,
57
+ onSelect: offCanvasOnselect,
58
+ LeafMoreMenu: LeafMoreMenu,
59
+ showAppender: false
60
+ }), createElement("div", {
61
+ style: {
62
+ visibility: 'hidden'
63
+ }
64
+ }, createElement(BlockTools, null, createElement(BlockList, null))));
65
+ }
66
+ //# sourceMappingURL=navigation-menu-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js"],"names":["privateApis","blockEditorPrivateApis","store","blockEditorStore","BlockList","BlockTools","useDispatch","useSelect","createBlock","useCallback","unlock","NavigationMenuLoader","NavigationMenuContent","rootClientId","onSelect","clientIdsTree","isLoading","select","__unstableGetClientIdsTree","areInnerBlocksControlled","replaceBlock","__unstableMarkNextChangeAsNotPersistent","OffCanvasEditor","LeafMoreMenu","offCanvasOnselect","block","name","attributes","url","clientId","visibility"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,sBADhB,EAECC,KAAK,IAAIC,gBAFV,EAGCC,SAHD,EAICC,UAJD,QAKO,yBALP;AAMA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,oBAAT,QAAqC,UAArC;AAEA,eAAe,SAASC,qBAAT,OAA6D;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AA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AAK,IAAA,KAAK,EAAG;AAAEO,MAAAA,UAAU,EAAE;AAAd;AAAb,KACC,cAAC,UAAD,QACC,cAAC,SAAD,OADD,CADD,CAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockList,\n\tBlockTools,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { NavigationMenuLoader } from './loader';\n\nexport default function NavigationMenuContent( { rootClientId, onSelect } ) {\n\tconst { clientIdsTree, isLoading } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree, areInnerBlocksControlled } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tclientIdsTree: __unstableGetClientIdsTree( rootClientId ),\n\n\t\t\t\t// This is a small hack to wait for the navigation block\n\t\t\t\t// to actually load its inner blocks.\n\t\t\t\tisLoading: ! areInnerBlocksControlled( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\tconst offCanvasOnselect = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\t! block.attributes.url\n\t\t\t) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlock(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\tcreateBlock( 'core/navigation-link', block.attributes )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonSelect( block );\n\t\t\t}\n\t\t},\n\t\t[ onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock ]\n\t);\n\n\t// The hidden block is needed because it makes block edit side effects trigger.\n\t// For example a navigation page list load its items has an effect on edit to load its items.\n\treturn (\n\t\t<>\n\t\t\t{ isLoading && <NavigationMenuLoader /> }\n\t\t\t{ ! isLoading && (\n\t\t\t\t<OffCanvasEditor\n\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\tonSelect={ offCanvasOnselect }\n\t\t\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t\t\t\tshowAppender={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div style={ { visibility: 'hidden' } }>\n\t\t\t\t<BlockTools>\n\t\t\t\t\t<BlockList />\n\t\t\t\t</BlockTools>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -1,11 +1,13 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { __ } from '@wordpress/i18n';
7
- import { useDispatch } from '@wordpress/data';
8
- import { Button } from '@wordpress/components';
6
+ import { __, sprintf, _x } from '@wordpress/i18n';
7
+ import { useDispatch, useSelect } from '@wordpress/data';
8
+ import { pencil } from '@wordpress/icons';
9
+ import { __experimentalUseNavigator as useNavigator, Icon } from '@wordpress/components';
10
+ import { store as coreStore } from '@wordpress/core-data';
9
11
  /**
10
12
  * Internal dependencies
11
13
  */
@@ -14,40 +16,75 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
14
16
  import useEditedEntityRecord from '../use-edited-entity-record';
15
17
  import { unlock } from '../../private-apis';
16
18
  import { store as editSiteStore } from '../../store';
17
- const config = {
18
- wp_template: {
19
- path: '/templates/single'
20
- },
21
- wp_template_part: {
22
- path: '/template-parts/single'
23
- }
24
- };
25
- export default function SidebarNavigationScreenTemplate(_ref) {
26
- let {
27
- postType = 'wp_template'
28
- } = _ref;
29
- const {
30
- setCanvasMode
31
- } = unlock(useDispatch(editSiteStore));
19
+ import SidebarButton from '../sidebar-button';
20
+ import { useAddedBy } from '../list/added-by';
21
+
22
+ function useTemplateTitleAndDescription(postType, postId) {
32
23
  const {
33
24
  getDescription,
34
25
  getTitle,
35
26
  record
36
- } = useEditedEntityRecord();
37
- let description = getDescription();
27
+ } = useEditedEntityRecord(postType, postId);
28
+ const currentTheme = useSelect(select => select(coreStore).getCurrentTheme(), []);
29
+ const addedBy = useAddedBy(postType, postId);
30
+ const isAddedByActiveTheme = addedBy.type === 'theme' && record.theme === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.stylesheet);
31
+ const title = getTitle();
32
+ let descriptionText = getDescription();
38
33
 
39
- if (!description && record.is_custom) {
40
- description = __('This is a custom template that can be applied manually to any Post or Page.');
34
+ if (!descriptionText && addedBy.text) {
35
+ if (record.type === 'wp_template' && record.is_custom) {
36
+ descriptionText = __('This is a custom template that can be applied manually to any Post or Page.');
37
+ } else if (record.type === 'wp_template_part') {
38
+ descriptionText = sprintf( // translators: %s: template part title e.g: "Header".
39
+ __('This is your %s template part.'), getTitle());
40
+ }
41
41
  }
42
42
 
43
+ const description = createElement(Fragment, null, descriptionText, addedBy.text && !isAddedByActiveTheme && createElement("span", {
44
+ className: "edit-site-sidebar-navigation-screen-template__added-by-description"
45
+ }, createElement("span", {
46
+ className: "edit-site-sidebar-navigation-screen-template__added-by-description-author"
47
+ }, createElement("span", {
48
+ className: "edit-site-sidebar-navigation-screen-template__added-by-description-author-icon"
49
+ }, addedBy.imageUrl ? createElement("img", {
50
+ src: addedBy.imageUrl,
51
+ alt: "",
52
+ width: "24",
53
+ height: "24"
54
+ }) : createElement(Icon, {
55
+ icon: addedBy.icon
56
+ })), addedBy.text), addedBy.isCustomized && createElement("span", {
57
+ className: "edit-site-sidebar-navigation-screen-template__added-by-description-customized"
58
+ }, postType === 'wp_template' ? _x('(Customized)', 'template') : _x('(Customized)', 'template part'))));
59
+ return {
60
+ title,
61
+ description
62
+ };
63
+ }
64
+
65
+ export default function SidebarNavigationScreenTemplate() {
66
+ const {
67
+ params
68
+ } = useNavigator();
69
+ const {
70
+ postType,
71
+ postId
72
+ } = params;
73
+ const {
74
+ setCanvasMode
75
+ } = unlock(useDispatch(editSiteStore));
76
+ const {
77
+ title,
78
+ description
79
+ } = useTemplateTitleAndDescription(postType, postId);
43
80
  return createElement(SidebarNavigationScreen, {
44
- path: config[postType].path,
45
- title: getTitle(),
46
- actions: createElement(Button, {
47
- variant: "primary",
48
- onClick: () => setCanvasMode('edit')
49
- }, __('Edit')),
50
- content: description ? createElement("p", null, description) : undefined
81
+ title: title,
82
+ actions: createElement(SidebarButton, {
83
+ onClick: () => setCanvasMode('edit'),
84
+ label: __('Edit'),
85
+ icon: pencil
86
+ }),
87
+ description: description
51
88
  });
52
89
  }
53
90
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["__","useDispatch","Button","SidebarNavigationScreen","useEditedEntityRecord","unlock","store","editSiteStore","config","wp_template","path","wp_template_part","SidebarNavigationScreenTemplate","postType","setCanvasMode","getDescription","getTitle","record","description","is_custom","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,qBAAP,MAAkC,6BAAlC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE;AADM,GADC;AAIdC,EAAAA,gBAAgB,EAAE;AACjBD,IAAAA,IAAI,EAAE;AADW;AAJJ,CAAf;AASA,eAAe,SAASE,+BAAT,OAEX;AAAA,MAFqD;AACxDC,IAAAA,QAAQ,GAAG;AAD6C,GAErD;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoBT,MAAM,CAAEJ,WAAW,CAAEM,aAAF,CAAb,CAAhC;AACA,QAAM;AAAEQ,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAuCb,qBAAqB,EAAlE;AACA,MAAIc,WAAW,GAAGH,cAAc,EAAhC;;AACA,MAAK,CAAEG,WAAF,IAAiBD,MAAM,CAACE,SAA7B,EAAyC;AACxCD,IAAAA,WAAW,GAAGlB,EAAE,CACf,6EADe,CAAhB;AAGA;;AAED,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAGQ,MAAM,CAAEK,QAAF,CAAN,CAAmBH,IAD3B;AAEC,IAAA,KAAK,EAAGM,QAAQ,EAFjB;AAGC,IAAA,OAAO,EACN,cAAC,MAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAMF,aAAa,CAAE,MAAF;AAF9B,OAIGd,EAAE,CAAE,MAAF,CAJL,CAJF;AAWC,IAAA,OAAO,EAAGkB,WAAW,GAAG,yBAAKA,WAAL,CAAH,GAA4BE;AAXlD,IADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates/single',\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts/single',\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplate( {\n\tpostType = 'wp_template',\n} ) {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord();\n\tlet description = getDescription();\n\tif ( ! description && record.is_custom ) {\n\t\tdescription = __(\n\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ getTitle() }\n\t\t\tactions={\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={ description ? <p>{ description }</p> : undefined }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/index.js"],"names":["__","sprintf","_x","useDispatch","useSelect","pencil","__experimentalUseNavigator","useNavigator","Icon","store","coreStore","SidebarNavigationScreen","useEditedEntityRecord","unlock","editSiteStore","SidebarButton","useAddedBy","useTemplateTitleAndDescription","postType","postId","getDescription","getTitle","record","currentTheme","select","getCurrentTheme","addedBy","isAddedByActiveTheme","type","theme","stylesheet","title","descriptionText","text","is_custom","description","imageUrl","icon","isCustomized","SidebarNavigationScreenTemplate","params","setCanvasMode"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,EAAsBC,EAAtB,QAAgC,iBAAhC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,IAFD,QAGO,uBAHP;AAIA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,qBAAP,MAAkC,6BAAlC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,UAAT,QAA2B,kBAA3B;;AA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GAAG,EAAGV,OAAO,CAACU,QADf;AAEC,IAAA,GAAG,EAAC,EAFL;AAGC,IAAA,KAAK,EAAC,IAHP;AAIC,IAAA,MAAM,EAAC;AAJR,IADC,GAQD,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGV,OAAO,CAACW;AAArB,IATF,CADD,EAaGX,OAAO,CAACO,IAbX,CADD,EAiBGP,OAAO,CAACY,YAAR,IACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGpB,QAAQ,KAAK,aAAb,GACChB,EAAE,CAAE,cAAF,EAAkB,UAAlB,CADH,GAECA,EAAE,CAAE,cAAF,EAAkB,eAAlB,CAHN,CAlBF,CAJF,CADD;AAkCA,SAAO;AAAE6B,IAAAA,KAAF;AAASI,IAAAA;AAAT,GAAP;AACA;;AAED,eAAe,SAASI,+BAAT,GAA2C;AACzD,QAAM;AAAEC,IAAAA;AAAF,MAAajC,YAAY,EAA/B;AACA,QAAM;AAAEW,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAuBqB,MAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB5B,MAAM,CAAEV,WAAW,CAAEW,aAAF,CAAb,CAAhC;AACA,QAAM;AAAEiB,IAAAA,KAAF;AAASI,IAAAA;AAAT,MAAyBlB,8BAA8B,CAC5DC,QAD4D,EAE5DC,MAF4D,CAA7D;AAKA,SACC,cAAC,uBAAD;AACC,IAAA,KAAK,EAAGY,KADT;AAEC,IAAA,OAAO,EACN,cAAC,aAAD;AACC,MAAA,OAAO,EAAG,MAAMU,aAAa,CAAE,MAAF,CAD9B;AAEC,MAAA,KAAK,EAAGzC,EAAE,CAAE,MAAF,CAFX;AAGC,MAAA,IAAI,EAAGK;AAHR,MAHF;AASC,IAAA,WAAW,EAAG8B;AATf,IADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { pencil } from '@wordpress/icons';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tIcon,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\nimport { useAddedBy } from '../list/added-by';\n\nfunction useTemplateTitleAndDescription( postType, postId ) {\n\tconst { getDescription, getTitle, record } = useEditedEntityRecord(\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst currentTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme(),\n\t\t[]\n\t);\n\tconst addedBy = useAddedBy( postType, postId );\n\tconst isAddedByActiveTheme =\n\t\taddedBy.type === 'theme' && record.theme === currentTheme?.stylesheet;\n\tconst title = getTitle();\n\tlet descriptionText = getDescription();\n\n\tif ( ! descriptionText && addedBy.text ) {\n\t\tif ( record.type === 'wp_template' && record.is_custom ) {\n\t\t\tdescriptionText = __(\n\t\t\t\t'This is a custom template that can be applied manually to any Post or Page.'\n\t\t\t);\n\t\t} else if ( record.type === 'wp_template_part' ) {\n\t\t\tdescriptionText = sprintf(\n\t\t\t\t// translators: %s: template part title e.g: \"Header\".\n\t\t\t\t__( 'This is your %s template part.' ),\n\t\t\t\tgetTitle()\n\t\t\t);\n\t\t}\n\t}\n\n\tconst description = (\n\t\t<>\n\t\t\t{ descriptionText }\n\n\t\t\t{ addedBy.text && ! isAddedByActiveTheme && (\n\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description\">\n\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author\">\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-author-icon\">\n\t\t\t\t\t\t\t{ addedBy.imageUrl ? (\n\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\tsrc={ addedBy.imageUrl }\n\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Icon icon={ addedBy.icon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ addedBy.text }\n\t\t\t\t\t</span>\n\n\t\t\t\t\t{ addedBy.isCustomized && (\n\t\t\t\t\t\t<span className=\"edit-site-sidebar-navigation-screen-template__added-by-description-customized\">\n\t\t\t\t\t\t\t{ postType === 'wp_template'\n\t\t\t\t\t\t\t\t? _x( '(Customized)', 'template' )\n\t\t\t\t\t\t\t\t: _x( '(Customized)', 'template part' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn { title, description };\n}\n\nexport default function SidebarNavigationScreenTemplate() {\n\tconst { params } = useNavigator();\n\tconst { postType, postId } = params;\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { title, description } = useTemplateTitleAndDescription(\n\t\tpostType,\n\t\tpostId\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ title }\n\t\t\tactions={\n\t\t\t\t<SidebarButton\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\ticon={ pencil }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tdescription={ description }\n\t\t/>\n\t);\n}\n"]}
@@ -4,9 +4,10 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  /**
5
5
  * WordPress dependencies
6
6
  */
7
- import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item } from '@wordpress/components';
7
+ import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalUseNavigator as useNavigator } from '@wordpress/components';
8
8
  import { __ } from '@wordpress/i18n';
9
9
  import { useEntityRecords } from '@wordpress/core-data';
10
+ import { useSelect } from '@wordpress/data';
10
11
  import { decodeEntities } from '@wordpress/html-entities';
11
12
  import { useViewportMatch } from '@wordpress/compose';
12
13
  /**
@@ -17,23 +18,25 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
17
18
  import { useLink } from '../routes/link';
18
19
  import SidebarNavigationItem from '../sidebar-navigation-item';
19
20
  import AddNewTemplate from '../add-new-template';
21
+ import { store as editSiteStore } from '../../store';
22
+ import SidebarButton from '../sidebar-button';
20
23
  const config = {
21
24
  wp_template: {
22
- path: '/templates',
23
25
  labels: {
24
26
  title: __('Templates'),
25
27
  loading: __('Loading templates'),
26
28
  notFound: __('No templates found'),
27
- manage: __('Manage all templates')
29
+ manage: __('Manage all templates'),
30
+ description: __('Express the layout of your site with templates.')
28
31
  }
29
32
  },
30
33
  wp_template_part: {
31
- path: '/template-parts',
32
34
  labels: {
33
35
  title: __('Template parts'),
34
36
  loading: __('Loading template parts'),
35
37
  notFound: __('No template parts found'),
36
- manage: __('Manage all template parts')
38
+ manage: __('Manage all template parts'),
39
+ description: __('Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.')
37
40
  }
38
41
  }
39
42
  };
@@ -46,38 +49,45 @@ const TemplateItem = _ref => {
46
49
  } = _ref;
47
50
  const linkInfo = useLink({
48
51
  postType,
49
- postId,
50
- path: config[postType].path + '/single'
52
+ postId
51
53
  });
52
54
  return createElement(SidebarNavigationItem, _extends({}, linkInfo, props));
53
55
  };
54
56
 
55
- export default function SidebarNavigationScreenTemplates(_ref2) {
56
- let {
57
- postType = 'wp_template'
58
- } = _ref2;
57
+ export default function SidebarNavigationScreenTemplates() {
58
+ const {
59
+ params: {
60
+ postType
61
+ }
62
+ } = useNavigator();
59
63
  const isMobileViewport = useViewportMatch('medium', '<');
64
+ const isTemplatePartsMode = useSelect(select => {
65
+ const settings = select(editSiteStore).getSettings();
66
+ return !!settings.supportsTemplatePartsMode;
67
+ }, []);
60
68
  const {
61
69
  records: templates,
62
70
  isResolving: isLoading
63
71
  } = useEntityRecords('postType', postType, {
64
72
  per_page: -1
65
73
  });
74
+ const sortedTemplates = templates ? [...templates] : [];
75
+ sortedTemplates.sort((a, b) => a.slug.localeCompare(b.slug));
66
76
  const browseAllLink = useLink({
67
- postType,
68
- postId: undefined,
69
- path: config[postType].path + '/all'
77
+ path: '/' + postType + '/all'
70
78
  });
79
+ const canCreate = !isMobileViewport && !isTemplatePartsMode;
71
80
  return createElement(SidebarNavigationScreen, {
72
- path: config[postType].path,
81
+ isRoot: isTemplatePartsMode,
73
82
  title: config[postType].labels.title,
74
- actions: !isMobileViewport && createElement(AddNewTemplate, {
83
+ description: config[postType].labels.description,
84
+ actions: canCreate && createElement(AddNewTemplate, {
75
85
  templateType: postType,
76
86
  toggleProps: {
77
- className: 'edit-site-sidebar-navigation-screen-templates__add-button'
87
+ as: SidebarButton
78
88
  }
79
89
  }),
80
- content: createElement(Fragment, null, isLoading && config[postType].labels.loading, !isLoading && createElement(ItemGroup, null, !(templates !== null && templates !== void 0 && templates.length) && createElement(Item, null, config[postType].labels.notFound), (templates !== null && templates !== void 0 ? templates : []).map(template => {
90
+ content: createElement(Fragment, null, isLoading && config[postType].labels.loading, !isLoading && createElement(ItemGroup, null, !(templates !== null && templates !== void 0 && templates.length) && createElement(Item, null, config[postType].labels.notFound), sortedTemplates.map(template => {
81
91
  var _template$title;
82
92
 
83
93
  return createElement(TemplateItem, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__","useEntityRecords","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","AddNewTemplate","config","wp_template","path","labels","title","loading","notFound","manage","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","isMobileViewport","records","templates","isResolving","isLoading","per_page","browseAllLink","undefined","className","length","map","template","id","rendered","slug"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,uBAAuB,IAAIC,SAD5B,EAECC,kBAAkB,IAAIC,IAFvB,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,OAAT,QAAwB,gBAAxB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE,YADM;AAEZC,IAAAA,MAAM,EAAE;AACPC,MAAAA,KAAK,EAAEZ,EAAE,CAAE,WAAF,CADF;AAEPa,MAAAA,OAAO,EAAEb,EAAE,CAAE,mBAAF,CAFJ;AAGPc,MAAAA,QAAQ,EAAEd,EAAE,CAAE,oBAAF,CAHL;AAIPe,MAAAA,MAAM,EAAEf,EAAE,CAAE,sBAAF;AAJH;AAFI,GADC;AAUdgB,EAAAA,gBAAgB,EAAE;AACjBN,IAAAA,IAAI,EAAE,iBADW;AAEjBC,IAAAA,MAAM,EAAE;AACPC,MAAAA,KAAK,EAAEZ,EAAE,CAAE,gBAAF,CADF;AAEPa,MAAAA,OAAO,EAAEb,EAAE,CAAE,wBAAF,CAFJ;AAGPc,MAAAA,QAAQ,EAAEd,EAAE,CAAE,yBAAF,CAHL;AAIPe,MAAAA,MAAM,EAAEf,EAAE,CAAE,2BAAF;AAJH;AAFS;AAVJ,CAAf;;AAqBA,MAAMiB,YAAY,GAAG,QAAsC;AAAA,MAApC;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAZ;AAAoB,OAAGC;AAAvB,GAAoC;AAC1D,QAAMC,QAAQ,GAA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ACG,EAAEF,SAAF,aAAEA,SAAF,eAAEA,SAAS,CAAEO,MAAb,KACD,cAAC,IAAD,QACGxB,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BG,QAD7B,CAFF,EAMG,CAAEW,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,EAAf,EAAoBQ,GAApB,CAA2BC,QAAF;AAAA;;AAAA,aAC1B,cAAC,YAAD;AACC,QAAA,QAAQ,EAAGhB,QADZ;AAEC,QAAA,MAAM,EAAGgB,QAAQ,CAACC,EAFnB;AAGC,QAAA,GAAG,EAAGD,QAAQ,CAACC;AAHhB,SAKGjC,cAAc,CACf,oBAAAgC,QAAQ,CAACtB,KAAT,oEAAgBwB,QAAhB,KACCF,QAAQ,CAACG,IAFK,CALjB,CAD0B;AAAA,KAAzB,CANH,EAkBG,CAAEd,gBAAF,IACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAC;AADX,OAEMM,aAFN;AAGC,MAAA,QAAQ,EACPrB,MAAM,CAAEU,QAAF,CAAN,CAAmBP,MAAnB,CAA0BI;AAJ5B,OAnBF,CAHF;AAfF,IADD;AAoDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport AddNewTemplate from '../add-new-template';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates',\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts',\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t},\n\t},\n};\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t\tpath: config[ postType ].path + '/single',\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates( {\n\tpostType = 'wp_template',\n} ) {\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tconst browseAllLink = useLink( {\n\t\tpostType,\n\t\tpostId: undefined,\n\t\tpath: config[ postType ].path + '/all',\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tactions={\n\t\t\t\t! isMobileViewport && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t'edit-site-sidebar-navigation-screen-templates__add-button',\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && config[ postType ].labels.loading }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t{ ! templates?.length && (\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.notFound }\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( templates ?? [] ).map( ( template ) => (\n\t\t\t\t\t\t\t\t<TemplateItem\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</TemplateItem>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\tchildren={\n\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels.manage\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates/index.js"],"names":["__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalUseNavigator","useNavigator","__","useEntityRecords","useSelect","decodeEntities","useViewportMatch","SidebarNavigationScreen","useLink","SidebarNavigationItem","AddNewTemplate","store","editSiteStore","SidebarButton","config","wp_template","labels","title","loading","notFound","manage","description","wp_template_part","TemplateItem","postType","postId","props","linkInfo","SidebarNavigationScreenTemplates","params","isMobileViewport","isTemplatePartsMode","select","settings","getSettings","supportsTemplatePartsMode","records","templates","isResolving","isLoading","per_page","sortedTemplates","sort","a","b","slug","localeCompare","browseAllLink","path","canCre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ent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalUseNavigator as useNavigator,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport AddNewTemplate from '../add-new-template';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nconst config = {\n\twp_template: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Templates' ),\n\t\t\tloading: __( 'Loading templates' ),\n\t\t\tnotFound: __( 'No templates found' ),\n\t\t\tmanage: __( 'Manage all templates' ),\n\t\t\tdescription: __(\n\t\t\t\t'Express the layout of your site with templates.'\n\t\t\t),\n\t\t},\n\t},\n\twp_template_part: {\n\t\tlabels: {\n\t\t\ttitle: __( 'Template parts' ),\n\t\t\tloading: __( 'Loading template parts' ),\n\t\t\tnotFound: __( 'No template parts found' ),\n\t\t\tmanage: __( 'Manage all template parts' ),\n\t\t\tdescription: __(\n\t\t\t\t'Template Parts are small pieces of a layout that can be reused across multiple templates and always appear the same way. Common template parts include the site header, footer, or sidebar.'\n\t\t\t),\n\t\t},\n\t},\n};\n\nconst TemplateItem = ( { postType, postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostType,\n\t\tpostId,\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenTemplates() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isTemplatePartsMode = useSelect( ( select ) => {\n\t\tconst settings = select( editSiteStore ).getSettings();\n\n\t\treturn !! settings.supportsTemplatePartsMode;\n\t}, [] );\n\n\tconst { records: templates, isResolving: isLoading } = useEntityRecords(\n\t\t'postType',\n\t\tpostType,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\tconst sortedTemplates = templates ? [ ...templates ] : [];\n\tsortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );\n\n\tconst browseAllLink = useLink( {\n\t\tpath: '/' + postType + '/all',\n\t} );\n\n\tconst canCreate = ! isMobileViewport && ! isTemplatePartsMode;\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot={ isTemplatePartsMode }\n\t\t\ttitle={ config[ postType ].labels.title }\n\t\t\tdescription={ config[ postType ].labels.description }\n\t\t\tactions={\n\t\t\t\tcanCreate && (\n\t\t\t\t\t<AddNewTemplate\n\t\t\t\t\t\ttemplateType={ postType }\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tas: SidebarButton,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ isLoading && config[ postType ].labels.loading }\n\t\t\t\t\t{ ! isLoading && (\n\t\t\t\t\t\t<ItemGroup>\n\t\t\t\t\t\t\t{ ! templates?.length && (\n\t\t\t\t\t\t\t\t<Item>\n\t\t\t\t\t\t\t\t\t{ config[ postType ].labels.notFound }\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ sortedTemplates.map( ( template ) => (\n\t\t\t\t\t\t\t\t<TemplateItem\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tpostId={ template.id }\n\t\t\t\t\t\t\t\t\tkey={ template.id }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\t\ttemplate.title?.rendered ||\n\t\t\t\t\t\t\t\t\t\t\ttemplate.slug\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</TemplateItem>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<SidebarNavigationItem\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-templates__see-all\"\n\t\t\t\t\t\t\t\t\t{ ...browseAllLink }\n\t\t\t\t\t\t\t\t\tchildren={\n\t\t\t\t\t\t\t\t\t\tconfig[ postType ].labels.manage\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -4,6 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __ } from '@wordpress/i18n';
7
+ import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
@@ -11,21 +12,23 @@ import { __ } from '@wordpress/i18n';
11
12
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
13
  const config = {
13
14
  wp_template: {
14
- path: '/templates/all',
15
- title: __('All templates')
15
+ title: __('All templates'),
16
+ description: __('Create new templates, or reset any customizations made to the templates supplied by your theme.')
16
17
  },
17
18
  wp_template_part: {
18
- path: '/template-parts/all',
19
- title: __('All template parts')
19
+ title: __('All template parts'),
20
+ description: __('Create new template parts, or reset any customizations made to the template parts supplied by your theme.')
20
21
  }
21
22
  };
22
- export default function SidebarNavigationScreenTemplatesBrowse(_ref) {
23
- let {
24
- postType = 'wp_template'
25
- } = _ref;
23
+ export default function SidebarNavigationScreenTemplatesBrowse() {
24
+ const {
25
+ params: {
26
+ postType
27
+ }
28
+ } = useNavigator();
26
29
  return createElement(SidebarNavigationScreen, {
27
- path: config[postType].path,
28
- title: config[postType].title
30
+ title: config[postType].title,
31
+ description: config[postType].description
29
32
  });
30
33
  }
31
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"names":["__","SidebarNavigationScreen","config","wp_template","path","title","wp_template_part","SidebarNavigationScreenTemplatesBrowse","postType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,IAAI,EAAE,gBADM;AAEZC,IAAAA,KAAK,EAAEL,EAAE,CAAE,eAAF;AAFG,GADC;AAKdM,EAAAA,gBAAgB,EAAE;AACjBF,IAAAA,IAAI,EAAE,qBADW;AAEjBC,IAAAA,KAAK,EAAEL,EAAE,CAAE,oBAAF;AAFQ;AALJ,CAAf;AAWA,eAAe,SAASO,sCAAT,OAEX;AAAA,MAF4D;AAC/DC,IAAAA,QAAQ,GAAG;AADoD,GAE5D;AACH,SACC,cAAC,uBAAD;AACC,IAAA,IAAI,EAAGN,MAAM,CAAEM,QAAF,CAAN,CAAmBJ,IAD3B;AAEC,IAAA,KAAK,EAAGF,MAAM,CAAEM,QAAF,CAAN,CAAmBH;AAF5B,IADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\n\nconst config = {\n\twp_template: {\n\t\tpath: '/templates/all',\n\t\ttitle: __( 'All templates' ),\n\t},\n\twp_template_part: {\n\t\tpath: '/template-parts/all',\n\t\ttitle: __( 'All template parts' ),\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplatesBrowse( {\n\tpostType = 'wp_template',\n} ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tpath={ config[ postType ].path }\n\t\t\ttitle={ config[ postType ].title }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js"],"names":["__","__experimentalUseNavigator","useNavigator","SidebarNavigationScreen","config","wp_template","title","description","wp_template_part","SidebarNavigationScreenTemplatesBrowse","params","postType"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAA0B,IAAIC,YAAvC,QAA2D,uBAA3D;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,WAAW,EAAE;AACZC,IAAAA,KAAK,EAAEN,EAAE,CAAE,eAAF,CADG;AAEZO,IAAAA,WAAW,EAAEP,EAAE,CACd,iGADc;AAFH,GADC;AAOdQ,EAAAA,gBAAgB,EAAE;AACjBF,IAAAA,KAAK,EAAEN,EAAE,CAAE,oBAAF,CADQ;AAEjBO,IAAAA,WAAW,EAAEP,EAAE,CACd,2GADc;AAFE;AAPJ,CAAf;AAeA,eAAe,SAASS,sCAAT,GAAkD;AAChE,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA;AAAF;AADH,MAEFT,YAAY,EAFhB;AAGA,SACC,cAAC,uBAAD;AACC,IAAA,KAAK,EAAGE,MAAM,CAAEO,QAAF,CAAN,CAAmBL,KAD5B;AAEC,IAAA,WAAW,EAAGF,MAAM,CAAEO,QAAF,CAAN,CAAmBJ;AAFlC,IADD;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\n\nconst config = {\n\twp_template: {\n\t\ttitle: __( 'All templates' ),\n\t\tdescription: __(\n\t\t\t'Create new templates, or reset any customizations made to the templates supplied by your theme.'\n\t\t),\n\t},\n\twp_template_part: {\n\t\ttitle: __( 'All template parts' ),\n\t\tdescription: __(\n\t\t\t'Create new template parts, or reset any customizations made to the template parts supplied by your theme.'\n\t\t),\n\t},\n};\n\nexport default function SidebarNavigationScreenTemplatesBrowse() {\n\tconst {\n\t\tparams: { postType },\n\t} = useNavigator();\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ config[ postType ].title }\n\t\t\tdescription={ config[ postType ].description }\n\t\t/>\n\t);\n}\n"]}
@@ -89,7 +89,9 @@ const SiteHub = forwardRef((props, ref) => {
89
89
  className: "edit-site-layout__view-mode-toggle"
90
90
  }), createElement(SiteIcon, {
91
91
  className: "edit-site-layout__view-mode-toggle-icon"
92
- }))), showLabels && createElement("div", null, siteTitle)));
92
+ }))), showLabels && createElement("div", {
93
+ className: "edit-site-site-hub__site-title"
94
+ }, siteTitle)));
93
95
  });
94
96
  export default SiteHub;
95
97
  //# sourceMappingURL=index.js.map