@wordpress/edit-site 4.19.0 → 5.0.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 (319) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +1 -0
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/index.js +8 -5
  5. package/build/components/add-new-template/index.js.map +1 -1
  6. package/build/components/add-new-template/new-template-part.js +21 -6
  7. package/build/components/add-new-template/new-template-part.js.map +1 -1
  8. package/build/components/add-new-template/new-template.js +12 -8
  9. package/build/components/add-new-template/new-template.js.map +1 -1
  10. package/build/components/app/index.js +15 -30
  11. package/build/components/app/index.js.map +1 -1
  12. package/build/components/block-editor/editor-canvas.js +64 -0
  13. package/build/components/block-editor/editor-canvas.js.map +1 -0
  14. package/build/components/block-editor/index.js +61 -59
  15. package/build/components/block-editor/index.js.map +1 -1
  16. package/build/components/block-editor/resizable-editor.js +10 -44
  17. package/build/components/block-editor/resizable-editor.js.map +1 -1
  18. package/build/components/editor/index.js +80 -127
  19. package/build/components/editor/index.js.map +1 -1
  20. package/build/components/global-styles/block-preview-panel.js +42 -0
  21. package/build/components/global-styles/block-preview-panel.js.map +1 -0
  22. package/build/components/global-styles/context-menu.js +6 -2
  23. package/build/components/global-styles/context-menu.js.map +1 -1
  24. package/build/components/global-styles/custom-css.js +61 -0
  25. package/build/components/global-styles/custom-css.js.map +1 -0
  26. package/build/components/global-styles/dimensions-panel.js +2 -6
  27. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  28. package/build/components/global-styles/global-styles-provider.js +15 -2
  29. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  30. package/build/components/global-styles/hooks.js +5 -2
  31. package/build/components/global-styles/hooks.js.map +1 -1
  32. package/build/components/global-styles/palette.js +1 -1
  33. package/build/components/global-styles/palette.js.map +1 -1
  34. package/build/components/global-styles/screen-block-list.js +2 -1
  35. package/build/components/global-styles/screen-block-list.js.map +1 -1
  36. package/build/components/global-styles/screen-block.js +10 -2
  37. package/build/components/global-styles/screen-block.js.map +1 -1
  38. package/build/components/global-styles/screen-border.js +43 -0
  39. package/build/components/global-styles/screen-border.js.map +1 -0
  40. package/build/components/global-styles/screen-colors.js +1 -1
  41. package/build/components/global-styles/screen-colors.js.map +1 -1
  42. package/build/components/global-styles/screen-css.js +42 -0
  43. package/build/components/global-styles/screen-css.js.map +1 -0
  44. package/build/components/global-styles/screen-layout.js +0 -5
  45. package/build/components/global-styles/screen-layout.js.map +1 -1
  46. package/build/components/global-styles/screen-root.js +14 -1
  47. package/build/components/global-styles/screen-root.js.map +1 -1
  48. package/build/components/global-styles/screen-style-variations.js +3 -3
  49. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  50. package/build/components/global-styles/ui.js +50 -4
  51. package/build/components/global-styles/ui.js.map +1 -1
  52. package/build/components/global-styles/use-global-styles-output.js +5 -1
  53. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  54. package/build/components/global-styles/utils.js +3 -3
  55. package/build/components/global-styles/utils.js.map +1 -1
  56. package/build/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -8
  57. package/build/components/global-styles-renderer/index.js.map +1 -0
  58. package/build/components/header-edit-mode/document-actions/index.js +12 -5
  59. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  60. package/build/components/header-edit-mode/index.js +19 -12
  61. package/build/components/header-edit-mode/index.js.map +1 -1
  62. package/build/components/keyboard-shortcuts/index.js +11 -1
  63. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  64. package/build/components/layout/index.js +231 -0
  65. package/build/components/layout/index.js.map +1 -0
  66. package/build/components/list/header.js +5 -1
  67. package/build/components/list/header.js.map +1 -1
  68. package/build/components/list/index.js +4 -22
  69. package/build/components/list/index.js.map +1 -1
  70. package/build/components/navigate-to-link/index.js +1 -3
  71. package/build/components/navigate-to-link/index.js.map +1 -1
  72. package/build/components/routes/index.js +1 -1
  73. package/build/components/routes/index.js.map +1 -1
  74. package/build/components/sidebar/index.js +42 -0
  75. package/build/components/sidebar/index.js.map +1 -0
  76. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +24 -4
  77. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  78. package/build/components/sidebar-edit-mode/index.js +1 -1
  79. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  80. package/build/components/sidebar-navigation-item/index.js +53 -0
  81. package/build/components/sidebar-navigation-item/index.js.map +1 -0
  82. package/build/components/sidebar-navigation-screen/index.js +49 -0
  83. package/build/components/sidebar-navigation-screen/index.js.map +1 -0
  84. package/build/components/sidebar-navigation-screen-main/index.js +76 -0
  85. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -0
  86. package/build/components/sidebar-navigation-screen-templates/index.js +188 -0
  87. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  88. package/build/components/site-icon/index.js +70 -0
  89. package/build/components/site-icon/index.js.map +1 -0
  90. package/build/components/site-title/index.js +55 -0
  91. package/build/components/site-title/index.js.map +1 -0
  92. package/build/components/style-book/index.js +173 -0
  93. package/build/components/style-book/index.js.map +1 -0
  94. package/build/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +5 -4
  95. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  96. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +53 -0
  97. package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  98. package/build/index.js +2 -45
  99. package/build/index.js.map +1 -1
  100. package/build/store/actions.js +93 -43
  101. package/build/store/actions.js.map +1 -1
  102. package/build/store/reducer.js +35 -107
  103. package/build/store/reducer.js.map +1 -1
  104. package/build/store/selectors.js +69 -78
  105. package/build/store/selectors.js.map +1 -1
  106. package/build-module/components/add-new-template/add-custom-template-modal.js +1 -0
  107. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  108. package/build-module/components/add-new-template/index.js +7 -5
  109. package/build-module/components/add-new-template/index.js.map +1 -1
  110. package/build-module/components/add-new-template/new-template-part.js +18 -6
  111. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  112. package/build-module/components/add-new-template/new-template.js +13 -9
  113. package/build-module/components/add-new-template/new-template.js.map +1 -1
  114. package/build-module/components/app/index.js +15 -28
  115. package/build-module/components/app/index.js.map +1 -1
  116. package/build-module/components/block-editor/editor-canvas.js +51 -0
  117. package/build-module/components/block-editor/editor-canvas.js.map +1 -0
  118. package/build-module/components/block-editor/index.js +61 -60
  119. package/build-module/components/block-editor/index.js.map +1 -1
  120. package/build-module/components/block-editor/resizable-editor.js +11 -40
  121. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  122. package/build-module/components/editor/index.js +81 -124
  123. package/build-module/components/editor/index.js.map +1 -1
  124. package/build-module/components/global-styles/block-preview-panel.js +32 -0
  125. package/build-module/components/global-styles/block-preview-panel.js.map +1 -0
  126. package/build-module/components/global-styles/context-menu.js +7 -3
  127. package/build-module/components/global-styles/context-menu.js.map +1 -1
  128. package/build-module/components/global-styles/custom-css.js +51 -0
  129. package/build-module/components/global-styles/custom-css.js.map +1 -0
  130. package/build-module/components/global-styles/dimensions-panel.js +3 -7
  131. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  132. package/build-module/components/global-styles/global-styles-provider.js +15 -2
  133. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  134. package/build-module/components/global-styles/hooks.js +5 -3
  135. package/build-module/components/global-styles/hooks.js.map +1 -1
  136. package/build-module/components/global-styles/palette.js +1 -1
  137. package/build-module/components/global-styles/palette.js.map +1 -1
  138. package/build-module/components/global-styles/screen-block-list.js +2 -1
  139. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  140. package/build-module/components/global-styles/screen-block.js +8 -2
  141. package/build-module/components/global-styles/screen-block.js.map +1 -1
  142. package/build-module/components/global-styles/screen-border.js +27 -0
  143. package/build-module/components/global-styles/screen-border.js.map +1 -0
  144. package/build-module/components/global-styles/screen-colors.js +1 -1
  145. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  146. package/build-module/components/global-styles/screen-css.js +28 -0
  147. package/build-module/components/global-styles/screen-css.js.map +1 -0
  148. package/build-module/components/global-styles/screen-layout.js +0 -4
  149. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  150. package/build-module/components/global-styles/screen-root.js +14 -1
  151. package/build-module/components/global-styles/screen-root.js.map +1 -1
  152. package/build-module/components/global-styles/screen-style-variations.js +2 -2
  153. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  154. package/build-module/components/global-styles/ui.js +48 -5
  155. package/build-module/components/global-styles/ui.js.map +1 -1
  156. package/build-module/components/global-styles/use-global-styles-output.js +5 -1
  157. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  158. package/build-module/components/global-styles/utils.js +4 -4
  159. package/build-module/components/global-styles/utils.js.map +1 -1
  160. package/build-module/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +4 -7
  161. package/build-module/components/global-styles-renderer/index.js.map +1 -0
  162. package/build-module/components/header-edit-mode/document-actions/index.js +13 -6
  163. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  164. package/build-module/components/header-edit-mode/index.js +16 -11
  165. package/build-module/components/header-edit-mode/index.js.map +1 -1
  166. package/build-module/components/keyboard-shortcuts/index.js +10 -1
  167. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  168. package/build-module/components/layout/index.js +203 -0
  169. package/build-module/components/layout/index.js.map +1 -0
  170. package/build-module/components/list/header.js +5 -1
  171. package/build-module/components/list/header.js.map +1 -1
  172. package/build-module/components/list/index.js +4 -19
  173. package/build-module/components/list/index.js.map +1 -1
  174. package/build-module/components/navigate-to-link/index.js +1 -3
  175. package/build-module/components/navigate-to-link/index.js.map +1 -1
  176. package/build-module/components/routes/index.js +1 -1
  177. package/build-module/components/routes/index.js.map +1 -1
  178. package/build-module/components/sidebar/index.js +30 -0
  179. package/build-module/components/sidebar/index.js.map +1 -0
  180. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +27 -7
  181. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  182. package/build-module/components/sidebar-edit-mode/index.js +3 -3
  183. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  184. package/build-module/components/sidebar-navigation-item/index.js +40 -0
  185. package/build-module/components/sidebar-navigation-item/index.js.map +1 -0
  186. package/build-module/components/sidebar-navigation-screen/index.js +39 -0
  187. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -0
  188. package/build-module/components/sidebar-navigation-screen-main/index.js +57 -0
  189. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -0
  190. package/build-module/components/sidebar-navigation-screen-templates/index.js +165 -0
  191. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -0
  192. package/build-module/components/site-icon/index.js +55 -0
  193. package/build-module/components/site-icon/index.js.map +1 -0
  194. package/build-module/components/site-title/index.js +43 -0
  195. package/build-module/components/site-title/index.js.map +1 -0
  196. package/build-module/components/style-book/index.js +156 -0
  197. package/build-module/components/style-book/index.js.map +1 -0
  198. package/build-module/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +4 -3
  199. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -0
  200. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +43 -0
  201. package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +1 -0
  202. package/build-module/index.js +5 -36
  203. package/build-module/index.js.map +1 -1
  204. package/build-module/store/actions.js +87 -42
  205. package/build-module/store/actions.js.map +1 -1
  206. package/build-module/store/reducer.js +35 -102
  207. package/build-module/store/reducer.js.map +1 -1
  208. package/build-module/store/selectors.js +60 -72
  209. package/build-module/store/selectors.js.map +1 -1
  210. package/build-style/style-rtl.css +550 -346
  211. package/build-style/style.css +550 -346
  212. package/package.json +32 -31
  213. package/src/components/add-new-template/add-custom-template-modal.js +1 -0
  214. package/src/components/add-new-template/index.js +6 -3
  215. package/src/components/add-new-template/new-template-part.js +15 -3
  216. package/src/components/add-new-template/new-template.js +14 -7
  217. package/src/components/add-new-template/style.scss +0 -4
  218. package/src/components/app/index.js +14 -43
  219. package/src/components/block-editor/editor-canvas.js +69 -0
  220. package/src/components/block-editor/index.js +102 -87
  221. package/src/components/block-editor/resizable-editor.js +9 -64
  222. package/src/components/block-editor/style.scss +25 -1
  223. package/src/components/code-editor/style.scss +1 -1
  224. package/src/components/editor/index.js +170 -236
  225. package/src/components/editor/style.scss +0 -22
  226. package/src/components/global-styles/block-preview-panel.js +29 -0
  227. package/src/components/global-styles/context-menu.js +11 -2
  228. package/src/components/global-styles/custom-css.js +73 -0
  229. package/src/components/global-styles/dimensions-panel.js +2 -5
  230. package/src/components/global-styles/global-styles-provider.js +39 -17
  231. package/src/components/global-styles/hooks.js +8 -3
  232. package/src/components/global-styles/palette.js +1 -1
  233. package/src/components/global-styles/screen-block-list.js +2 -1
  234. package/src/components/global-styles/screen-block.js +9 -1
  235. package/src/components/global-styles/screen-border.js +23 -0
  236. package/src/components/global-styles/screen-colors.js +2 -1
  237. package/src/components/global-styles/screen-css.js +33 -0
  238. package/src/components/global-styles/screen-layout.js +0 -3
  239. package/src/components/global-styles/screen-root.js +30 -1
  240. package/src/components/global-styles/screen-style-variations.js +5 -2
  241. package/src/components/global-styles/style.scss +31 -2
  242. package/src/components/global-styles/ui.js +47 -4
  243. package/src/components/global-styles/use-global-styles-output.js +5 -0
  244. package/src/components/global-styles/utils.js +8 -5
  245. package/src/components/{editor/global-styles-renderer.js → global-styles-renderer/index.js} +3 -9
  246. package/src/components/header-edit-mode/document-actions/index.js +14 -9
  247. package/src/components/header-edit-mode/document-actions/style.scss +8 -1
  248. package/src/components/header-edit-mode/index.js +96 -78
  249. package/src/components/header-edit-mode/style.scss +5 -33
  250. package/src/components/keyboard-shortcuts/index.js +13 -0
  251. package/src/components/layout/index.js +278 -0
  252. package/src/components/layout/style.scss +176 -0
  253. package/src/components/list/header.js +5 -1
  254. package/src/components/list/index.js +12 -31
  255. package/src/components/list/style.scss +10 -4
  256. package/src/components/navigate-to-link/index.js +2 -8
  257. package/src/components/routes/index.js +1 -1
  258. package/src/components/sidebar/index.js +34 -0
  259. package/src/components/sidebar/style.scss +8 -0
  260. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +42 -7
  261. package/src/components/sidebar-edit-mode/index.js +3 -3
  262. package/src/components/sidebar-edit-mode/navigation-menu-sidebar/style.scss +21 -3
  263. package/src/components/sidebar-edit-mode/settings-header/style.scss +47 -34
  264. package/src/components/sidebar-edit-mode/style.scss +0 -13
  265. package/src/components/sidebar-navigation-item/index.js +51 -0
  266. package/src/components/sidebar-navigation-item/style.scss +17 -0
  267. package/src/components/sidebar-navigation-screen/index.js +55 -0
  268. package/src/components/sidebar-navigation-screen/style.scss +41 -0
  269. package/src/components/sidebar-navigation-screen-main/index.js +72 -0
  270. package/src/components/sidebar-navigation-screen-templates/index.js +181 -0
  271. package/src/components/sidebar-navigation-screen-templates/style.scss +9 -0
  272. package/src/components/site-icon/index.js +56 -0
  273. package/src/components/site-icon/style.scss +10 -0
  274. package/src/components/site-title/index.js +39 -0
  275. package/src/components/style-book/index.js +193 -0
  276. package/src/components/style-book/style.scss +78 -0
  277. package/src/components/{url-query-controller/index.js → sync-state-with-url/use-init-edited-entity-from-url.js} +3 -3
  278. package/src/components/sync-state-with-url/use-sync-sidebar-path-with-url.js +36 -0
  279. package/src/components/template-details/style.scss +4 -0
  280. package/src/index.js +3 -53
  281. package/src/store/actions.js +93 -48
  282. package/src/store/reducer.js +29 -91
  283. package/src/store/selectors.js +61 -101
  284. package/src/store/test/actions.js +3 -15
  285. package/src/store/test/reducer.js +8 -192
  286. package/src/store/test/selectors.js +3 -42
  287. package/src/style.scss +19 -3
  288. package/build/components/editor/global-styles-renderer.js.map +0 -1
  289. package/build/components/navigation-sidebar/index.js +0 -62
  290. package/build/components/navigation-sidebar/index.js.map +0 -1
  291. package/build/components/navigation-sidebar/navigation-panel/constants.js +0 -77
  292. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  293. package/build/components/navigation-sidebar/navigation-panel/index.js +0 -152
  294. package/build/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  295. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  296. package/build/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  297. package/build/components/navigation-sidebar/navigation-toggle/index.js +0 -124
  298. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  299. package/build/components/url-query-controller/index.js.map +0 -1
  300. package/build-module/components/editor/global-styles-renderer.js.map +0 -1
  301. package/build-module/components/navigation-sidebar/index.js +0 -45
  302. package/build-module/components/navigation-sidebar/index.js.map +0 -1
  303. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -49
  304. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +0 -1
  305. package/build-module/components/navigation-sidebar/navigation-panel/index.js +0 -131
  306. package/build-module/components/navigation-sidebar/navigation-panel/index.js.map +0 -1
  307. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -66
  308. package/build-module/components/navigation-sidebar/navigation-panel/template-hierarchy.js.map +0 -1
  309. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +0 -108
  310. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +0 -1
  311. package/build-module/components/url-query-controller/index.js.map +0 -1
  312. package/src/components/navigation-sidebar/index.js +0 -46
  313. package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -94
  314. package/src/components/navigation-sidebar/navigation-panel/index.js +0 -142
  315. package/src/components/navigation-sidebar/navigation-panel/style.scss +0 -152
  316. package/src/components/navigation-sidebar/navigation-panel/template-hierarchy.js +0 -81
  317. package/src/components/navigation-sidebar/navigation-toggle/index.js +0 -114
  318. package/src/components/navigation-sidebar/navigation-toggle/style.scss +0 -71
  319. package/src/components/navigation-sidebar/navigation-toggle/test/index.js +0 -65
@@ -7,24 +7,16 @@ exports.blockInserterPanel = blockInserterPanel;
7
7
  exports.default = void 0;
8
8
  exports.deviceType = deviceType;
9
9
  exports.editedPost = editedPost;
10
- exports.homeTemplateId = homeTemplateId;
11
10
  exports.listViewPanel = listViewPanel;
12
- exports.navigationPanel = navigationPanel;
13
11
  exports.saveViewPanel = saveViewPanel;
14
12
  exports.settings = settings;
15
13
 
16
14
  var _data = require("@wordpress/data");
17
15
 
18
- var _constants = require("../components/navigation-sidebar/navigation-panel/constants");
19
-
20
16
  /**
21
17
  * WordPress dependencies
22
18
  */
23
19
 
24
- /**
25
- * Internal dependencies
26
- */
27
-
28
20
  /**
29
21
  * Reducer returning the editing canvas device type.
30
22
  *
@@ -83,91 +75,16 @@ function editedPost() {
83
75
  let action = arguments.length > 1 ? arguments[1] : undefined;
84
76
 
85
77
  switch (action.type) {
86
- case 'SET_TEMPLATE':
87
- case 'SET_PAGE':
88
- return {
89
- type: 'wp_template',
90
- id: action.templateId,
91
- page: action.page
92
- };
93
-
94
- case 'SET_TEMPLATE_PART':
78
+ case 'SET_EDITED_POST':
95
79
  return {
96
- type: 'wp_template_part',
97
- id: action.templatePartId
98
- };
99
- }
100
-
101
- return state;
102
- }
103
- /**
104
- * Reducer for information about the site's homepage.
105
- *
106
- * @param {Object} state Current state.
107
- * @param {Object} action Dispatched action.
108
- *
109
- * @return {Object} Updated state.
110
- */
111
-
112
-
113
- function homeTemplateId(state, action) {
114
- switch (action.type) {
115
- case 'SET_HOME_TEMPLATE':
116
- return action.homeTemplateId;
117
- }
118
-
119
- return state;
120
- }
121
- /**
122
- * Reducer for information about the navigation panel, such as its active menu
123
- * and whether it should be opened or closed.
124
- *
125
- * Note: this reducer interacts with the inserter and list view panels reducers
126
- * to make sure that only one of the three panels is open at the same time.
127
- *
128
- * @param {Object} state Current state.
129
- * @param {Object} action Dispatched action.
130
- */
131
-
132
-
133
- function navigationPanel() {
134
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
135
- menu: _constants.MENU_ROOT,
136
- isOpen: false
137
- };
138
- let action = arguments.length > 1 ? arguments[1] : undefined;
139
-
140
- switch (action.type) {
141
- case 'SET_NAVIGATION_PANEL_ACTIVE_MENU':
142
- return { ...state,
143
- menu: action.menu
80
+ postType: action.postType,
81
+ id: action.id,
82
+ context: action.context
144
83
  };
145
84
 
146
- case 'OPEN_NAVIGATION_PANEL_TO_MENU':
85
+ case 'SET_EDITED_POST_CONTEXT':
147
86
  return { ...state,
148
- isOpen: true,
149
- menu: action.menu
150
- };
151
-
152
- case 'SET_IS_NAVIGATION_PANEL_OPENED':
153
- return { ...state,
154
- menu: !action.isOpen ? _constants.MENU_ROOT : state.menu,
155
- // Set menu to root when closing panel.
156
- isOpen: action.isOpen
157
- };
158
-
159
- case 'SET_IS_LIST_VIEW_OPENED':
160
- return { ...state,
161
- menu: state.isOpen && action.isOpen ? _constants.MENU_ROOT : state.menu,
162
- // Set menu to root when closing panel.
163
- isOpen: action.isOpen ? false : state.isOpen
164
- };
165
-
166
- case 'SET_IS_INSERTER_OPENED':
167
- return { ...state,
168
- menu: state.isOpen && action.value ? _constants.MENU_ROOT : state.menu,
169
- // Set menu to root when closing panel.
170
- isOpen: action.value ? false : state.isOpen
87
+ context: action.context
171
88
  };
172
89
  }
173
90
 
@@ -189,15 +106,14 @@ function blockInserterPanel() {
189
106
  let action = arguments.length > 1 ? arguments[1] : undefined;
190
107
 
191
108
  switch (action.type) {
192
- case 'OPEN_NAVIGATION_PANEL_TO_MENU':
193
- return false;
194
-
195
- case 'SET_IS_NAVIGATION_PANEL_OPENED':
196
109
  case 'SET_IS_LIST_VIEW_OPENED':
197
110
  return action.isOpen ? false : state;
198
111
 
199
112
  case 'SET_IS_INSERTER_OPENED':
200
113
  return action.value;
114
+
115
+ case 'SET_CANVAS_MODE':
116
+ return false;
201
117
  }
202
118
 
203
119
  return state;
@@ -218,17 +134,14 @@ function listViewPanel() {
218
134
  let action = arguments.length > 1 ? arguments[1] : undefined;
219
135
 
220
136
  switch (action.type) {
221
- case 'OPEN_NAVIGATION_PANEL_TO_MENU':
222
- return false;
223
-
224
- case 'SET_IS_NAVIGATION_PANEL_OPENED':
225
- return action.isOpen ? false : state;
226
-
227
137
  case 'SET_IS_INSERTER_OPENED':
228
138
  return action.value ? false : state;
229
139
 
230
140
  case 'SET_IS_LIST_VIEW_OPENED':
231
141
  return action.isOpen;
142
+
143
+ case 'SET_CANVAS_MODE':
144
+ return false;
232
145
  }
233
146
 
234
147
  return state;
@@ -246,14 +159,30 @@ function saveViewPanel() {
246
159
  let action = arguments.length > 1 ? arguments[1] : undefined;
247
160
 
248
161
  switch (action.type) {
249
- case 'OPEN_NAVIGATION_PANEL_TO_MENU':
162
+ case 'SET_IS_SAVE_VIEW_OPENED':
163
+ return action.isOpen;
164
+
165
+ case 'SET_CANVAS_MODE':
250
166
  return false;
167
+ }
251
168
 
252
- case 'SET_IS_NAVIGATION_PANEL_OPENED':
253
- return action.isOpen ? false : state;
169
+ return state;
170
+ }
171
+ /**
172
+ * Reducer used to track the site editor canvas mode (edit or view).
173
+ *
174
+ * @param {Object} state Current state.
175
+ * @param {Object} action Dispatched action.
176
+ */
254
177
 
255
- case 'SET_IS_SAVE_VIEW_OPENED':
256
- return action.isOpen;
178
+
179
+ function canvasMode() {
180
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'view';
181
+ let action = arguments.length > 1 ? arguments[1] : undefined;
182
+
183
+ switch (action.type) {
184
+ case 'SET_CANVAS_MODE':
185
+ return action.mode;
257
186
  }
258
187
 
259
188
  return state;
@@ -263,11 +192,10 @@ var _default = (0, _data.combineReducers)({
263
192
  deviceType,
264
193
  settings,
265
194
  editedPost,
266
- homeTemplateId,
267
- navigationPanel,
268
195
  blockInserterPanel,
269
196
  listViewPanel,
270
- saveViewPanel
197
+ saveViewPanel,
198
+ canvasMode
271
199
  });
272
200
 
273
201
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["deviceType","state","action","type","settings","editedPost","id","templateId","page","templatePartId","homeTemplateId","navigationPanel","menu","MENU_ROOT","isOpen","value","blockInserterPanel","listViewPanel","saveViewPanel"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAT,GAAiD;AAAA,MAA5BC,KAA4B,uEAApB,SAAoB;AAAA,MAATC,MAAS;;AACvD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACF,UAAd;AAFF;;AAKA,SAAOC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,QAAT,GAAwC;AAAA,MAArBH,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC9C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,iBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,WAAGC,MAAM,CAACE;AAFJ,OAAP;AAFF;;AAQA,SAAOH,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,UAAT,GAA0C;AAAA,MAArBJ,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAChD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,cAAL;AACA,SAAK,UAAL;AACC,aAAO;AACNA,QAAAA,IAAI,EAAE,aADA;AAENG,QAAAA,EAAE,EAAEJ,MAAM,CAACK,UAFL;AAGNC,QAAAA,IAAI,EAAEN,MAAM,CAACM;AAHP,OAAP;;AAKD,SAAK,mBAAL;AACC,aAAO;AACNL,QAAAA,IAAI,EAAE,kBADA;AAENG,QAAAA,EAAE,EAAEJ,MAAM,CAACO;AAFL,OAAP;AATF;;AAeA,SAAOR,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;A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SAAK,yBAAL;AACC,aAAOC,MAAM,CAACY,MAAd;AANF;;AAQA,SAAOb,KAAP;AACA;;eAEc,2BAAiB;AAC/BD,EAAAA,UAD+B;AAE/BI,EAAAA,QAF+B;AAG/BC,EAAAA,UAH+B;AAI/BK,EAAAA,cAJ+B;AAK/BC,EAAAA,eAL+B;AAM/BK,EAAAA,kBAN+B;AAO/BC,EAAAA,aAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { MENU_ROOT } from '../components/navigation-sidebar/navigation-panel/constants';\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Object} state Current edited post.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editedPost( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE':\n\t\tcase 'SET_PAGE':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template',\n\t\t\t\tid: action.templateId,\n\t\t\t\tpage: action.page,\n\t\t\t};\n\t\tcase 'SET_TEMPLATE_PART':\n\t\t\treturn {\n\t\t\t\ttype: 'wp_template_part',\n\t\t\t\tid: action.templatePartId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the site's homepage.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function homeTemplateId( state, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_HOME_TEMPLATE':\n\t\t\treturn action.homeTemplateId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for information about the navigation panel, such as its active menu\n * and whether it should be opened or closed.\n *\n * Note: this reducer interacts with the inserter and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function navigationPanel(\n\tstate = { menu: MENU_ROOT, isOpen: false },\n\taction\n) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_NAVIGATION_PANEL_ACTIVE_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisOpen: true,\n\t\t\t\tmenu: action.menu,\n\t\t\t};\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: ! action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.isOpen ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.isOpen ? false : state.isOpen,\n\t\t\t};\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tmenu: state.isOpen && action.value ? MENU_ROOT : state.menu, // Set menu to root when closing panel.\n\t\t\t\tisOpen: action.value ? false : state.isOpen,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the save view panel open or closed.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function saveViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_NAVIGATION_PANEL_TO_MENU':\n\t\t\treturn false;\n\t\tcase 'SET_IS_NAVIGATION_PANEL_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_SAVE_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\thomeTemplateId,\n\tnavigationPanel,\n\tblockInserterPanel,\n\tlistViewPanel,\n\tsaveViewPanel,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/reducer.js"],"names":["deviceType","state","action","type","settings","editedPost","postType","id","context","blockInserterPanel","isOpen","value","listViewPanel","saveViewPanel","canvasMode","mode"],"mappings":";;;;;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,UAAT,GAAiD;AAAA,MAA5BC,KAA4B,uEAApB,SAAoB;AAAA,MAATC,MAAS;;AACvD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACF,UAAd;AAFF;;AAKA,SAAOC,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,QAAT,GAAwC;AAAA,MAArBH,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAC9C,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,iBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,WAAGC,MAAM,CAACE;AAFJ,OAAP;AAFF;;AAQA,SAAOH,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,UAAT,GAA0C;AAAA,MAArBJ,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AAChD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,iBAAL;AACC,aAAO;AACNG,QAAAA,QAAQ,EAAEJ,MAAM,CAACI,QADX;AAENC,QAAAA,EAAE,EAAEL,MAAM,CAACK,EAFL;AAGNC,QAAAA,OAAO,EAAEN,MAAM,CAACM;AAHV,OAAP;;AAKD,SAAK,yBAAL;AACC,aAAO,EACN,GAAGP,KADG;AAENO,QAAAA,OAAO,EAAEN,MAAM,CAACM;AAFV,OAAP;AARF;;AAcA,SAAO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AA,UAD+B;AAE/BI,EAAAA,QAF+B;AAG/BC,EAAAA,UAH+B;AAI/BI,EAAAA,kBAJ+B;AAK/BG,EAAAA,aAL+B;AAM/BC,EAAAA,aAN+B;AAO/BC,EAAAA;AAP+B,CAAjB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the settings.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function settings( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the currently edited Post Type,\n * Post Id and the context provided to fill the content of the block editor.\n *\n * @param {Object} state Current edited post.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editedPost( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn {\n\t\t\t\tpostType: action.postType,\n\t\t\t\tid: action.id,\n\t\t\t\tcontext: action.context,\n\t\t\t};\n\t\tcase 'SET_EDITED_POST_CONTEXT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tcontext: action.context,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the navigation and list view panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {boolean|Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t\tcase 'SET_CANVAS_MODE':\n\t\t\treturn false;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the navigation and inserter panels reducers\n * to make sure that only one of the three panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t\tcase 'SET_CANVAS_MODE':\n\t\t\treturn false;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the save view panel open or closed.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function saveViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_SAVE_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t\tcase 'SET_CANVAS_MODE':\n\t\t\treturn false;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer used to track the site editor canvas mode (edit or view).\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nfunction canvasMode( state = 'view', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CANVAS_MODE':\n\t\t\treturn action.mode;\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tdeviceType,\n\tsettings,\n\teditedPost,\n\tblockInserterPanel,\n\tlistViewPanel,\n\tsaveViewPanel,\n\tcanvasMode,\n} );\n"]}
@@ -7,7 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
9
9
  exports.__experimentalGetPreviewDeviceType = __experimentalGetPreviewDeviceType;
10
- exports.getCurrentTemplateTemplateParts = exports.getCurrentTemplateNavigationPanelSubMenu = exports.getCanUserCreateMedia = exports.__unstableGetPreference = void 0;
10
+ exports.__unstableGetCanvasMode = __unstableGetCanvasMode;
11
+ exports.getCanUserCreateMedia = exports.__unstableGetPreference = void 0;
12
+ exports.getCurrentTemplateNavigationPanelSubMenu = getCurrentTemplateNavigationPanelSubMenu;
13
+ exports.getCurrentTemplateTemplateParts = void 0;
14
+ exports.getEditedPostContext = getEditedPostContext;
11
15
  exports.getEditedPostId = getEditedPostId;
12
16
  exports.getEditedPostType = getEditedPostType;
13
17
  exports.getEditorMode = getEditorMode;
@@ -21,8 +25,6 @@ exports.isListViewOpened = isListViewOpened;
21
25
  exports.isNavigationOpened = isNavigationOpened;
22
26
  exports.isSaveViewOpened = isSaveViewOpened;
23
27
 
24
- var _lodash = require("lodash");
25
-
26
28
  var _rememo = _interopRequireDefault(require("rememo"));
27
29
 
28
30
  var _coreData = require("@wordpress/core-data");
@@ -39,10 +41,6 @@ var _element = require("@wordpress/element");
39
41
 
40
42
  var _preferences = require("@wordpress/preferences");
41
43
 
42
- var _constants = require("../components/navigation-sidebar/navigation-panel/constants");
43
-
44
- var _templateHierarchy = require("../components/navigation-sidebar/navigation-panel/template-hierarchy");
45
-
46
44
  /**
47
45
  * External dependencies
48
46
  */
@@ -51,10 +49,6 @@ var _templateHierarchy = require("../components/navigation-sidebar/navigation-pa
51
49
  * WordPress dependencies
52
50
  */
53
51
 
54
- /**
55
- * Internal dependencies
56
- */
57
-
58
52
  /**
59
53
  * @typedef {'template'|'template_type'} TemplateType Template type.
60
54
  */
@@ -172,21 +166,16 @@ const getSettings = (0, _rememo.default)((state, setIsInserterOpen) => {
172
166
  return settings;
173
167
  }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
174
168
  /**
175
- * Returns the current home template ID.
176
- *
177
- * @param {Object} state Global application state.
178
- *
179
- * @return {number?} Home template ID.
169
+ * @deprecated
180
170
  */
181
171
 
182
172
  exports.getSettings = getSettings;
183
173
 
184
- function getHomeTemplateId(state) {
185
- return state.homeTemplateId;
186
- }
187
-
188
- function getCurrentEditedPost(state) {
189
- return state.editedPost;
174
+ function getHomeTemplateId() {
175
+ (0, _deprecated.default)("select( 'core/edit-site' ).getHomeTemplateId", {
176
+ since: '6.2',
177
+ version: '6.4'
178
+ });
190
179
  }
191
180
  /**
192
181
  * Returns the current edited post type (wp_template or wp_template_part).
@@ -198,7 +187,7 @@ function getCurrentEditedPost(state) {
198
187
 
199
188
 
200
189
  function getEditedPostType(state) {
201
- return getCurrentEditedPost(state).type;
190
+ return state.editedPost.postType;
202
191
  }
203
192
  /**
204
193
  * Returns the ID of the currently edited template or template part.
@@ -210,78 +199,35 @@ function getEditedPostType(state) {
210
199
 
211
200
 
212
201
  function getEditedPostId(state) {
213
- return getCurrentEditedPost(state).id;
202
+ return state.editedPost.id;
214
203
  }
215
204
  /**
216
- * Returns the current page object.
205
+ * Returns the edited post's context object.
217
206
  *
207
+ * @deprecated
218
208
  * @param {Object} state Global application state.
219
209
  *
220
210
  * @return {Object} Page.
221
211
  */
222
212
 
223
213
 
224
- function getPage(state) {
225
- return getCurrentEditedPost(state).page;
214
+ function getEditedPostContext(state) {
215
+ return state.editedPost.context;
226
216
  }
227
217
  /**
228
- * Returns the active menu in the navigation panel.
229
- *
230
- * @param {Object} state Global application state.
231
- *
232
- * @return {string} Active menu.
233
- */
234
-
235
-
236
- function getNavigationPanelActiveMenu(state) {
237
- return state.navigationPanel.menu;
238
- }
239
- /**
240
- * Returns the current template or template part's corresponding
241
- * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.
242
- *
243
- * @param {Object} state Global application state.
244
- *
245
- * @return {string} The current template or template part's sub menu.
246
- */
247
-
248
-
249
- const getCurrentTemplateNavigationPanelSubMenu = (0, _data.createRegistrySelector)(select => state => {
250
- const templateType = getEditedPostType(state);
251
- const templateId = getEditedPostId(state);
252
- const template = templateId ? select(_coreData.store).getEntityRecord('postType', templateType, templateId) : null;
253
-
254
- if (!template) {
255
- return _constants.MENU_ROOT;
256
- }
257
-
258
- if ('wp_template_part' === templateType) {
259
- var _TEMPLATE_PARTS_SUB_M;
260
-
261
- return ((_TEMPLATE_PARTS_SUB_M = _constants.TEMPLATE_PARTS_SUB_MENUS.find(submenu => submenu.area === (template === null || template === void 0 ? void 0 : template.area))) === null || _TEMPLATE_PARTS_SUB_M === void 0 ? void 0 : _TEMPLATE_PARTS_SUB_M.menu) || _constants.MENU_TEMPLATE_PARTS;
262
- }
263
-
264
- const templates = select(_coreData.store).getEntityRecords('postType', 'wp_template');
265
- const showOnFront = select(_coreData.store).getEditedEntityRecord('root', 'site').show_on_front;
266
-
267
- if ((0, _templateHierarchy.isTemplateSuperseded)(template.slug, (0, _lodash.map)(templates, 'slug'), showOnFront)) {
268
- return _constants.MENU_TEMPLATES_UNUSED;
269
- }
270
-
271
- return (0, _templateHierarchy.getTemplateLocation)(template.slug);
272
- });
273
- /**
274
- * Returns the current opened/closed state of the navigation panel.
218
+ * Returns the current page object.
275
219
  *
220
+ * @deprecated
276
221
  * @param {Object} state Global application state.
277
222
  *
278
- * @return {boolean} True if the navigation panel should be open; false if closed.
223
+ * @return {Object} Page.
279
224
  */
280
225
 
281
- exports.getCurrentTemplateNavigationPanelSubMenu = getCurrentTemplateNavigationPanelSubMenu;
282
226
 
283
- function isNavigationOpened(state) {
284
- return state.navigationPanel.isOpen;
227
+ function getPage(state) {
228
+ return {
229
+ context: state.editedPost.context
230
+ };
285
231
  }
286
232
  /**
287
233
  * Returns the current opened/closed state of the inserter panel.
@@ -394,4 +340,49 @@ exports.getCurrentTemplateTemplateParts = getCurrentTemplateTemplateParts;
394
340
  function getEditorMode(state) {
395
341
  return __unstableGetPreference(state, 'editorMode');
396
342
  }
343
+ /**
344
+ * Returns the current canvas mode.
345
+ *
346
+ * @param {Object} state Global application state.
347
+ *
348
+ * @return {string} Canvas mode.
349
+ */
350
+
351
+
352
+ function __unstableGetCanvasMode(state) {
353
+ return state.canvasMode;
354
+ }
355
+ /**
356
+ * @deprecated
357
+ */
358
+
359
+
360
+ function getCurrentTemplateNavigationPanelSubMenu() {
361
+ (0, _deprecated.default)("dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu", {
362
+ since: '6.2',
363
+ version: '6.4'
364
+ });
365
+ }
366
+ /**
367
+ * @deprecated
368
+ */
369
+
370
+
371
+ function getNavigationPanelActiveMenu() {
372
+ (0, _deprecated.default)("dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu", {
373
+ since: '6.2',
374
+ version: '6.4'
375
+ });
376
+ }
377
+ /**
378
+ * @deprecated
379
+ */
380
+
381
+
382
+ function isNavigationOpened() {
383
+ (0, _deprecated.default)("dispatch( 'core/edit-site' ).isNavigationOpened", {
384
+ since: '6.2',
385
+ version: '6.4'
386
+ });
387
+ }
397
388
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","type","getEditedPostId","id","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","MENU_ROOT","find","submenu","area","MENU_TEMPLATE_PARTS","templates","showOnFront","getEditedEntityRecord","show_on_front","slug","MENU_TEMPLATES_UNUSED","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateParts","templatePartsById","reduce","newTemplateParts","part","blocks","filter","block","map","attributes","theme","templatePartId","templatePart","getEditorMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AA1BA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;;AAYA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAG,kCACpCC,MAAF,IAAc,CAAEC,KAAF,EAASC,IAAT,KACbF,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,gBAAhC,EAAkDF,IAAlD,CAFqC,CAAhC;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASG,eAAT,CAA0BJ,KAA1B,EAAiCK,WAAjC,EAA+C;AACrD,2BAAa,4CAAb,EAA0D;AACzDC,IAAAA,KAAK,EAAE,KADkD;AAEzDC,IAAAA,WAAW,EAAG;AAF2C,GAA1D;AAKA,SAAO,CAAC,CAAET,uBAAuB,CAAEE,KAAF,EAASK,WAAT,CAAjC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,kCAAT,CAA6CR,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACS,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAClCX,MAAF,IAAc,MAAMA,MAAM,CAAEY,eAAF,CAAN,CAAwBC,OAAxB,CAAiC,QAA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AwBM,gBAAxB,CACrB,UADqB,EAErB,kBAFqB,EAGrB;AAAEC,IAAAA,QAAQ,EAAE,CAAC;AAAb,GAHqB,CAAtB;AAKA,QAAM8D,iBAAiB,GAAGD,aAAa,GACpC;AACAA,EAAAA,aAAa,CAACE,MAAd,CACA,CAAEC,gBAAF,EAAoBC,IAApB,MAAgC,EAC/B,GAAGD,gBAD4B;AAE/B,KAAEC,IAAI,CAACvC,EAAP,GAAauC;AAFkB,GAAhC,CADA,EAKA,EALA,CAFoC,GASpC,EATH;AAWA,SAAO,qBAAE9B,QAAQ,CAAC+B,MAAX,+DAAqB,EAArB,EACLC,MADK,CACKC,KAAF,IAAa,4BAAgBA,KAAhB,CADhB,EAELC,GAFK,CAEED,KAAF,IAAa;AAClB,UAAM;AACLE,MAAAA,UAAU,EAAE;AAAEC,QAAAA,KAAF;AAASzB,QAAAA;AAAT;AADP,QAEFsB,KAFJ;AAGA,UAAMI,cAAc,GAAI,GAAGD,KAAO,KAAKzB,IAAM,EAA7C;AACA,UAAM2B,YAAY,GAAGX,iBAAiB,CAAEU,cAAF,CAAtC;AAEA,WAAO;AACNC,MAAAA,YADM;AAENL,MAAAA;AAFM,KAAP;AAIA,GAbK,EAcLD,MAdK,CAcG;AAAA,QAAE;AAAEM,MAAAA;AAAF,KAAF;AAAA,WAAwB,CAAC,CAAEA,YAA3B;AAAA,GAdH,CAAP;AAeA,CAzC6C,CAAxC;AA4CP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,aAAT,CAAwB5F,KAAxB,EAAgC;AACtC,SAAOF,uBAAuB,CAAEE,KAAF,EAAS,YAAT,CAA9B;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost;\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn getCurrentEditedPost( state ).type;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\t\tconst templatePartsById = templateParts\n\t\t\t? // Key template parts by their ID.\n\t\t\t templateParts.reduce(\n\t\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t )\n\t\t\t: {};\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","templatePartsById","reduce","newTemplateParts","part","blocks","filter","block","map","attributes","theme","slug","templatePartId","templatePart","getEditorMode","__unstableGetCanvasMode","canvasMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAG,kCACpCC,MAAF,IAAc,CAAEC,KAAF,EAASC,IAAT,KACbF,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,gBAAhC,EAAkDF,IAAlD,CAFqC,CAAhC;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASG,eAAT,CAA0BJ,KAA1B,EAAiCK,WAAjC,EAA+C;AACrD,2BAAa,4CAAb,EAA0D;AACzDC,IAAAA,KAAK,EAAE,KADkD;AAEzDC,IAAAA,WAAW,EAAG;AAF2C,GAA1D;AAKA,SAAO,CAAC,CAAET,uBAAuB,CAAEE,KAAF,EAASK,WAAT,CAAjC;AACA;AAED;AACA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SAAOF,uBAAuB,CAAEE,KAAF,EAAS,YAAT,CAA9B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS6E,uBAAT,CAAkC7E,KAAlC,EAA0C;AAChD,SAAOA,KAAK,CAAC8E,UAAb;AACA;AAED;AACA;AACA;;;AACO,SAASC,wCAAT,GAAoD;AAC1D,2BACC,uEADD,EAEC;AACCzE,IAAAA,KAAK,EAAE,KADR;AAECiC,IAAAA,OAAO,EAAE;AAFV,GAFD;AAOA;AAED;AACA;AACA;;;AACO,SAASyC,4BAAT,GAAwC;AAC9C,2BAAY,2DAAZ,EAAyE;AACxE1E,IAAAA,KAAK,EAAE,KADiE;AAExEiC,IAAAA,OAAO,EAAE;AAF+D,GAAzE;AAIA;AAED;AACA;AACA;;;AACO,SAAS0C,kBAAT,GAA8B;AACpC,2BAAY,iDAAZ,EAA+D;AAC9D3E,IAAAA,KAAK,EAAE,KADuD;AAE9DiC,IAAAA,OAAO,EAAE;AAFqD,GAA/D;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\t\tconst templatePartsById = templateParts\n\t\t\t? // Key template parts by their ID.\n\t\t\t templateParts.reduce(\n\t\t\t\t\t( newTemplateParts, part ) => ( {\n\t\t\t\t\t\t...newTemplateParts,\n\t\t\t\t\t\t[ part.id ]: part,\n\t\t\t\t\t} ),\n\t\t\t\t\t{}\n\t\t\t )\n\t\t\t: {};\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * Returns the current canvas mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Canvas mode.\n */\nexport function __unstableGetCanvasMode( state ) {\n\treturn state.canvasMode;\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n"]}
@@ -110,6 +110,7 @@ function SuggestionList(_ref2) {
110
110
  }
111
111
 
112
112
  return createElement(Fragment, null, showSearchControl && createElement(SearchControl, {
113
+ __nextHasNoMarginBottom: true,
113
114
  onChange: setSearch,
114
115
  value: search,
115
116
  label: labels.search_items,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal.js"],"names":["useState","useMemo","useEffect","__","sprintf","Button","Flex","FlexItem","Modal","SearchControl","TextHighlight","__experimentalText","Text","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useDebounce","useEntityRecords","decodeEntities","TemplateActionsLoadingScreen","mapToIHasNameAndId","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","composite","baseCssClass","config","getSpecificTemplate","name","link","useDebouncedInput","input","setInput","debounced","setter","setDebounced","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","orientation","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","search_items","map","not_found","AddCustomTemplateModal","onClose","isCreatingTemplate","showSearchEntities","setShowSearchEntities","hasGeneralTemplate","singular_name","title","description","templatePrefix","template","all_items"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,EAA4BC,SAA5B,QAA6C,oBAA7C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,MADD,EAECC,IAFD,EAGCC,QAHD,EAICC,KAJD,EAKCC,aALD,EAMCC,aAND,EAOCC,kBAAkB,IAAIC,IAPvB,EAQCC,mBAAmB,IAAIC,SARxB,EASCC,2BAA2B,IAAIC,iBAThC,EAUCC,uBAAuB,IAAIC,aAV5B,QAWO,uBAXP;AAYA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SA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CAAR;AAMA;AAhBF,KAkBC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC,MAAT;AAAgB,IAAA,MAAM,EAAG;AAAzB,KACGjD,oBAAoB,CAACkC,MAArB,CAA4BiB,SAD/B,CAlBD,EAqBC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC;AAAT,KAEE;AACA7E,EAAAA,EAAE,CAAE,eAAF,CAHJ,CArBD,CALD,EAiCC,cAAC,QAAD;AACC,IAAA,OAAO,MADR;AAEC,IAAA,EAAE,EAAGE,MAFN;AAGC,IAAA,OAAO,EAAG,MAAM;AACfoE,MAAAA,qBAAqB,CAAE,IAAF,CAArB;AACA;AALF,KAOC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC,MAAT;AAAgB,IAAA,MAAM,EAAG;AAAzB,KACG5C,oBAAoB,CAACkC,MAArB,CAA4BY,aAD/B,CAPD,EAUC,cAAC,IAAD;AAAM,IAAA,EAAE,EAAC;AAAT,KAEE;AACAxE,EAAAA,EAAE,CAAE,qBAAF,CAHJ,CAVD,CAjCD,CAND,CAZF,EAuEGqE,kBAAkB,IACnB,8BACC,yBACGrE,EAAE,CACH,+DADG,CADL,CADD,EAMC,cAAC,cAAD;AACC,IAAA,oBAAoB,EAAG0B,oBADxB;AAEC,IAAA,QAAQ,EAAGD;AAFZ,IAND,CAxEF,CADD;AAuFA;;AAED,eAAeyC,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tModal,\n\tSearchControl,\n\tTextHighlight,\n\t__experimentalText as Text,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n\tcomposite,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<CompositeItem\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName={ baseCssClass }\n\t\t\tonClick={ () =>\n\t\t\t\tonSelect(\n\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\tsuggestion\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<span className={ `${ baseCssClass }__title` }>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<span className={ `${ baseCssClass }__info` }>\n\t\t\t\t\t{ suggestion.link }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</CompositeItem>\n\t);\n}\n\nfunction useDebouncedInput() {\n\tconst [ input, setInput ] = useState( '' );\n\tconst [ debounced, setter ] = useState( '' );\n\tconst setDebounced = useDebounce( setter, 250 );\n\tuseEffect( () => {\n\t\tif ( debounced !== input ) {\n\t\t\tsetDebounced( input );\n\t\t}\n\t}, [ debounced, input ] );\n\treturn [ input, setInput, debounced ];\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<p className=\"edit-site-custom-template-modal__no-results\">\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModal( {\n\tonClose,\n\tonSelect,\n\tentityForSuggestions,\n\tisCreatingTemplate,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState(\n\t\tentityForSuggestions.hasGeneralTemplate\n\t);\n\tconst baseCssClass = 'edit-site-custom-template-modal';\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t__( 'Add template: %s' ),\n\t\t\t\tentityForSuggestions.labels.singular_name\n\t\t\t) }\n\t\t\tclassName={ baseCssClass }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName={ `${ baseCssClass }__contents` }\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n\nexport default AddCustomTemplateModal;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/add-custom-template-modal.js"],"names":["useState","useMemo","useEffect","__","sprintf","Button","Flex","FlexItem","Modal","SearchControl","TextHighlight","__experimentalText","Text","__unstableComposite","Composite","__unstableUseCompositeState","useCompositeState","__unstableCompositeItem","CompositeItem","useDebounce","useEntityRecords","decodeEntities","TemplateActionsLoadingScreen","mapToIHasNameAndId","EMPTY_ARRAY","SuggestionListItem","suggestion","search","onSelect","entityForSuggestions","composite","baseCssClass","config","getSpecificTemplate","name","link","useDebouncedInput","input","setInput","debounced","setter","setDebounced","useSearchSuggestions","query","order","context","per_page","queryArgs","records","searchResults","hasResolved","searchHasResolved","type","slug","suggestions","setSuggestions","newSuggestions","length","recordNamePath","SuggestionList","orientation","setSearch","debouncedSearch","labels","showSearchControl","setShowSearchControl","search_items","map","not_found","AddCustomTemplateModal","onClose","isCreatingTemplate","showSearchEntities","setShowSearchEntities","hasGeneralTemplate","singular_name","title","description","templatePrefix","template","all_items"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,EAA4BC,SAA5B,QAA6C,oBAA7C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ADD,EAMC,cAAC,cAAD;AACC,IAAA,oBAAoB,EAAG0B,oBADxB;AAEC,IAAA,QAAQ,EAAGD;AAFZ,IAND,CAxEF,CADD;AAuFA;;AAED,eAAeyC,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tFlex,\n\tFlexItem,\n\tModal,\n\tSearchControl,\n\tTextHighlight,\n\t__experimentalText as Text,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useDebounce } from '@wordpress/compose';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { mapToIHasNameAndId } from './utils';\n\nconst EMPTY_ARRAY = [];\n\nfunction SuggestionListItem( {\n\tsuggestion,\n\tsearch,\n\tonSelect,\n\tentityForSuggestions,\n\tcomposite,\n} ) {\n\tconst baseCssClass =\n\t\t'edit-site-custom-template-modal__suggestions_list__list-item';\n\treturn (\n\t\t<CompositeItem\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName={ baseCssClass }\n\t\t\tonClick={ () =>\n\t\t\t\tonSelect(\n\t\t\t\t\tentityForSuggestions.config.getSpecificTemplate(\n\t\t\t\t\t\tsuggestion\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<span className={ `${ baseCssClass }__title` }>\n\t\t\t\t<TextHighlight\n\t\t\t\t\ttext={ decodeEntities( suggestion.name ) }\n\t\t\t\t\thighlight={ search }\n\t\t\t\t/>\n\t\t\t</span>\n\t\t\t{ suggestion.link && (\n\t\t\t\t<span className={ `${ baseCssClass }__info` }>\n\t\t\t\t\t{ suggestion.link }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</CompositeItem>\n\t);\n}\n\nfunction useDebouncedInput() {\n\tconst [ input, setInput ] = useState( '' );\n\tconst [ debounced, setter ] = useState( '' );\n\tconst setDebounced = useDebounce( setter, 250 );\n\tuseEffect( () => {\n\t\tif ( debounced !== input ) {\n\t\t\tsetDebounced( input );\n\t\t}\n\t}, [ debounced, input ] );\n\treturn [ input, setInput, debounced ];\n}\n\nfunction useSearchSuggestions( entityForSuggestions, search ) {\n\tconst { config } = entityForSuggestions;\n\tconst query = useMemo(\n\t\t() => ( {\n\t\t\torder: 'asc',\n\t\t\tcontext: 'view',\n\t\t\tsearch,\n\t\t\tper_page: search ? 20 : 10,\n\t\t\t...config.queryArgs( search ),\n\t\t} ),\n\t\t[ search, config ]\n\t);\n\tconst { records: searchResults, hasResolved: searchHasResolved } =\n\t\tuseEntityRecords(\n\t\t\tentityForSuggestions.type,\n\t\t\tentityForSuggestions.slug,\n\t\t\tquery\n\t\t);\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tlet newSuggestions = EMPTY_ARRAY;\n\t\tif ( searchResults?.length ) {\n\t\t\tnewSuggestions = searchResults;\n\t\t\tif ( config.recordNamePath ) {\n\t\t\t\tnewSuggestions = mapToIHasNameAndId(\n\t\t\t\t\tnewSuggestions,\n\t\t\t\t\tconfig.recordNamePath\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// Update suggestions only when the query has resolved, so as to keep\n\t\t// the previous results in the UI.\n\t\tsetSuggestions( newSuggestions );\n\t}, [ searchResults, searchHasResolved ] );\n\treturn suggestions;\n}\n\nfunction SuggestionList( { entityForSuggestions, onSelect } ) {\n\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst suggestions = useSearchSuggestions(\n\t\tentityForSuggestions,\n\t\tdebouncedSearch\n\t);\n\tconst { labels } = entityForSuggestions;\n\tconst [ showSearchControl, setShowSearchControl ] = useState( false );\n\tif ( ! showSearchControl && suggestions?.length > 9 ) {\n\t\tsetShowSearchControl( true );\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ showSearchControl && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tonChange={ setSearch }\n\t\t\t\t\tvalue={ search }\n\t\t\t\t\tlabel={ labels.search_items }\n\t\t\t\t\tplaceholder={ labels.search_items }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! suggestions?.length && (\n\t\t\t\t<Composite\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"edit-site-custom-template-modal__suggestions_list\"\n\t\t\t\t\taria-label={ __( 'Suggestions list' ) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion ) => (\n\t\t\t\t\t\t<SuggestionListItem\n\t\t\t\t\t\t\tkey={ suggestion.slug }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tsearch={ debouncedSearch }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</Composite>\n\t\t\t) }\n\t\t\t{ debouncedSearch && ! suggestions?.length && (\n\t\t\t\t<p className=\"edit-site-custom-template-modal__no-results\">\n\t\t\t\t\t{ labels.not_found }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction AddCustomTemplateModal( {\n\tonClose,\n\tonSelect,\n\tentityForSuggestions,\n\tisCreatingTemplate,\n} ) {\n\tconst [ showSearchEntities, setShowSearchEntities ] = useState(\n\t\tentityForSuggestions.hasGeneralTemplate\n\t);\n\tconst baseCssClass = 'edit-site-custom-template-modal';\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %s: Name of the post type e.g: \"Post\".\n\t\t\t\t__( 'Add template: %s' ),\n\t\t\t\tentityForSuggestions.labels.singular_name\n\t\t\t) }\n\t\t\tclassName={ baseCssClass }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t{ isCreatingTemplate && <TemplateActionsLoadingScreen /> }\n\t\t\t{ ! showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select whether to create a single template for all items or a specific one.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Flex\n\t\t\t\t\t\tclassName={ `${ baseCssClass }__contents` }\n\t\t\t\t\t\tgap=\"4\"\n\t\t\t\t\t\talign=\"initial\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} = entityForSuggestions.template;\n\t\t\t\t\t\t\t\tonSelect( {\n\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\ttemplatePrefix,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.all_items }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For all items' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowSearchEntities( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text as=\"span\" weight={ 600 }>\n\t\t\t\t\t\t\t\t{ entityForSuggestions.labels.singular_name }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<Text as=\"span\">\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.\n\t\t\t\t\t\t\t\t\t__( 'For a specific item' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showSearchEntities && (\n\t\t\t\t<>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This template will be used only for the specific item chosen.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<SuggestionList\n\t\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Modal>\n\t);\n}\n\nexport default AddCustomTemplateModal;\n"]}