@wordpress/edit-site 5.7.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template.js +2 -1
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/block-editor/index.js +7 -7
  5. package/build/components/block-editor/index.js.map +1 -1
  6. package/build/components/editor/index.js +6 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor-canvas-container/index.js +117 -0
  9. package/build/components/editor-canvas-container/index.js.map +1 -0
  10. package/build/components/global-styles/border-panel.js +81 -1
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/context-menu.js +6 -8
  13. package/build/components/global-styles/context-menu.js.map +1 -1
  14. package/build/components/global-styles/dimensions-panel.js +11 -1
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/effects-panel.js +53 -0
  17. package/build/components/global-styles/effects-panel.js.map +1 -0
  18. package/build/components/global-styles/filters-panel.js +50 -0
  19. package/build/components/global-styles/filters-panel.js.map +1 -0
  20. package/build/components/global-styles/global-styles-provider.js +4 -15
  21. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  22. package/build/components/global-styles/preview.js +1 -1
  23. package/build/components/global-styles/preview.js.map +1 -1
  24. package/build/components/global-styles/screen-block-list.js +14 -8
  25. package/build/components/global-styles/screen-block-list.js.map +1 -1
  26. package/build/components/global-styles/screen-css.js +1 -1
  27. package/build/components/global-styles/screen-css.js.map +1 -1
  28. package/build/components/global-styles/screen-effects.js +15 -7
  29. package/build/components/global-styles/screen-effects.js.map +1 -1
  30. package/build/components/global-styles/screen-filters.js +2 -2
  31. package/build/components/global-styles/screen-filters.js.map +1 -1
  32. package/build/components/global-styles/screen-style-variations.js +8 -118
  33. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  34. package/build/components/global-styles/style-variations-container.js +149 -0
  35. package/build/components/global-styles/style-variations-container.js.map +1 -0
  36. package/build/components/global-styles/ui.js +52 -15
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/header-edit-mode/index.js +11 -7
  39. package/build/components/header-edit-mode/index.js.map +1 -1
  40. package/build/components/header-edit-mode/more-menu/index.js +1 -1
  41. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  42. package/build/components/keyboard-shortcuts/index.js +0 -137
  43. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  44. package/build/components/layout/index.js +17 -8
  45. package/build/components/layout/index.js.map +1 -1
  46. package/build/components/list/table.js +3 -3
  47. package/build/components/list/table.js.map +1 -1
  48. package/build/components/preferences-modal/index.js +4 -0
  49. package/build/components/preferences-modal/index.js.map +1 -1
  50. package/build/components/sidebar/index.js +4 -0
  51. package/build/components/sidebar/index.js.map +1 -1
  52. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +28 -13
  53. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen/index.js +8 -6
  55. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  56. package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
  57. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  58. package/build/components/sidebar-navigation-screen-main/index.js +5 -0
  59. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
  61. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  62. package/build/components/site-hub/index.js +40 -17
  63. package/build/components/site-hub/index.js.map +1 -1
  64. package/build/components/site-icon/index.js +8 -7
  65. package/build/components/site-icon/index.js.map +1 -1
  66. package/build/components/start-template-options/index.js +9 -8
  67. package/build/components/start-template-options/index.js.map +1 -1
  68. package/build/components/style-book/index.js +9 -41
  69. package/build/components/style-book/index.js.map +1 -1
  70. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
  71. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  72. package/build/components/template-details/index.js +3 -1
  73. package/build/components/template-details/index.js.map +1 -1
  74. package/build/components/welcome-guide/styles.js +1 -1
  75. package/build/components/welcome-guide/styles.js.map +1 -1
  76. package/build/hooks/commands/index.js +19 -0
  77. package/build/hooks/commands/index.js.map +1 -0
  78. package/build/hooks/commands/use-navigation-commands.js +126 -0
  79. package/build/hooks/commands/use-navigation-commands.js.map +1 -0
  80. package/build/hooks/commands/use-wp-admin-commands.js +97 -0
  81. package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
  82. package/build/hooks/template-part-edit.js +2 -1
  83. package/build/hooks/template-part-edit.js.map +1 -1
  84. package/build/index.js +2 -1
  85. package/build/index.js.map +1 -1
  86. package/build/store/private-actions.js +19 -1
  87. package/build/store/private-actions.js.map +1 -1
  88. package/build/store/private-selectors.js +13 -0
  89. package/build/store/private-selectors.js.map +1 -1
  90. package/build/store/reducer.js +23 -1
  91. package/build/store/reducer.js.map +1 -1
  92. package/build/store/selectors.js +2 -1
  93. package/build/store/selectors.js.map +1 -1
  94. package/build-module/components/add-new-template/new-template.js +3 -2
  95. package/build-module/components/add-new-template/new-template.js.map +1 -1
  96. package/build-module/components/block-editor/index.js +6 -6
  97. package/build-module/components/block-editor/index.js.map +1 -1
  98. package/build-module/components/editor/index.js +6 -4
  99. package/build-module/components/editor/index.js.map +1 -1
  100. package/build-module/components/editor-canvas-container/index.js +100 -0
  101. package/build-module/components/editor-canvas-container/index.js.map +1 -0
  102. package/build-module/components/global-styles/border-panel.js +81 -1
  103. package/build-module/components/global-styles/border-panel.js.map +1 -1
  104. package/build-module/components/global-styles/context-menu.js +6 -6
  105. package/build-module/components/global-styles/context-menu.js.map +1 -1
  106. package/build-module/components/global-styles/dimensions-panel.js +11 -1
  107. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  108. package/build-module/components/global-styles/effects-panel.js +43 -0
  109. package/build-module/components/global-styles/effects-panel.js.map +1 -0
  110. package/build-module/components/global-styles/filters-panel.js +40 -0
  111. package/build-module/components/global-styles/filters-panel.js.map +1 -0
  112. package/build-module/components/global-styles/global-styles-provider.js +5 -16
  113. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  114. package/build-module/components/global-styles/preview.js +1 -1
  115. package/build-module/components/global-styles/preview.js.map +1 -1
  116. package/build-module/components/global-styles/screen-block-list.js +13 -8
  117. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  118. package/build-module/components/global-styles/screen-css.js +1 -1
  119. package/build-module/components/global-styles/screen-css.js.map +1 -1
  120. package/build-module/components/global-styles/screen-effects.js +13 -4
  121. package/build-module/components/global-styles/screen-effects.js.map +1 -1
  122. package/build-module/components/global-styles/screen-filters.js +2 -2
  123. package/build-module/components/global-styles/screen-filters.js.map +1 -1
  124. package/build-module/components/global-styles/screen-style-variations.js +11 -114
  125. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  126. package/build-module/components/global-styles/style-variations-container.js +130 -0
  127. package/build-module/components/global-styles/style-variations-container.js.map +1 -0
  128. package/build-module/components/global-styles/ui.js +49 -16
  129. package/build-module/components/global-styles/ui.js.map +1 -1
  130. package/build-module/components/header-edit-mode/index.js +10 -7
  131. package/build-module/components/header-edit-mode/index.js.map +1 -1
  132. package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
  133. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  134. package/build-module/components/keyboard-shortcuts/index.js +1 -135
  135. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  136. package/build-module/components/layout/index.js +14 -8
  137. package/build-module/components/layout/index.js.map +1 -1
  138. package/build-module/components/list/table.js +3 -3
  139. package/build-module/components/list/table.js.map +1 -1
  140. package/build-module/components/preferences-modal/index.js +4 -0
  141. package/build-module/components/preferences-modal/index.js.map +1 -1
  142. package/build-module/components/sidebar/index.js +3 -0
  143. package/build-module/components/sidebar/index.js.map +1 -1
  144. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +28 -15
  145. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  146. package/build-module/components/sidebar-navigation-screen/index.js +9 -7
  147. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  148. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  149. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  150. package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
  151. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  152. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
  153. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  154. package/build-module/components/site-hub/index.js +40 -18
  155. package/build-module/components/site-hub/index.js.map +1 -1
  156. package/build-module/components/site-icon/index.js +8 -7
  157. package/build-module/components/site-icon/index.js.map +1 -1
  158. package/build-module/components/start-template-options/index.js +9 -8
  159. package/build-module/components/start-template-options/index.js.map +1 -1
  160. package/build-module/components/style-book/index.js +10 -41
  161. package/build-module/components/style-book/index.js.map +1 -1
  162. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
  163. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  164. package/build-module/components/template-details/index.js +3 -1
  165. package/build-module/components/template-details/index.js.map +1 -1
  166. package/build-module/components/welcome-guide/styles.js +1 -1
  167. package/build-module/components/welcome-guide/styles.js.map +1 -1
  168. package/build-module/hooks/commands/index.js +10 -0
  169. package/build-module/hooks/commands/index.js.map +1 -0
  170. package/build-module/hooks/commands/use-navigation-commands.js +109 -0
  171. package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
  172. package/build-module/hooks/commands/use-wp-admin-commands.js +81 -0
  173. package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
  174. package/build-module/hooks/template-part-edit.js +2 -1
  175. package/build-module/hooks/template-part-edit.js.map +1 -1
  176. package/build-module/index.js +2 -1
  177. package/build-module/index.js.map +1 -1
  178. package/build-module/store/private-actions.js +15 -0
  179. package/build-module/store/private-actions.js.map +1 -1
  180. package/build-module/store/private-selectors.js +11 -0
  181. package/build-module/store/private-selectors.js.map +1 -1
  182. package/build-module/store/reducer.js +23 -1
  183. package/build-module/store/reducer.js.map +1 -1
  184. package/build-module/store/selectors.js +2 -1
  185. package/build-module/store/selectors.js.map +1 -1
  186. package/build-style/style-rtl.css +133 -107
  187. package/build-style/style.css +133 -107
  188. package/package.json +34 -32
  189. package/src/components/add-new-template/new-template.js +3 -0
  190. package/src/components/block-editor/index.js +8 -8
  191. package/src/components/editor/index.js +11 -3
  192. package/src/components/editor-canvas-container/index.js +115 -0
  193. package/src/components/editor-canvas-container/style.scss +19 -0
  194. package/src/components/global-styles/border-panel.js +73 -1
  195. package/src/components/global-styles/context-menu.js +6 -6
  196. package/src/components/global-styles/dimensions-panel.js +11 -0
  197. package/src/components/global-styles/effects-panel.js +40 -0
  198. package/src/components/global-styles/filters-panel.js +39 -0
  199. package/src/components/global-styles/global-styles-provider.js +4 -18
  200. package/src/components/global-styles/preview.js +1 -1
  201. package/src/components/global-styles/screen-block-list.js +9 -5
  202. package/src/components/global-styles/screen-css.js +1 -1
  203. package/src/components/global-styles/screen-effects.js +12 -5
  204. package/src/components/global-styles/screen-filters.js +2 -2
  205. package/src/components/global-styles/screen-style-variations.js +10 -129
  206. package/src/components/global-styles/style-variations-container.js +136 -0
  207. package/src/components/global-styles/style.scss +0 -39
  208. package/src/components/global-styles/ui.js +54 -8
  209. package/src/components/header-edit-mode/index.js +14 -5
  210. package/src/components/header-edit-mode/more-menu/index.js +1 -1
  211. package/src/components/keyboard-shortcuts/index.js +1 -155
  212. package/src/components/layout/index.js +13 -16
  213. package/src/components/layout/style.scss +31 -4
  214. package/src/components/list/table.js +16 -2
  215. package/src/components/preferences-modal/index.js +7 -0
  216. package/src/components/secondary-sidebar/style.scss +23 -5
  217. package/src/components/sidebar/index.js +4 -0
  218. package/src/components/sidebar/style.scss +2 -1
  219. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +36 -17
  220. package/src/components/sidebar-navigation-screen/index.js +10 -5
  221. package/src/components/sidebar-navigation-screen/style.scss +20 -5
  222. package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  223. package/src/components/sidebar-navigation-screen-main/index.js +9 -1
  224. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
  225. package/src/components/site-hub/index.js +51 -23
  226. package/src/components/site-icon/index.js +6 -11
  227. package/src/components/site-icon/style.scss +8 -3
  228. package/src/components/start-template-options/index.js +13 -12
  229. package/src/components/start-template-options/style.scss +18 -43
  230. package/src/components/style-book/index.js +7 -51
  231. package/src/components/style-book/style.scss +0 -18
  232. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -3
  233. package/src/components/template-details/index.js +1 -0
  234. package/src/components/welcome-guide/styles.js +1 -1
  235. package/src/hooks/commands/index.js +10 -0
  236. package/src/hooks/commands/use-navigation-commands.js +112 -0
  237. package/src/hooks/commands/use-wp-admin-commands.js +79 -0
  238. package/src/hooks/template-part-edit.js +1 -0
  239. package/src/index.js +1 -0
  240. package/src/store/private-actions.js +14 -0
  241. package/src/store/private-selectors.js +11 -0
  242. package/src/store/reducer.js +18 -0
  243. package/src/store/selectors.js +2 -1
  244. package/src/style.scss +1 -0
  245. package/build/components/global-styles/duotone-panel.js +0 -78
  246. package/build/components/global-styles/duotone-panel.js.map +0 -1
  247. package/build/components/global-styles/filter-utils.js +0 -17
  248. package/build/components/global-styles/filter-utils.js.map +0 -1
  249. package/build/components/global-styles/shadow-panel.js +0 -197
  250. package/build/components/global-styles/shadow-panel.js.map +0 -1
  251. package/build-module/components/global-styles/duotone-panel.js +0 -67
  252. package/build-module/components/global-styles/duotone-panel.js.map +0 -1
  253. package/build-module/components/global-styles/filter-utils.js +0 -9
  254. package/build-module/components/global-styles/filter-utils.js.map +0 -1
  255. package/build-module/components/global-styles/shadow-panel.js +0 -178
  256. package/build-module/components/global-styles/shadow-panel.js.map +0 -1
  257. package/src/components/global-styles/duotone-panel.js +0 -82
  258. package/src/components/global-styles/filter-utils.js +0 -9
  259. package/src/components/global-styles/shadow-panel.js +0 -178
@@ -13,6 +13,12 @@ var _data = require("@wordpress/data");
13
13
 
14
14
  var _blocks = require("@wordpress/blocks");
15
15
 
16
+ var _components = require("@wordpress/components");
17
+
18
+ var _dom = require("@wordpress/dom");
19
+
20
+ var _coreData = require("@wordpress/core-data");
21
+
16
22
  var _privateApis = require("../../private-apis");
17
23
 
18
24
  var _loader = require("./loader");
@@ -24,30 +30,126 @@ var _loader = require("./loader");
24
30
  /**
25
31
  * Internal dependencies
26
32
  */
27
- function NavigationMenuContent(_ref) {
33
+ function CustomLinkAdditionalBlockUI(_ref) {
34
+ let {
35
+ block,
36
+ onClose
37
+ } = _ref;
38
+ const {
39
+ updateBlockAttributes
40
+ } = (0, _data.useDispatch)(_blockEditor.store);
41
+ const {
42
+ label,
43
+ url,
44
+ opensInNewTab
45
+ } = block.attributes;
46
+ const link = {
47
+ url,
48
+ opensInNewTab,
49
+ title: label && (0, _dom.__unstableStripHTML)(label)
50
+ };
51
+ return (0, _element.createElement)(_components.Popover, {
52
+ placement: "bottom",
53
+ shift: true,
54
+ onClose: onClose
55
+ }, (0, _element.createElement)(_blockEditor.__experimentalLinkControl, {
56
+ hasTextControl: true,
57
+ hasRichPreviews: true,
58
+ value: link,
59
+ onChange: updatedValue => {
60
+ updateBlockAttributes(block.clientId, {
61
+ label: updatedValue.title,
62
+ url: updatedValue.url,
63
+ opensInNewTab: updatedValue.opensInNewTab
64
+ });
65
+ onClose();
66
+ },
67
+ onCancel: onClose
68
+ }));
69
+ } // Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.
70
+
71
+
72
+ const MAX_PAGE_COUNT = 100;
73
+ const PAGES_QUERY = ['postType', 'page', {
74
+ per_page: MAX_PAGE_COUNT,
75
+ _fields: ['id', 'link', 'menu_order', 'parent', 'title', 'type'],
76
+ // TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby
77
+ // values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent
78
+ // sort.
79
+ orderby: 'menu_order',
80
+ order: 'asc'
81
+ }];
82
+
83
+ function NavigationMenuContent(_ref2) {
28
84
  let {
29
85
  rootClientId,
30
86
  onSelect
31
- } = _ref;
87
+ } = _ref2;
88
+ const [isLoading, setIsLoading] = (0, _element.useState)(true);
32
89
  const {
33
90
  clientIdsTree,
34
- isLoading
91
+ shouldKeepLoading,
92
+ isSinglePageList
35
93
  } = (0, _data.useSelect)(select => {
36
94
  const {
37
95
  __unstableGetClientIdsTree,
38
- areInnerBlocksControlled
96
+ areInnerBlocksControlled,
97
+ getBlockName
39
98
  } = select(_blockEditor.store);
99
+ const {
100
+ isResolving
101
+ } = select(_coreData.store);
102
+
103
+ const _clientIdsTree = __unstableGetClientIdsTree(rootClientId);
104
+
105
+ const hasOnlyPageListBlock = _clientIdsTree.length === 1 && getBlockName(_clientIdsTree[0].clientId) === 'core/page-list';
106
+ const isLoadingPages = isResolving('getEntityRecords', PAGES_QUERY);
40
107
  return {
41
- clientIdsTree: __unstableGetClientIdsTree(rootClientId),
108
+ clientIdsTree: _clientIdsTree,
42
109
  // This is a small hack to wait for the navigation block
43
110
  // to actually load its inner blocks.
44
- isLoading: !areInnerBlocksControlled(rootClientId)
111
+ shouldKeepLoading: !areInnerBlocksControlled(rootClientId) || isLoadingPages,
112
+ isSinglePageList: hasOnlyPageListBlock && !isLoadingPages && _clientIdsTree[0].innerBlocks.length > 0
45
113
  };
46
114
  }, [rootClientId]);
47
115
  const {
48
116
  replaceBlock,
49
117
  __unstableMarkNextChangeAsNotPersistent
50
118
  } = (0, _data.useDispatch)(_blockEditor.store);
119
+ const [customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId] = (0, _element.useState)(false);
120
+ const renderAdditionalBlockUICallback = (0, _element.useCallback)(block => {
121
+ if (customLinkEditPopoverOpenId && block.clientId === customLinkEditPopoverOpenId) {
122
+ return (0, _element.createElement)(CustomLinkAdditionalBlockUI, {
123
+ block: block,
124
+ onClose: () => {
125
+ setIsCustomLinkEditPopoverOpenId(false);
126
+ }
127
+ });
128
+ }
129
+
130
+ return null;
131
+ }, [customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId]); // Delay loading stop by 50ms to avoid flickering.
132
+
133
+ (0, _element.useEffect)(() => {
134
+ let timeoutId;
135
+
136
+ if (shouldKeepLoading && !isLoading) {
137
+ setIsLoading(true);
138
+ }
139
+
140
+ if (!shouldKeepLoading && isLoading) {
141
+ timeoutId = setTimeout(() => {
142
+ setIsLoading(false);
143
+ timeoutId = undefined;
144
+ }, 50);
145
+ }
146
+
147
+ return () => {
148
+ if (timeoutId) {
149
+ clearTimeout(timeoutId);
150
+ }
151
+ };
152
+ }, [shouldKeepLoading, clientIdsTree, isLoading]);
51
153
  const {
52
154
  OffCanvasEditor,
53
155
  LeafMoreMenu
@@ -57,17 +159,20 @@ function NavigationMenuContent(_ref) {
57
159
  __unstableMarkNextChangeAsNotPersistent();
58
160
 
59
161
  replaceBlock(block.clientId, (0, _blocks.createBlock)('core/navigation-link', block.attributes));
162
+ } else if (block.name === 'core/navigation-link' && block.attributes.kind === 'custom' && block.attributes.url) {
163
+ setIsCustomLinkEditPopoverOpenId(block.clientId);
60
164
  } else {
61
165
  onSelect(block);
62
166
  }
63
- }, [onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock]); // The hidden block is needed because it makes block edit side effects trigger.
167
+ }, [onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock, setIsCustomLinkEditPopoverOpenId]); // The hidden block is needed because it makes block edit side effects trigger.
64
168
  // For example a navigation page list load its items has an effect on edit to load its items.
65
169
 
66
170
  return (0, _element.createElement)(_element.Fragment, null, isLoading && (0, _element.createElement)(_loader.NavigationMenuLoader, null), !isLoading && (0, _element.createElement)(OffCanvasEditor, {
67
- blocks: clientIdsTree,
171
+ blocks: isSinglePageList ? clientIdsTree[0].innerBlocks : clientIdsTree,
68
172
  onSelect: offCanvasOnselect,
69
173
  LeafMoreMenu: LeafMoreMenu,
70
- showAppender: false
174
+ showAppender: false,
175
+ renderAdditionalBlockUI: renderAdditionalBlockUICallback
71
176
  }), (0, _element.createElement)("div", {
72
177
  style: {
73
178
  visibility: 'hidden'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js"],"names":["NavigationMenuContent","rootClientId","onSelect","clientIdsTree","isLoading","select","__unstableGetClientIdsTree","areInnerBlocksControlled","blockEditorStore","replaceBlock","__unstableMarkNextChangeAsNotPersistent","OffCanvasEditor","LeafMoreMenu","blockEditorPrivateApis","offCanvasOnselect","block","name","attributes","url","clientId","visibility"],"mappings":";;;;;;;AAWA;;AARA;;AAMA;;AACA;;AAMA;;AACA;;AAjBA;AACA;AACA;;AAWA;AACA;AACA;AAIe,SAASA,qBAAT,OAA6D;AAAA,MAA7B;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAA6B;AAC3E,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAA+B,qBAClCC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,0BAAF;AAA8BC,MAAAA;AAA9B,QACLF,MAAM,CAAEG,kBAAF,CADP;AAEA,WAAO;AACNL,MAAAA,aAAa,EAAEG,0BAA0B,CAAEL,YAAF,CADnC;AAGN;AACA;AACAG,MAAAA,SAAS,EAAE,CAAEG,wBAAwB,CAAEN,YAAF;AAL/B,KAAP;AAOA,GAXmC,EAYpC,CAAEA,YAAF,CAZoC,CAArC;AAcA,QAAM;AAAEQ,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MACL,uBAAaF,kBAAb,CADD;AAGA,QAAM;AAAEG,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAoC,yBAAQC,wBAAR,CAA1C;AAEA,QAAMC,iBAAiB,GAAG,0BACvBC,KAAF,IAAa;AACZ,QACCA,KAAK,CAACC,IAAN,KAAe,sBAAf,IACA,CAAED,KAAK,CAACE,UAAN,CAAiBC,GAFpB,EAGE;AACDR,MAAAA,uCAAuC;;AACvCD,MAAAA,YAAY,CACXM,KAAK,CAACI,QADK,EAEX,yBAAa,sBAAb,EAAqCJ,KAAK,CAACE,UAA3C,CAFW,CAAZ;AAIA,KATD,MASO;AACNf,MAAAA,QAAQ,CAAEa,KAAF,CAAR;AACA;AACD,GAdwB,EAezB,CAAEb,QAAF,EAAYQ,uCAAZ,EAAqDD,YAArD,CAfyB,CAA1B,CApB2E,CAsC3E;AACA;;AACA,SACC,qDACGL,SAAS,IAAI,4BAAC,4BAAD,OADhB,EAEG,CAAEA,SAAF,IACD,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGD,aADV;AAEC,IAAA,QAAQ,EAAGW,iBAFZ;AAGC,IAAA,YAAY,EAAGF,YAHhB;AAIC,IAAA,YAAY,EAAG;AAJhB,IAHF,EAUC;AAAK,IAAA,KAAK,EAAG;AAAEQ,MAAAA,UAAU,EAAE;AAAd;AAAb,KACC,4BAAC,uBAAD,QACC,4BAAC,sBAAD,OADD,CADD,CAVD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockList,\n\tBlockTools,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { NavigationMenuLoader } from './loader';\n\nexport default function NavigationMenuContent( { rootClientId, onSelect } ) {\n\tconst { clientIdsTree, isLoading } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree, areInnerBlocksControlled } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tclientIdsTree: __unstableGetClientIdsTree( rootClientId ),\n\n\t\t\t\t// This is a small hack to wait for the navigation block\n\t\t\t\t// to actually load its inner blocks.\n\t\t\t\tisLoading: ! areInnerBlocksControlled( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\tconst offCanvasOnselect = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\t! block.attributes.url\n\t\t\t) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlock(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\tcreateBlock( 'core/navigation-link', block.attributes )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tonSelect( block );\n\t\t\t}\n\t\t},\n\t\t[ onSelect, __unstableMarkNextChangeAsNotPersistent, replaceBlock ]\n\t);\n\n\t// The hidden block is needed because it makes block edit side effects trigger.\n\t// For example a navigation page list load its items has an effect on edit to load its items.\n\treturn (\n\t\t<>\n\t\t\t{ isLoading && <NavigationMenuLoader /> }\n\t\t\t{ ! isLoading && (\n\t\t\t\t<OffCanvasEditor\n\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\tonSelect={ offCanvasOnselect }\n\t\t\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t\t\t\tshowAppender={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div style={ { visibility: 'hidden' } }>\n\t\t\t\t<BlockTools>\n\t\t\t\t\t<BlockList />\n\t\t\t\t</BlockTools>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js"],"names":["CustomLinkAdditionalBlockUI","block","onClose","updateBlockAttributes","blockEditorStore","label","url","opensInNewTab","attributes","link","title","updatedValue","clientId","MAX_PAGE_COUNT","PAGES_QUERY","per_page","_fields","orderby","order","NavigationMenuContent","rootClientId","onSelect","isLoading","setIsLoading","clientIdsTree","shouldKeepLoading","isSinglePageList","select","__unstableGetClientIdsTree","areInnerBlocksControlled","getBlockName","isResolving","coreStore","_clientIdsTree","hasOnlyPageListBlock","length","isLoadingPages","innerBlocks","replaceBlock","__unstableMarkNextChangeAsNotPersistent","customLinkEditPopoverOpenId","setIsCustomLinkEditPopoverOpenId","renderAdditionalBlockUICallback","timeoutId","setTimeout","undefined","clearTimeout","OffCanvasEditor","LeafMoreMenu","blockEditorPrivateApis","offCanvasOnselect","name","kind","visibility"],"mappings":";;;;;;;AAcA;;AAXA;;AAOA;;AACA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIA,SAASA,2BAAT,OAA2D;AAAA,MAArB;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAqB;AAC1D,QAAM;AAAEC,IAAAA;AAAF,MAA4B,uBAAaC,kBAAb,CAAlC;AACA,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,GAAT;AAAcC,IAAAA;AAAd,MAAgCN,KAAK,CAACO,UAA5C;AACA,QAAMC,IAAI,GAAG;AACZH,IAAAA,GADY;AAEZC,IAAAA,aAFY;AAGZG,IAAAA,KAAK,EAAEL,KAAK,IAAI,8BAAWA,KAAX;AAHJ,GAAb;AAKA,SACC,4BAAC,mBAAD;AAAS,IAAA,SAAS,EAAC,QAAnB;AAA4B,IAAA,KAAK,MAAjC;AAAkC,IAAA,OAAO,EAAGH;AAA5C,KACC,4BAAC,sCAAD;AACC,IAAA,cAAc,MADf;AAEC,IAAA,eAAe,MAFhB;AAGC,IAAA,KAAK,EAAGO,IAHT;AAIC,IAAA,QAAQ,EAAKE,YAAF,IAAoB;AAC9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AY,EAAG,KARhB;AASC,IAAA,uBAAuB,EAAGN;AAT3B,IAHF,EAeC;AAAK,IAAA,KAAK,EAAG;AAAEW,MAAAA,UAAU,EAAE;AAAd;AAAb,KACC,4BAAC,uBAAD,QACC,4BAAC,sBAAD,OADD,CADD,CAfD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\tBlockList,\n\tBlockTools,\n\t__experimentalLinkControl as LinkControl,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { createBlock } from '@wordpress/blocks';\nimport { Popover } from '@wordpress/components';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { NavigationMenuLoader } from './loader';\n\nfunction CustomLinkAdditionalBlockUI( { block, onClose } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { label, url, opensInNewTab } = block.attributes;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t\ttitle: label && stripHTML( label ),\n\t};\n\treturn (\n\t\t<Popover placement=\"bottom\" shift onClose={ onClose }>\n\t\t\t<LinkControl\n\t\t\t\thasTextControl\n\t\t\t\thasRichPreviews\n\t\t\t\tvalue={ link }\n\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\t\t\tlabel: updatedValue.title,\n\t\t\t\t\t\turl: updatedValue.url,\n\t\t\t\t\t\topensInNewTab: updatedValue.opensInNewTab,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\tonCancel={ onClose }\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n// Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js.\nconst MAX_PAGE_COUNT = 100;\nconst PAGES_QUERY = [\n\t'postType',\n\t'page',\n\t{\n\t\tper_page: MAX_PAGE_COUNT,\n\t\t_fields: [ 'id', 'link', 'menu_order', 'parent', 'title', 'type' ],\n\t\t// TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby\n\t\t// values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent\n\t\t// sort.\n\t\torderby: 'menu_order',\n\t\torder: 'asc',\n\t},\n];\n\nexport default function NavigationMenuContent( { rootClientId, onSelect } ) {\n\tconst [ isLoading, setIsLoading ] = useState( true );\n\tconst { clientIdsTree, shouldKeepLoading, isSinglePageList } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__unstableGetClientIdsTree,\n\t\t\t\tareInnerBlocksControlled,\n\t\t\t\tgetBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { isResolving } = select( coreStore );\n\n\t\t\tconst _clientIdsTree = __unstableGetClientIdsTree( rootClientId );\n\t\t\tconst hasOnlyPageListBlock =\n\t\t\t\t_clientIdsTree.length === 1 &&\n\t\t\t\tgetBlockName( _clientIdsTree[ 0 ].clientId ) ===\n\t\t\t\t\t'core/page-list';\n\t\t\tconst isLoadingPages = isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tPAGES_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tclientIdsTree: _clientIdsTree,\n\t\t\t\t// This is a small hack to wait for the navigation block\n\t\t\t\t// to actually load its inner blocks.\n\t\t\t\tshouldKeepLoading:\n\t\t\t\t\t! areInnerBlocksControlled( rootClientId ) ||\n\t\t\t\t\tisLoadingPages,\n\t\t\t\tisSinglePageList:\n\t\t\t\t\thasOnlyPageListBlock &&\n\t\t\t\t\t! isLoadingPages &&\n\t\t\t\t\t_clientIdsTree[ 0 ].innerBlocks.length > 0,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst [ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ] =\n\t\tuseState( false );\n\n\tconst renderAdditionalBlockUICallback = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tcustomLinkEditPopoverOpenId &&\n\t\t\t\tblock.clientId === customLinkEditPopoverOpenId\n\t\t\t) {\n\t\t\t\treturn (\n\t\t\t\t\t<CustomLinkAdditionalBlockUI\n\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\tsetIsCustomLinkEditPopoverOpenId( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\t[ customLinkEditPopoverOpenId, setIsCustomLinkEditPopoverOpenId ]\n\t);\n\n\t// Delay loading stop by 50ms to avoid flickering.\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\t\tif ( shouldKeepLoading && ! isLoading ) {\n\t\t\tsetIsLoading( true );\n\t\t}\n\t\tif ( ! shouldKeepLoading && isLoading ) {\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetIsLoading( false );\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}, 50 );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( timeoutId ) {\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t}\n\t\t};\n\t}, [ shouldKeepLoading, clientIdsTree, isLoading ] );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\tconst offCanvasOnselect = useCallback(\n\t\t( block ) => {\n\t\t\tif (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\t! block.attributes.url\n\t\t\t) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlock(\n\t\t\t\t\tblock.clientId,\n\t\t\t\t\tcreateBlock( 'core/navigation-link', block.attributes )\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tblock.name === 'core/navigation-link' &&\n\t\t\t\tblock.attributes.kind === 'custom' &&\n\t\t\t\tblock.attributes.url\n\t\t\t) {\n\t\t\t\tsetIsCustomLinkEditPopoverOpenId( block.clientId );\n\t\t\t} else {\n\t\t\t\tonSelect( block );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tonSelect,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\treplaceBlock,\n\t\t\tsetIsCustomLinkEditPopoverOpenId,\n\t\t]\n\t);\n\n\t// The hidden block is needed because it makes block edit side effects trigger.\n\t// For example a navigation page list load its items has an effect on edit to load its items.\n\treturn (\n\t\t<>\n\t\t\t{ isLoading && <NavigationMenuLoader /> }\n\t\t\t{ ! isLoading && (\n\t\t\t\t<OffCanvasEditor\n\t\t\t\t\tblocks={\n\t\t\t\t\t\tisSinglePageList\n\t\t\t\t\t\t\t? clientIdsTree[ 0 ].innerBlocks\n\t\t\t\t\t\t\t: clientIdsTree\n\t\t\t\t\t}\n\t\t\t\t\tonSelect={ offCanvasOnselect }\n\t\t\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t\t\t\tshowAppender={ false }\n\t\t\t\t\trenderAdditionalBlockUI={ renderAdditionalBlockUICallback }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div style={ { visibility: 'hidden' } }>\n\t\t\t\t<BlockTools>\n\t\t\t\t\t<BlockList />\n\t\t\t\t</BlockTools>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -25,6 +25,8 @@ var _blockEditor = require("@wordpress/block-editor");
25
25
 
26
26
  var _coreData = require("@wordpress/core-data");
27
27
 
28
+ var _htmlEntities = require("@wordpress/html-entities");
29
+
28
30
  var _store = require("../../store");
29
31
 
30
32
  var _siteIcon = _interopRequireDefault(require("../site-icon"));
@@ -45,10 +47,8 @@ var _privateApis = require("../../private-apis");
45
47
  const HUB_ANIMATION_DURATION = 0.3;
46
48
  const SiteHub = (0, _element.forwardRef)((props, ref) => {
47
49
  const {
48
- canvasMode,
49
- dashboardLink
50
+ canvasMode
50
51
  } = (0, _data.useSelect)(select => {
51
- select(_store.store).getEditedPostType();
52
52
  const {
53
53
  getCanvasMode,
54
54
  getSettings
@@ -65,16 +65,13 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
65
65
  const {
66
66
  clearSelectedBlock
67
67
  } = (0, _data.useDispatch)(_blockEditor.store);
68
- const isBackToDashboardButton = canvasMode === 'view';
69
- const showLabels = canvasMode !== 'edit';
70
- const siteIconButtonProps = isBackToDashboardButton ? {
71
- href: dashboardLink || 'index.php',
72
- 'aria-label': (0, _i18n.__)('Go back to the dashboard')
73
- } : {
74
- label: (0, _i18n.__)('Open Navigation Sidebar'),
68
+ const siteIconButtonProps = {
69
+ label: (0, _i18n.__)('Open Admin Sidebar'),
75
70
  onClick: () => {
76
- clearSelectedBlock();
77
- setCanvasMode('view');
71
+ if (canvasMode === 'edit') {
72
+ clearSelectedBlock();
73
+ setCanvasMode('view');
74
+ }
78
75
  }
79
76
  };
80
77
  const siteTitle = (0, _data.useSelect)(select => {
@@ -86,7 +83,7 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
86
83
  ref: ref
87
84
  }, props, {
88
85
  className: (0, _classnames.default)('edit-site-site-hub', props.className),
89
- layout: true,
86
+ initial: false,
90
87
  transition: {
91
88
  type: 'tween',
92
89
  duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
@@ -106,11 +103,37 @@ const SiteHub = (0, _element.forwardRef)((props, ref) => {
106
103
  }
107
104
  }, (0, _element.createElement)(_components.Button, (0, _extends2.default)({}, siteIconButtonProps, {
108
105
  className: "edit-site-layout__view-mode-toggle"
109
- }), (0, _element.createElement)(_siteIcon.default, {
106
+ }), (0, _element.createElement)(_components.__unstableMotion.div, {
107
+ initial: false,
108
+ animate: {
109
+ scale: canvasMode === 'view' ? 0.5 : 1
110
+ },
111
+ whileHover: {
112
+ scale: canvasMode === 'view' ? 0.5 : 0.96
113
+ },
114
+ transition: {
115
+ type: 'tween',
116
+ duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
117
+ ease: 'easeOut'
118
+ }
119
+ }, (0, _element.createElement)(_siteIcon.default, {
110
120
  className: "edit-site-layout__view-mode-toggle-icon"
111
- }))), showLabels && (0, _element.createElement)("div", {
112
- className: "edit-site-site-hub__site-title"
113
- }, siteTitle)));
121
+ })))), (0, _element.createElement)(_components.__unstableAnimatePresence, null, (0, _element.createElement)(_components.__unstableMotion.div, {
122
+ layout: canvasMode === 'edit',
123
+ animate: {
124
+ opacity: canvasMode === 'view' ? 1 : 0
125
+ },
126
+ exit: {
127
+ opacity: 0
128
+ },
129
+ className: "edit-site-site-hub__site-title",
130
+ transition: {
131
+ type: 'tween',
132
+ duration: disableMotion ? 0 : 0.2,
133
+ ease: 'easeOut',
134
+ delay: canvasMode === 'view' ? 0.1 : 0
135
+ }
136
+ }, (0, _htmlEntities.decodeEntities)(siteTitle)))));
114
137
  });
115
138
  var _default = SiteHub;
116
139
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","dashboardLink","select","editSiteStore","getEditedPostType","getCanvasMode","getSettings","__experimentalDashboardLink","disableMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","isBackToDashboardButton","showLabels","siteIconButtonProps","href","label","onClick","siteTitle","coreStore","getEntityRecord","title","className","type","duration","ease"],"mappings":";;;;;;;;;AAkBA;;;;AAfA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,GAA/B;AAEA,MAAMC,OAAO,GAAG,yBAAY,CAAEC,KAAF,EAASC,GAAT,KAAkB;AAC7C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MA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,MAJP;AAKC,IAAA,UAAU,EAAG;AACZC,MAAAA,IAAI,EAAE,OADM;AAEZC,MAAAA,QAAQ,EAAEhB,aAAa,GAAG,CAAH,GAAOZ,sBAFlB;AAGZ6B,MAAAA,IAAI,EAAE;AAHM;AALd,MAWC,4BAAC,gCAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,OAAO,EAAC;AAHT,KAKC,4BAAC,4BAAD,CAAQ,GAAR;AACC,IAAA,SAAS,EAAC,gDADX;AAEC,IAAA,MAAM,MAFP;AAGC,IAAA,UAAU,EAAG;AACZF,MAAAA,IAAI,EAAE,OADM;AAEZC,MAAAA,QAAQ,EAAEhB,aAAa,GAAG,CAAH,GAAOZ,sBAFlB;AAGZ6B,MAAAA,IAAI,EAAE;AAHM;AAHd,KASC,4BAAC,kBAAD,6BACMX,mBADN;AAEC,IAAA,SAAS,EAAC;AAFX,MAIC,4BAAC,iBAAD;AAAU,IAAA,SAAS,EAAC;AAApB,IAJD,CATD,CALD,EAsBGD,UAAU,IACX;AAAK,IAAA,SAAS,EAAC;AAAf,KACGK,SADH,CAvBF,CAXD,CADD;AA0CA,CA5Ee,CAAhB;eA8EerB,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../private-apis';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( props, ref ) => {\n\tconst { canvasMode, dashboardLink } = useSelect( ( select ) => {\n\t\tselect( editSiteStore ).getEditedPostType();\n\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst showLabels = canvasMode !== 'edit';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink || 'index.php',\n\t\t\t\t'aria-label': __( 'Go back to the dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\tlabel: __( 'Open Navigation Sidebar' ),\n\t\t\t\tonClick: () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t},\n\t\t };\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames( 'edit-site-site-hub', props.className ) }\n\t\t\tlayout\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\tspacing=\"0\"\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\tlayout\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t</Button>\n\t\t\t\t</motion.div>\n\n\t\t\t\t{ showLabels && (\n\t\t\t\t\t<div className=\"edit-site-site-hub__site-title\">\n\t\t\t\t\t\t{ siteTitle }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"names":["HUB_ANIMATION_DURATION","SiteHub","props","ref","canvasMode","select","getCanvasMode","getSettings","editSiteStore","dashboardLink","__experimentalDashboardLink","disableMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","siteIconButtonProps","label","onClick","siteTitle","coreStore","getEntityRecord","title","className","type","duration","ease","scale","opacity","delay"],"mappings":";;;;;;;;;AAoBA;;;;AAjBA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,GAA/B;AAEA,MAAMC,OAAO,GAAG,yBAAY,CAAEC,KAAF,EAASC,GAAT,KAAkB;AAC7C,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBAAaC,MAAF,IAAc;AAC/C,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAAiC,yBACtCF,MAAM,CAAEG,YAAF,CADgC,CAAvC;AAGA,WAAO;AACNJ,MAAAA,UAAU,EAAEE,aAAa,EADnB;AA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AAhB,CAhBH,CADD,CAvCD,CAXD,CADD;AA0EA,CAtGe,CAAhB;eAwGejB,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../private-apis';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = forwardRef( ( props, ref ) => {\n\tconst { canvasMode } = useSelect( ( select ) => {\n\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\tselect( editSiteStore )\n\t\t);\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\tdashboardLink: getSettings().__experimentalDashboardLink,\n\t\t};\n\t}, [] );\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst siteIconButtonProps = {\n\t\tlabel: __( 'Open Admin Sidebar' ),\n\t\tonClick: () => {\n\t\t\tif ( canvasMode === 'edit' ) {\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t}\n\t\t},\n\t};\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames( 'edit-site-site-hub', props.className ) }\n\t\t\tinitial={ false }\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"edit-site-site-hub__text-content\"\n\t\t\t\tspacing=\"0\"\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"edit-site-site-hub__view-mode-toggle-container\"\n\t\t\t\t\tlayout\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tinitial={ false }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\twhileHover={ {\n\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 0.96,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t</Button>\n\t\t\t\t</motion.div>\n\n\t\t\t\t<AnimatePresence>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tlayout={ canvasMode === 'edit' }\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: canvasMode === 'view' ? 1 : 0,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\texit={ {\n\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tclassName=\"edit-site-site-hub__site-title\"\n\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.2,\n\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\tdelay: canvasMode === 'view' ? 0.1 : 0,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t</motion.div>\n\t\t\t\t</AnimatePresence>\n\t\t\t</HStack>\n\t\t</motion.div>\n\t);\n} );\n\nexport default SiteHub;\n"]}
@@ -37,18 +37,19 @@ function SiteIcon(_ref) {
37
37
  siteIconUrl
38
38
  } = (0, _data.useSelect)(select => {
39
39
  const {
40
- getEntityRecord,
41
- isResolving
40
+ getEntityRecord
42
41
  } = select(_coreData.store);
43
- const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
42
+ const siteData = getEntityRecord('root', '__unstableBase', undefined);
44
43
  return {
45
- isRequestingSite: isResolving('core', 'getEntityRecord', ['root', '__unstableBase', undefined]),
46
- siteIconUrl: siteData.site_icon_url
44
+ isRequestingSite: !siteData,
45
+ siteIconUrl: siteData === null || siteData === void 0 ? void 0 : siteData.site_icon_url
47
46
  };
48
47
  }, []);
49
48
 
50
49
  if (isRequestingSite && !siteIconUrl) {
51
- return null;
50
+ return (0, _element.createElement)("div", {
51
+ className: "edit-site-site-icon__image"
52
+ });
52
53
  }
53
54
 
54
55
  const icon = siteIconUrl ? (0, _element.createElement)("img", {
@@ -57,7 +58,7 @@ function SiteIcon(_ref) {
57
58
  src: siteIconUrl
58
59
  }) : (0, _element.createElement)(_components.Icon, {
59
60
  className: "edit-site-site-icon__icon",
60
- size: "32px",
61
+ size: "48px",
61
62
  icon: _icons.wordpress
62
63
  });
63
64
  return (0, _element.createElement)("div", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/site-icon/index.js"],"names":["SiteIcon","className","isRequestingSite","siteIconUrl","select","getEntityRecord","isResolving","coreDataStore","siteData","undefined","site_icon_url","icon","wordpress"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;AAOA,SAASA,QAAT,OAAmC;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAClC,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAoC,qBAAaC,MAAF,IAAc;AAClE,UAAM;AAAEC,MAAAA,eAAF;AAAmBC,MAAAA;AAAnB,QAAmCF,MAAM,CAAEG,eAAF,CAA/C;AACA,UAAMC,QAAQ,GACbH,eAAe,CAAE,MAAF,EAAU,gBAAV,EAA4BI,SAA5B,CAAf,IAA0D,EAD3D;AAGA,WAAO;AACNP,MAAAA,gBAAgB,EAAEI,WAAW,CAAE,MAAF,EAAU,iBAAV,EAA6B,CACzD,MADyD,EAEzD,gBAFyD,EAGzDG,SAHyD,CAA7B,CADvB;AAMNN,MAAAA,WAAW,EAAEK,QAAQ,CAACE;AANhB,KAAP;AAQA,GAbyC,EAavC,EAbuC,CAA1C;;AAeA,MAAKR,gBAAgB,IAAI,CAAEC,WAA3B,EAAyC;AACxC,WAAO,IAAP;AACA;;AAED,QAAMQ,IAAI,GAAGR,WAAW,GACvB;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,GAAG,EAAG,cAAI,WAAJ,CAFP;AAGC,IAAA,GAAG,EAAGA;AAHP,IADuB,GAOvB,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,2BADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,IAAA,IAAI,EAAGS;AAHR,IAPD;AAcA,SACC;AAAK,IAAA,SAAS,EAAG,yBAAYX,SAAZ,EAAuB,qBAAvB;AAAjB,KACGU,IADH,CADD;AAKA;;eAEcX,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Icon } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { wordpress } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\nfunction SiteIcon( { className } ) {\n\tconst { isRequestingSite, siteIconUrl } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, isResolving } = select( coreDataStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\tisRequestingSite: isResolving( 'core', 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t};\n\t}, [] );\n\n\tif ( isRequestingSite && ! siteIconUrl ) {\n\t\treturn null;\n\t}\n\n\tconst icon = siteIconUrl ? (\n\t\t<img\n\t\t\tclassName=\"edit-site-site-icon__image\"\n\t\t\talt={ __( 'Site Icon' ) }\n\t\t\tsrc={ siteIconUrl }\n\t\t/>\n\t) : (\n\t\t<Icon\n\t\t\tclassName=\"edit-site-site-icon__icon\"\n\t\t\tsize=\"32px\"\n\t\t\ticon={ wordpress }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<div className={ classnames( className, 'edit-site-site-icon' ) }>\n\t\t\t{ icon }\n\t\t</div>\n\t);\n}\n\nexport default SiteIcon;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/site-icon/index.js"],"names":["SiteIcon","className","isRequestingSite","siteIconUrl","select","getEntityRecord","coreDataStore","siteData","undefined","site_icon_url","icon","wordpress"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;AAOA,SAASA,QAAT,OAAmC;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAClC,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAoC,qBAAaC,MAAF,IAAc;AAClE,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAEE,eAAF,CAAlC;AACA,UAAMC,QAAQ,GAAGF,eAAe,CAAE,MAAF,EAAU,gBAAV,EAA4BG,SAA5B,CAAhC;AAEA,WAAO;AACNN,MAAAA,gBAAgB,EAAE,CAAEK,QADd;AAENJ,MAAAA,WAAW,EAAEI,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEE;AAFjB,KAAP;AAIA,GARyC,EAQvC,EARuC,CAA1C;;AAUA,MAAKP,gBAAgB,IAAI,CAAEC,WAA3B,EAAyC;AACxC,WAAO;AAAK,MAAA,SAAS,EAAC;AAAf,MAAP;AACA;;AAED,QAAMO,IAAI,GAAGP,WAAW,GACvB;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,GAAG,EAAG,cAAI,WAAJ,CAFP;AAGC,IAAA,GAAG,EAAGA;AAHP,IADuB,GAOvB,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,2BADX;AAEC,IAAA,IAAI,EAAC,MAFN;AAGC,IAAA,IAAI,EAAGQ;AAHR,IAPD;AAcA,SACC;AAAK,IAAA,SAAS,EAAG,yBAAYV,SAAZ,EAAuB,qBAAvB;AAAjB,KACGS,IADH,CADD;AAKA;;eAEcV,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Icon } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { wordpress } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\nfunction SiteIcon( { className } ) {\n\tconst { isRequestingSite, siteIconUrl } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreDataStore );\n\t\tconst siteData = getEntityRecord( 'root', '__unstableBase', undefined );\n\n\t\treturn {\n\t\t\tisRequestingSite: ! siteData,\n\t\t\tsiteIconUrl: siteData?.site_icon_url,\n\t\t};\n\t}, [] );\n\n\tif ( isRequestingSite && ! siteIconUrl ) {\n\t\treturn <div className=\"edit-site-site-icon__image\" />;\n\t}\n\n\tconst icon = siteIconUrl ? (\n\t\t<img\n\t\t\tclassName=\"edit-site-site-icon__image\"\n\t\t\talt={ __( 'Site Icon' ) }\n\t\t\tsrc={ siteIconUrl }\n\t\t/>\n\t) : (\n\t\t<Icon\n\t\t\tclassName=\"edit-site-site-icon__icon\"\n\t\t\tsize=\"48px\"\n\t\t\ticon={ wordpress }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<div className={ classnames( className, 'edit-site-site-icon' ) }>\n\t\t\t{ icon }\n\t\t</div>\n\t);\n}\n\nexport default SiteIcon;\n"]}
@@ -54,7 +54,7 @@ function useFallbackTemplateContent(slug) {
54
54
  } = _ref;
55
55
  return setTemplateContent(content.raw);
56
56
  });
57
- }, [slug]);
57
+ }, [isCustom, slug]);
58
58
  return templateContent;
59
59
  }
60
60
 
@@ -147,7 +147,8 @@ function StartModal(_ref3) {
147
147
  title: (0, _i18n.__)('Choose a pattern'),
148
148
  closeLabel: (0, _i18n.__)('Cancel'),
149
149
  focusOnMount: "firstElement",
150
- onRequestClose: onClose
150
+ onRequestClose: onClose,
151
+ isFullScreen: true
151
152
  }, (0, _element.createElement)("div", {
152
153
  className: "edit-site-start-template-options__modal-content"
153
154
  }, (0, _element.createElement)(PatternSelection, {
@@ -169,7 +170,7 @@ const START_TEMPLATE_MODAL_STATES = {
169
170
  function StartTemplateOptions() {
170
171
  const [modalState, setModalState] = (0, _element.useState)(START_TEMPLATE_MODAL_STATES.INITIAL);
171
172
  const {
172
- shouldOpenModel,
173
+ shouldOpenModal,
173
174
  slug,
174
175
  isCustom,
175
176
  postType
@@ -183,20 +184,20 @@ function StartTemplateOptions() {
183
184
 
184
185
  const postId = getEditedPostId();
185
186
  const {
186
- __experimentalGetDirtyEntityRecords,
187
- getEditedEntityRecord
187
+ getEditedEntityRecord,
188
+ hasEditsForEntityRecord
188
189
  } = select(_coreData.store);
189
190
  const templateRecord = getEditedEntityRecord('postType', _postType, postId);
190
- const hasDirtyEntityRecords = __experimentalGetDirtyEntityRecords().length > 0;
191
+ const hasEdits = hasEditsForEntityRecord('postType', _postType, postId);
191
192
  return {
192
- shouldOpenModel: !hasDirtyEntityRecords && '' === templateRecord.content && 'wp_template' === _postType && !select(_preferences.store).get('core/edit-site', 'welcomeGuide'),
193
+ shouldOpenModal: !hasEdits && '' === templateRecord.content && 'wp_template' === _postType && !select(_preferences.store).get('core/edit-site', 'welcomeGuide'),
193
194
  slug: templateRecord.slug,
194
195
  isCustom: templateRecord.is_custom,
195
196
  postType: _postType
196
197
  };
197
198
  }, []);
198
199
 
199
- if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModel || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) {
200
+ if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModal || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) {
200
201
  return null;
201
202
  }
202
203
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"names":["useFallbackTemplateContent","slug","isCustom","templateContent","setTemplateContent","path","is_custom","ignore_empty","then","content","raw","START_BLANK_TITLE","useStartPatterns","fallbackContent","patterns","select","getEditedPostType","getEditedPostId","editSiteStore","getEntityRecord","coreStore","postId","postType","record","getSettings","blockEditorStore","__experimentalBlockPatterns","name","blocks","title","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","map","PatternSelection","onChoosePattern","onChange","blockPatterns","shownBlockPatterns","selection","undefined","StartModal","onClose","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","shouldOpenModel","_postType","__experimentalGetDirtyEntityRecords","getEditedEntityRecord","templateRecord","hasDirtyEntityRecords","length","preferencesStore","get"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAaA;AACA;AACA;AAMA,SAASA,0BAAT,CAAqCC,IAArC,EAA8D;AAAA,MAAnBC,QAAmB,uEAAR,KAAQ;AAC7D,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,EAAV,CAAhD;AAEA,0BAAW,MAAM;AAChB,2BAAU;AACTC,MAAAA,IAAI,EAAE,uBAAc,yBAAd,EAAyC;AAC9CJ,QAAAA,IAD8C;AAE9CK,QAAAA,SAAS,EAAEJ,QAFmC;AAG9CK,QAAAA,YAAY,EAAE;AAHgC,OAAzC;AADG,KAAV,EAMIC,IANJ,CAMU;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAmBL,kBAAkB,CAAEK,OAAO,CAACC,GAAV,CAArC;AAAA,KANV;AAOA,GARD,EAQG,CAAET,IAAF,CARH;AASA,SAAOE,eAAP;AACA;;AAED,MAAMQ,iBAAiB,GAAG,cAAI,aAAJ,CAA1B;;AAEA,SAASC,gBAAT,CAA2BC,eAA3B,EAA6C;AAC5C,QAAM;AAAEZ,IAAAA,IAAF;AAAQa,IAAAA;AAAR,MAAqB,qBAAaC,MAAF,IAAc;AACnD,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBJ,MAAM,CAAEK,eAAF,CAAlC;AACA,UAAMC,MAAM,GAAGJ,eAAe,EAA9B;AACA,UAAMK,QAAQ,GAAGN,iBAA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,2BAA2B,CAACC,OAA3C,IACD,CAAEK,eADH,IAEAF,UAAU,KAAKJ,2BAA2B,CAACE,MAH5C,EAIE;AACD,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,UAAD;AACC,IAAA,IAAI,EAAGjD,IADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGoB,QAHZ;AAIC,IAAA,OAAO,EAAG,MACT+B,aAAa,CAAEL,2BAA2B,CAACE,MAA9B;AALf,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalBlockPatternsList as BlockPatternsList,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\tconst [ templateContent, setTemplateContent ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} ),\n\t\t} ).then( ( { content } ) => setTemplateContent( content.raw ) );\n\t}, [ slug ] );\n\treturn templateContent;\n}\n\nconst START_BLANK_TITLE = __( 'Start blank' );\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postId = getEditedPostId();\n\t\tconst postType = getEditedPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getSettings().__experimentalBlockPatterns,\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn { ...pattern, blocks: parse( pattern.content ) };\n\t\t\t\t} ),\n\t\t\t{\n\t\t\t\tname: 'start-blank',\n\t\t\t\tblocks: parse(\n\t\t\t\t\t'<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->'\n\t\t\t\t),\n\t\t\t\ttitle: START_BLANK_TITLE,\n\t\t\t},\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"edit-site-start-template-options__pattern-container\"\n\t\t\tstyle={ {\n\t\t\t\t'--wp-edit-site-start-template-options-start-blank': `\"${ START_BLANK_TITLE }\"`,\n\t\t\t} }\n\t\t>\n\t\t\t<BlockPatternsList\n\t\t\t\tblockPatterns={ blockPatterns }\n\t\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\tonChange( 'start-blank' === pattern.name ? [] : blocks, {\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonChoosePattern();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-site-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nconst START_TEMPLATE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartTemplateOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_TEMPLATE_MODAL_STATES.INITIAL\n\t);\n\tconst { shouldOpenModel, slug, isCustom, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst postId = getEditedPostId();\n\t\t\tconst {\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\tconst hasDirtyEntityRecords =\n\t\t\t\t__experimentalGetDirtyEntityRecords().length > 0;\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModel:\n\t\t\t\t\t! hasDirtyEntityRecords &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\t'wp_template' === _postType &&\n\t\t\t\t\t! select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t),\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&\n\t\t\t! shouldOpenModel ) ||\n\t\tmodalState === START_TEMPLATE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () =>\n\t\t\t\tsetModalState( START_TEMPLATE_MODAL_STATES.CLOSED )\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"names":["useFallbackTemplateContent","slug","isCustom","templateContent","setTemplateContent","path","is_custom","ignore_empty","then","content","raw","START_BLANK_TITLE","useStartPatterns","fallbackContent","patterns","select","getEditedPostType","getEditedPostId","editSiteStore","getEntityRecord","coreStore","postId","postType","record","getSettings","blockEditorStore","__experimentalBlockPatterns","name","blocks","title","filter","pattern","Array","isArray","templateTypes","some","templateType","startsWith","map","PatternSelection","onChoosePattern","onChange","blockPatterns","shownBlockPatterns","selection","undefined","StartModal","onClose","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","shouldOpenModal","_postType","getEditedEntityRecord","hasEditsForEntityRecord","templateRecord","hasEdits","preferencesStore","get"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAaA;AACA;AACA;AAMA,SAASA,0BAAT,CAAqCC,IAArC,EAA8D;AAAA,MAAnBC,QAAmB,uEAAR,KAAQ;AAC7D,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,EAAV,CAAhD;AAEA,0BAAW,MAAM;AAChB,2BAAU;AACTC,MAAAA,IAAI,EAAE,uBAAc,yBAAd,EAAyC;AAC9CJ,QAAAA,IAD8C;AAE9CK,QAAAA,SAAS,EAAEJ,QAFmC;AAG9CK,QAAAA,YAAY,EAAE;AAHgC,OAAzC;AADG,KAAV,EAMIC,IANJ,CAMU;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAmBL,kBAAkB,CAAEK,OAAO,CAACC,GAAV,CAArC;AAAA,KANV;AAOA,GARD,EAQG,CAAER,QAAF,EAAYD,IAAZ,CARH;AASA,SAAOE,eAAP;AACA;;AAED,MAAMQ,iBAAiB,GAAG,cAAI,aAAJ,CAA1B;;AAEA,SAASC,gBAAT,CAA2BC,eAA3B,EAA6C;AAC5C,QAAM;AAAEZ,IAAAA,IAAF;AAAQa,IAAAA;AAAR,MAAqB,qBAAaC,MAAF,IAAc;AACnD,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBJ,MAAM,CAAEK,eAAF,CAAlC;AACA,UAAMC,MAAM,GAAGJ,eAAe,EAA9B;AACA,UAAMK,QAAQ,GAAGN,iBAAiB,EAAlC;AACA,UAAMO,MAAM,GAAGJ,eAAe,CAAE,UAAF,EAAcG,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CAACC,OAA3C,IACD,CAAEK,eADH,IAEAF,UAAU,KAAKJ,2BAA2B,CAACE,MAH5C,EAIE;AACD,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,UAAD;AACC,IAAA,IAAI,EAAGjD,IADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGoB,QAHZ;AAIC,IAAA,OAAO,EAAG,MACT+B,aAAa,CAAEL,2BAA2B,CAACE,MAA9B;AALf,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalBlockPatternsList as BlockPatternsList,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\nfunction useFallbackTemplateContent( slug, isCustom = false ) {\n\tconst [ templateContent, setTemplateContent ] = useState( '' );\n\n\tuseEffect( () => {\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\tslug,\n\t\t\t\tis_custom: isCustom,\n\t\t\t\tignore_empty: true,\n\t\t\t} ),\n\t\t} ).then( ( { content } ) => setTemplateContent( content.raw ) );\n\t}, [ isCustom, slug ] );\n\treturn templateContent;\n}\n\nconst START_BLANK_TITLE = __( 'Start blank' );\n\nfunction useStartPatterns( fallbackContent ) {\n\tconst { slug, patterns } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst postId = getEditedPostId();\n\t\tconst postType = getEditedPostType();\n\t\tconst record = getEntityRecord( 'postType', postType, postId );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tslug: record.slug,\n\t\t\tpatterns: getSettings().__experimentalBlockPatterns,\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\t// filter patterns that are supposed to be used in the current template being edited.\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'fallback',\n\t\t\t\tblocks: parse( fallbackContent ),\n\t\t\t\ttitle: __( 'Fallback content' ),\n\t\t\t},\n\t\t\t...patterns\n\t\t\t\t.filter( ( pattern ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tArray.isArray( pattern.templateTypes ) &&\n\t\t\t\t\t\tpattern.templateTypes.some( ( templateType ) =>\n\t\t\t\t\t\t\tslug.startsWith( templateType )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( pattern ) => {\n\t\t\t\t\treturn { ...pattern, blocks: parse( pattern.content ) };\n\t\t\t\t} ),\n\t\t\t{\n\t\t\t\tname: 'start-blank',\n\t\t\t\tblocks: parse(\n\t\t\t\t\t'<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->'\n\t\t\t\t),\n\t\t\t\ttitle: START_BLANK_TITLE,\n\t\t\t},\n\t\t];\n\t}, [ fallbackContent, slug, patterns ] );\n}\n\nfunction PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useStartPatterns( fallbackContent );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"edit-site-start-template-options__pattern-container\"\n\t\t\tstyle={ {\n\t\t\t\t'--wp-edit-site-start-template-options-start-blank': `\"${ START_BLANK_TITLE }\"`,\n\t\t\t} }\n\t\t>\n\t\t\t<BlockPatternsList\n\t\t\t\tblockPatterns={ blockPatterns }\n\t\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\tonChange( 'start-blank' === pattern.name ? [] : blocks, {\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonChoosePattern();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction StartModal( { slug, isCustom, onClose, postType } ) {\n\tconst fallbackContent = useFallbackTemplateContent( slug, isCustom );\n\tif ( ! fallbackContent ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-start-template-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\tfocusOnMount=\"firstElement\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen={ true }\n\t\t>\n\t\t\t<div className=\"edit-site-start-template-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tfallbackContent={ fallbackContent }\n\t\t\t\t\tslug={ slug }\n\t\t\t\t\tisCustom={ isCustom }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nconst START_TEMPLATE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartTemplateOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_TEMPLATE_MODAL_STATES.INITIAL\n\t);\n\tconst { shouldOpenModal, slug, isCustom, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst _postType = getEditedPostType();\n\t\t\tconst postId = getEditedPostId();\n\t\t\tconst { getEditedEntityRecord, hasEditsForEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst templateRecord = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst hasEdits = hasEditsForEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\tpostId\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tshouldOpenModal:\n\t\t\t\t\t! hasEdits &&\n\t\t\t\t\t'' === templateRecord.content &&\n\t\t\t\t\t'wp_template' === _postType &&\n\t\t\t\t\t! select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-site',\n\t\t\t\t\t\t'welcomeGuide'\n\t\t\t\t\t),\n\t\t\t\tslug: templateRecord.slug,\n\t\t\t\tisCustom: templateRecord.is_custom,\n\t\t\t\tpostType: _postType,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif (\n\t\t( modalState === START_TEMPLATE_MODAL_STATES.INITIAL &&\n\t\t\t! shouldOpenModal ) ||\n\t\tmodalState === START_TEMPLATE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<StartModal\n\t\t\tslug={ slug }\n\t\t\tisCustom={ isCustom }\n\t\t\tpostType={ postType }\n\t\t\tonClose={ () =>\n\t\t\t\tsetModalState( START_TEMPLATE_MODAL_STATES.CLOSED )\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
- exports.useHasStyleBook = useHasStyleBook;
10
9
 
11
10
  var _element = require("@wordpress/element");
12
11
 
@@ -24,14 +23,12 @@ var _blockEditor = require("@wordpress/block-editor");
24
23
 
25
24
  var _data = require("@wordpress/data");
26
25
 
27
- var _icons = require("@wordpress/icons");
28
-
29
26
  var _compose = require("@wordpress/compose");
30
27
 
31
- var _keycodes = require("@wordpress/keycodes");
32
-
33
28
  var _privateApis = require("../../private-apis");
34
29
 
30
+ var _editorCanvasContainer = _interopRequireDefault(require("../editor-canvas-container"));
31
+
35
32
  /**
36
33
  * External dependencies
37
34
  */
@@ -46,12 +43,7 @@ var _privateApis = require("../../private-apis");
46
43
  const {
47
44
  ExperimentalBlockEditorProvider,
48
45
  useGlobalStyle
49
- } = (0, _privateApis.unlock)(_blockEditor.privateApis);
50
- const SLOT_FILL_NAME = 'EditSiteStyleBook';
51
- const {
52
- Slot: StyleBookSlot,
53
- Fill: StyleBookFill
54
- } = (0, _components.createSlotFill)(SLOT_FILL_NAME); // The content area of the Style Book is rendered within an iframe so that global styles
46
+ } = (0, _privateApis.unlock)(_blockEditor.privateApis); // The content area of the Style Book is rendered within an iframe so that global styles
55
47
  // are applied to elements within the entire content area. To support elements that are
56
48
  // not part of the block previews, such as headings and layout for the block previews,
57
49
  // additional CSS rules need to be passed into the iframe. These are hard-coded below.
@@ -165,12 +157,9 @@ function getExamples() {
165
157
  function StyleBook(_ref) {
166
158
  let {
167
159
  isSelected,
168
- onSelect,
169
- onClose
160
+ onSelect
170
161
  } = _ref;
171
162
  const [resizeObserver, sizes] = (0, _compose.useResizeObserver)();
172
- const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
173
- const sectionFocusReturnRef = (0, _compose.useFocusReturn)();
174
163
  const [textColor] = useGlobalStyle('color.text');
175
164
  const [backgroundColor] = useGlobalStyle('color.background');
176
165
  const examples = (0, _element.useMemo)(getExamples, []);
@@ -183,32 +172,17 @@ function StyleBook(_ref) {
183
172
  const settings = (0, _element.useMemo)(() => ({ ...originalSettings,
184
173
  __unstableIsPreviewMode: true
185
174
  }), [originalSettings]);
186
-
187
- function closeOnEscape(event) {
188
- if (event.keyCode === _keycodes.ESCAPE && !event.defaultPrevented) {
189
- event.preventDefault();
190
- onClose();
191
- }
192
- }
193
-
194
- return (0, _element.createElement)(StyleBookFill, null, (0, _element.createElement)("section", {
175
+ return (0, _element.createElement)(_editorCanvasContainer.default, {
176
+ closeButtonLabel: (0, _i18n.__)('Close Style Book')
177
+ }, (0, _element.createElement)("div", {
195
178
  className: (0, _classnames.default)('edit-site-style-book', {
196
179
  'is-wide': sizes.width > 600
197
180
  }),
198
181
  style: {
199
182
  color: textColor,
200
183
  background: backgroundColor
201
- },
202
- "aria-label": (0, _i18n.__)('Style Book'),
203
- onKeyDown: closeOnEscape,
204
- ref: (0, _compose.useMergeRefs)([sectionFocusReturnRef, focusOnMountRef])
205
- }, resizeObserver, (0, _element.createElement)(_components.Button, {
206
- className: "edit-site-style-book__close-button",
207
- icon: _icons.closeSmall,
208
- label: (0, _i18n.__)('Close Style Book'),
209
- onClick: onClose,
210
- showTooltip: false
211
- }), (0, _element.createElement)(_components.TabPanel, {
184
+ }
185
+ }, resizeObserver, (0, _element.createElement)(_components.TabPanel, {
212
186
  className: "edit-site-style-book__tab-panel",
213
187
  tabs: tabs
214
188
  }, tab => (0, _element.createElement)(_blockEditor.__unstableIframe, {
@@ -301,12 +275,6 @@ const Example = _ref3 => {
301
275
  })))));
302
276
  };
303
277
 
304
- function useHasStyleBook() {
305
- const fills = (0, _components.__experimentalUseSlotFills)(SLOT_FILL_NAME);
306
- return !!(fills !== null && fills !== void 0 && fills.length);
307
- }
308
-
309
- StyleBook.Slot = StyleBookSlot;
310
278
  var _default = StyleBook;
311
279
  exports.default = _default;
312
280
  //# sourceMappingURL=index.js.map