@wordpress/edit-site 5.3.5 → 5.3.7

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 (196) hide show
  1. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  2. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  3. package/build/components/add-new-template/new-template-part.js +5 -1
  4. package/build/components/add-new-template/new-template-part.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +2 -1
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -3
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/screen-variations.js +1 -1
  10. package/build/components/global-styles/screen-variations.js.map +1 -1
  11. package/build/components/global-styles/shadow-panel.js +6 -4
  12. package/build/components/global-styles/shadow-panel.js.map +1 -1
  13. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  14. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  15. package/build/components/keyboard-shortcuts/global.js +48 -0
  16. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  17. package/build/components/keyboard-shortcuts/register.js +153 -0
  18. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  19. package/build/components/layout/index.js +11 -1
  20. package/build/components/layout/index.js.map +1 -1
  21. package/build/components/list/added-by.js +41 -42
  22. package/build/components/list/added-by.js.map +1 -1
  23. package/build/components/list/index.js +2 -1
  24. package/build/components/list/index.js.map +1 -1
  25. package/build/components/list/table.js +3 -1
  26. package/build/components/list/table.js.map +1 -1
  27. package/build/components/routes/link.js +4 -1
  28. package/build/components/routes/link.js.map +1 -1
  29. package/build/components/save-hub/index.js +82 -0
  30. package/build/components/save-hub/index.js.map +1 -0
  31. package/build/components/sidebar/index.js +14 -4
  32. package/build/components/sidebar/index.js.map +1 -1
  33. package/build/components/sidebar-button/index.js +30 -0
  34. package/build/components/sidebar-button/index.js.map +1 -0
  35. package/build/components/sidebar-navigation-screen/index.js +11 -5
  36. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-main/index.js +1 -0
  38. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen-navigation-item/index.js +18 -18
  40. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +139 -11
  42. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +19 -0
  44. package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  45. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +77 -0
  46. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  47. package/build/components/sidebar-navigation-screen-template/index.js +25 -8
  48. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  49. package/build/components/sidebar-navigation-screen-templates/index.js +22 -5
  50. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  51. package/build/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  52. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  53. package/build/components/style-book/index.js +17 -2
  54. package/build/components/style-book/index.js.map +1 -1
  55. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  56. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  57. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  58. package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  59. package/build/components/sync-state-with-url/use-sync-path-with-url.js +29 -29
  60. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  61. package/build/components/template-details/index.js +5 -10
  62. package/build/components/template-details/index.js.map +1 -1
  63. package/build/components/use-edited-entity-record/index.js +6 -6
  64. package/build/components/use-edited-entity-record/index.js.map +1 -1
  65. package/build/index.js +13 -22
  66. package/build/index.js.map +1 -1
  67. package/build/utils/history.js +8 -2
  68. package/build/utils/history.js.map +1 -1
  69. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  70. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  71. package/build-module/components/add-new-template/new-template-part.js +5 -1
  72. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  73. package/build-module/components/block-editor/editor-canvas.js +2 -1
  74. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  75. package/build-module/components/editor/index.js +3 -3
  76. package/build-module/components/editor/index.js.map +1 -1
  77. package/build-module/components/global-styles/screen-variations.js +1 -1
  78. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  79. package/build-module/components/global-styles/shadow-panel.js +6 -4
  80. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  81. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  82. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  83. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  84. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  85. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  86. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  87. package/build-module/components/layout/index.js +9 -1
  88. package/build-module/components/layout/index.js.map +1 -1
  89. package/build-module/components/list/added-by.js +43 -44
  90. package/build-module/components/list/added-by.js.map +1 -1
  91. package/build-module/components/list/index.js +2 -1
  92. package/build-module/components/list/index.js.map +1 -1
  93. package/build-module/components/list/table.js +3 -1
  94. package/build-module/components/list/table.js.map +1 -1
  95. package/build-module/components/routes/link.js +5 -2
  96. package/build-module/components/routes/link.js.map +1 -1
  97. package/build-module/components/save-hub/index.js +68 -0
  98. package/build-module/components/save-hub/index.js.map +1 -0
  99. package/build-module/components/sidebar/index.js +10 -5
  100. package/build-module/components/sidebar/index.js.map +1 -1
  101. package/build-module/components/sidebar-button/index.js +18 -0
  102. package/build-module/components/sidebar-button/index.js.map +1 -0
  103. package/build-module/components/sidebar-navigation-screen/index.js +9 -6
  104. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  105. package/build-module/components/sidebar-navigation-screen-main/index.js +1 -0
  106. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  107. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +20 -22
  108. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  109. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +131 -11
  110. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  111. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +11 -0
  112. package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +1 -0
  113. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +66 -0
  114. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -0
  115. package/build-module/components/sidebar-navigation-screen-template/index.js +25 -10
  116. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  117. package/build-module/components/sidebar-navigation-screen-templates/index.js +19 -5
  118. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  119. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +6 -3
  120. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  121. package/build-module/components/style-book/index.js +17 -3
  122. package/build-module/components/style-book/index.js.map +1 -1
  123. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  124. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  125. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +24 -8
  126. package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
  127. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +27 -29
  128. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  129. package/build-module/components/template-details/index.js +5 -9
  130. package/build-module/components/template-details/index.js.map +1 -1
  131. package/build-module/components/use-edited-entity-record/index.js +6 -6
  132. package/build-module/components/use-edited-entity-record/index.js.map +1 -1
  133. package/build-module/index.js +16 -23
  134. package/build-module/index.js.map +1 -1
  135. package/build-module/utils/history.js +9 -3
  136. package/build-module/utils/history.js.map +1 -1
  137. package/build-style/style-rtl.css +100 -94
  138. package/build-style/style.css +100 -94
  139. package/package.json +10 -10
  140. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  141. package/src/components/add-new-template/new-template-part.js +4 -3
  142. package/src/components/add-new-template/style.scss +0 -5
  143. package/src/components/block-editor/editor-canvas.js +2 -1
  144. package/src/components/block-editor/style.scss +1 -1
  145. package/src/components/editor/index.js +4 -3
  146. package/src/components/global-styles/screen-variations.js +0 -1
  147. package/src/components/global-styles/shadow-panel.js +4 -3
  148. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  149. package/src/components/keyboard-shortcuts/global.js +35 -0
  150. package/src/components/keyboard-shortcuts/register.js +157 -0
  151. package/src/components/layout/index.js +18 -0
  152. package/src/components/layout/style.scss +1 -3
  153. package/src/components/list/added-by.js +48 -55
  154. package/src/components/list/index.js +3 -1
  155. package/src/components/list/style.scss +5 -13
  156. package/src/components/list/table.js +4 -1
  157. package/src/components/routes/link.js +9 -2
  158. package/src/components/save-hub/index.js +78 -0
  159. package/src/components/save-hub/style.scss +15 -0
  160. package/src/components/sidebar/index.js +11 -6
  161. package/src/components/sidebar/style.scss +4 -3
  162. package/src/components/sidebar-button/index.js +21 -0
  163. package/src/components/sidebar-button/style.scss +24 -0
  164. package/src/components/sidebar-navigation-item/style.scss +0 -20
  165. package/src/components/sidebar-navigation-screen/index.js +9 -4
  166. package/src/components/sidebar-navigation-screen/style.scss +16 -10
  167. package/src/components/sidebar-navigation-screen-main/index.js +3 -0
  168. package/src/components/sidebar-navigation-screen-navigation-item/index.js +33 -26
  169. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +141 -10
  170. package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +9 -0
  171. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +78 -0
  172. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +55 -4
  173. package/src/components/sidebar-navigation-screen-template/index.js +27 -13
  174. package/src/components/sidebar-navigation-screen-templates/index.js +23 -4
  175. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  176. package/src/components/sidebar-navigation-screen-templates-browse/index.js +12 -1
  177. package/src/components/style-book/index.js +25 -1
  178. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -9
  179. package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +38 -8
  180. package/src/components/sync-state-with-url/use-sync-path-with-url.js +34 -35
  181. package/src/components/template-details/index.js +4 -8
  182. package/src/components/use-edited-entity-record/index.js +26 -18
  183. package/src/index.js +11 -22
  184. package/src/style.scss +2 -1
  185. package/src/utils/history.js +13 -9
  186. package/build/components/navigation-inspector/index.js +0 -190
  187. package/build/components/navigation-inspector/index.js.map +0 -1
  188. package/build/components/navigation-inspector/navigation-menu.js +0 -62
  189. package/build/components/navigation-inspector/navigation-menu.js.map +0 -1
  190. package/build-module/components/navigation-inspector/index.js +0 -173
  191. package/build-module/components/navigation-inspector/index.js.map +0 -1
  192. package/build-module/components/navigation-inspector/navigation-menu.js +0 -52
  193. package/build-module/components/navigation-inspector/navigation-menu.js.map +0 -1
  194. package/src/components/navigation-inspector/index.js +0 -223
  195. package/src/components/navigation-inspector/navigation-menu.js +0 -66
  196. package/src/components/navigation-inspector/style.scss +0 -46
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","href","window","location","Link","children","props"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,SAASA,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAG,wBAAhB;;AAEA,WAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,SAAO;AACNQ,IAAAA,IAAI,EAAE,uBAAcC,MAAM,CAACC,QAAP,CAAgBF,IAA9B,EAAoCT,MAApC,CADA;AAENI,IAAAA;AAFM,GAAP;AAIA;;AAEc,SAASQ,IAAT,OAMX;AAAA,MAN0B;AAC7BZ,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BW,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEL,IAAAA,IAAF;AAAQL,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGO,IAAV;AAAiB,IAAA,OAAO,EAAGL;AAA3B,KAA0CU,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\treturn {\n\t\thref: addQueryArgs( window.location.href, params ),\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","newUrl","Link","children","props"],"mappings":";;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGO,SAASA,OAAT,GAA8D;AAAA,MAA5CC,MAA4C,uEAAnC,EAAmC;AAAA,MAA/BC,KAA+B;AAAA,MAAxBC,aAAwB,uEAAR,KAAQ;AACpE,QAAMC,OAAO,GAAG,wBAAhB;;AAEA,WAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzBA,IAAAA,KAAK,CAACC,cAAN;;AAEA,QAAKJ,aAAL,EAAqB;AACpBC,MAAAA,OAAO,CAACI,OAAR,CAAiBP,MAAjB,EAAyBC,KAAzB;AACA,KAFD,MAEO;AACNE,MAAAA,OAAO,CAACK,IAAR,CAAcR,MAAd,EAAsBC,KAAtB;AACA;AACD;;AAED,QAAMQ,WAAW,GAAG,uBAAcC,MAAM,CAACC,QAAP,CAAgBC,IAA9B,CAApB;AACA,QAAMC,qBAAqB,GAAG,0BAC7BH,MAAM,CAACC,QAAP,CAAgBC,IADa,EAE7B,GAAGE,MAAM,CAACC,IAAP,CAAaN,WAAb,CAF0B,CAA9B;AAIA,QAAMO,MAAM,GAAG,uBAAcH,qBAAd,EAAqCb,MAArC,CAAf;AAEA,SAAO;AACNY,IAAAA,IAAI,EAAEI,MADA;AAENZ,IAAAA;AAFM,GAAP;AAIA;;AAEc,SAASa,IAAT,OAMX;AAAA,MAN0B;AAC7BjB,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BgB,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAEP,IAAAA,IAAF;AAAQR,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGU,IAAV;AAAiB,IAAA,OAAO,EAAGR;AAA3B,KAA0Ce,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from './index';\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\tconst currentArgs = getQueryArgs( window.location.href );\n\tconst currentUrlWithoutArgs = removeQueryArgs(\n\t\twindow.location.href,\n\t\t...Object.keys( currentArgs )\n\t);\n\tconst newUrl = addQueryArgs( currentUrlWithoutArgs, params );\n\n\treturn {\n\t\thref: newUrl,\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = SaveButton;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _i18n = require("@wordpress/i18n");
15
+
16
+ var _coreData = require("@wordpress/core-data");
17
+
18
+ var _keycodes = require("@wordpress/keycodes");
19
+
20
+ var _icons = require("@wordpress/icons");
21
+
22
+ var _store = require("../../store");
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+ function SaveButton() {
32
+ const {
33
+ countUnsavedChanges,
34
+ isDirty,
35
+ isSaving,
36
+ isSaveViewOpen
37
+ } = (0, _data.useSelect)(select => {
38
+ const {
39
+ __experimentalGetDirtyEntityRecords,
40
+ isSavingEntityRecord
41
+ } = select(_coreData.store);
42
+
43
+ const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
44
+
45
+ const {
46
+ isSaveViewOpened
47
+ } = select(_store.store);
48
+ return {
49
+ isDirty: dirtyEntityRecords.length > 0,
50
+ isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
51
+ isSaveViewOpen: isSaveViewOpened(),
52
+ countUnsavedChanges: dirtyEntityRecords.length
53
+ };
54
+ }, []);
55
+ const {
56
+ setIsSaveViewOpened
57
+ } = (0, _data.useDispatch)(_store.store);
58
+ const disabled = !isDirty || isSaving;
59
+ const label = disabled ? (0, _i18n.__)('Saved') : (0, _i18n.__)('Save');
60
+ return (0, _element.createElement)(_components.__experimentalHStack, {
61
+ className: "edit-site-save-hub",
62
+ alignment: "right",
63
+ spacing: 4
64
+ }, isDirty && (0, _element.createElement)("span", null, (0, _i18n.sprintf)( // translators: %d: number of unsaved changes (number).
65
+ (0, _i18n._n)('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), (0, _element.createElement)(_components.Button, {
66
+ className: "edit-site-save-hub__button",
67
+ variant: disabled ? undefined : 'primary',
68
+ "aria-disabled": disabled,
69
+ "aria-expanded": isSaveViewOpen,
70
+ isBusy: isSaving,
71
+ onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
72
+ label: label
73
+ /*
74
+ * We want the tooltip to show the keyboard shortcut only when the
75
+ * button does something, i.e. when it's not disabled.
76
+ */
77
+ ,
78
+ shortcut: disabled ? undefined : _keycodes.displayShortcut.primary('s'),
79
+ icon: disabled ? _icons.check : undefined
80
+ }, label));
81
+ }
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/save-hub/index.js"],"names":["SaveButton","countUnsavedChanges","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","coreStore","dirtyEntityRecords","isSaveViewOpened","editSiteStore","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","displayShortcut","primary","check"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,UAAT,GAAsB;AACpC,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA,QAAhC;AAA0CC,IAAAA;AAA1C,MACL,qBAAaC,MAAF,IAAc;AACxB,UAAM;AACLC,MAAAA,mCADK;AAELC,MAAAA;AAFK,QAGFF,MAAM,CAAEG,eAAF,CAHV;;AAIA,UAAMC,kBAAkB,GAAGH,mCAAmC,EAA9D;;AACA,UAAM;AAAEI,MAAAA;AAAF,QAAuBL,MAAM,CAAEM,YAAF,CAAnC;AACA,WAAO;AACNT,MAAAA,OAAO,EAAEO,kBAAkB,CAACG,MAAnB,GAA4B,CAD/B;AAENT,MAAAA,QAAQ,EAAEM,kBAAkB,CAACI,IAAnB,CAA2BC,MAAF,IAClCP,oBAAoB,CAAEO,MAAM,CAACC,IAAT,EAAeD,MAAM,CAACE,IAAtB,EAA4BF,MAAM,CAACG,GAAnC,CADX,CAFJ;AAKNb,MAAAA,cAAc,EAAEM,gBAAgB,EAL1B;AAMNT,MAAAA,mBAAmB,EAAEQ,kBAAkB,CAACG;AANlC,KAAP;AAQA,GAfD,EAeG,EAfH,CADD;AAiBA,QAAM;AAAEM,IAAAA;AAAF,MAA0B,uBAAaP,YAAb,CAAhC;AAEA,QAAMQ,QAAQ,GAAG,CAAEjB,OAAF,IAAaC,QAA9B;AAEA,QAAMiB,KAAK,GAAGD,QAAQ,GAAG,cAAI,OAAJ,CAAH,GAAmB,cAAI,MAAJ,CAAzC;AAEA,SACC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC,oBAAlB;AAAuC,IAAA,SAAS,EAAC,OAAjD;AAAyD,IAAA,OAAO,EAAG;AAAnE,KACGjB,OAAO,IACR,0CACG,oBACD;AACA,gBACC,mBADD,EAEC,oBAFD,EAGCD,mBAHD,CAFC,EAODA,mBAPC,CADH,CAFF,EAcC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,OAAO,EAAGkB,QAAQ,GAAGE,SAAH,GAAe,SAFlC;AAGC,qBAAgBF,QAHjB;AAIC,qBAAgBf,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EACNgB,QAAQ,GAAGE,SAAH,GAAe,MAAMH,mBAAmB,CAAE,IAAF,CAPlD;AASC,IAAA,KAAK,EAAGE;AACR;AACJ;AACA;AACA;AAbG;AAcC,IAAA,QAAQ,EACPD,QAAQ,GAAGE,SAAH,GAAeC,0BAAgBC,OAAhB,CAAyB,GAAzB,CAfzB;AAiBC,IAAA,IAAI,EAAGJ,QAAQ,GAAGK,YAAH,GAAWH;AAjB3B,KAmBGD,KAnBH,CAdD,CADD;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, __experimentalHStack as HStack } from '@wordpress/components';\nimport { sprintf, __, _n } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function SaveButton() {\n\tconst { countUnsavedChanges, isDirty, isSaving, isSaveViewOpen } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t\tisSavingEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\t\treturn {\n\t\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t\t),\n\t\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t\t\tcountUnsavedChanges: dirtyEntityRecords.length,\n\t\t\t};\n\t\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst disabled = ! isDirty || isSaving;\n\n\tconst label = disabled ? __( 'Saved' ) : __( 'Save' );\n\n\treturn (\n\t\t<HStack className=\"edit-site-save-hub\" alignment=\"right\" spacing={ 4 }>\n\t\t\t{ isDirty && (\n\t\t\t\t<span>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %d: number of unsaved changes (number).\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d unsaved change',\n\t\t\t\t\t\t\t'%d unsaved changes',\n\t\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-save-hub__button\"\n\t\t\t\tvariant={ disabled ? undefined : 'primary' }\n\t\t\t\taria-disabled={ disabled }\n\t\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tonClick={\n\t\t\t\t\tdisabled ? undefined : () => setIsSaveViewOpened( true )\n\t\t\t\t}\n\t\t\t\tlabel={ label }\n\t\t\t\t/*\n\t\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t\t */\n\t\t\t\tshortcut={\n\t\t\t\t\tdisabled ? undefined : displayShortcut.primary( 's' )\n\t\t\t\t}\n\t\t\t\ticon={ disabled ? check : undefined }\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</Button>\n\t\t</HStack>\n\t);\n}\n"]}
@@ -17,16 +17,22 @@ var _sidebarNavigationScreenTemplates = _interopRequireDefault(require("../sideb
17
17
 
18
18
  var _sidebarNavigationScreenTemplate = _interopRequireDefault(require("../sidebar-navigation-screen-template"));
19
19
 
20
- var _useSyncPathWithUrl = _interopRequireDefault(require("../sync-state-with-url/use-sync-path-with-url"));
20
+ var _useSyncPathWithUrl = _interopRequireWildcard(require("../sync-state-with-url/use-sync-path-with-url"));
21
21
 
22
22
  var _sidebarNavigationScreenNavigationMenus = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-menus"));
23
23
 
24
24
  var _sidebarNavigationScreenTemplatesBrowse = _interopRequireDefault(require("../sidebar-navigation-screen-templates-browse"));
25
25
 
26
- var _saveButton = _interopRequireDefault(require("../save-button"));
26
+ var _saveHub = _interopRequireDefault(require("../save-hub"));
27
27
 
28
28
  var _sidebarNavigationScreenNavigationItem = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-item"));
29
29
 
30
+ var _routes = require("../routes");
31
+
32
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
+
34
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
35
+
30
36
  /**
31
37
  * WordPress dependencies
32
38
  */
@@ -52,12 +58,16 @@ function SidebarScreens() {
52
58
  }
53
59
 
54
60
  function Sidebar() {
61
+ const {
62
+ params: urlParams
63
+ } = (0, _routes.useLocation)();
64
+ const initialPath = (0, _element.useRef)((0, _useSyncPathWithUrl.getPathFromURL)(urlParams));
55
65
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalNavigatorProvider, {
56
66
  className: "edit-site-sidebar__content",
57
- initialPath: "/"
67
+ initialPath: initialPath.current
58
68
  }, (0, _element.createElement)(SidebarScreens, null)), (0, _element.createElement)("div", {
59
69
  className: "edit-site-sidebar__footer"
60
- }, (0, _element.createElement)(_saveButton.default, null)));
70
+ }, (0, _element.createElement)(_saveHub.default, null)));
61
71
  }
62
72
 
63
73
  var _default = (0, _element.memo)(Sidebar);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["SidebarScreens","Sidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAOA;AACA;AACA;AAUA,SAASA,cAAT,GAA0B;AACzB;AAEA,SACC,qDACC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,oCAAD,OADD,CADD,EAIC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAJD,EAOC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,8CAAD,OADD,CAPD,EAUC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,yCAAD,OADD,CAVD,EAaC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAbD,EAgBC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,wCAAD,OADD,CAhBD,CADD;AAsBA;;AAED,SAASC,OAAT,GAAmB;AAClB,SACC,qDACC,4BAAC,2CAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,WAAW,EAAC;AAFb,KAIC,4BAAC,cAAD,OAJD,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,mBAAD,OADD,CARD,CADD;AAcA;;eAEc,mBAAMA,OAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport useSyncPathWithURL from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveButton from '../save-button';\nimport SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t<SidebarNavigationScreenMain />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation\">\n\t\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation/:postType/:postId\">\n\t\t\t\t<SidebarNavigationScreenNavigationItem />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)\">\n\t\t\t\t<SidebarNavigationScreenTemplates />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/all\">\n\t\t\t\t<SidebarNavigationScreenTemplatesBrowse />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/:postId\">\n\t\t\t\t<SidebarNavigationScreenTemplate />\n\t\t\t</NavigatorScreen>\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath=\"/\"\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\n\t\t\t<div className=\"edit-site-sidebar__footer\">\n\t\t\t\t<SaveButton />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["SidebarScreens","Sidebar","params","urlParams","initialPath","current"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;AAtBA;AACA;AACA;;AAOA;AACA;AACA;AAaA,SAASA,cAAT,GAA0B;AACzB;AAEA,SACC,qDACC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,oCAAD,OADD,CADD,EAIC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAJD,EAOC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,8CAAD,OADD,CAPD,EAUC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,yCAAD,OADD,CAVD,EAaC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,+CAAD,OADD,CAbD,EAgBC,4BAAC,yCAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,4BAAC,wCAAD,OADD,CAhBD,CADD;AAsBA;;AAED,SAASC,OAAT,GAAmB;AAClB,QAAM;AAAEC,IAAAA,MAAM,EAAEC;AAAV,MAAwB,0BAA9B;AACA,QAAMC,WAAW,GAAG,qBAAQ,wCAAgBD,SAAhB,CAAR,CAApB;AAEA,SACC,qDACC,4BAAC,2CAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,WAAW,EAAGC,WAAW,CAACC;AAF3B,KAIC,4BAAC,cAAD,OAJD,CADD,EAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD,OADD,CAPD,CADD;AAaA;;eAEc,mBAAMJ,OAAN,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo, useRef } from '@wordpress/element';\nimport {\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport useSyncPathWithURL, {\n\tgetPathFromURL,\n} from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveHub from '../save-hub';\nimport SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';\nimport { useLocation } from '../routes';\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t<SidebarNavigationScreenMain />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation\">\n\t\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/navigation/:postType/:postId\">\n\t\t\t\t<SidebarNavigationScreenNavigationItem />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)\">\n\t\t\t\t<SidebarNavigationScreenTemplates />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/all\">\n\t\t\t\t<SidebarNavigationScreenTemplatesBrowse />\n\t\t\t</NavigatorScreen>\n\t\t\t<NavigatorScreen path=\"/:postType(wp_template|wp_template_part)/:postId\">\n\t\t\t\t<SidebarNavigationScreenTemplate />\n\t\t\t</NavigatorScreen>\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\tconst { params: urlParams } = useLocation();\n\tconst initialPath = useRef( getPathFromURL( urlParams ) );\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath={ initialPath.current }\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\t\t\t<div className=\"edit-site-sidebar__footer\">\n\t\t\t\t<SaveHub />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"]}
@@ -0,0 +1,30 @@
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 = SidebarButton;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _components = require("@wordpress/components");
17
+
18
+ /**
19
+ * External dependencies
20
+ */
21
+
22
+ /**
23
+ * WordPress dependencies
24
+ */
25
+ function SidebarButton(props) {
26
+ return (0, _element.createElement)(_components.Button, (0, _extends2.default)({}, props, {
27
+ className: (0, _classnames.default)('edit-site-sidebar-button', props.className)
28
+ }));
29
+ }
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-button/index.js"],"names":["SidebarButton","props","className"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AAC9C,SACC,4BAAC,kBAAD,6BACMA,KADN;AAEC,IAAA,SAAS,EAAG,yBACX,0BADW,EAEXA,KAAK,CAACC,SAFK;AAFb,KADD;AASA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\n\nexport default function SidebarButton( props ) {\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'edit-site-sidebar-button',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t/>\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
  });
@@ -19,6 +21,8 @@ var _store = require("../../store");
19
21
 
20
22
  var _privateApis = require("../../private-apis");
21
23
 
24
+ var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
25
+
22
26
  /**
23
27
  * WordPress dependencies
24
28
  */
@@ -31,7 +35,8 @@ function SidebarNavigationScreen(_ref) {
31
35
  isRoot,
32
36
  title,
33
37
  actions,
34
- content
38
+ content,
39
+ description
35
40
  } = _ref;
36
41
  const {
37
42
  dashboardLink
@@ -50,11 +55,10 @@ function SidebarNavigationScreen(_ref) {
50
55
  justify: "flex-start",
51
56
  className: "edit-site-sidebar-navigation-screen__title-icon"
52
57
  }, !isRoot ? (0, _element.createElement)(_components.__experimentalNavigatorToParentButton, {
53
- className: "edit-site-sidebar-navigation-screen__back",
58
+ as: _sidebarButton.default,
54
59
  icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
55
60
  "aria-label": (0, _i18n.__)('Back')
56
- }) : (0, _element.createElement)(_components.Button, {
57
- className: "edit-site-sidebar-navigation-screen__back",
61
+ }) : (0, _element.createElement)(_sidebarButton.default, {
58
62
  icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
59
63
  "aria-label": (0, _i18n.__)('Navigate to the Dashboard'),
60
64
  href: dashboardLink || 'index.php',
@@ -63,6 +67,8 @@ function SidebarNavigationScreen(_ref) {
63
67
  className: "edit-site-sidebar-navigation-screen__title"
64
68
  }, title), actions), (0, _element.createElement)("nav", {
65
69
  className: "edit-site-sidebar-navigation-screen__content"
66
- }, content));
70
+ }, description && (0, _element.createElement)("p", {
71
+ className: "edit-site-sidebar-navigation-screen__description"
72
+ }, description), content));
67
73
  }
68
74
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","isRoot","title","actions","content","dashboardLink","select","getSettings","editSiteStore","__experimentalDashboardLink","chevronRight","chevronLeft"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIe,SAASA,uBAAT,OAKX;AAAA,MAL6C;AAChDC,IAAAA,MADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,OAHgD;AAIhDC,IAAAA;AAJgD,GAK7C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoB,qBAAaC,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,QAAkB,yBAAQD,MAAM,CAAEE,YAAF,CAAd,CAAxB;AACA,WAAO;AACNH,MAAAA,aAAa,EAAEE,WAAW,GAAGE;AADvB,KAAP;AAGA,GALyB,EAKvB,EALuB,CAA1B;AAOA,SACC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,4BAAC,gCAAD;AACC,IAAA,OAAO,EAAG,CADX;AAEC,IAAA,OAAO,EAAC,YAFT;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAER,MAAF,GACD,4BAAC,iDAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAG,qBAAUS,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,MAAJ;AAHd,IADC,GAOD,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAG,qBAAUD,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,2BAAJ,CAHd;AAIC,IAAA,IAAI,EAAGN,aAAa,IAAI,WAJzB;AAKC,IAAA,KAAK,EAAG,cAAI,WAAJ;AALT,IAZF,EAoBC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGH,KADH,CApBD,EAuBGC,OAvBH,CADD,EA2BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,OADH,CA3BD,CADD;AAiCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n\tButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nexport default function SidebarNavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n} ) {\n\tconst { dashboardLink } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\treturn {\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<VStack spacing={ 2 }>\n\t\t\t<HStack\n\t\t\t\tspacing={ 4 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__title-icon\"\n\t\t\t>\n\t\t\t\t{ ! isRoot ? (\n\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Back' ) }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Navigate to the Dashboard' ) }\n\t\t\t\t\t\thref={ dashboardLink || 'index.php' }\n\t\t\t\t\t\tlabel={ __( 'Dashboard' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<h2 className=\"edit-site-sidebar-navigation-screen__title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\t\t\t\t{ actions }\n\t\t\t</HStack>\n\n\t\t\t<nav className=\"edit-site-sidebar-navigation-screen__content\">\n\t\t\t\t{ content }\n\t\t\t</nav>\n\t\t</VStack>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen/index.js"],"names":["SidebarNavigationScreen","isRoot","title","actions","content","description","dashboardLink","select","getSettings","editSiteStore","__experimentalDashboardLink","SidebarButton","chevronRight","chevronLeft"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,uBAAT,OAMX;AAAA,MAN6C;AAChDC,IAAAA,MADgD;AAEhDC,IAAAA,KAFgD;AAGhDC,IAAAA,OAHgD;AAIhDC,IAAAA,OAJgD;AAKhDC,IAAAA;AALgD,GAM7C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAoB,qBAAaC,MAAF,IAAc;AAClD,UAAM;AAAEC,MAAAA;AAAF,QAAkB,yBAAQD,MAAM,CAAEE,YAAF,CAAd,CAAxB;AACA,WAAO;AACNH,MAAAA,aAAa,EAAEE,WAAW,GAAGE;AADvB,KAAP;AAGA,GALyB,EAKvB,EALuB,CAA1B;AAOA,SACC,4BAAC,gCAAD;AAAQ,IAAA,OAAO,EAAG;AAAlB,KACC,4BAAC,gCAAD;AACC,IAAA,OAAO,EAAG,CADX;AAEC,IAAA,OAAO,EAAC,YAFT;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAET,MAAF,GACD,4BAAC,iDAAD;AACC,IAAA,EAAE,EAAGU,sBADN;AAEC,IAAA,IAAI,EAAG,qBAAUC,mBAAV,GAAyBC,kBAFjC;AAGC,kBAAa,cAAI,MAAJ;AAHd,IADC,GAOD,4BAAC,sBAAD;AACC,IAAA,IAAI,EAAG,qBAAUD,mBAAV,GAAyBC,kBADjC;AAEC,kBAAa,cAAI,2BAAJ,CAFd;AAGC,IAAA,IAAI,EAAGP,aAAa,IAAI,WAHzB;AAIC,IAAA,KAAK,EAAG,cAAI,WAAJ;AAJT,IAZF,EAmBC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGJ,KADH,CAnBD,EAsBGC,OAtBH,CADD,EA0BC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGE,WAAW,IACZ;AAAG,IAAA,SAAS,EAAC;AAAb,KACGA,WADH,CAFF,EAMGD,OANH,CA1BD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalNavigatorToParentButton as NavigatorToParentButton,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n\tdescription,\n} ) {\n\tconst { dashboardLink } = useSelect( ( select ) => {\n\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\treturn {\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<VStack spacing={ 2 }>\n\t\t\t<HStack\n\t\t\t\tspacing={ 4 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__title-icon\"\n\t\t\t>\n\t\t\t\t{ ! isRoot ? (\n\t\t\t\t\t<NavigatorToParentButton\n\t\t\t\t\t\tas={ SidebarButton }\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Back' ) }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\taria-label={ __( 'Navigate to the Dashboard' ) }\n\t\t\t\t\t\thref={ dashboardLink || 'index.php' }\n\t\t\t\t\t\tlabel={ __( 'Dashboard' ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<h2 className=\"edit-site-sidebar-navigation-screen__title\">\n\t\t\t\t\t{ title }\n\t\t\t\t</h2>\n\t\t\t\t{ actions }\n\t\t\t</HStack>\n\n\t\t\t<nav className=\"edit-site-sidebar-navigation-screen__content\">\n\t\t\t\t{ description && (\n\t\t\t\t\t<p className=\"edit-site-sidebar-navigation-screen__description\">\n\t\t\t\t\t\t{ description }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ content }\n\t\t\t</nav>\n\t\t</VStack>\n\t);\n}\n"]}
@@ -47,6 +47,7 @@ function SidebarNavigationScreenMain() {
47
47
  return (0, _element.createElement)(_sidebarNavigationScreen.default, {
48
48
  isRoot: true,
49
49
  title: (0, _i18n.__)('Design'),
50
+ description: (0, _i18n.__)('Customize the appearance of your website using the block editor.'),
50
51
  content: (0, _element.createElement)(_components.__experimentalItemGroup, null, !!navigationMenus && navigationMenus.length > 0 && (0, _element.createElement)(_components.__experimentalNavigatorButton, {
51
52
  as: _sidebarNavigationItem.default,
52
53
  path: "/navigation",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","navigationMenus","select","getEntityRecords","coreStore","per_page","status","length","SidebarNavigationItem","navigation","layout","symbolFilled"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIe,SAASA,2BAAT,GAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,WAAO;AACNH,MAAAA,eAAe,EAAEE,gBAAgB,CAAE,UAAF,EAAc,eAAd,EAA+B;AAC/DE,QAAAA,QAAQ,EAAE,CAAC,CADoD;AAE/DC,QAAAA,MAAM,EAAE;AAFuD,OAA/B;AAD3B,KAAP;AAMA,GAR2B,CAA5B;AAUA,SACC,4BAAC,gCAAD;AACC,IAAA,MAAM,MADP;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,OAAO,EACN,4BAAC,mCAAD,QACG,CAAC,CAAEL,eAAH,IAAsBA,eAAe,CAACM,MAAhB,GAAyB,CAA/C,IACD,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGC,8BADN;AAEC,MAAA,IAAI,EAAC,aAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGC;AAJR,OAMG,cAAI,YAAJ,CANH,CAFF,EAWC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGD,8BADN;AAEC,MAAA,IAAI,EAAC,cAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGE;AAJR,OAMG,cAAI,WAAJ,CANH,CAXD,EAmBC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGF,8BADN;AAEC,MAAA,IAAI,EAAC,mBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGG;AAJR,OAMG,cAAI,gBAAJ,CANH,CAnBD;AAJF,IADD;AAoCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalNavigatorButton as NavigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbolFilled, navigation } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nexport default function SidebarNavigationScreenMain() {\n\tconst { navigationMenus } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords } = select( coreStore );\n\t\treturn {\n\t\t\tnavigationMenus: getEntityRecords( 'postType', 'wp_navigation', {\n\t\t\t\tper_page: -1,\n\t\t\t\tstatus: 'publish',\n\t\t\t} ),\n\t\t};\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ !! navigationMenus && navigationMenus.length > 0 && (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\t\tpath=\"/navigation\"\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template_part\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbolFilled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template Parts' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-main/index.js"],"names":["SidebarNavigationScreenMain","navigationMenus","select","getEntityRecords","coreStore","per_page","status","length","SidebarNavigationItem","navigation","layout","symbolFilled"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAUA;AACA;AACA;AAIe,SAASA,2BAAT,GAAuC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,WAAO;AACNH,MAAAA,eAAe,EAAEE,gBAAgB,CAAE,UAAF,EAAc,eAAd,EAA+B;AAC/DE,QAAAA,QAAQ,EAAE,CAAC,CADoD;AAE/DC,QAAAA,MAAM,EAAE;AAFuD,OAA/B;AAD3B,KAAP;AAMA,GAR2B,CAA5B;AAUA,SACC,4BAAC,gCAAD;AACC,IAAA,MAAM,MADP;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,WAAW,EAAG,cACb,kEADa,CAHf;AAMC,IAAA,OAAO,EACN,4BAAC,mCAAD,QACG,CAAC,CAAEL,eAAH,IAAsBA,eAAe,CAACM,MAAhB,GAAyB,CAA/C,IACD,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGC,8BADN;AAEC,MAAA,IAAI,EAAC,aAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGC;AAJR,OAMG,cAAI,YAAJ,CANH,CAFF,EAWC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGD,8BADN;AAEC,MAAA,IAAI,EAAC,cAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGE;AAJR,OAMG,cAAI,WAAJ,CANH,CAXD,EAmBC,4BAAC,yCAAD;AACC,MAAA,EAAE,EAAGF,8BADN;AAEC,MAAA,IAAI,EAAC,mBAFN;AAGC,MAAA,WAAW,MAHZ;AAIC,MAAA,IAAI,EAAGG;AAJR,OAMG,cAAI,gBAAJ,CANH,CAnBD;AAPF,IADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalNavigatorButton as NavigatorButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { layout, symbolFilled, navigation } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nexport default function SidebarNavigationScreenMain() {\n\tconst { navigationMenus } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords } = select( coreStore );\n\t\treturn {\n\t\t\tnavigationMenus: getEntityRecords( 'postType', 'wp_navigation', {\n\t\t\t\tper_page: -1,\n\t\t\t\tstatus: 'publish',\n\t\t\t} ),\n\t\t};\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\tisRoot\n\t\t\ttitle={ __( 'Design' ) }\n\t\t\tdescription={ __(\n\t\t\t\t'Customize the appearance of your website using the block editor.'\n\t\t\t) }\n\t\t\tcontent={\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ !! navigationMenus && navigationMenus.length > 0 && (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\t\tpath=\"/navigation\"\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t\ticon={ navigation }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Navigation' ) }\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) }\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Templates' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\tas={ SidebarNavigationItem }\n\t\t\t\t\t\tpath=\"/wp_template_part\"\n\t\t\t\t\t\twithChevron\n\t\t\t\t\t\ticon={ symbolFilled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Template Parts' ) }\n\t\t\t\t\t</NavigatorButton>\n\t\t\t\t</ItemGroup>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -19,12 +19,16 @@ var _coreData = require("@wordpress/core-data");
19
19
 
20
20
  var _htmlEntities = require("@wordpress/html-entities");
21
21
 
22
+ var _icons = require("@wordpress/icons");
23
+
22
24
  var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
23
25
 
24
26
  var _privateApis = require("../../private-apis");
25
27
 
26
28
  var _store = require("../../store");
27
29
 
30
+ var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
31
+
28
32
  /**
29
33
  * WordPress dependencies
30
34
  */
@@ -33,7 +37,7 @@ var _store = require("../../store");
33
37
  * Internal dependencies
34
38
  */
35
39
  function SidebarNavigationScreenNavigationItem() {
36
- var _post$title, _post$description;
40
+ var _record$title, _record$description;
37
41
 
38
42
  const {
39
43
  setCanvasMode
@@ -45,24 +49,20 @@ function SidebarNavigationScreenNavigationItem() {
45
49
  }
46
50
  } = (0, _components.__experimentalUseNavigator)();
47
51
  const {
48
- post
49
- } = (0, _data.useSelect)(select => {
50
- const {
51
- getEntityRecord
52
- } = select(_coreData.store); // The currently selected entity to display.
53
- // Typically template or template part in the site editor.
54
-
55
- return {
56
- post: postId && postType ? getEntityRecord('postType', postType, postId) : null
57
- };
58
- }, [postType, postId]);
52
+ record
53
+ } = (0, _coreData.useEntityRecord)('postType', postType, postId);
59
54
  return (0, _element.createElement)(_sidebarNavigationScreen.default, {
60
- title: post ? (0, _htmlEntities.decodeEntities)(post === null || post === void 0 ? void 0 : (_post$title = post.title) === null || _post$title === void 0 ? void 0 : _post$title.rendered) : null,
61
- actions: (0, _element.createElement)(_components.Button, {
62
- variant: "primary",
63
- onClick: () => setCanvasMode('edit')
64
- }, (0, _i18n.__)('Edit')),
65
- content: post ? (0, _htmlEntities.decodeEntities)(post === null || post === void 0 ? void 0 : (_post$description = post.description) === null || _post$description === void 0 ? void 0 : _post$description.rendered) : null
55
+ title: record ? (0, _htmlEntities.decodeEntities)(record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) : null,
56
+ actions: (0, _element.createElement)(_sidebarButton.default, {
57
+ onClick: () => setCanvasMode('edit'),
58
+ label: (0, _i18n.__)('Edit'),
59
+ icon: _icons.pencil
60
+ }),
61
+ description: postType === 'page' ? (0, _i18n.__)('Pages are static and are not listed by date. Pages do not use tags or categories.') : (0, _i18n.__)('Posts are entries listed in reverse chronological order on the site homepage or on the posts page.'),
62
+ content: (0, _element.createElement)(_element.Fragment, null, record !== null && record !== void 0 && record.link ? (0, _element.createElement)(_components.ExternalLink, {
63
+ className: "edit-site-sidebar-navigation-screen__page-link",
64
+ href: record.link
65
+ }, record.link) : null, record ? (0, _htmlEntities.decodeEntities)(record === null || record === void 0 ? void 0 : (_record$description = record.description) === null || _record$description === void 0 ? void 0 : _record$description.rendered) : null)
66
66
  });
67
67
  }
68
68
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","params","postType","postId","post","select","getEntityRecord","coreStore","title","rendered","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,qCAAT,GAAiD;AAAA;;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AADH,MAEF,6CAFJ;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAW,qBACdC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,eAAF,CAAlC,CADa,CAGb;AACA;;AACA,WAAO;AACNH,MAAAA,IAAI,EACHD,MAAM,IAAID,QAAV,GACGI,eAAe,CAAE,UAAF,EAAcJ,QAAd,EAAwBC,MAAxB,CADlB,GAEG;AAJE,KAAP;AAMA,GAZe,EAahB,CAAED,QAAF,EAAYC,MAAZ,CAbgB,CAAjB;AAgBA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGC,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,sCAAgBA,IAAI,CAAEI,KAAtB,gDAAgB,YAAaC,QAA7B,CAAH,GAA6C,IAD1D;AAEC,IAAA,OAAO,EACN,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAMV,aAAa,CAAE,MAAF;AAF9B,OAIG,cAAI,MAAJ,CAJH,CAHF;AAUC,IAAA,OAAO,EACNK,IAAI,GAAG,kCAAgBA,IAAhB,aAAgBA,IAAhB,4CAAgBA,IAAI,CAAEM,WAAtB,sDAAgB,kBAAmBD,QAAnC,CAAH,GAAmD;AAXzD,IADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalUseNavigator as useNavigator,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nexport default function SidebarNavigationScreenNavigationItem() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst {\n\t\tparams: { postType, postId },\n\t} = useNavigator();\n\n\tconst { post } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\n\t\t\t// The currently selected entity to display.\n\t\t\t// Typically template or template part in the site editor.\n\t\t\treturn {\n\t\t\t\tpost:\n\t\t\t\t\tpostId && postType\n\t\t\t\t\t\t? getEntityRecord( 'postType', postType, postId )\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ post ? decodeEntities( post?.title?.rendered ) : null }\n\t\t\tactions={\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Edit' ) }\n\t\t\t\t</Button>\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\tpost ? decodeEntities( post?.description?.rendered ) : null\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-item/index.js"],"names":["SidebarNavigationScreenNavigationItem","setCanvasMode","editSiteStore","params","postType","postId","record","title","rendered","pencil","link","description"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAWA;AACA;AACA;AAMe,SAASA,qCAAT,GAAiD;AAAA;;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaC,YAAb,CAAR,CAA1B;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ;AADH,MAEF,6CAFJ;AAGA,QAAM;AAAEC,IAAAA;AAAF,MAAa,+BAAiB,UAAjB,EAA6BF,QAA7B,EAAuCC,MAAvC,CAAnB;AAEA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGC,MAAM,GAAG,kCAAgBA,MAAhB,aAAgBA,MAAhB,wCAAgBA,MAAM,CAAEC,KAAxB,kDAAgB,cAAeC,QAA/B,CAAH,GAA+C,IAD9D;AAEC,IAAA,OAAO,EACN,4BAAC,sBAAD;AACC,MAAA,OAAO,EAAG,MAAMP,aAAa,CAAE,MAAF,CAD9B;AAEC,MAAA,KAAK,EAAG,cAAI,MAAJ,CAFT;AAGC,MAAA,IAAI,EAAGQ;AAHR,MAHF;AASC,IAAA,WAAW,EACVL,QAAQ,KAAK,MAAb,GACG,cACA,mFADA,CADH,GAIG,cACA,oGADA,CAdL;AAkBC,IAAA,OAAO,EACN,qDACGE,MAAM,SAAN,IAAAA,MAAM,WAAN,IAAAA,MAAM,CAAEI,IAAR,GACD,4BAAC,wBAAD;AACC,MAAA,SAAS,EAAC,gDADX;AAEC,MAAA,IAAI,EAAGJ,MAAM,CAACI;AAFf,OAIGJ,MAAM,CAACI,IAJV,CADC,GAOE,IARL,EASGJ,MAAM,GACL,kCAAgBA,MAAhB,aAAgBA,MAAhB,8CAAgBA,MAAM,CAAEK,WAAxB,wDAAgB,oBAAqBH,QAArC,CADK,GAEL,IAXJ;AAnBF,IADD;AAoCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport {\n\t__experimentalUseNavigator as useNavigator,\n\tExternalLink,\n} from '@wordpress/components';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { pencil } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\nimport SidebarButton from '../sidebar-button';\n\nexport default function SidebarNavigationScreenNavigationItem() {\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst {\n\t\tparams: { postType, postId },\n\t} = useNavigator();\n\tconst { record } = useEntityRecord( 'postType', postType, postId );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ record ? decodeEntities( record?.title?.rendered ) : null }\n\t\t\tactions={\n\t\t\t\t<SidebarButton\n\t\t\t\t\tonClick={ () => setCanvasMode( 'edit' ) }\n\t\t\t\t\tlabel={ __( 'Edit' ) }\n\t\t\t\t\ticon={ pencil }\n\t\t\t\t/>\n\t\t\t}\n\t\t\tdescription={\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Pages are static and are not listed by date. Pages do not use tags or categories.'\n\t\t\t\t\t )\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'Posts are entries listed in reverse chronological order on the site homepage or on the posts page.'\n\t\t\t\t\t )\n\t\t\t}\n\t\t\tcontent={\n\t\t\t\t<>\n\t\t\t\t\t{ record?.link ? (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__page-link\"\n\t\t\t\t\t\t\thref={ record.link }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ record.link }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) : null }\n\t\t\t\t\t{ record\n\t\t\t\t\t\t? decodeEntities( record?.description?.rendered )\n\t\t\t\t\t\t: null }\n\t\t\t\t</>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -11,12 +11,28 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _i18n = require("@wordpress/i18n");
13
13
 
14
- var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
14
+ var _data = require("@wordpress/data");
15
+
16
+ var _coreData = require("@wordpress/core-data");
17
+
18
+ var _blockEditor = require("@wordpress/block-editor");
15
19
 
16
- var _navigationInspector = _interopRequireDefault(require("../navigation-inspector"));
20
+ var _blocks = require("@wordpress/blocks");
21
+
22
+ var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
17
23
 
18
24
  var _routes = require("../routes");
19
25
 
26
+ var _navigationMenuContent = _interopRequireDefault(require("./navigation-menu-content"));
27
+
28
+ var _sidebarButton = _interopRequireDefault(require("../sidebar-button"));
29
+
30
+ var _loader = require("./loader");
31
+
32
+ var _privateApis = require("../../private-apis");
33
+
34
+ var _store = require("../../store");
35
+
20
36
  /**
21
37
  * WordPress dependencies
22
38
  */
@@ -24,11 +40,69 @@ var _routes = require("../routes");
24
40
  /**
25
41
  * Internal dependencies
26
42
  */
43
+ const noop = () => {};
44
+
45
+ const NAVIGATION_MENUS_QUERY = {
46
+ per_page: -1,
47
+ status: 'publish'
48
+ };
49
+
50
+ function SidebarNavigationScreenWrapper(_ref) {
51
+ let {
52
+ children,
53
+ actions
54
+ } = _ref;
55
+ return (0, _element.createElement)(_sidebarNavigationScreen.default, {
56
+ title: (0, _i18n.__)('Navigation'),
57
+ actions: actions,
58
+ description: (0, _i18n.__)('Browse your site, edit pages, and manage your primary navigation menu.'),
59
+ content: children
60
+ });
61
+ }
62
+
63
+ const prioritizedInserterBlocks = ['core/navigation-link/page', 'core/navigation-link'];
64
+
27
65
  function SidebarNavigationScreenNavigationMenus() {
66
+ var _orderedNavigationMen;
67
+
28
68
  const history = (0, _routes.useHistory)();
69
+ const {
70
+ navigationMenus,
71
+ hasResolvedNavigationMenus,
72
+ storedSettings
73
+ } = (0, _data.useSelect)(select => {
74
+ const {
75
+ getSettings
76
+ } = (0, _privateApis.unlock)(select(_store.store));
77
+ const {
78
+ getEntityRecords,
79
+ hasFinishedResolution
80
+ } = select(_coreData.store);
81
+ const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY];
82
+ return {
83
+ storedSettings: getSettings(false),
84
+ navigationMenus: getEntityRecords(...navigationMenusQuery),
85
+ hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
86
+ };
87
+ }, []); // Sort navigation menus by date.
88
+
89
+ const orderedNavigationMenus = (0, _element.useMemo)(() => navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.sort((menuA, menuB) => {
90
+ const menuADate = new Date(menuA.date);
91
+ const menuBDate = new Date(menuB.date);
92
+ return menuADate.getTime() > menuBDate.getTime();
93
+ }), [navigationMenus]);
94
+ const firstNavigationMenu = orderedNavigationMenus === null || orderedNavigationMenus === void 0 ? void 0 : (_orderedNavigationMen = orderedNavigationMenus[0]) === null || _orderedNavigationMen === void 0 ? void 0 : _orderedNavigationMen.id;
95
+ const blocks = (0, _element.useMemo)(() => {
96
+ return [(0, _blocks.createBlock)('core/navigation', {
97
+ ref: firstNavigationMenu
98
+ })];
99
+ }, [firstNavigationMenu]);
100
+ const isLoading = !hasResolvedNavigationMenus;
101
+ const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
29
102
  const onSelect = (0, _element.useCallback)(selectedBlock => {
30
103
  const {
31
- attributes
104
+ attributes,
105
+ name
32
106
  } = selectedBlock;
33
107
 
34
108
  if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) {
@@ -37,14 +111,68 @@ function SidebarNavigationScreenNavigationMenus() {
37
111
  postId: attributes.id
38
112
  });
39
113
  }
114
+
115
+ if (name === 'core/page-list-item' && attributes.id && history) {
116
+ history.push({
117
+ postType: 'page',
118
+ postId: attributes.id
119
+ });
120
+ }
40
121
  }, [history]);
41
- return (0, _element.createElement)(_sidebarNavigationScreen.default, {
42
- title: (0, _i18n.__)('Navigation'),
43
- content: (0, _element.createElement)("div", {
44
- className: "edit-site-sidebar-navigation-screen-navigation-menus"
45
- }, (0, _element.createElement)(_navigationInspector.default, {
46
- onSelect: onSelect
47
- }))
48
- });
122
+ const orderInitialBlockItems = (0, _element.useCallback)(items => {
123
+ items.sort((_ref2, _ref3) => {
124
+ let {
125
+ id: aName
126
+ } = _ref2;
127
+ let {
128
+ id: bName
129
+ } = _ref3;
130
+ // Sort block items according to `prioritizedInserterBlocks`.
131
+ let aIndex = prioritizedInserterBlocks.indexOf(aName);
132
+ let bIndex = prioritizedInserterBlocks.indexOf(bName); // All other block items should come after that.
133
+
134
+ if (aIndex < 0) aIndex = prioritizedInserterBlocks.length;
135
+ if (bIndex < 0) bIndex = prioritizedInserterBlocks.length;
136
+ return aIndex - bIndex;
137
+ });
138
+ return items;
139
+ }, []);
140
+
141
+ if (hasResolvedNavigationMenus && !hasNavigationMenus) {
142
+ return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _i18n.__)('There are no Navigation Menus.'));
143
+ }
144
+
145
+ if (!hasResolvedNavigationMenus || isLoading) {
146
+ return (0, _element.createElement)(SidebarNavigationScreenWrapper, null, (0, _element.createElement)(_loader.NavigationMenuLoader, null));
147
+ }
148
+
149
+ const {
150
+ PrivateInserter
151
+ } = (0, _privateApis.unlock)(_blockEditor.privateApis);
152
+ return (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
153
+ settings: storedSettings,
154
+ value: blocks,
155
+ onChange: noop,
156
+ onInput: noop
157
+ }, (0, _element.createElement)(SidebarNavigationScreenWrapper, {
158
+ actions: (0, _element.createElement)(PrivateInserter, {
159
+ rootClientId: blocks[0].clientId,
160
+ position: "bottom right",
161
+ isAppender: true,
162
+ selectBlockOnInsert: false,
163
+ shouldDirectInsert: false,
164
+ __experimentalIsQuick: true,
165
+ toggleProps: {
166
+ as: _sidebarButton.default,
167
+ label: (0, _i18n.__)('Add menu item')
168
+ },
169
+ orderInitialBlockItems: orderInitialBlockItems
170
+ })
171
+ }, (0, _element.createElement)("div", {
172
+ className: "edit-site-sidebar-navigation-screen-navigation-menus__content"
173
+ }, (0, _element.createElement)(_navigationMenuContent.default, {
174
+ rootClientId: blocks[0].clientId,
175
+ onSelect: onSelect
176
+ }))));
49
177
  }
50
178
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["SidebarNavigationScreenNavigationMenus","history","onSelect","selectedBlock","attributes","kind","id","type","push","postType","postId"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,sCAAT,GAAkD;AAChE,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAMC,QAAQ,GAAG,0BACdC,aAAF,IAAqB;AACpB,UAAM;AAAEC,MAAAA;AAAF,QAAiBD,aAAvB;;AACA,QACCC,UAAU,CAACC,IAAX,KAAoB,WAApB,IACAD,UAAU,CAACE,EADX,IAEAF,UAAU,CAACG,IAFX,IAGAN,OAJD,EAKE;AACDA,MAAAA,OAAO,CAACO,IAAR,CAAc;AACbC,QAAAA,QAAQ,EAAEL,UAAU,CAACG,IADR;AAEbG,QAAAA,MAAM,EAAEN,UAAU,CAACE;AAFN,OAAd;AAIA;AACD,GAde,EAehB,CAAEL,OAAF,CAfgB,CAAjB;AAiBA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAG,cAAI,YAAJ,CADT;AAEC,IAAA,OAAO,EACN;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,4BAAD;AAAqB,MAAA,QAAQ,EAAGC;AAAhC,MADD;AAHF,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport NavigationInspector from '../navigation-inspector';\nimport { useHistory } from '../routes';\n\nexport default function SidebarNavigationScreenNavigationMenus() {\n\tconst history = useHistory();\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Navigation' ) }\n\t\t\tcontent={\n\t\t\t\t<div className=\"edit-site-sidebar-navigation-screen-navigation-menus\">\n\t\t\t\t\t<NavigationInspector onSelect={ onSelect } />\n\t\t\t\t</div>\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js"],"names":["noop","NAVIGATION_MENUS_QUERY","per_page","status","SidebarNavigationScreenWrapper","children","actions","prioritizedInserterBlocks","SidebarNavigationScreenNavigationMenus","history","navigationMenus","hasResolvedNavigationMenus","storedSettings","select","getSettings","editSiteStore","getEntityRecords","hasFinishedResolution","coreStore","navigationMenusQuery","orderedNavigationMenus","sort","menuA","menuB","menuADate","Date","date","menuBDate","getTime","firstNavigationMenu","id","blocks","ref","isLoading","hasNavigationMenus","length","onSelect","selectedBlock","attributes","name","kind","type","push","postType","postId","orderInitialBlockItems","items","aName","bName","aIndex","indexOf","bIndex","PrivateInserter","blockEditorPrivateApis","clientId","as","SidebarButton","label"],"mappings":"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","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 {\n\tBlockEditorProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport { useHistory } from '../routes';\nimport NavigationMenuContent from './navigation-menu-content';\nimport SidebarButton from '../sidebar-button';\nimport { NavigationMenuLoader } from './loader';\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\nconst noop = () => {};\nconst NAVIGATION_MENUS_QUERY = { per_page: -1, status: 'publish' };\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\nconst prioritizedInserterBlocks = [\n\t'core/navigation-link/page',\n\t'core/navigation-link',\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\t// Sort navigation menus by date.\n\tconst orderedNavigationMenus = useMemo(\n\t\t() =>\n\t\t\tnavigationMenus?.sort( ( menuA, menuB ) => {\n\t\t\t\tconst menuADate = new Date( menuA.date );\n\t\t\t\tconst menuBDate = new Date( menuB.date );\n\t\t\t\treturn menuADate.getTime() > menuBDate.getTime();\n\t\t\t} ),\n\t\t[ navigationMenus ]\n\t);\n\tconst firstNavigationMenu = orderedNavigationMenus?.[ 0 ]?.id;\n\tconst blocks = useMemo( () => {\n\t\treturn [\n\t\t\tcreateBlock( 'core/navigation', { ref: firstNavigationMenu } ),\n\t\t];\n\t}, [ firstNavigationMenu ] );\n\n\tconst isLoading = ! hasResolvedNavigationMenus;\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\tconst onSelect = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: 'page',\n\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\tconst orderInitialBlockItems = useCallback( ( items ) => {\n\t\titems.sort( ( { id: aName }, { id: bName } ) => {\n\t\t\t// Sort block items according to `prioritizedInserterBlocks`.\n\t\t\tlet aIndex = prioritizedInserterBlocks.indexOf( aName );\n\t\t\tlet bIndex = prioritizedInserterBlocks.indexOf( bName );\n\t\t\t// All other block items should come after that.\n\t\t\tif ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;\n\t\t\tif ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;\n\t\t\treturn aIndex - bIndex;\n\t\t} );\n\t\treturn items;\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\tconst { PrivateInserter } = unlock( blockEditorPrivateApis );\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\tactions={\n\t\t\t\t\t<PrivateInserter\n\t\t\t\t\t\trootClientId={ blocks[ 0 ].clientId }\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\tisAppender\n\t\t\t\t\t\tselectBlockOnInsert={ false }\n\t\t\t\t\t\tshouldDirectInsert={ false }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\tas: SidebarButton,\n\t\t\t\t\t\t\tlabel: __( 'Add menu item' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t\torderInitialBlockItems={ orderInitialBlockItems }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\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"]}