@wordpress/edit-site 3.0.17 → 3.0.20

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 (126) hide show
  1. package/build/components/block-editor/index.js +1 -1
  2. package/build/components/block-editor/index.js.map +1 -1
  3. package/build/components/block-editor/resizable-editor.js +37 -7
  4. package/build/components/block-editor/resizable-editor.js.map +1 -1
  5. package/build/components/global-styles/gradients-palette-panel.js +7 -3
  6. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  7. package/build/components/list/added-by.js +9 -3
  8. package/build/components/list/added-by.js.map +1 -1
  9. package/build/components/navigation-sidebar/navigation-panel/constants.js +1 -11
  10. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  11. package/build/components/navigation-sidebar/navigation-toggle/index.js +11 -0
  12. package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  13. package/build/plugins/site-export.js +8 -2
  14. package/build/plugins/site-export.js.map +1 -1
  15. package/build-module/components/block-editor/index.js +2 -2
  16. package/build-module/components/block-editor/index.js.map +1 -1
  17. package/build-module/components/block-editor/resizable-editor.js +37 -7
  18. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  19. package/build-module/components/global-styles/gradients-palette-panel.js +5 -4
  20. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  21. package/build-module/components/list/added-by.js +10 -4
  22. package/build-module/components/list/added-by.js.map +1 -1
  23. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -5
  24. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  25. package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -0
  26. package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
  27. package/build-module/plugins/site-export.js +9 -3
  28. package/build-module/plugins/site-export.js.map +1 -1
  29. package/build-style/style-rtl.css +13 -3
  30. package/build-style/style.css +13 -3
  31. package/package.json +17 -17
  32. package/src/components/block-editor/index.js +2 -2
  33. package/src/components/block-editor/resizable-editor.js +52 -12
  34. package/src/components/global-styles/gradients-palette-panel.js +4 -4
  35. package/src/components/global-styles/style.scss +8 -1
  36. package/src/components/global-styles/test/use-global-styles-output.js +7 -1
  37. package/src/components/list/added-by.js +25 -9
  38. package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
  39. package/src/components/navigation-sidebar/navigation-toggle/index.js +14 -0
  40. package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
  41. package/src/plugins/site-export.js +7 -3
  42. package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -101
  43. package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
  44. package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -82
  45. package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
  46. package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -82
  47. package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
  48. package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -107
  49. package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
  50. package/build/components/navigation-sidebar/navigation-panel/menus/index.js +0 -57
  51. package/build/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
  52. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -48
  53. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
  54. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -100
  55. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
  56. package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -62
  57. package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
  58. package/build/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -143
  59. package/build/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
  60. package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -76
  61. package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
  62. package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -125
  63. package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
  64. package/build/components/navigation-sidebar/navigation-panel/search-results.js +0 -132
  65. package/build/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
  66. package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -86
  67. package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
  68. package/build/components/navigation-sidebar/navigation-panel/template-preview.js +0 -46
  69. package/build/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
  70. package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
  71. package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
  72. package/build/components/navigation-sidebar/navigation-panel/utils.js +0 -21
  73. package/build/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
  74. package/build/utils/get-closest-available-template.js +0 -48
  75. package/build/utils/get-closest-available-template.js.map +0 -1
  76. package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -86
  77. package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
  78. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -65
  79. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
  80. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -65
  81. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
  82. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -90
  83. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
  84. package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js +0 -40
  85. package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
  86. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -35
  87. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
  88. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -84
  89. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
  90. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -50
  91. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
  92. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -124
  93. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
  94. package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -65
  95. package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
  96. package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -106
  97. package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
  98. package/build-module/components/navigation-sidebar/navigation-panel/search-results.js +0 -116
  99. package/build-module/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
  100. package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -71
  101. package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
  102. package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js +0 -38
  103. package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
  104. package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -37
  105. package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
  106. package/build-module/components/navigation-sidebar/navigation-panel/utils.js +0 -8
  107. package/build-module/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
  108. package/build-module/utils/get-closest-available-template.js +0 -40
  109. package/build-module/utils/get-closest-available-template.js.map +0 -1
  110. package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -89
  111. package/src/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -85
  112. package/src/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -85
  113. package/src/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -117
  114. package/src/components/navigation-sidebar/navigation-panel/menus/index.js +0 -61
  115. package/src/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -34
  116. package/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -94
  117. package/src/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -42
  118. package/src/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -147
  119. package/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -53
  120. package/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -110
  121. package/src/components/navigation-sidebar/navigation-panel/search-results.js +0 -117
  122. package/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -83
  123. package/src/components/navigation-sidebar/navigation-panel/template-preview.js +0 -32
  124. package/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
  125. package/src/components/navigation-sidebar/navigation-panel/utils.js +0 -11
  126. package/src/utils/get-closest-available-template.js +0 -31
@@ -57,22 +57,49 @@ function ResizableEditor( { enableResizing, settings, ...props } ) {
57
57
  return;
58
58
  }
59
59
 
60
- const resizeObserver = new iframe.contentWindow.ResizeObserver(
61
- () => {
62
- setHeight(
63
- iframe.contentDocument.querySelector(
64
- `.edit-site-block-editor__block-list`
65
- ).offsetHeight
60
+ let animationFrame = null;
61
+
62
+ function resizeHeight() {
63
+ if ( ! animationFrame ) {
64
+ // Throttle the updates on animation frame.
65
+ animationFrame = iframe.contentWindow.requestAnimationFrame(
66
+ () => {
67
+ setHeight(
68
+ iframe.contentDocument.documentElement
69
+ .scrollHeight
70
+ );
71
+ animationFrame = null;
72
+ }
66
73
  );
67
74
  }
68
- );
75
+ }
76
+
77
+ let resizeObserver;
78
+
79
+ function registerObserver() {
80
+ resizeObserver?.disconnect();
81
+
82
+ resizeObserver = new iframe.contentWindow.ResizeObserver(
83
+ resizeHeight
84
+ );
85
+ // Observing the <html> rather than the <body> because the latter
86
+ // gets destroyed and remounted after initialization in <Iframe>.
87
+ resizeObserver.observe(
88
+ iframe.contentDocument.documentElement
89
+ );
90
+
91
+ resizeHeight();
92
+ }
69
93
 
70
- // Observing the <html> rather than the <body> because the latter
71
- // gets destroyed and remounted after initialization in <Iframe>.
72
- resizeObserver.observe( iframe.contentDocument.documentElement );
94
+ // This is only required in Firefox for some unknown reasons.
95
+ iframe.addEventListener( 'load', registerObserver );
96
+ // This is required in Chrome and Safari.
97
+ registerObserver();
73
98
 
74
99
  return () => {
75
- resizeObserver.disconnect();
100
+ iframe.contentWindow?.cancelAnimationFrame( animationFrame );
101
+ resizeObserver?.disconnect();
102
+ iframe.removeEventListener( 'load', registerObserver );
76
103
  };
77
104
  },
78
105
  [ enableResizing ]
@@ -133,8 +160,21 @@ function ResizableEditor( { enableResizing, settings, ...props } ) {
133
160
  <style>{
134
161
  // Forming a "block formatting context" to prevent margin collapsing.
135
162
  // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
136
- `.edit-site-block-editor__block-list { display: flow-root; }`
163
+ `.is-root-container { display: flow-root; }`
137
164
  }</style>
165
+ { enableResizing && (
166
+ <style>
167
+ {
168
+ // Force the <html> and <body>'s heights to fit the content.
169
+ `html, body { height: -moz-fit-content !important; height: fit-content !important; min-height: 0 !important; }`
170
+ }
171
+ {
172
+ // Some themes will have `min-height: 100vh` for the root container,
173
+ // which isn't a requirement in auto resize mode.
174
+ `.is-root-container { min-height: 0 !important; }`
175
+ }
176
+ </style>
177
+ ) }
138
178
  </>
139
179
  }
140
180
  ref={ ref }
@@ -9,8 +9,8 @@ import { noop } from 'lodash';
9
9
  import {
10
10
  __experimentalVStack as VStack,
11
11
  __experimentalPaletteEdit as PaletteEdit,
12
+ __experimentalSpacer as Spacer,
12
13
  DuotonePicker,
13
- __experimentalHeading as Heading,
14
14
  } from '@wordpress/components';
15
15
  import { __ } from '@wordpress/i18n';
16
16
 
@@ -18,6 +18,7 @@ import { __ } from '@wordpress/i18n';
18
18
  * Internal dependencies
19
19
  */
20
20
  import { useSetting } from './hooks';
21
+ import Subtitle from './subtitle';
21
22
 
22
23
  export default function GradientPalettePanel( { name } ) {
23
24
  const [ themeGradients, setThemeGradients ] = useSetting(
@@ -83,9 +84,8 @@ export default function GradientPalettePanel( { name } ) {
83
84
  slugPrefix="custom-"
84
85
  />
85
86
  <div>
86
- <Heading className="edit-site-global-styles-gradient-palette-panel__duotone-heading">
87
- { __( 'Duotone' ) }
88
- </Heading>
87
+ <Subtitle>{ __( 'Duotone' ) }</Subtitle>
88
+ <Spacer margin={ 3 } />
89
89
  <DuotonePicker
90
90
  duotonePalette={ duotonePalette }
91
91
  disableCustomDuotone={ true }
@@ -64,7 +64,8 @@
64
64
  // Need to override the too specific styles for complementary areas.
65
65
  margin-bottom: 0 !important;
66
66
  text-transform: uppercase;
67
- font-weight: 500;
67
+ font-weight: 500 !important;
68
+ font-size: 11px !important;
68
69
  }
69
70
 
70
71
  .edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle {
@@ -83,3 +84,9 @@ h2.edit-site-global-styles-gradient-palette-panel__duotone-heading.components-he
83
84
  font-size: 11px;
84
85
  margin-bottom: $grid-unit-10;
85
86
  }
87
+
88
+ .edit-site-screen-text-color__control,
89
+ .edit-site-screen-link-color__control,
90
+ .edit-site-screen-background-color__control {
91
+ padding: $grid-unit-20;
92
+ }
@@ -217,10 +217,16 @@ describe( 'global styles renderer', () => {
217
217
  slug: 'black',
218
218
  color: 'black',
219
219
  },
220
+ {
221
+ name: 'White to Black',
222
+ slug: 'white2black',
223
+ color: 'value',
224
+ },
220
225
  ],
221
226
  },
222
227
  },
223
228
  custom: {
229
+ white2black: 'value',
224
230
  'font-primary': 'value',
225
231
  'line-height': {
226
232
  body: 1.7,
@@ -257,7 +263,7 @@ describe( 'global styles renderer', () => {
257
263
  };
258
264
 
259
265
  expect( toCustomProperties( tree, blockSelectors ) ).toEqual(
260
- 'body{--wp--preset--color--white: white;--wp--preset--color--black: black;--wp--custom--font-primary: value;--wp--custom--line-height--body: 1.7;--wp--custom--line-height--heading: 1.3;}h1,h2,h3,h4,h5,h6{--wp--preset--font-size--small: 12px;--wp--preset--font-size--medium: 23px;}'
266
+ 'body{--wp--preset--color--white: white;--wp--preset--color--black: black;--wp--preset--color--white-2-black: value;--wp--custom--white-2-black: value;--wp--custom--font-primary: value;--wp--custom--line-height--body: 1.7;--wp--custom--line-height--heading: 1.3;}h1,h2,h3,h4,h5,h6{--wp--preset--font-size--small: 12px;--wp--preset--font-size--medium: 23px;}'
261
267
  );
262
268
  } );
263
269
  } );
@@ -14,7 +14,11 @@ import {
14
14
  import { store as coreStore } from '@wordpress/core-data';
15
15
  import { useSelect } from '@wordpress/data';
16
16
  import { useState } from '@wordpress/element';
17
- import { layout as themeIcon, plugins as pluginIcon } from '@wordpress/icons';
17
+ import {
18
+ commentAuthorAvatar as authorIcon,
19
+ layout as themeIcon,
20
+ plugins as pluginIcon,
21
+ } from '@wordpress/icons';
18
22
  import { __ } from '@wordpress/i18n';
19
23
 
20
24
  const TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];
@@ -77,18 +81,30 @@ function AddedByAuthor( { id } ) {
77
81
  ] );
78
82
  const [ isImageLoaded, setIsImageLoaded ] = useState( false );
79
83
 
84
+ const avatarURL = user?.avatar_urls?.[ 48 ];
85
+ const hasAvatar = !! avatarURL;
86
+
80
87
  return (
81
88
  <HStack alignment="left">
82
89
  <div
83
- className={ classnames( 'edit-site-list-added-by__avatar', {
84
- 'is-loaded': isImageLoaded,
85
- } ) }
90
+ className={ classnames(
91
+ hasAvatar
92
+ ? 'edit-site-list-added-by__avatar'
93
+ : 'edit-site-list-added-by__icon',
94
+ {
95
+ 'is-loaded': isImageLoaded,
96
+ }
97
+ ) }
86
98
  >
87
- <img
88
- onLoad={ () => setIsImageLoaded( true ) }
89
- alt=""
90
- src={ user?.avatar_urls[ 48 ] }
91
- />
99
+ { hasAvatar ? (
100
+ <img
101
+ onLoad={ () => setIsImageLoaded( true ) }
102
+ alt=""
103
+ src={ avatarURL }
104
+ />
105
+ ) : (
106
+ <Icon icon={ authorIcon } />
107
+ ) }
92
108
  </div>
93
109
  <span>{ user?.nickname }</span>
94
110
  </HStack>
@@ -51,16 +51,6 @@ export const TEMPLATES_POSTS_PREFIXES = [
51
51
 
52
52
  export const TEMPLATES_PAGES_PREFIXES = [ 'page-' ];
53
53
 
54
- export const TEMPLATES_NEW_OPTIONS = [
55
- 'front-page',
56
- 'single-post',
57
- 'page',
58
- 'archive',
59
- 'search',
60
- '404',
61
- 'index',
62
- ];
63
-
64
54
  export const TEMPLATE_OVERRIDES = {
65
55
  singular: [ 'single', 'page' ],
66
56
  index: [ 'archive', '404', 'search', 'singular', 'home' ],
@@ -68,9 +58,6 @@ export const TEMPLATE_OVERRIDES = {
68
58
  };
69
59
 
70
60
  export const MENU_ROOT = 'root';
71
- export const MENU_CONTENT_CATEGORIES = 'content-categories';
72
- export const MENU_CONTENT_PAGES = 'content-pages';
73
- export const MENU_CONTENT_POSTS = 'content-posts';
74
61
  export const MENU_TEMPLATE_PARTS = 'template-parts';
75
62
  export const MENU_TEMPLATES = 'templates';
76
63
  export const MENU_TEMPLATES_GENERAL = 'templates-general';
@@ -78,8 +65,6 @@ export const MENU_TEMPLATES_PAGES = 'templates-pages';
78
65
  export const MENU_TEMPLATES_POSTS = 'templates-posts';
79
66
  export const MENU_TEMPLATES_UNUSED = 'templates-unused';
80
67
 
81
- export const SEARCH_DEBOUNCE_IN_MS = 75;
82
-
83
68
  export const MENU_TEMPLATE_PARTS_HEADERS = 'template-parts-headers';
84
69
  export const MENU_TEMPLATE_PARTS_FOOTERS = 'template-parts-footers';
85
70
  export const MENU_TEMPLATE_PARTS_SIDEBARS = 'template-parts-sidebars';
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { useEffect, useRef } from '@wordpress/element';
5
6
  import {
6
7
  Button,
7
8
  Icon,
@@ -40,6 +41,16 @@ function NavigationToggle( { icon } ) {
40
41
 
41
42
  const disableMotion = useReducedMotion();
42
43
 
44
+ const navigationToggleRef = useRef();
45
+
46
+ useEffect( () => {
47
+ // TODO: Remove this effect when alternative solution is merged.
48
+ // See: https://github.com/WordPress/gutenberg/pull/37314
49
+ if ( ! isNavigationOpen ) {
50
+ navigationToggleRef.current.focus();
51
+ }
52
+ }, [ isNavigationOpen ] );
53
+
43
54
  const toggleNavigationPanel = () =>
44
55
  setIsNavigationPanelOpened( ! isNavigationOpen );
45
56
 
@@ -79,6 +90,9 @@ function NavigationToggle( { icon } ) {
79
90
  <Button
80
91
  className="edit-site-navigation-toggle__button has-icon"
81
92
  label={ __( 'Toggle navigation' ) }
93
+ ref={ navigationToggleRef }
94
+ // isPressed will add unwanted styles.
95
+ aria-pressed={ isNavigationOpen }
82
96
  onClick={ toggleNavigationPanel }
83
97
  showTooltip
84
98
  >
@@ -58,9 +58,13 @@
58
58
  box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
59
59
  }
60
60
  }
61
- }
62
61
 
63
- .edit-site-navigation-toggle__site-icon {
64
- width: $button-size;
65
- border-radius: $radius-block-ui;
62
+ .edit-site-navigation-toggle__site-icon {
63
+ width: $button-size;
64
+ height: $button-size;
65
+ border-radius: $radius-block-ui;
66
+ object-fit: cover;
67
+ // Compensate for the top-bar border.
68
+ margin-top: -($border-width);
69
+ }
66
70
  }
@@ -6,7 +6,7 @@ import downloadjs from 'downloadjs';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { __ } from '@wordpress/i18n';
9
+ import { __, _x } from '@wordpress/i18n';
10
10
  import { MenuItem } from '@wordpress/components';
11
11
  import apiFetch from '@wordpress/api-fetch';
12
12
  import { download } from '@wordpress/icons';
@@ -25,7 +25,11 @@ export default function SiteExport() {
25
25
  const blob = await response.blob();
26
26
 
27
27
  downloadjs( blob, 'edit-site-export.zip', 'application/zip' );
28
- } catch ( error ) {
28
+ } catch ( errorResponse ) {
29
+ let error = {};
30
+ try {
31
+ error = await errorResponse.json();
32
+ } catch ( e ) {}
29
33
  const errorMessage =
30
34
  error.message && error.code !== 'unknown_error'
31
35
  ? error.message
@@ -42,7 +46,7 @@ export default function SiteExport() {
42
46
  onClick={ handleExport }
43
47
  info={ __( 'Download your templates and template parts.' ) }
44
48
  >
45
- { __( 'Export' ) }
49
+ { _x( 'Export', 'site exporter menu item' ) }
46
50
  </MenuItem>
47
51
  );
48
52
  }
@@ -1,101 +0,0 @@
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 = ContentNavigationItem;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _components = require("@wordpress/components");
13
-
14
- var _data = require("@wordpress/data");
15
-
16
- var _i18n = require("@wordpress/i18n");
17
-
18
- var _url = require("@wordpress/url");
19
-
20
- var _coreData = require("@wordpress/core-data");
21
-
22
- var _ = require("..");
23
-
24
- var _templatePreview = _interopRequireDefault(require("./template-preview"));
25
-
26
- var _store = require("../../../store");
27
-
28
- /**
29
- * WordPress dependencies
30
- */
31
-
32
- /**
33
- * Internal dependencies
34
- */
35
- const getTitle = entity => {
36
- var _entity$title;
37
-
38
- const title = entity.taxonomy ? entity.name : entity === null || entity === void 0 ? void 0 : (_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered; // Make sure encoded characters are displayed as the characters they represent.
39
-
40
- const titleElement = document.createElement('div');
41
- titleElement.innerHTML = title;
42
- return titleElement.textContent || titleElement.innerText || '';
43
- };
44
-
45
- function ContentNavigationItem(_ref) {
46
- let {
47
- item
48
- } = _ref;
49
- const [isPreviewVisible, setIsPreviewVisible] = (0, _element.useState)(false);
50
- const previewContent = (0, _data.useSelect)(select => {
51
- if (!isPreviewVisible) {
52
- return null;
53
- }
54
-
55
- const template = select(_coreData.store).__experimentalGetTemplateForLink(item.link);
56
-
57
- return template === null || template === void 0 ? void 0 : template.content;
58
- }, [isPreviewVisible]);
59
- const {
60
- setPage,
61
- setIsNavigationPanelOpened
62
- } = (0, _data.useDispatch)(_store.store);
63
- const onActivateItem = (0, _element.useCallback)(() => {
64
- const {
65
- type,
66
- slug,
67
- link,
68
- id
69
- } = item;
70
- setPage({
71
- type,
72
- slug,
73
- path: (0, _url.getPathAndQueryString)(link),
74
- context: {
75
- postType: type,
76
- postId: id
77
- }
78
- });
79
- setIsNavigationPanelOpened(false);
80
- }, [setPage, item]);
81
-
82
- if (!item) {
83
- return null;
84
- }
85
-
86
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalNavigationItem, {
87
- className: "edit-site-navigation-panel__content-item",
88
- item: `${item.taxonomy || item.type}-${item.id}`,
89
- title: getTitle(item) || (0, _i18n.__)('(no title)'),
90
- onClick: onActivateItem,
91
- onMouseEnter: () => setIsPreviewVisible(true),
92
- onMouseLeave: () => setIsPreviewVisible(false)
93
- }), isPreviewVisible && previewContent && (0, _element.createElement)(_.NavigationPanelPreviewFill, null, (0, _element.createElement)(_templatePreview.default, {
94
- rawContent: previewContent,
95
- blockContext: {
96
- postType: item.type,
97
- postId: item.id
98
- }
99
- })));
100
- }
101
- //# sourceMappingURL=content-navigation-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js"],"names":["getTitle","entity","title","taxonomy","name","rendered","titleElement","document","createElement","innerHTML","textContent","innerText","ContentNavigationItem","item","isPreviewVisible","setIsPreviewVisible","previewContent","select","template","coreStore","__experimentalGetTemplateForLink","link","content","setPage","setIsNavigationPanelOpened","editSiteStore","onActivateItem","type","slug","id","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AA,OAAO,CAAE;AACRI,MAAAA,IADQ;AAERC,MAAAA,IAFQ;AAGRE,MAAAA,IAAI,EAAE,gCAAuBT,IAAvB,CAHE;AAIRU,MAAAA,OAAO,EAAE;AACRC,QAAAA,QAAQ,EAAEL,IADF;AAERM,QAAAA,MAAM,EAAEJ;AAFA;AAJD,KAAF,CAAP;AASAL,IAAAA,0BAA0B,CAAE,KAAF,CAA1B;AACA,GAZsB,EAYpB,CAAED,OAAF,EAAWV,IAAX,CAZoB,CAAvB;;AAcA,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,wCAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,IAAI,EAAI,GAAGA,IAAI,CAACV,QAAL,IAAiBU,IAAI,CAACc,IAAM,IAAId,IAAI,CAACgB,EAAI,EAFrD;AAGC,IAAA,KAAK,EAAG7B,QAAQ,CAAEa,IAAF,CAAR,IAAoB,cAAI,YAAJ,CAH7B;AAIC,IAAA,OAAO,EAAGa,cAJX;AAKC,IAAA,YAAY,EAAG,MAAMX,mBAAmB,CAAE,IAAF,CALzC;AAMC,IAAA,YAAY,EAAG,MAAMA,mBAAmB,CAAE,KAAF;AANzC,IADD,EAUGD,gBAAgB,IAAIE,cAApB,IACD,4BAAC,4BAAD,QACC,4BAAC,wBAAD;AACC,IAAA,UAAU,EAAGA,cADd;AAEC,IAAA,YAAY,EAAG;AACdgB,MAAAA,QAAQ,EAAEnB,IAAI,CAACc,IADD;AAEdM,MAAAA,MAAM,EAAEpB,IAAI,CAACgB;AAFC;AAFhB,IADD,CAXF,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getPathAndQueryString } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { NavigationPanelPreviewFill } from '..';\nimport TemplatePreview from './template-preview';\nimport { store as editSiteStore } from '../../../store';\n\nconst getTitle = ( entity ) => {\n\tconst title = entity.taxonomy ? entity.name : entity?.title?.rendered;\n\n\t// Make sure encoded characters are displayed as the characters they represent.\n\tconst titleElement = document.createElement( 'div' );\n\ttitleElement.innerHTML = title;\n\n\treturn titleElement.textContent || titleElement.innerText || '';\n};\n\nexport default function ContentNavigationItem( { item } ) {\n\tconst [ isPreviewVisible, setIsPreviewVisible ] = useState( false );\n\tconst previewContent = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPreviewVisible ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst template = select(\n\t\t\t\tcoreStore\n\t\t\t).__experimentalGetTemplateForLink( item.link );\n\t\t\treturn template?.content;\n\t\t},\n\t\t[ isPreviewVisible ]\n\t);\n\tconst { setPage, setIsNavigationPanelOpened } = useDispatch(\n\t\teditSiteStore\n\t);\n\n\tconst onActivateItem = useCallback( () => {\n\t\tconst { type, slug, link, id } = item;\n\t\tsetPage( {\n\t\t\ttype,\n\t\t\tslug,\n\t\t\tpath: getPathAndQueryString( link ),\n\t\t\tcontext: {\n\t\t\t\tpostType: type,\n\t\t\t\tpostId: id,\n\t\t\t},\n\t\t} );\n\t\tsetIsNavigationPanelOpened( false );\n\t}, [ setPage, item ] );\n\n\tif ( ! item ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<NavigationItem\n\t\t\t\tclassName=\"edit-site-navigation-panel__content-item\"\n\t\t\t\titem={ `${ item.taxonomy || item.type }-${ item.id }` }\n\t\t\t\ttitle={ getTitle( item ) || __( '(no title)' ) }\n\t\t\t\tonClick={ onActivateItem }\n\t\t\t\tonMouseEnter={ () => setIsPreviewVisible( true ) }\n\t\t\t\tonMouseLeave={ () => setIsPreviewVisible( false ) }\n\t\t\t/>\n\n\t\t\t{ isPreviewVisible && previewContent && (\n\t\t\t\t<NavigationPanelPreviewFill>\n\t\t\t\t\t<TemplatePreview\n\t\t\t\t\t\trawContent={ previewContent }\n\t\t\t\t\t\tblockContext={ {\n\t\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</NavigationPanelPreviewFill>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -1,82 +0,0 @@
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 = ContentCategoriesMenu;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _components = require("@wordpress/components");
13
-
14
- var _i18n = require("@wordpress/i18n");
15
-
16
- var _data = require("@wordpress/data");
17
-
18
- var _coreData = require("@wordpress/core-data");
19
-
20
- var _constants = require("../constants");
21
-
22
- var _contentNavigationItem = _interopRequireDefault(require("../content-navigation-item"));
23
-
24
- var _searchResults = _interopRequireDefault(require("../search-results"));
25
-
26
- var _useDebouncedSearch = _interopRequireDefault(require("../use-debounced-search"));
27
-
28
- /**
29
- * WordPress dependencies
30
- */
31
-
32
- /**
33
- * Internal dependencies
34
- */
35
- function ContentCategoriesMenu() {
36
- const {
37
- search,
38
- searchQuery,
39
- onSearch,
40
- isDebouncing
41
- } = (0, _useDebouncedSearch.default)();
42
- const {
43
- categories,
44
- isResolved
45
- } = (0, _data.useSelect)(select => {
46
- const {
47
- getEntityRecords,
48
- hasFinishedResolution
49
- } = select(_coreData.store);
50
- const query = searchQuery ? {
51
- search: searchQuery
52
- } : undefined;
53
- const getEntityRecordsArgs = ['taxonomy', 'category', query];
54
- const hasResolvedPosts = hasFinishedResolution('getEntityRecords', getEntityRecordsArgs);
55
- return {
56
- categories: getEntityRecords(...getEntityRecordsArgs),
57
- isResolved: hasResolvedPosts
58
- };
59
- }, [searchQuery]);
60
- const shouldShowLoadingForDebouncing = search && isDebouncing;
61
- const showLoading = !isResolved || shouldShowLoadingForDebouncing;
62
- return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
63
- menu: _constants.MENU_CONTENT_CATEGORIES,
64
- title: (0, _i18n.__)('Categories'),
65
- parentMenu: _constants.MENU_ROOT,
66
- hasSearch: true,
67
- onSearch: onSearch,
68
- search: search,
69
- isSearchDebouncing: isDebouncing || !isResolved
70
- }, search && !isDebouncing && (0, _element.createElement)(_searchResults.default, {
71
- items: categories,
72
- search: search,
73
- disableFilter: true
74
- }), !search && (categories === null || categories === void 0 ? void 0 : categories.map(category => (0, _element.createElement)(_contentNavigationItem.default, {
75
- item: category,
76
- key: `${category.taxonomy}-${category.id}`
77
- }))), showLoading && (0, _element.createElement)(_components.__experimentalNavigationItem, {
78
- title: (0, _i18n.__)('Loading…'),
79
- isText: true
80
- }));
81
- }
82
- //# sourceMappingURL=content-categories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/content-categories.js"],"names":["ContentCategoriesMenu","search","searchQuery","onSearch","isDebouncing","categories","isResolved","select","getEntityRecords","hasFinishedResolution","coreStore","query","undefined","getEntityRecordsArgs","hasResolvedPosts","shouldShowLoadingForDebouncing","showLoading","MENU_CONTENT_CATEGORIES","MENU_ROOT","map","category","taxonomy","id"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;;AASA;AACA;AACA;AAMe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AACLC,IAAAA,MADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,QAHK;AAILC,IAAAA;AAJK,MAKF,kCALJ;AAOA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA6B,qBAChCC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,QAA8CF,MAAM,CACzDG,eAD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,cAAI,UAAJ,CAAxB;AAA2C,IAAA,MAAM;AAAjD,IA1BF,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigationMenu as NavigationMenu,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { MENU_CONTENT_CATEGORIES, MENU_ROOT } from '../constants';\nimport ContentNavigationItem from '../content-navigation-item';\nimport SearchResults from '../search-results';\nimport useDebouncedSearch from '../use-debounced-search';\n\nexport default function ContentCategoriesMenu() {\n\tconst {\n\t\tsearch,\n\t\tsearchQuery,\n\t\tonSearch,\n\t\tisDebouncing,\n\t} = useDebouncedSearch();\n\n\tconst { categories, isResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, hasFinishedResolution } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst query = searchQuery\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: searchQuery,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\t\t\tconst getEntityRecordsArgs = [ 'taxonomy', 'category', query ];\n\t\t\tconst hasResolvedPosts = hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tgetEntityRecordsArgs\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcategories: getEntityRecords( ...getEntityRecordsArgs ),\n\t\t\t\tisResolved: hasResolvedPosts,\n\t\t\t};\n\t\t},\n\t\t[ searchQuery ]\n\t);\n\n\tconst shouldShowLoadingForDebouncing = search && isDebouncing;\n\tconst showLoading = ! isResolved || shouldShowLoadingForDebouncing;\n\n\treturn (\n\t\t<NavigationMenu\n\t\t\tmenu={ MENU_CONTENT_CATEGORIES }\n\t\t\ttitle={ __( 'Categories' ) }\n\t\t\tparentMenu={ MENU_ROOT }\n\t\t\thasSearch={ true }\n\t\t\tonSearch={ onSearch }\n\t\t\tsearch={ search }\n\t\t\tisSearchDebouncing={ isDebouncing || ! isResolved }\n\t\t>\n\t\t\t{ search && ! isDebouncing && (\n\t\t\t\t<SearchResults\n\t\t\t\t\titems={ categories }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tdisableFilter\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ ! search &&\n\t\t\t\tcategories?.map( ( category ) => (\n\t\t\t\t\t<ContentNavigationItem\n\t\t\t\t\t\titem={ category }\n\t\t\t\t\t\tkey={ `${ category.taxonomy }-${ category.id }` }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\n\t\t\t{ showLoading && (\n\t\t\t\t<NavigationItem title={ __( 'Loading…' ) } isText />\n\t\t\t) }\n\t\t</NavigationMenu>\n\t);\n}\n"]}
@@ -1,82 +0,0 @@
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 = ContentPagesMenu;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _components = require("@wordpress/components");
13
-
14
- var _i18n = require("@wordpress/i18n");
15
-
16
- var _data = require("@wordpress/data");
17
-
18
- var _coreData = require("@wordpress/core-data");
19
-
20
- var _constants = require("../constants");
21
-
22
- var _contentNavigationItem = _interopRequireDefault(require("../content-navigation-item"));
23
-
24
- var _searchResults = _interopRequireDefault(require("../search-results"));
25
-
26
- var _useDebouncedSearch = _interopRequireDefault(require("../use-debounced-search"));
27
-
28
- /**
29
- * WordPress dependencies
30
- */
31
-
32
- /**
33
- * Internal dependencies
34
- */
35
- function ContentPagesMenu() {
36
- const {
37
- search,
38
- searchQuery,
39
- onSearch,
40
- isDebouncing
41
- } = (0, _useDebouncedSearch.default)();
42
- const {
43
- pages,
44
- isResolved
45
- } = (0, _data.useSelect)(select => {
46
- const {
47
- getEntityRecords,
48
- hasFinishedResolution
49
- } = select(_coreData.store);
50
- const query = searchQuery ? {
51
- search: searchQuery
52
- } : undefined;
53
- const getEntityRecordsArgs = ['postType', 'page', query];
54
- const hasResolvedPosts = hasFinishedResolution('getEntityRecords', getEntityRecordsArgs);
55
- return {
56
- pages: getEntityRecords(...getEntityRecordsArgs),
57
- isResolved: hasResolvedPosts
58
- };
59
- }, [searchQuery]);
60
- const shouldShowLoadingForDebouncing = search && isDebouncing;
61
- const showLoading = !isResolved || shouldShowLoadingForDebouncing;
62
- return (0, _element.createElement)(_components.__experimentalNavigationMenu, {
63
- menu: _constants.MENU_CONTENT_PAGES,
64
- title: (0, _i18n.__)('Pages'),
65
- parentMenu: _constants.MENU_ROOT,
66
- hasSearch: true,
67
- onSearch: onSearch,
68
- search: search,
69
- isSearchDebouncing: isDebouncing || !isResolved
70
- }, search && !isDebouncing && (0, _element.createElement)(_searchResults.default, {
71
- items: pages,
72
- search: search,
73
- disableFilter: true
74
- }), !search && (pages === null || pages === void 0 ? void 0 : pages.map(page => (0, _element.createElement)(_contentNavigationItem.default, {
75
- item: page,
76
- key: `${page.type}-${page.id}`
77
- }))), showLoading && (0, _element.createElement)(_components.__experimentalNavigationItem, {
78
- title: (0, _i18n.__)('Loading…'),
79
- isText: true
80
- }));
81
- }
82
- //# sourceMappingURL=content-pages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/menus/content-pages.js"],"names":["ContentPagesMenu","search","searchQuery","onSearch","isDebouncing","pages","isResolved","select","getEntityRecords","hasFinishedResolution","coreStore","query","undefined","getEntityRecordsArgs","hasResolvedPosts","shouldShowLoadingForDebouncing","showLoading","MENU_CONTENT_PAGES","MENU_ROOT","map","page","type","id"],"mappings":";;;;;;;;;;;AAGA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;;AASA;AACA;AACA;AAMe,SAASA,gBAAT,GAA4B;AAC1C,QAAM;AACLC,IAAAA,MADK;AAELC,IAAAA,WAFK;AAGLC,I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AAC,8BAAD;AACC,IAAA,IAAI,EAAGA,IADR;AAEC,IAAA,GAAG,EAAI,GAAGA,IAAI,CAACC,IAAM,IAAID,IAAI,CAACE,EAAI;AAFnC,IADD,CADC,CAjBH,EAyBGN,WAAW,IACZ,4BAAC,wCAAD;AAAgB,IAAA,KAAK,EAAG,cAAI,UAAJ,CAAxB;AAA2C,IAAA,MAAM;AAAjD,IA1BF,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigationMenu as NavigationMenu,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { MENU_CONTENT_PAGES, MENU_ROOT } from '../constants';\nimport ContentNavigationItem from '../content-navigation-item';\nimport SearchResults from '../search-results';\nimport useDebouncedSearch from '../use-debounced-search';\n\nexport default function ContentPagesMenu() {\n\tconst {\n\t\tsearch,\n\t\tsearchQuery,\n\t\tonSearch,\n\t\tisDebouncing,\n\t} = useDebouncedSearch();\n\n\tconst { pages, isResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, hasFinishedResolution } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst query = searchQuery\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: searchQuery,\n\t\t\t\t }\n\t\t\t\t: undefined;\n\t\t\tconst getEntityRecordsArgs = [ 'postType', 'page', query ];\n\t\t\tconst hasResolvedPosts = hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tgetEntityRecordsArgs\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tpages: getEntityRecords( ...getEntityRecordsArgs ),\n\t\t\t\tisResolved: hasResolvedPosts,\n\t\t\t};\n\t\t},\n\t\t[ searchQuery ]\n\t);\n\n\tconst shouldShowLoadingForDebouncing = search && isDebouncing;\n\tconst showLoading = ! isResolved || shouldShowLoadingForDebouncing;\n\n\treturn (\n\t\t<NavigationMenu\n\t\t\tmenu={ MENU_CONTENT_PAGES }\n\t\t\ttitle={ __( 'Pages' ) }\n\t\t\tparentMenu={ MENU_ROOT }\n\t\t\thasSearch={ true }\n\t\t\tonSearch={ onSearch }\n\t\t\tsearch={ search }\n\t\t\tisSearchDebouncing={ isDebouncing || ! isResolved }\n\t\t>\n\t\t\t{ search && ! isDebouncing && (\n\t\t\t\t<SearchResults\n\t\t\t\t\titems={ pages }\n\t\t\t\t\tsearch={ search }\n\t\t\t\t\tdisableFilter\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ ! search &&\n\t\t\t\tpages?.map( ( page ) => (\n\t\t\t\t\t<ContentNavigationItem\n\t\t\t\t\t\titem={ page }\n\t\t\t\t\t\tkey={ `${ page.type }-${ page.id }` }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\n\t\t\t{ showLoading && (\n\t\t\t\t<NavigationItem title={ __( 'Loading…' ) } isText />\n\t\t\t) }\n\t\t</NavigationMenu>\n\t);\n}\n"]}