@wordpress/edit-site 5.10.0 → 5.11.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 (252) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
  3. package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  4. package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +11 -21
  5. package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  6. package/build/components/add-new-template/new-template.js +98 -65
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/block-editor/index.js +1 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/create-template-part-modal/index.js +6 -7
  11. package/build/components/create-template-part-modal/index.js.map +1 -1
  12. package/build/components/editor/index.js +15 -40
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/editor-canvas-container/index.js +10 -3
  15. package/build/components/editor-canvas-container/index.js.map +1 -1
  16. package/build/components/global-styles/screen-block.js +80 -3
  17. package/build/components/global-styles/screen-block.js.map +1 -1
  18. package/build/components/global-styles/screen-revisions/index.js +3 -10
  19. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  20. package/build/components/global-styles/screen-revisions/revisions-buttons.js +16 -18
  21. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  22. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  23. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  24. package/build/components/global-styles/screen-root.js +4 -4
  25. package/build/components/global-styles/screen-root.js.map +1 -1
  26. package/build/components/global-styles/style-variations-container.js +6 -10
  27. package/build/components/global-styles/style-variations-container.js.map +1 -1
  28. package/build/components/global-styles/ui.js +9 -9
  29. package/build/components/global-styles/ui.js.map +1 -1
  30. package/build/components/header-edit-mode/document-actions/index.js +28 -103
  31. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  32. package/build/components/header-edit-mode/index.js +14 -1
  33. package/build/components/header-edit-mode/index.js.map +1 -1
  34. package/build/components/layout/hooks.js +54 -0
  35. package/build/components/layout/hooks.js.map +1 -0
  36. package/build/components/layout/index.js +45 -98
  37. package/build/components/layout/index.js.map +1 -1
  38. package/build/components/list/actions/index.js +5 -2
  39. package/build/components/list/actions/index.js.map +1 -1
  40. package/build/components/resizable-frame/index.js +242 -0
  41. package/build/components/resizable-frame/index.js.map +1 -0
  42. package/build/components/revisions/index.js +2 -1
  43. package/build/components/revisions/index.js.map +1 -1
  44. package/build/components/secondary-sidebar/list-view-sidebar.js +4 -3
  45. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  46. package/build/components/sidebar/index.js +4 -4
  47. package/build/components/sidebar/index.js.map +1 -1
  48. package/build/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  49. package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  50. package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
  51. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  52. package/build/components/sidebar-navigation-screen-main/index.js +24 -33
  53. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
  55. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  56. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
  57. package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  58. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +53 -103
  59. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
  61. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  62. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
  63. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  64. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
  65. package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  66. package/build/components/sidebar-navigation-screen-templates/index.js +36 -11
  67. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  68. package/build/components/site-hub/index.js +1 -3
  69. package/build/components/site-hub/index.js.map +1 -1
  70. package/build/components/style-book/index.js +93 -19
  71. package/build/components/style-book/index.js.map +1 -1
  72. package/build/components/use-edited-entity-record/index.js +8 -4
  73. package/build/components/use-edited-entity-record/index.js.map +1 -1
  74. package/build/hooks/commands/use-edit-mode-commands.js +105 -0
  75. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
  76. package/build/store/actions.js +5 -3
  77. package/build/store/actions.js.map +1 -1
  78. package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
  79. package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
  80. package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -22
  81. package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
  82. package/build-module/components/add-new-template/new-template.js +98 -67
  83. package/build-module/components/add-new-template/new-template.js.map +1 -1
  84. package/build-module/components/block-editor/index.js +1 -3
  85. package/build-module/components/block-editor/index.js.map +1 -1
  86. package/build-module/components/create-template-part-modal/index.js +7 -8
  87. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  88. package/build-module/components/editor/index.js +16 -43
  89. package/build-module/components/editor/index.js.map +1 -1
  90. package/build-module/components/editor-canvas-container/index.js +7 -3
  91. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  92. package/build-module/components/global-styles/screen-block.js +82 -4
  93. package/build-module/components/global-styles/screen-block.js.map +1 -1
  94. package/build-module/components/global-styles/screen-revisions/index.js +3 -10
  95. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  96. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +16 -19
  97. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  98. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -24
  99. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  100. package/build-module/components/global-styles/screen-root.js +4 -4
  101. package/build-module/components/global-styles/screen-root.js.map +1 -1
  102. package/build-module/components/global-styles/style-variations-container.js +7 -11
  103. package/build-module/components/global-styles/style-variations-container.js.map +1 -1
  104. package/build-module/components/global-styles/ui.js +10 -10
  105. package/build-module/components/global-styles/ui.js.map +1 -1
  106. package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
  107. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  108. package/build-module/components/header-edit-mode/index.js +14 -2
  109. package/build-module/components/header-edit-mode/index.js.map +1 -1
  110. package/build-module/components/layout/hooks.js +41 -0
  111. package/build-module/components/layout/hooks.js.map +1 -0
  112. package/build-module/components/layout/index.js +46 -101
  113. package/build-module/components/layout/index.js.map +1 -1
  114. package/build-module/components/list/actions/index.js +6 -3
  115. package/build-module/components/list/actions/index.js.map +1 -1
  116. package/build-module/components/resizable-frame/index.js +228 -0
  117. package/build-module/components/resizable-frame/index.js.map +1 -0
  118. package/build-module/components/revisions/index.js +2 -1
  119. package/build-module/components/revisions/index.js.map +1 -1
  120. package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
  121. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  122. package/build-module/components/sidebar/index.js +3 -3
  123. package/build-module/components/sidebar/index.js.map +1 -1
  124. package/build-module/components/sidebar-edit-mode/template-revisions/index.js +1 -1
  125. package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -1
  126. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
  127. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  128. package/build-module/components/sidebar-navigation-screen-main/index.js +21 -32
  129. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  130. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
  131. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
  132. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
  133. package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
  134. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -103
  135. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  136. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
  137. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
  138. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +12 -71
  139. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  140. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
  141. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
  142. package/build-module/components/sidebar-navigation-screen-templates/index.js +35 -11
  143. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  144. package/build-module/components/site-hub/index.js +1 -3
  145. package/build-module/components/site-hub/index.js.map +1 -1
  146. package/build-module/components/style-book/index.js +93 -20
  147. package/build-module/components/style-book/index.js.map +1 -1
  148. package/build-module/components/use-edited-entity-record/index.js +8 -4
  149. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  150. package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
  151. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
  152. package/build-module/store/actions.js +5 -3
  153. package/build-module/store/actions.js.map +1 -1
  154. package/build-style/style-rtl.css +233 -210
  155. package/build-style/style.css +234 -210
  156. package/package.json +37 -37
  157. package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
  158. package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +13 -26
  159. package/src/components/add-new-template/new-template.js +139 -153
  160. package/src/components/add-new-template/style.scss +79 -66
  161. package/src/components/block-editor/index.js +2 -3
  162. package/src/components/create-template-part-modal/index.js +19 -25
  163. package/src/components/editor/index.js +16 -45
  164. package/src/components/editor/style.scss +21 -6
  165. package/src/components/editor-canvas-container/index.js +28 -19
  166. package/src/components/global-styles/screen-block.js +74 -3
  167. package/src/components/global-styles/screen-revisions/index.js +3 -11
  168. package/src/components/global-styles/screen-revisions/revisions-buttons.js +33 -25
  169. package/src/components/global-styles/screen-revisions/style.scss +3 -2
  170. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +16 -3
  171. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +15 -19
  172. package/src/components/global-styles/screen-root.js +5 -3
  173. package/src/components/global-styles/style-variations-container.js +13 -18
  174. package/src/components/global-styles/style.scss +3 -0
  175. package/src/components/global-styles/ui.js +11 -9
  176. package/src/components/header-edit-mode/document-actions/index.js +26 -129
  177. package/src/components/header-edit-mode/document-actions/style.scss +28 -59
  178. package/src/components/header-edit-mode/index.js +18 -0
  179. package/src/components/header-edit-mode/style.scss +1 -0
  180. package/src/components/layout/hooks.js +46 -0
  181. package/src/components/layout/index.js +56 -125
  182. package/src/components/layout/style.scss +8 -2
  183. package/src/components/list/actions/index.js +12 -5
  184. package/src/components/list/style.scss +1 -0
  185. package/src/components/resizable-frame/index.js +253 -0
  186. package/src/components/resizable-frame/style.scss +69 -0
  187. package/src/components/revisions/index.js +1 -0
  188. package/src/components/secondary-sidebar/list-view-sidebar.js +2 -1
  189. package/src/components/sidebar/index.js +4 -4
  190. package/src/components/sidebar-edit-mode/template-revisions/index.js +1 -2
  191. package/src/components/sidebar-navigation-item/style.scss +9 -0
  192. package/src/components/sidebar-navigation-screen/style.scss +1 -2
  193. package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
  194. package/src/components/sidebar-navigation-screen-main/index.js +35 -52
  195. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
  196. package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
  197. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -117
  198. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
  199. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +6 -72
  200. package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
  201. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
  202. package/src/components/sidebar-navigation-screen-templates/index.js +53 -14
  203. package/src/components/site-hub/index.js +8 -9
  204. package/src/components/start-template-options/style.scss +20 -21
  205. package/src/components/style-book/index.js +132 -43
  206. package/src/components/style-book/style.scss +19 -0
  207. package/src/components/use-edited-entity-record/index.js +12 -3
  208. package/src/hooks/commands/use-edit-mode-commands.js +79 -0
  209. package/src/store/actions.js +4 -5
  210. package/src/store/test/utils.js +15 -5
  211. package/src/style.scss +1 -1
  212. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  213. package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
  214. package/build/components/global-styles/border-panel.js +0 -135
  215. package/build/components/global-styles/border-panel.js.map +0 -1
  216. package/build/components/navigate-to-link/index.js +0 -51
  217. package/build/components/navigate-to-link/index.js.map +0 -1
  218. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
  219. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  220. package/build/components/template-details/edit-template-title.js +0 -42
  221. package/build/components/template-details/edit-template-title.js.map +0 -1
  222. package/build/components/template-details/index.js +0 -103
  223. package/build/components/template-details/index.js.map +0 -1
  224. package/build/components/template-details/template-areas.js +0 -166
  225. package/build/components/template-details/template-areas.js.map +0 -1
  226. package/build/components/template-details/template-part-area-selector.js +0 -48
  227. package/build/components/template-details/template-part-area-selector.js.map +0 -1
  228. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
  229. package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
  230. package/build-module/components/global-styles/border-panel.js +0 -125
  231. package/build-module/components/global-styles/border-panel.js.map +0 -1
  232. package/build-module/components/navigate-to-link/index.js +0 -39
  233. package/build-module/components/navigate-to-link/index.js.map +0 -1
  234. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
  235. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
  236. package/build-module/components/template-details/edit-template-title.js +0 -33
  237. package/build-module/components/template-details/edit-template-title.js.map +0 -1
  238. package/build-module/components/template-details/index.js +0 -83
  239. package/build-module/components/template-details/index.js.map +0 -1
  240. package/build-module/components/template-details/template-areas.js +0 -145
  241. package/build-module/components/template-details/template-areas.js.map +0 -1
  242. package/build-module/components/template-details/template-part-area-selector.js +0 -36
  243. package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
  244. package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
  245. package/src/components/global-styles/border-panel.js +0 -114
  246. package/src/components/navigate-to-link/index.js +0 -46
  247. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
  248. package/src/components/template-details/edit-template-title.js +0 -41
  249. package/src/components/template-details/index.js +0 -113
  250. package/src/components/template-details/style.scss +0 -72
  251. package/src/components/template-details/template-areas.js +0 -167
  252. package/src/components/template-details/template-part-area-selector.js +0 -39
@@ -5,33 +5,30 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.SidebarNavigationScreenWrapper = SidebarNavigationScreenWrapper;
8
9
  exports.default = SidebarNavigationScreenNavigationMenus;
9
10
 
10
11
  var _element = require("@wordpress/element");
11
12
 
12
- var _i18n = require("@wordpress/i18n");
13
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14
 
14
- var _data = require("@wordpress/data");
15
+ var _i18n = require("@wordpress/i18n");
15
16
 
16
17
  var _coreData = require("@wordpress/core-data");
17
18
 
18
- var _blockEditor = require("@wordpress/block-editor");
19
+ var _htmlEntities = require("@wordpress/html-entities");
19
20
 
20
- var _blocks = require("@wordpress/blocks");
21
+ var _components = require("@wordpress/components");
21
22
 
22
- var _router = require("@wordpress/router");
23
+ var _icons = require("@wordpress/icons");
23
24
 
24
25
  var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
25
26
 
26
- var _navigationMenuContent = _interopRequireDefault(require("./navigation-menu-content"));
27
-
28
- var _loader = require("./loader");
29
-
30
- var _privateApis = require("../../private-apis");
27
+ var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
31
28
 
32
- var _store = require("../../store");
29
+ var _constants = require("./constants");
33
30
 
34
- var _isPreviewingTheme = require("../../utils/is-previewing-theme");
31
+ var _link = require("../routes/link");
35
32
 
36
33
  /**
37
34
  * WordPress dependencies
@@ -40,108 +37,61 @@ var _isPreviewingTheme = require("../../utils/is-previewing-theme");
40
37
  /**
41
38
  * Internal dependencies
42
39
  */
43
- const {
44
- useHistory
45
- } = (0, _privateApis.unlock)(_router.privateApis);
40
+ function SidebarNavigationScreenNavigationMenus() {
41
+ const {
42
+ records: navigationMenus,
43
+ isResolving: isLoading
44
+ } = (0, _coreData.useEntityRecords)('postType', `wp_navigation`, _constants.PRELOADED_NAVIGATION_MENUS_QUERY);
45
+ const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
46
46
 
47
- const noop = () => {};
47
+ if (isLoading) {
48
+ return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _element.createElement)(_components.Spinner, {
49
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__loading"
50
+ }));
51
+ }
48
52
 
49
- const NAVIGATION_MENUS_QUERY = {
50
- per_page: 1,
51
- status: 'publish',
52
- order: 'desc',
53
- orderby: 'date'
54
- };
53
+ if (!isLoading && !hasNavigationMenus) {
54
+ return (0, _element.createElement)(SidebarNavigationScreenWrapper, {
55
+ description: (0, _i18n.__)('No Navigation Menus found.')
56
+ });
57
+ }
58
+
59
+ return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _element.createElement)(_components.__experimentalItemGroup, null, navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.map(navMenu => {
60
+ var _navMenu$title;
61
+
62
+ return (0, _element.createElement)(NavMenuItem, {
63
+ postId: navMenu.id,
64
+ key: navMenu.id,
65
+ withChevron: true,
66
+ icon: _icons.navigation
67
+ }, (0, _htmlEntities.decodeEntities)(((_navMenu$title = navMenu.title) === null || _navMenu$title === void 0 ? void 0 : _navMenu$title.rendered) || navMenu.slug));
68
+ })));
69
+ }
55
70
 
56
71
  function SidebarNavigationScreenWrapper(_ref) {
57
72
  let {
58
73
  children,
59
- actions
74
+ actions,
75
+ title,
76
+ description
60
77
  } = _ref;
61
78
  return (0, _element.createElement)(_sidebarNavigationScreen.default, {
62
- title: (0, _i18n.__)('Navigation'),
79
+ title: title || (0, _i18n.__)('Navigation'),
63
80
  actions: actions,
64
- description: (0, _i18n.__)('Browse your site, edit pages, and manage your primary navigation menu.'),
81
+ description: description || (0, _i18n.__)('Manage your Navigation menus.'),
65
82
  content: children
66
83
  });
67
84
  }
68
85
 
69
- function SidebarNavigationScreenNavigationMenus() {
70
- var _navigationMenus$;
71
-
72
- const history = useHistory();
73
- const {
74
- navigationMenus,
75
- hasResolvedNavigationMenus,
76
- storedSettings
77
- } = (0, _data.useSelect)(select => {
78
- const {
79
- getSettings
80
- } = (0, _privateApis.unlock)(select(_store.store));
81
- const {
82
- getEntityRecords,
83
- hasFinishedResolution
84
- } = select(_coreData.store);
85
- const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY];
86
- return {
87
- storedSettings: getSettings(false),
88
- navigationMenus: getEntityRecords(...navigationMenusQuery),
89
- hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
90
- };
91
- }, []);
92
- const firstNavigationMenu = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id;
93
- const blocks = (0, _element.useMemo)(() => {
94
- return [(0, _blocks.createBlock)('core/navigation', {
95
- ref: firstNavigationMenu
96
- })];
97
- }, [firstNavigationMenu]);
98
- const isLoading = !hasResolvedNavigationMenus;
99
- const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
100
- const onSelect = (0, _element.useCallback)(selectedBlock => {
101
- const {
102
- attributes,
103
- name
104
- } = selectedBlock;
105
-
106
- if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) {
107
- history.push({
108
- postType: attributes.type,
109
- postId: attributes.id,
110
- ...((0, _isPreviewingTheme.isPreviewingTheme)() && {
111
- theme_preview: (0, _isPreviewingTheme.currentlyPreviewingTheme)()
112
- })
113
- });
114
- }
115
-
116
- if (name === 'core/page-list-item' && attributes.id && history) {
117
- history.push({
118
- postType: 'page',
119
- postId: attributes.id,
120
- ...((0, _isPreviewingTheme.isPreviewingTheme)() && {
121
- theme_preview: (0, _isPreviewingTheme.currentlyPreviewingTheme)()
122
- })
123
- });
124
- }
125
- }, [history]);
126
-
127
- if (hasResolvedNavigationMenus && !hasNavigationMenus) {
128
- return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _i18n.__)('There are no Navigation Menus.'));
129
- }
130
-
131
- if (!hasResolvedNavigationMenus || isLoading) {
132
- return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _element.createElement)(_loader.NavigationMenuLoader, null));
133
- }
134
-
135
- return (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
136
- settings: storedSettings,
137
- value: blocks,
138
- onChange: noop,
139
- onInput: noop
140
- }, (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _element.createElement)("div", {
141
- className: "edit-site-sidebar-navigation-screen-navigation-menus__content"
142
- }, (0, _element.createElement)(_navigationMenuContent.default, {
143
- rootClientId: blocks[0].clientId,
144
- onSelect: onSelect
145
- }))));
146
- }
86
+ const NavMenuItem = _ref2 => {
87
+ let {
88
+ postId,
89
+ ...props
90
+ } = _ref2;
91
+ const linkInfo = (0, _link.useLink)({
92
+ postId,
93
+ postType: 'wp_navigation'
94
+ });
95
+ return (0, _element.createElement)(_sidebarNavigationItem.default, (0, _extends2.default)({}, linkInfo, props));
96
+ };
147
97
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["useHistory","routerPrivateApis","noop","NAVIGATION_MENUS_QUERY","per_page","status","order","orderby","SidebarNavigationScreenWrapper","children","actions","SidebarNavigationScreenNavigationMenus","history","navigationMenus","hasResolvedNavigationMenus","storedSettings","select","getSettings","editSiteStore","getEntityRecords","hasFinishedResolution","coreStore","navigationMenusQuery","firstNavigationMenu","id","blocks","ref","isLoading","hasNavigationMenus","length","onSelect","selectedBlock","attributes","name","kind","type","push","postType","postId","theme_preview","clientId"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AASA;AACA;AACA;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,yBAAQC,mBAAR,CAAvB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,sBAAsB,GAAG;AAC9BC,EAAAA,QAAQ,EAAE,CADoB;AAE9BC,EAAAA,MAAM,EAAE,SAFsB;AAG9BC,EAAAA,KAAK,EAAE,MAHuB;AAI9BC,EAAAA,OAAO,EAAE;AAJqB,CAA/B;;AAOA,SAASC,8BAAT,OAAiE;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAChE,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAA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CAAE,CAAF,CAAN,CAAYe,QAD5B;AAEC,IAAA,QAAQ,EAAGV;AAFZ,IADD,CADD,CAND,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { BlockEditorProvider } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport NavigationMenuContent from './navigation-menu-content';\nimport { NavigationMenuLoader } from './loader';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from '../../utils/is-previewing-theme';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nconst noop = () => {};\nconst NAVIGATION_MENUS_QUERY = {\n\tper_page: 1,\n\tstatus: 'publish',\n\torder: 'desc',\n\torderby: 'date',\n};\n\nfunction SidebarNavigationScreenWrapper( { children, actions } ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Navigation' ) }\n\t\t\tactions={ actions }\n\t\t\tdescription={ __(\n\t\t\t\t'Browse your site, edit pages, and manage your primary navigation menu.'\n\t\t\t) }\n\t\t\tcontent={ children }\n\t\t/>\n\t);\n}\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst history = useHistory();\n\tconst { navigationMenus, hasResolvedNavigationMenus, storedSettings } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst navigationMenusQuery = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tNAVIGATION_MENUS_QUERY,\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( false ),\n\t\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tnavigationMenusQuery\n\t\t\t\t),\n\t\t\t};\n\t\t}, [] );\n\n\tconst firstNavigationMenu = navigationMenus?.[ 0 ]?.id;\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock( 'core/navigation', { ref: firstNavigationMenu } ),\n\t\t];\n\t}, [ firstNavigationMenu ] );\n\n\tconst isLoading = ! hasResolvedNavigationMenus;\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\ttheme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\ttheme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\tif ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\tif ( ! hasResolvedNavigationMenus || isLoading ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t<NavigationMenuLoader />\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\treturn (\n\t\t<BlockEditorProvider\n\t\t\tsettings={ storedSettings }\n\t\t\tvalue={ blocks }\n\t\t\tonChange={ noop }\n\t\t\tonInput={ noop }\n\t\t>\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus__content\">\n\t\t\t\t\t<NavigationMenuContent\n\t\t\t\t\t\trootClientId={ blocks[ 0 ].clientId }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t</BlockEditorProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["SidebarNavigationScreenNavigationMenus","records","navigationMenus","isResolving","isLoading","PRELOADED_NAVIGATION_MENUS_QUERY","hasNavigationMenus","length","map","navMenu","id","navigation","title","rendered","slug","SidebarNavigationScreenWrapper","children","actions","description","NavMenuItem","postId","props","linkInfo","postType"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AAEA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAWA;AACA;AACA;AAMe,SAASA,sCAAT,GAAkD;AAChE,QAAM;AAAEC,IAAAA,OAAO,EAAEC,eAAX;AAA4BC,IAAAA,WAAW,EAAEC;AAAzC,MACL,gCACC,UADD,EAEE,eAFF,EAGCC,2CAHD,CADD;AAOA,QAAMC,kBAAkB,GAAG,CAAC,EAAEJ,eAAF,aAAEA,eAAF,eAAEA,eAAe,CAAEK,MAAnB,CAA5B;;AAEA,MAAKH,SAAL,EAAiB;AAChB,WACC,4BAAC,8BAAD,QACC,4BAAC,mBA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WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecords } from '@wordpress/core-data';\n\nimport { decodeEntities } from '@wordpress/html-entities';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\tSpinner,\n} from '@wordpress/components';\nimport { navigation } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport { PRELOADED_NAVIGATION_MENUS_QUERY } from './constants';\nimport { useLink } from '../routes/link';\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst { records: navigationMenus, isResolving: isLoading } =\n\t\tuseEntityRecords(\n\t\t\t'postType',\n\t\t\t`wp_navigation`,\n\t\t\tPRELOADED_NAVIGATION_MENUS_QUERY\n\t\t);\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper>\n\t\t\t\t<Spinner className=\"edit-site-sidebar-navigation-screen-navigation-menus__loading\" />\n\t\t\t</SidebarNavigationScreenWrapper>\n\t\t);\n\t}\n\n\tif ( ! isLoading && ! hasNavigationMenus ) {\n\t\treturn (\n\t\t\t<SidebarNavigationScreenWrapper\n\t\t\t\tdescription={ __( 'No Navigation Menus found.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<SidebarNavigationScreenWrapper>\n\t\t\t<ItemGroup>\n\t\t\t\t{ navigationMenus?.map( ( navMenu ) => (\n\t\t\t\t\t<NavMenuItem\n\t\t\t\t\t\tpostId={ navMenu.id }\n\t\t\t\t\t\tkey={ navMenu.id }\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\tnavMenu.title?.rendered || navMenu.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t</NavMenuItem>\n\t\t\t\t) ) }\n\t\t\t</ItemGroup>\n\t\t</SidebarNavigationScreenWrapper>\n\t);\n}\n\nexport function SidebarNavigationScreenWrapper( {\n\tchildren,\n\tactions,\n\ttitle,\n\tdescription,\n} ) {\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ title || __( 'Navigation' ) }\n\t\t\tactions={ actions }\n\t\t\tdescription={ description || __( 'Manage your Navigation menus.' ) }\n\t\t\tcontent={ children }\n\t\t/>\n\t);\n}\n\nconst NavMenuItem = ( { postId, ...props } ) => {\n\tconst linkInfo = useLink( {\n\t\tpostId,\n\t\tpostType: 'wp_navigation',\n\t} );\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n"]}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = LeafMoreMenu;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _icons = require("@wordpress/icons");
15
+
16
+ var _components = require("@wordpress/components");
17
+
18
+ var _data = require("@wordpress/data");
19
+
20
+ var _i18n = require("@wordpress/i18n");
21
+
22
+ var _blockEditor = require("@wordpress/block-editor");
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+ const POPOVER_PROPS = {
28
+ className: 'block-editor-block-settings-menu__popover',
29
+ position: 'bottom right',
30
+ variant: 'toolbar'
31
+ };
32
+
33
+ function LeafMoreMenu(props) {
34
+ const {
35
+ block
36
+ } = props;
37
+ const {
38
+ clientId
39
+ } = block;
40
+ const {
41
+ moveBlocksDown,
42
+ moveBlocksUp,
43
+ removeBlocks
44
+ } = (0, _data.useDispatch)(_blockEditor.store);
45
+ const removeLabel = (0, _i18n.sprintf)(
46
+ /* translators: %s: block name */
47
+ (0, _i18n.__)('Remove %s'), (0, _blockEditor.BlockTitle)({
48
+ clientId,
49
+ maximumLength: 25
50
+ }));
51
+ const rootClientId = (0, _data.useSelect)(select => {
52
+ const {
53
+ getBlockRootClientId
54
+ } = select(_blockEditor.store);
55
+ return getBlockRootClientId(clientId);
56
+ }, [clientId]);
57
+ return (0, _element.createElement)(_components.DropdownMenu, (0, _extends2.default)({
58
+ icon: _icons.moreVertical,
59
+ label: (0, _i18n.__)('Options'),
60
+ className: "block-editor-block-settings-menu",
61
+ popoverProps: POPOVER_PROPS,
62
+ noIcons: true
63
+ }, props), _ref => {
64
+ let {
65
+ onClose
66
+ } = _ref;
67
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
68
+ icon: _icons.chevronUp,
69
+ onClick: () => {
70
+ moveBlocksUp([clientId], rootClientId);
71
+ onClose();
72
+ }
73
+ }, (0, _i18n.__)('Move up')), (0, _element.createElement)(_components.MenuItem, {
74
+ icon: _icons.chevronDown,
75
+ onClick: () => {
76
+ moveBlocksDown([clientId], rootClientId);
77
+ onClose();
78
+ }
79
+ }, (0, _i18n.__)('Move down'))), (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
80
+ onClick: () => {
81
+ removeBlocks([clientId], false);
82
+ onClose();
83
+ }
84
+ }, removeLabel)));
85
+ });
86
+ }
87
+ //# sourceMappingURL=leaf-more-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js"],"names":["POPOVER_PROPS","className","position","variant","LeafMoreMenu","props","block","clientId","moveBlocksDown","moveBlocksUp","removeBlocks","blockEditorStore","removeLabel","maximumLength","rootClientId","select","getBlockRootClientId","moreVertical","onClose","chevronUp","chevronDown"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AAQA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,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AE,CAAED,QAAF,CAAF,EAAgBO,YAAhB,CAAd;AACAI,QAAAA,OAAO;AACP;AALF,OAOG,cAAI,WAAJ,CAPH,CAVD,CADD,EAqBC,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfR,QAAAA,YAAY,CAAE,CAAEH,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAW,QAAAA,OAAO;AACP;AAJF,OAMGN,WANH,CADD,CArBD,CADC;AAAA,GARH,CADD;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { chevronUp, chevronDown, moreVertical } from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { BlockTitle, store as blockEditorStore } from '@wordpress/block-editor';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nexport default function LeafMoreMenu( props ) {\n\tconst { block } = props;\n\tconst { clientId } = block;\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -15,13 +17,11 @@ var _blocks = require("@wordpress/blocks");
15
17
 
16
18
  var _components = require("@wordpress/components");
17
19
 
18
- var _dom = require("@wordpress/dom");
19
-
20
20
  var _coreData = require("@wordpress/core-data");
21
21
 
22
22
  var _privateApis = require("../../private-apis");
23
23
 
24
- var _loader = require("./loader");
24
+ var _leafMoreMenu = _interopRequireDefault(require("./leaf-more-menu"));
25
25
 
26
26
  /**
27
27
  * WordPress dependencies
@@ -30,45 +30,7 @@ var _loader = require("./loader");
30
30
  /**
31
31
  * Internal dependencies
32
32
  */
33
- function CustomLinkAdditionalBlockUI(_ref) {
34
- let {
35
- block,
36
- onClose
37
- } = _ref;
38
- const {
39
- updateBlockAttributes
40
- } = (0, _data.useDispatch)(_blockEditor.store);
41
- const {
42
- label,
43
- url,
44
- opensInNewTab
45
- } = block.attributes;
46
- const link = {
47
- url,
48
- opensInNewTab,
49
- title: label && (0, _dom.__unstableStripHTML)(label)
50
- };
51
- return (0, _element.createElement)(_components.Popover, {
52
- placement: "bottom",
53
- shift: true,
54
- onClose: onClose
55
- }, (0, _element.createElement)(_blockEditor.__experimentalLinkControl, {
56
- hasTextControl: true,
57
- hasRichPreviews: true,
58
- value: link,
59
- onChange: updatedValue => {
60
- updateBlockAttributes(block.clientId, {
61
- label: updatedValue.title,
62
- url: updatedValue.url,
63
- opensInNewTab: updatedValue.opensInNewTab
64
- });
65
- onClose();
66
- },
67
- onCancel: onClose
68
- }));
69
- } // Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.
70
-
71
-
33
+ // Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.
72
34
  const MAX_PAGE_COUNT = 100;
73
35
  const PAGES_QUERY = ['postType', 'page', {
74
36
  per_page: MAX_PAGE_COUNT,
@@ -80,11 +42,11 @@ const PAGES_QUERY = ['postType', 'page', {
80
42
  order: 'asc'
81
43
  }];
82
44
 
83
- function NavigationMenuContent(_ref2) {
45
+ function NavigationMenuContent(_ref) {
84
46
  let {
85
47
  rootClientId,
86
48
  onSelect
87
- } = _ref2;
49
+ } = _ref;
88
50
  const [isLoading, setIsLoading] = (0, _element.useState)(true);
89
51
  const {
90
52
  clientIdsTree,
@@ -115,20 +77,7 @@ function NavigationMenuContent(_ref2) {
115
77
  const {
116
78
  replaceBlock,
117
79
  __unstableMarkNextChangeAsNotPersistent
118
- } = (0, _data.useDispatch)(_blockEditor.store);
119
- const [customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId] = (0, _element.useState)(false);
120
- const renderAdditionalBlockUICallback = (0, _element.useCallback)(block => {
121
- if (customLinkEditPopoverOpenId && block.clientId === customLinkEditPopoverOpenId) {
122
- return (0, _element.createElement)(CustomLinkAdditionalBlockUI, {
123
- block: block,
124
- onClose: () => {
125
- setIsCustomLinkEditPopoverOpenId(false);
126
- }
127
- });
128
- }
129
-
130
- return null;
131
- }, [customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId]); // Delay loading stop by 50ms to avoid flickering.
80
+ } = (0, _data.useDispatch)(_blockEditor.store); // Delay loading stop by 50ms to avoid flickering.
132
81
 
133
82
  (0, _element.useEffect)(() => {
134
83
  let timeoutId;
@@ -151,32 +100,26 @@ function NavigationMenuContent(_ref2) {
151
100
  };
152
101
  }, [shouldKeepLoading, clientIdsTree, isLoading]);
153
102
  const {
154
- PrivateListView,
155
- LeafMoreMenu
103
+ PrivateListView
156
104
  } = (0, _privateApis.unlock)(_blockEditor.privateApis);
157
105
  const offCanvasOnselect = (0, _element.useCallback)(block => {
158
106
  if (block.name === 'core/navigation-link' && !block.attributes.url) {
159
107
  __unstableMarkNextChangeAsNotPersistent();
160
108
 
161
109
  replaceBlock(block.clientId, (0, _blocks.createBlock)('core/navigation-link', block.attributes));
162
- } else if (block.name === 'core/navigation-link' && block.attributes.kind === 'custom' && block.attributes.url) {
163
- setIsCustomLinkEditPopoverOpenId(block.clientId);
164
110
  } else {
165
111
  onSelect(block);
166
112
  }
167
- }, [onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock, setIsCustomLinkEditPopoverOpenId]); // The hidden block is needed because it makes block edit side effects trigger.
113
+ }, [onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock]); // The hidden block is needed because it makes block edit side effects trigger.
168
114
  // For example a navigation page list load its items has an effect on edit to load its items.
169
115
 
170
- return (0, _element.createElement)(_element.Fragment, null, isLoading && (0, _element.createElement)(_loader.NavigationMenuLoader, null), !isLoading && (0, _element.createElement)(PrivateListView, {
116
+ return (0, _element.createElement)(_element.Fragment, null, !isLoading && (0, _element.createElement)(PrivateListView, {
171
117
  blocks: isSinglePageList ? clientIdsTree[0].innerBlocks : clientIdsTree,
172
118
  onSelect: offCanvasOnselect,
173
- blockSettingsMenu: LeafMoreMenu,
174
- showAppender: false,
175
- renderAdditionalBlockUI: renderAdditionalBlockUICallback
176
- }), (0, _element.createElement)("div", {
177
- style: {
178
- visibility: 'hidden'
179
- }
119
+ blockSettingsMenu: _leafMoreMenu.default,
120
+ showAppender: false
121
+ }), (0, _element.createElement)(_components.VisuallyHidden, {
122
+ "aria-hidden": "true"
180
123
  }, (0, _element.createElement)(_blockEditor.BlockTools, null, (0, _element.createElement)(_blockEditor.BlockList, null))));
181
124
  }
182
125
  //# sourceMappingURL=navigation-menu-content.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js"],"names":["CustomLinkAdditionalBlockUI","block","onClose","updateBlockAttributes","blockEditorStore","label","url","opensInNewTab","attributes","link","title","updatedValue","clientId","MAX_PAGE_COUNT","PAGES_QUERY","per_page","_fields","orderby","order","NavigationMenuContent","rootClientId","onSelect","isLoading","setIsLoading","clientIdsTree","shouldKeepLoading","isSinglePageList","select","__unstableGetClientIdsTree","areInnerBlocksControlled","getBlockName","isResolving","coreStore","_clientIdsTree","hasOnlyPageListBlock","length","isLoadingPages","innerBlocks","replaceBlock","__unstableMarkNextChangeAsNotPersistent","customLinkEditPopoverOpenId","setIsCustomLinkEditPopoverOpenId","renderAdditionalBlockUICallback","timeoutId","setTimeout","undefined","clearTimeout","PrivateListView","LeafMoreMenu","blockEditorPrivateApis","offCanvasOnselect","name","kind","visibility"],"mappings":";;;;;;;AAcA;;AAXA;;AAOA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AArBA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O,UAA3C,CAFW,CAAZ;AAIA,KATD,MASO,IACNP,KAAK,CAACkD,IAAN,KAAe,sBAAf,IACAlD,KAAK,CAACO,UAAN,CAAiB4C,IAAjB,KAA0B,QAD1B,IAEAnD,KAAK,CAACO,UAAN,CAAiBF,GAHX,EAIL;AACDmC,MAAAA,gCAAgC,CAAExC,KAAK,CAACW,QAAR,CAAhC;AACA,KANM,MAMA;AACNS,MAAAA,QAAQ,CAAEpB,KAAF,CAAR;AACA;AACD,GApBwB,EAqBzB,CACCoB,QADD,EAECkB,uCAFD,EAGCD,YAHD,EAICG,gCAJD,CArByB,CAA1B,CAlF2E,CA+G3E;AACA;;AACA,SACC,qDACGnB,SAAS,IAAI,4BAAC,4BAAD,OADhB,EAEG,CAAEA,SAAF,IACD,4BAAC,eAAD;AACC,IAAA,MAAM,EACLI,gBAAgB,GACbF,aAAa,CAAE,CAAF,CAAb,CAAmBa,WADN,GAEbb,aAJL;AAMC,IAAA,QAAQ,EAAG0B,iBANZ;AAOC,IAAA,iBAAiB,EAAGF,YAPrB;AAQC,IAAA,YAAY,EAAG,KARhB;AASC,IAAA,uBAAuB,EAAGN;AAT3B,IAHF,EAeC;AAAK,IAAA,KAAK,EAAG;AAAEW,MAAAA,UAAU,EAAE;AAAd;AAAb,KACC,4BAAC,uBAAD,QACC,4BAAC,sBAAD,OADD,CADD,CAfD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockList,\n\tBlockTools,\n\t__experimentalLinkControl as LinkControl,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { Popover } from '@wordpress/components';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { NavigationMenuLoader } from './loader';\n\nfunction CustomLinkAdditionalBlockUI( { block, onClose } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { label, url, opensInNewTab } = block.attributes;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\treturn (\n\t\t<Popover placement=\"bottom\" shift onClose={ onClose }>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tvalue={ link }\n\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\t\t\tlabel: updatedValue.title,\n\t\t\t\t\t\turl: updatedValue.url,\n\t\t\t\t\t\topensInNewTab: updatedValue.opensInNewTab,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonCancel={ onClose }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n// Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.\nconst MAX_PAGE_COUNT = 100;\nconst PAGES_QUERY = [\n\t'postType',\n\t'page',\n\t{\n\t\tper_page: MAX_PAGE_COUNT,\n\t\t_fields: [ 'id', 'link', 'menu_order', 'parent', 'title', 'type' ],\n\t\t// TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby\n\t\t// values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent\n\t\t// sort.\n\t\torderby: 'menu_order',\n\t\torder: 'asc',\n\t},\n];\n\nexport default function NavigationMenuContent( { rootClientId, onSelect } ) {\n\tconst [ isLoading, setIsLoading ] = useState( true );\n\tconst { clientIdsTree, shouldKeepLoading, isSinglePageList } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t\tareInnerBlocksControlled,\n\t\t\t\tgetBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { isResolving } = select( coreStore );\n\n\t\t\tconst _clientIdsTree = __unstableGetClientIdsTree( rootClientId );\n\t\t\tconst hasOnlyPageListBlock =\n\t\t\t\t_clientIdsTree.length === 1 &&\n\t\t\t\tgetBlockName( _clientIdsTree[ 0 ].clientId ) ===\n\t\t\t\t\t'core/page-list';\n\t\t\tconst isLoadingPages = isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tPAGES_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tclientIdsTree: _clientIdsTree,\n\t\t\t\t// This is a small hack to wait for the navigation block\n\t\t\t\t// to actually load its inner blocks.\n\t\t\t\tshouldKeepLoading:\n\t\t\t\t\t! areInnerBlocksControlled( rootClientId ) ||\n\t\t\t\t\tisLoadingPages,\n\t\t\t\tisSinglePageList:\n\t\t\t\t\thasOnlyPageListBlock &&\n\t\t\t\t\t! isLoadingPages &&\n\t\t\t\t\t_clientIdsTree[ 0 ].innerBlocks.length > 0,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst [ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ] =\n\t\tuseState( false );\n\n\tconst renderAdditionalBlockUICallback = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tcustomLinkEditPopoverOpenId &&\n\t\t\t\tblock.clientId === customLinkEditPopoverOpenId\n\t\t\t) {\n\t\t\t\treturn (\n\t\t\t\t\t<CustomLinkAdditionalBlockUI\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsCustomLinkEditPopoverOpenId( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\t[ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ]\n\t);\n\n\t// Delay loading stop by 50ms to avoid flickering.\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\t\tif ( shouldKeepLoading && ! isLoading ) {\n\t\t\tsetIsLoading( true );\n\t\t}\n\t\tif ( ! shouldKeepLoading && isLoading ) {\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetIsLoading( false );\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}, 50 );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( timeoutId ) {\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t}\n\t\t};\n\t}, [ shouldKeepLoading, clientIdsTree, isLoading ] );\n\n\tconst { PrivateListView, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\tconst offCanvasOnselect = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\t! block.attributes.url\n\t\t\t) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlock(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\tcreateBlock( 'core/navigation-link', block.attributes )\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\tblock.attributes.kind === 'custom' &&\n\t\t\t\tblock.attributes.url\n\t\t\t) {\n\t\t\t\tsetIsCustomLinkEditPopoverOpenId( block.clientId );\n\t\t\t} else {\n\t\t\t\tonSelect( block );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tonSelect,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\treplaceBlock,\n\t\t\tsetIsCustomLinkEditPopoverOpenId,\n\t\t]\n\t);\n\n\t// The hidden block is needed because it makes block edit side effects trigger.\n\t// For example a navigation page list load its items has an effect on edit to load its items.\n\treturn (\n\t\t<>\n\t\t\t{ isLoading && <NavigationMenuLoader /> }\n\t\t\t{ ! isLoading && (\n\t\t\t\t<PrivateListView\n\t\t\t\t\tblocks={\n\t\t\t\t\t\tisSinglePageList\n\t\t\t\t\t\t\t? clientIdsTree[ 0 ].innerBlocks\n\t\t\t\t\t\t\t: clientIdsTree\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={ offCanvasOnselect }\n\t\t\t\t\tblockSettingsMenu={ LeafMoreMenu }\n\t\t\t\t\tshowAppender={ false }\n\t\t\t\t\trenderAdditionalBlockUI={ renderAdditionalBlockUICallback }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div style={ { visibility: 'hidden' } }>\n\t\t\t\t<BlockTools>\n\t\t\t\t\t<BlockList />\n\t\t\t\t</BlockTools>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js"],"names":["MAX_PAGE_COUNT","PAGES_QUERY","per_page","_fields","orderby","order","NavigationMenuContent","rootClientId","onSelect","isLoading","setIsLoading","clientIdsTree","shouldKeepLoading","isSinglePageList","select","__unstableGetClientIdsTree","areInnerBlocksControlled","getBlockName","blockEditorStore","isResolving","coreStore","_clientIdsTree","hasOnlyPageListBlock","length","clientId","isLoadingPages","innerBlocks","replaceBlock","__unstableMarkNextChangeAsNotPersistent","timeoutId","setTimeout","undefined","clearTimeout","PrivateListView","blockEditorPrivateApis","offCanvasOnselect","block","name","attributes","url","LeafMoreMenu"],"mappings":";;;;;;;;;AAYA;;AATA;;AAMA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIA;AACA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,WAAW,GAAG,CACnB,UADmB,EAEnB,MAFmB,EAGnB;AACCC,EAAAA,QAAQ,EAAEF,cADX;AAECG,EAAAA,OAAO,EAAE,CAAE,IAAF,EAAQ,MAAR,EAAgB,YAAhB,EAA8B,QAA9B,EAAwC,OAAxC,EAAiD,MAAjD,CAFV;AAGC;AACA;AACA;AACAC,EAAAA,OAAO,EAAE,YANV;AAOCC,EAAAA,KAAK,EAAE;AAPR,CAHmB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D,OADD,CADD,CAbD,CADD;AAqBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockList,\n\tBlockTools,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { VisuallyHidden } from '@wordpress/components';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport LeafMoreMenu from './leaf-more-menu';\n\n// Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.\nconst MAX_PAGE_COUNT = 100;\nconst PAGES_QUERY = [\n\t'postType',\n\t'page',\n\t{\n\t\tper_page: MAX_PAGE_COUNT,\n\t\t_fields: [ 'id', 'link', 'menu_order', 'parent', 'title', 'type' ],\n\t\t// TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby\n\t\t// values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent\n\t\t// sort.\n\t\torderby: 'menu_order',\n\t\torder: 'asc',\n\t},\n];\n\nexport default function NavigationMenuContent( { rootClientId, onSelect } ) {\n\tconst [ isLoading, setIsLoading ] = useState( true );\n\tconst { clientIdsTree, shouldKeepLoading, isSinglePageList } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t\tareInnerBlocksControlled,\n\t\t\t\tgetBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { isResolving } = select( coreStore );\n\n\t\t\tconst _clientIdsTree = __unstableGetClientIdsTree( rootClientId );\n\t\t\tconst hasOnlyPageListBlock =\n\t\t\t\t_clientIdsTree.length === 1 &&\n\t\t\t\tgetBlockName( _clientIdsTree[ 0 ].clientId ) ===\n\t\t\t\t\t'core/page-list';\n\t\t\tconst isLoadingPages = isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tPAGES_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tclientIdsTree: _clientIdsTree,\n\t\t\t\t// This is a small hack to wait for the navigation block\n\t\t\t\t// to actually load its inner blocks.\n\t\t\t\tshouldKeepLoading:\n\t\t\t\t\t! areInnerBlocksControlled( rootClientId ) ||\n\t\t\t\t\tisLoadingPages,\n\t\t\t\tisSinglePageList:\n\t\t\t\t\thasOnlyPageListBlock &&\n\t\t\t\t\t! isLoadingPages &&\n\t\t\t\t\t_clientIdsTree[ 0 ].innerBlocks.length > 0,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Delay loading stop by 50ms to avoid flickering.\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\t\tif ( shouldKeepLoading && ! isLoading ) {\n\t\t\tsetIsLoading( true );\n\t\t}\n\t\tif ( ! shouldKeepLoading && isLoading ) {\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetIsLoading( false );\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}, 50 );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( timeoutId ) {\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t}\n\t\t};\n\t}, [ shouldKeepLoading, clientIdsTree, isLoading ] );\n\n\tconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\tconst offCanvasOnselect = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\t! block.attributes.url\n\t\t\t) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlock(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\tcreateBlock( 'core/navigation-link', block.attributes )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonSelect( block );\n\t\t\t}\n\t\t},\n\t\t[ onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock ]\n\t);\n\n\t// The hidden block is needed because it makes block edit side effects trigger.\n\t// For example a navigation page list load its items has an effect on edit to load its items.\n\treturn (\n\t\t<>\n\t\t\t{ ! isLoading && (\n\t\t\t\t<PrivateListView\n\t\t\t\t\tblocks={\n\t\t\t\t\t\tisSinglePageList\n\t\t\t\t\t\t\t? clientIdsTree[ 0 ].innerBlocks\n\t\t\t\t\t\t\t: clientIdsTree\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={ offCanvasOnselect }\n\t\t\t\t\tblockSettingsMenu={ LeafMoreMenu }\n\t\t\t\t\tshowAppender={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<VisuallyHidden aria-hidden=\"true\">\n\t\t\t\t<BlockTools>\n\t\t\t\t\t<BlockList />\n\t\t\t\t</BlockTools>\n\t\t\t</VisuallyHidden>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = SidebarNavigationScreenNavigationMenuButton;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _coreData = require("@wordpress/core-data");
17
+
18
+ var _constants = require("./constants");
19
+
20
+ /**
21
+ * WordPress dependencies
22
+ */
23
+
24
+ /**
25
+ * Internal dependencies
26
+ */
27
+ function SidebarNavigationScreenNavigationMenuButton(_ref) {
28
+ let {
29
+ children,
30
+ ...props
31
+ } = _ref;
32
+ const {
33
+ records: navigationMenus,
34
+ isResolving: isLoading
35
+ } = (0, _coreData.useEntityRecords)('postType', `wp_navigation`, _constants.PRELOADED_NAVIGATION_MENUS_QUERY);
36
+ const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
37
+ const hasSingleNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) === 1;
38
+ const firstNavigationMenu = navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus[0];
39
+ const showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN ? hasNavigationMenus : false; // If there is a single menu then we can go directly to that menu.
40
+ // Otherwise we go to the navigation listing screen.
41
+
42
+ const path = hasSingleNavigationMenu ? `/navigation/wp_navigation/${firstNavigationMenu === null || firstNavigationMenu === void 0 ? void 0 : firstNavigationMenu.id}` : '/navigation';
43
+
44
+ if (!showNavigationScreen) {
45
+ return null;
46
+ }
47
+
48
+ return (0, _element.createElement)(_components.__experimentalNavigatorButton, (0, _extends2.default)({}, props, {
49
+ disabled: isLoading,
50
+ path: path
51
+ }), children);
52
+ }
53
+ //# sourceMappingURL=navigator-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js"],"names":["SidebarNavigationScreenNavigationMenuButton","children","props","records","navigationMenus","isResolving","isLoading","PRELOADED_NAVIGATION_MENUS_QUERY","hasNavigationMenus","length","hasSingleNavigationMenu","firstNavigationMenu","showNavigationScreen","process","env","IS_GUTENBERG_PLUGIN","path","id"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,2CAAT,OAGX;AAAA,MAHiE;AACpEC,IAAAA,QADoE;AAEpE,OAAGC;AAFiE,GAGjE;AACH,QAAM;AAAEC,IAAAA,OAAO,EAAEC,eAAX;AAA4BC,IAAAA,WAAW,EAAEC;AAAzC,MACL,gCACC,UADD,EAEE,eAFF,EAGCC,2CAHD,CADD;AAOA,QAAMC,kBAAkB,GAAG,CAAC,EAAEJ,eAAF,aAAEA,eAAF,eAAEA,eAAe,CAAEK,MAAnB,CAA5B;AACA,QAAMC,uBAAuB,GAAG,CAAAN,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAEK,MAAjB,MAA4B,CAA5D;AACA,QAAME,mBAAmB,GAAGP,eAAH,aAAGA,eAAH,uBAAGA,eAAe,CAAI,CAAJ,CAA3C;AAEA,QAAMQ,oBAAoB,GAAGC,OAAO,CAACC,GAAR,CAAYC,mBAAZ,GAC1BP,kBAD0B,GAE1B,KAFH,CAZG,CAgBH;AACA;;AACA,QAAMQ,IAAI,GAAGN,uBAAuB,GAChC,6BAA6BC,mBAA9B,aAA8BA,mBAA9B,uBAA8BA,mBAAmB,CAAEM,EAAI,EADtB,GAEjC,aAFH;;AAIA,MAAK,CAAEL,oBAAP,EAA8B;AAC7B,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,yCAAD,6BAAsBV,KAAtB;AAA8B,IAAA,QAAQ,EAAGI,SAAzC;AAAqD,IAAA,IAAI,EAAGU;AAA5D,MACGf,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { __experimentalNavigatorButton as NavigatorButton } from '@wordpress/components';\nimport { useEntityRecords } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { PRELOADED_NAVIGATION_MENUS_QUERY } from './constants';\n\nexport default function SidebarNavigationScreenNavigationMenuButton( {\n\tchildren,\n\t...props\n} ) {\n\tconst { records: navigationMenus, isResolving: isLoading } =\n\t\tuseEntityRecords(\n\t\t\t'postType',\n\t\t\t`wp_navigation`,\n\t\t\tPRELOADED_NAVIGATION_MENUS_QUERY\n\t\t);\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasSingleNavigationMenu = navigationMenus?.length === 1;\n\tconst firstNavigationMenu = navigationMenus?.[ 0 ];\n\n\tconst showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN\n\t\t? hasNavigationMenus\n\t\t: false;\n\n\t// If there is a single menu then we can go directly to that menu.\n\t// Otherwise we go to the navigation listing screen.\n\tconst path = hasSingleNavigationMenu\n\t\t? `/navigation/wp_navigation/${ firstNavigationMenu?.id }`\n\t\t: '/navigation';\n\n\tif ( ! showNavigationScreen ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<NavigatorButton { ...props } disabled={ isLoading } path={ path }>\n\t\t\t{ children }\n\t\t</NavigatorButton>\n\t);\n}\n"]}