@wordpress/edit-site 5.3.3 → 5.4.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 (172) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/new-template.js +1 -20
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +1 -0
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -1
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/border-panel.js +4 -4
  10. package/build/components/global-styles/border-panel.js.map +1 -1
  11. package/build/components/global-styles/color-palette-panel.js +5 -2
  12. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  13. package/build/components/global-styles/color-utils.js +1 -1
  14. package/build/components/global-styles/color-utils.js.map +1 -1
  15. package/build/components/global-styles/context-menu.js +16 -3
  16. package/build/components/global-styles/context-menu.js.map +1 -1
  17. package/build/components/global-styles/custom-css.js +1 -1
  18. package/build/components/global-styles/custom-css.js.map +1 -1
  19. package/build/components/global-styles/dimensions-panel.js +8 -7
  20. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  21. package/build/components/global-styles/gradients-palette-panel.js +8 -3
  22. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  23. package/build/components/global-styles/header.js +3 -1
  24. package/build/components/global-styles/header.js.map +1 -1
  25. package/build/components/global-styles/hooks.js +14 -51
  26. package/build/components/global-styles/hooks.js.map +1 -1
  27. package/build/components/global-styles/palette.js +3 -1
  28. package/build/components/global-styles/palette.js.map +1 -1
  29. package/build/components/global-styles/screen-background-color.js +3 -2
  30. package/build/components/global-styles/screen-background-color.js.map +1 -1
  31. package/build/components/global-styles/screen-block-list.js +14 -3
  32. package/build/components/global-styles/screen-block-list.js.map +1 -1
  33. package/build/components/global-styles/screen-button-color.js +7 -5
  34. package/build/components/global-styles/screen-button-color.js.map +1 -1
  35. package/build/components/global-styles/screen-colors.js +8 -6
  36. package/build/components/global-styles/screen-colors.js.map +1 -1
  37. package/build/components/global-styles/screen-heading-color.js +8 -6
  38. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  39. package/build/components/global-styles/screen-link-color.js +3 -2
  40. package/build/components/global-styles/screen-link-color.js.map +1 -1
  41. package/build/components/global-styles/screen-text-color.js +3 -2
  42. package/build/components/global-styles/screen-text-color.js.map +1 -1
  43. package/build/components/global-styles/screen-typography.js +3 -1
  44. package/build/components/global-styles/screen-typography.js.map +1 -1
  45. package/build/components/global-styles/shadow-panel.js +2 -3
  46. package/build/components/global-styles/shadow-panel.js.map +1 -1
  47. package/build/components/global-styles/subtitle.js +3 -2
  48. package/build/components/global-styles/subtitle.js.map +1 -1
  49. package/build/components/global-styles/typography-panel.js +23 -300
  50. package/build/components/global-styles/typography-panel.js.map +1 -1
  51. package/build/components/navigation-inspector/index.js +0 -29
  52. package/build/components/navigation-inspector/index.js.map +1 -1
  53. package/build/components/navigation-inspector/navigation-menu.js +4 -2
  54. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  55. package/build/components/sidebar/index.js +1 -20
  56. package/build/components/sidebar/index.js.map +1 -1
  57. package/build/components/sidebar-edit-mode/index.js +1 -1
  58. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  59. package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
  60. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  61. package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
  62. package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  63. package/build/components/start-template-options/index.js +175 -0
  64. package/build/components/start-template-options/index.js.map +1 -0
  65. package/build/hooks/push-changes-to-global-styles/index.js +5 -4
  66. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  67. package/build-module/components/add-new-template/new-template.js +1 -18
  68. package/build-module/components/add-new-template/new-template.js.map +1 -1
  69. package/build-module/components/app/index.js.map +1 -1
  70. package/build-module/components/block-editor/editor-canvas.js +1 -0
  71. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  72. package/build-module/components/editor/index.js +2 -1
  73. package/build-module/components/editor/index.js.map +1 -1
  74. package/build-module/components/global-styles/border-panel.js +5 -5
  75. package/build-module/components/global-styles/border-panel.js.map +1 -1
  76. package/build-module/components/global-styles/color-palette-panel.js +5 -2
  77. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  78. package/build-module/components/global-styles/color-utils.js +2 -2
  79. package/build-module/components/global-styles/color-utils.js.map +1 -1
  80. package/build-module/components/global-styles/context-menu.js +13 -2
  81. package/build-module/components/global-styles/context-menu.js.map +1 -1
  82. package/build-module/components/global-styles/custom-css.js +1 -1
  83. package/build-module/components/global-styles/custom-css.js.map +1 -1
  84. package/build-module/components/global-styles/dimensions-panel.js +9 -8
  85. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  86. package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
  87. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  88. package/build-module/components/global-styles/header.js +3 -1
  89. package/build-module/components/global-styles/header.js.map +1 -1
  90. package/build-module/components/global-styles/hooks.js +12 -49
  91. package/build-module/components/global-styles/hooks.js.map +1 -1
  92. package/build-module/components/global-styles/palette.js +3 -1
  93. package/build-module/components/global-styles/palette.js.map +1 -1
  94. package/build-module/components/global-styles/screen-background-color.js +4 -3
  95. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  96. package/build-module/components/global-styles/screen-block-list.js +12 -3
  97. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  98. package/build-module/components/global-styles/screen-button-color.js +8 -6
  99. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  100. package/build-module/components/global-styles/screen-colors.js +9 -7
  101. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  102. package/build-module/components/global-styles/screen-heading-color.js +9 -7
  103. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  104. package/build-module/components/global-styles/screen-link-color.js +4 -3
  105. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  106. package/build-module/components/global-styles/screen-text-color.js +4 -3
  107. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  108. package/build-module/components/global-styles/screen-typography.js +3 -1
  109. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  110. package/build-module/components/global-styles/shadow-panel.js +3 -4
  111. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  112. package/build-module/components/global-styles/subtitle.js +3 -2
  113. package/build-module/components/global-styles/subtitle.js.map +1 -1
  114. package/build-module/components/global-styles/typography-panel.js +27 -300
  115. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  116. package/build-module/components/navigation-inspector/index.js +0 -27
  117. package/build-module/components/navigation-inspector/index.js.map +1 -1
  118. package/build-module/components/navigation-inspector/navigation-menu.js +4 -2
  119. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  120. package/build-module/components/sidebar/index.js +1 -18
  121. package/build-module/components/sidebar/index.js.map +1 -1
  122. package/build-module/components/sidebar-edit-mode/index.js +1 -1
  123. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  124. package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
  125. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  126. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
  127. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  128. package/build-module/components/start-template-options/index.js +156 -0
  129. package/build-module/components/start-template-options/index.js.map +1 -0
  130. package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
  131. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  132. package/build-style/style-rtl.css +73 -4
  133. package/build-style/style.css +73 -4
  134. package/package.json +31 -31
  135. package/src/components/add-new-template/new-template.js +1 -16
  136. package/src/components/app/index.js +0 -1
  137. package/src/components/block-editor/editor-canvas.js +1 -0
  138. package/src/components/editor/index.js +2 -0
  139. package/src/components/global-styles/border-panel.js +5 -5
  140. package/src/components/global-styles/color-palette-panel.js +3 -0
  141. package/src/components/global-styles/color-utils.js +2 -3
  142. package/src/components/global-styles/context-menu.js +17 -2
  143. package/src/components/global-styles/custom-css.js +1 -1
  144. package/src/components/global-styles/dimensions-panel.js +12 -8
  145. package/src/components/global-styles/gradients-palette-panel.js +4 -1
  146. package/src/components/global-styles/header.js +7 -1
  147. package/src/components/global-styles/hooks.js +17 -90
  148. package/src/components/global-styles/palette.js +1 -1
  149. package/src/components/global-styles/screen-background-color.js +3 -2
  150. package/src/components/global-styles/screen-block-list.js +19 -3
  151. package/src/components/global-styles/screen-button-color.js +8 -6
  152. package/src/components/global-styles/screen-colors.js +7 -7
  153. package/src/components/global-styles/screen-heading-color.js +9 -7
  154. package/src/components/global-styles/screen-link-color.js +3 -2
  155. package/src/components/global-styles/screen-text-color.js +3 -2
  156. package/src/components/global-styles/screen-typography.js +1 -1
  157. package/src/components/global-styles/shadow-panel.js +6 -3
  158. package/src/components/global-styles/style.scss +5 -0
  159. package/src/components/global-styles/subtitle.js +5 -2
  160. package/src/components/global-styles/typography-panel.js +30 -394
  161. package/src/components/navigation-inspector/index.js +0 -32
  162. package/src/components/navigation-inspector/navigation-menu.js +8 -2
  163. package/src/components/sidebar/index.js +4 -17
  164. package/src/components/sidebar-edit-mode/index.js +1 -1
  165. package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
  166. package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
  167. package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
  168. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
  169. package/src/components/start-template-options/index.js +171 -0
  170. package/src/components/start-template-options/style.scss +76 -0
  171. package/src/hooks/push-changes-to-global-styles/index.js +26 -21
  172. package/src/style.scss +1 -0
@@ -5,11 +5,9 @@ import { createElement, Fragment } from "@wordpress/element";
5
5
  */
6
6
  import { useSelect } from '@wordpress/data';
7
7
  import { useState, useEffect } from '@wordpress/element';
8
- import { SelectControl } from '@wordpress/components';
9
8
  import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
10
9
  import { store as blockEditorStore, BlockEditorProvider } from '@wordpress/block-editor';
11
10
  import { speak } from '@wordpress/a11y';
12
- import { useInstanceId } from '@wordpress/compose';
13
11
  import { __ } from '@wordpress/i18n';
14
12
  /**
15
13
  * Internal dependencies
@@ -66,7 +64,6 @@ export default function NavigationInspector(_ref) {
66
64
  hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
67
65
  };
68
66
  }, []);
69
- const navMenuListId = useInstanceId(NavigationMenu, 'edit-site-navigation-inspector-menu');
70
67
  const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
71
68
  const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
72
69
  // - the Navigation Menu referenced by the first Nav block within the template.
@@ -83,21 +80,6 @@ export default function NavigationInspector(_ref) {
83
80
  setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
84
81
  }
85
82
  }, [selectedNavigationBlockId]);
86
- let options = [];
87
-
88
- if (navigationMenus) {
89
- options = navigationMenus.map(_ref2 => {
90
- let {
91
- id,
92
- title
93
- } = _ref2;
94
- return {
95
- value: id,
96
- label: title.rendered
97
- };
98
- });
99
- }
100
-
101
83
  const [innerBlocks, onInput, onChange] = useEntityBlockEditor('postType', 'wp_navigation', {
102
84
  id: currentMenuId || defaultNavigationMenuId
103
85
  });
@@ -115,7 +97,6 @@ export default function NavigationInspector(_ref) {
115
97
  };
116
98
  }, [currentMenuId, defaultNavigationMenuId]);
117
99
  const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
118
- const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
119
100
  const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
120
101
  // Guard by only allowing their usage if there are published Nav Menus.
121
102
 
@@ -145,14 +126,6 @@ export default function NavigationInspector(_ref) {
145
126
  className: "edit-site-navigation-inspector__empty-msg"
146
127
  }, __('There are no Navigation Menus.')), !hasResolvedNavigationMenus && createElement("div", {
147
128
  className: "edit-site-navigation-inspector__placeholder"
148
- }), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && createElement(SelectControl, {
149
- __nextHasNoMarginBottom: true,
150
- className: "edit-site-navigation-inspector__select-menu",
151
- "aria-controls": // aria-controls should only apply when referenced element is in DOM
152
- hasLoadedInnerBlocks ? navMenuListId : undefined,
153
- value: currentMenuId || defaultNavigationMenuId,
154
- options: options,
155
- onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
156
129
  }), isLoading && createElement(Fragment, null, createElement("div", {
157
130
  className: "edit-site-navigation-inspector__placeholder is-child"
158
131
  }), createElement("div", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/index.js"],"names":["useSelect","useState","useEffect","SelectControl","store","coreStore","useEntityBlockEditor","blockEditorStore","BlockEditorProvider","speak","useInstanceId","__","NavigationMenu","NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","onSelect","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","getEntityRecords","hasFinishedResolution","isResolving","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","navMenuListId","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","options","map","title","value","label","rendered","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasMoreThanOneNavigationMenu","length","hasNavigationMenus","publishedInnerBlocks","hasInnerBlocks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,EAAKkB,SAAF,IACVnB,gBAAgB,CAAEoB,MAAM,CAAED,SAAF,CAAR;AAVlB,IAXF,EAyBGP,SAAS,IACV,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,CA1BF,EAgCGK,cAAc,IAAI,CAAEL,SAApB,IACD,cAAC,mBAAD;AACC,IAAA,KAAK,EAAGI,oBADT;AAEC,IAAA,QAAQ,EAAGP,QAFZ;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKC,cAAC,cAAD;AACC,IAAA,WAAW,EAAGQ,oBADf;AAEC,IAAA,QAAQ,EAAG3C;AAFZ,IALD,CAjCF,EA6CG,CAAE4C,cAAF,IAAoB,CAAEL,SAAtB,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACG7C,EAAE,CAAE,2BAAF,CADL,CA9CF,CADD;AAqDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector( { onSelect } ) {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } =\n\t\t\tselect( coreStore );\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId =\n\t\t\t__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds =\n\t\t\t__experimentalGetGlobalBlocksByName( 'core/navigation' );\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst navMenuListId = useInstanceId(\n\t\tNavigationMenu,\n\t\t'edit-site-navigation-inspector-menu'\n\t);\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tlet options = [];\n\tif ( navigationMenus ) {\n\t\toptions = navigationMenus.map( ( { id, title } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: title.rendered,\n\t\t} ) );\n\t}\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tclassName=\"edit-site-navigation-inspector__select-menu\"\n\t\t\t\t\taria-controls={\n\t\t\t\t\t\t// aria-controls should only apply when referenced element is in DOM\n\t\t\t\t\t\thasLoadedInnerBlocks ? navMenuListId : undefined\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ currentMenuId || defaultNavigationMenuId }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( newMenuId ) =>\n\t\t\t\t\t\tsetCurrentMenuId( Number( newMenuId ) )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/index.js"],"names":["useSelect","useState","useEffect","store","coreStore","useEntityBlockEditor","blockEditorStore","BlockEditorProvider","speak","__","NavigationMenu","NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","onSelect","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","getEntityRecords","hasFinishedResolution","isResolving","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasNavigation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CAAE,MAAM;AAChB,QAAK2C,oBAAL,EAA4B;AAC3BrC,MAAAA,KAAK,CAAE,iDAAF,CAAL;AACA;;AAED,QAAKsC,oBAAL,EAA4B;AAC3BtC,MAAAA,KAAK,CAAE,qDAAF,CAAL;AACA;AACD,GARQ,EAQN,CAAEqC,oBAAF,EAAwBC,oBAAxB,CARM,CAAT;AAUA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG1B,0BAA0B,IAAI,CAAE4B,kBAAhC,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACGvC,EAAE,CAAE,gCAAF,CADL,CAFF,EAOG,CAAEW,0BAAF,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,IARF,EAUG2B,SAAS,IACV,8BACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,CAXF,EAiBGI,cAAc,IAAI,CAAEJ,SAApB,IACD,cAAC,mBAAD;AACC,IAAA,KAAK,EAAGG,oBADT;AAEC,IAAA,QAAQ,EAAGN,QAFZ;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKC,cAAC,cAAD;AACC,IAAA,WAAW,EAAGO,oBADf;AAEC,IAAA,QAAQ,EAAGnC;AAFZ,IALD,CAlBF,EA8BG,CAAEoC,cAAF,IAAoB,CAAEJ,SAAtB,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACGtC,EAAE,CAAE,2BAAF,CADL,CA/BF,CADD;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector( { onSelect } ) {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } =\n\t\t\tselect( coreStore );\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId =\n\t\t\t__experimentalGetActiveBlockIdByBlockNames( 'core/navigation' );\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds =\n\t\t\t__experimentalGetGlobalBlocksByName( 'core/navigation' );\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
@@ -26,7 +26,8 @@ export default function NavigationMenu(_ref) {
26
26
  updateBlockListSettings
27
27
  } = useDispatch(blockEditorStore);
28
28
  const {
29
- OffCanvasEditor
29
+ OffCanvasEditor,
30
+ LeafMoreMenu
30
31
  } = unlock(blockEditorPrivateApis); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
31
32
  //Think through a better way of doing this, possible with adding allowed blocks to block library metadata
32
33
 
@@ -44,7 +45,8 @@ export default function NavigationMenu(_ref) {
44
45
  }, [updateBlockListSettings, innerBlocks]);
45
46
  return createElement(OffCanvasEditor, {
46
47
  blocks: innerBlocks,
47
- onSelect: onSelect
48
+ onSelect: onSelect,
49
+ LeafMoreMenu: LeafMoreMenu
48
50
  });
49
51
  }
50
52
  //# sourceMappingURL=navigation-menu.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/navigation-menu.js"],"names":["privateApis","blockEditorPrivateApis","store","blockEditorStore","useEffect","useDispatch","unlock","ALLOWED_BLOCKS","NavigationMenu","innerBlocks","onSelect","updateBlockListSettings","OffCanvasEditor","allowedBlocks","forEach","block","name","clientId"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,WAAW,IAAIC,sBADhB,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAu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} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, onSelect } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor } = unlock( blockEditorPrivateApis );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\treturn <OffCanvasEditor blocks={ innerBlocks } onSelect={ onSelect } />;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-inspector/navigation-menu.js"],"names":["privateApis","blockEditorPrivateApis","store","blockEditorStore","useEffect","useDispatch","unlock","ALLOWED_BLOCKS","NavigationMenu","innerBlocks","onSelect","updateBlockListSettings","OffCanvasEditor","Leaf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KAND;AAOA,GAXQ,EAWN,CAAEN,uBAAF,EAA2BF,WAA3B,CAXM,CAAT;AAaA,SACC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGA,WADV;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,YAAY,EAAGG;AAHhB,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, onSelect } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\tconst { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ innerBlocks }\n\t\t\tonSelect={ onSelect }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n}\n"]}
@@ -4,9 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { memo } from '@wordpress/element';
7
- import { useSelect } from '@wordpress/data';
8
7
  import { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress/components';
9
- import { store as coreStore } from '@wordpress/core-data';
10
8
  /**
11
9
  * Internal dependencies
12
10
  */
@@ -38,25 +36,10 @@ function SidebarScreens() {
38
36
  }
39
37
 
40
38
  function Sidebar() {
41
- const {
42
- isDirty
43
- } = useSelect(select => {
44
- const {
45
- __experimentalGetDirtyEntityRecords
46
- } = select(coreStore);
47
-
48
- const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); // The currently selected entity to display.
49
- // Typically template or template part in the site editor.
50
-
51
-
52
- return {
53
- isDirty: dirtyEntityRecords.length > 0
54
- };
55
- }, []);
56
39
  return createElement(Fragment, null, createElement(NavigatorProvider, {
57
40
  className: "edit-site-sidebar__content",
58
41
  initialPath: "/"
59
- }, createElement(SidebarScreens, null)), isDirty && createElement("div", {
42
+ }, createElement(SidebarScreens, null)), createElement("div", {
60
43
  className: "edit-site-sidebar__footer"
61
44
  }, createElement(SaveButton, null)));
62
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["memo","useSelect","__experimentalNavigatorProvider","NavigatorProvider","store","coreStore","SidebarNavigationScreenMain","SidebarNavigationScreenTemplates","SidebarNavigationScreenTemplate","useSyncPathWithURL","SidebarNavigationScreenNavigationMenus","SidebarNavigationScreenTemplatesBrowse","SaveButton","SidebarNavigationScreenNavigationItem","SidebarScreens","Sidebar","isDirty","select","__experimentalGetDirtyEntityRecords","dir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AAAA,OAAO,EAAEG,kBAAkB,CAACC,MAAnB,GAA4B;AAD/B,KAAP;AAGA,GAR4B,EAQ1B,EAR0B,CAA7B;AAUA,SACC,8BACC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,WAAW,EAAC;AAFb,KAIC,cAAC,cAAD,OAJD,CADD,EAOGJ,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,UAAD,OADD,CARF,CADD;AAeA;;AAED,eAAehB,IAAI,CAAEe,OAAF,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport useSyncPathWithURL from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveButton from '../save-button';\nimport SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationScreenMain />\n\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t<SidebarNavigationScreenNavigationItem />\n\t\t\t<SidebarNavigationScreenTemplates postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplates postType=\"wp_template_part\" />\n\t\t\t<SidebarNavigationScreenTemplate postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplate postType=\"wp_template_part\" />\n\t\t\t<SidebarNavigationScreenTemplatesBrowse postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplatesBrowse postType=\"wp_template_part\" />\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\tconst { isDirty } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords } = select( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t// The currently selected entity to display.\n\t\t// Typically template or template part in the site editor.\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath=\"/\"\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\t\t\t{ isDirty && (\n\t\t\t\t<div className=\"edit-site-sidebar__footer\">\n\t\t\t\t\t<SaveButton />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["memo","__experimentalNavigatorProvider","NavigatorProvider","SidebarNavigationScreenMain","SidebarNavigationScreenTemplates","SidebarNavigationScreenTemplate","useSyncPathWithURL","SidebarNavigationScreenNavigationMenus","SidebarNavigationScreenTemplatesBrowse","SaveButton","SidebarNavigationScreenNavigationItem","SidebarScreens","Sidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA,SAASC,+BAA+B,IAAIC,iBAA5C,QAAqE,uBAArE;AAEA;AACA;AACA;;AACA,OAAOC,2BAAP,MAAwC,mCAAxC;AACA,OAAOC,gCAAP,MAA6C,wCAA7C;AACA,OAAOC,+BAAP,MAA4C,uCAA5C;AACA,OAAOC,kBAAP,MAA+B,+CAA/B;AACA,OAAOC,sCAAP,MAAmD,+CAAnD;AACA,OAAOC,sCAAP,MAAmD,+CAAnD;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,qCAAP,MAAkD,8CAAlD;;AAEA,SAASC,cAAT,GAA0B;AACzBL,EAAAA,kBAAkB;AAElB,SACC,8BACC,cAAC,2BAAD,OADD,EAEC,cAAC,sCAAD,OAFD,EAGC,cAAC,qCAAD,OAHD,EAIC,cAAC,gCAAD;AAAkC,IAAA,QAAQ,EAAC;AAA3C,IAJD,EAKC,cAAC,gCAAD;AAAkC,IAAA,QAAQ,EAAC;AAA3C,IALD,EAMC,cAAC,+BAAD;AAAiC,IAAA,QAAQ,EAAC;AAA1C,IAND,EAOC,cAAC,+BAAD;AAAiC,IAAA,QAAQ,EAAC;AAA1C,IAPD,EAQC,cAAC,sCAAD;AAAwC,IAAA,QAAQ,EAAC;AAAjD,IARD,EASC,cAAC,sCAAD;AAAwC,IAAA,QAAQ,EAAC;AAAjD,IATD,CADD;AAaA;;AAED,SAASM,OAAT,GAAmB;AAClB,SACC,8BACC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,WAAW,EAAC;AAFb,KAIC,cAAC,cAAD,OAJD,CADD,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,UAAD,OADD,CARD,CADD;AAcA;;AAED,eAAeZ,IAAI,CAAEY,OAAF,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';\nimport SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';\nimport SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';\nimport useSyncPathWithURL from '../sync-state-with-url/use-sync-path-with-url';\nimport SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';\nimport SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';\nimport SaveButton from '../save-button';\nimport SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';\n\nfunction SidebarScreens() {\n\tuseSyncPathWithURL();\n\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationScreenMain />\n\t\t\t<SidebarNavigationScreenNavigationMenus />\n\t\t\t<SidebarNavigationScreenNavigationItem />\n\t\t\t<SidebarNavigationScreenTemplates postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplates postType=\"wp_template_part\" />\n\t\t\t<SidebarNavigationScreenTemplate postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplate postType=\"wp_template_part\" />\n\t\t\t<SidebarNavigationScreenTemplatesBrowse postType=\"wp_template\" />\n\t\t\t<SidebarNavigationScreenTemplatesBrowse postType=\"wp_template_part\" />\n\t\t</>\n\t);\n}\n\nfunction Sidebar() {\n\treturn (\n\t\t<>\n\t\t\t<NavigatorProvider\n\t\t\t\tclassName=\"edit-site-sidebar__content\"\n\t\t\t\tinitialPath=\"/\"\n\t\t\t>\n\t\t\t\t<SidebarScreens />\n\t\t\t</NavigatorProvider>\n\n\t\t\t<div className=\"edit-site-sidebar__footer\">\n\t\t\t\t<SaveButton />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default memo( Sidebar );\n"]}
@@ -67,7 +67,7 @@ export function SidebarComplementaryAreaFills() {
67
67
  identifier: sidebarName,
68
68
  title: __('Settings'),
69
69
  icon: isRTL() ? drawerLeft : drawerRight,
70
- closeLabel: __('Close settings sidebar'),
70
+ closeLabel: __('Close settings'),
71
71
  header: createElement(SettingsHeader, {
72
72
  sidebarName: sidebarName
73
73
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/index.js"],"names":["createSlotFill","PanelBody","isRTL","__","drawerLeft","drawerRight","useEffect","Fragment","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","editSiteStore","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","supportsGlobalStyles","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","settings","getSettings","getBlockSelectionStart","supportsTemplatePartsMode","enableComplementaryArea","sidebarName"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,kBAAxC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,aAAhD;AACA,SAAST,KAAK,IAAIU,aAAlB,QAAuC,aAAvC;AAEA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IAA+CxB,cAAc,CAClE,0BADkE,CAAnE;AAGA,OAAO,MAAMyB,oBAAoB,GAAGD,aAA7B;AAEP,OAAO,SAASE,6BAAT,GAAyC;AAC/C,QAAM;AACLC,IAAAA,OADK;AAELC,IAAAA,qBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA;AAJK,MAKFtB,SAAS,CAAIuB,MAAF,IAAc;AAC5B,UAAMC,QAAQ,GACbD,MAAM,CAAEpB,cAAF,CAAN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E,wBAAF,CAJhB;AAKC,IAAA,MAAM,EAAG,cAAC,cAAD;AAAgB,MAAA,WAAW,EAAGsC;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKtB,gBAAhB,IACD,cAAC,SAAD,QACC,cAAC,YAAD,OADD,CATF,EAaGsB,WAAW,KAAKvB,aAAhB,IACD,cAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBGY,oBAAoB,IAAI,cAAC,mBAAD,OAlB3B,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { useEffect, Fragment } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\nimport { store as editSiteStore } from '../../store';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst {\n\t\tsidebar,\n\t\tisEditorSidebarOpened,\n\t\thasBlockSelection,\n\t\tsupportsGlobalStyles,\n\t} = useSelect( ( select ) => {\n\t\tconst _sidebar =\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea( STORE_NAME );\n\t\tconst _isEditorSidebarOpened = [\n\t\t\tSIDEBAR_BLOCK,\n\t\t\tSIDEBAR_TEMPLATE,\n\t\t].includes( _sidebar );\n\t\tconst settings = select( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tsidebar: _sidebar,\n\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tsupportsGlobalStyles: ! settings?.supportsTemplatePartsMode,\n\t\t};\n\t}, [] );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\t\tcloseLabel={ __( 'Close settings sidebar' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar-edit-mode__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t{ supportsGlobalStyles && <GlobalStylesSidebar /> }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/index.js"],"names":["createSlotFill","PanelBody","isRTL","__","drawerLeft","drawerRight","useEffect","Fragment","useSelect","useDispatch","store","interfaceStore","blockEditorStore","DefaultSidebar","GlobalStylesSidebar","STORE_NAME","SettingsHeader","TemplateCard","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","editSiteStore","Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","supportsGlobalStyles","select","_sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","settings","getSettings","getBlockSelectionStart","supportsTemplatePartsMode","enableComplementaryArea","sidebarName"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,kBAAxC;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,UAAT,QAA2B,uBAA3B;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,aAAhD;AACA,SAAST,KAAK,IAAIU,aAAlB,QAAuC,aAAvC;AAEA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IAA+CxB,cAAc,CAClE,0BADkE,CAAnE;AAGA,OAAO,MAAMyB,oBAAoB,GAAGD,aAA7B;AAEP,OAAO,SAASE,6BAAT,GAAyC;A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AD;AACC,IAAA,UAAU,EAAGsB,WADd;AAEC,IAAA,KAAK,EAAGtC,EAAE,CAAE,UAAF,CAFX;AAGC,IAAA,IAAI,EAAGD,KAAK,KAAKE,UAAL,GAAkBC,WAH/B;AAIC,IAAA,UAAU,EAAGF,EAAE,CAAE,gBAAF,CAJhB;AAKC,IAAA,MAAM,EAAG,cAAC,cAAD;AAAgB,MAAA,WAAW,EAAGsC;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKtB,gBAAhB,IACD,cAAC,SAAD,QACC,cAAC,YAAD,OADD,CATF,EAaGsB,WAAW,KAAKvB,aAAhB,IACD,cAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBGY,oBAAoB,IAAI,cAAC,mBAAD,OAlB3B,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { useEffect, Fragment } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\nimport { store as editSiteStore } from '../../store';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst {\n\t\tsidebar,\n\t\tisEditorSidebarOpened,\n\t\thasBlockSelection,\n\t\tsupportsGlobalStyles,\n\t} = useSelect( ( select ) => {\n\t\tconst _sidebar =\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea( STORE_NAME );\n\t\tconst _isEditorSidebarOpened = [\n\t\t\tSIDEBAR_BLOCK,\n\t\t\tSIDEBAR_TEMPLATE,\n\t\t].includes( _sidebar );\n\t\tconst settings = select( editSiteStore ).getSettings();\n\t\treturn {\n\t\t\tsidebar: _sidebar,\n\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tsupportsGlobalStyles: ! settings?.supportsTemplatePartsMode,\n\t\t};\n\t}, [] );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\t\tcloseLabel={ __( 'Close settings' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar-edit-mode__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t{ supportsGlobalStyles && <GlobalStylesSidebar /> }\n\t\t</>\n\t);\n}\n"]}
@@ -1,10 +1,11 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
+ import { __ } from '@wordpress/i18n';
6
7
  import { useSelect } from '@wordpress/data';
7
- import { Icon } from '@wordpress/components';
8
+ import { PanelRow, Icon } from '@wordpress/components';
8
9
  import { store as editorStore } from '@wordpress/editor';
9
10
  import { store as coreStore } from '@wordpress/core-data';
10
11
  import { decodeEntities } from '@wordpress/html-entities';
@@ -15,6 +16,7 @@ import { decodeEntities } from '@wordpress/html-entities';
15
16
  import { store as editSiteStore } from '../../../store';
16
17
  import TemplateActions from './template-actions';
17
18
  import TemplateAreas from './template-areas';
19
+ import LastRevision from './last-revision';
18
20
  export default function TemplateCard() {
19
21
  const {
20
22
  info: {
@@ -48,7 +50,7 @@ export default function TemplateCard() {
48
50
  return null;
49
51
  }
50
52
 
51
- return createElement("div", {
53
+ return createElement(Fragment, null, createElement("div", {
52
54
  className: "edit-site-template-card"
53
55
  }, createElement(Icon, {
54
56
  className: "edit-site-template-card__icon",
@@ -63,6 +65,9 @@ export default function TemplateCard() {
63
65
  template: template
64
66
  })), createElement("div", {
65
67
  className: "edit-site-template-card__description"
66
- }, decodeEntities(description)), createElement(TemplateAreas, null)));
68
+ }, decodeEntities(description)), createElement(TemplateAreas, null))), createElement(PanelRow, {
69
+ header: __('Editing history'),
70
+ className: "edit-site-template-revisions"
71
+ }, createElement(LastRevision, null)));
67
72
  }
68
73
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-card/index.js"],"names":["useSelect","Icon","store","editorStore","coreStore","decodeEntities","editSiteStore","TemplateActions","TemplateAreas","TemplateCard","info","title","description","icon","template","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","__experimentalGetTemplateInfo","getTemplateInfo","postType","postId","record"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,gBAAvC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AAEA,eAAe,SAASC,YAAT,GAAwB;AACtC,QAAM;AACLC,IAAAA,IAAI,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBC,MAAAA;AAAtB,KADD;AAELC,IAAAA;AAFK,MAGFd,SAAS,CAAIe,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAET,aAAF,CAArD;AACA,UAAM;AAAEY,MAAAA;AAAF,QAA4BH,MAAM,CAAEX,SAAF,CAAxC;AACA,UAAM;AAAEe,MAAAA,6BAA6B,EAAEC;AAAjC,QACLL,MAAM,CAAEZ,WAAF,CADP;AAGA,UAAMkB,QAAQ,GAAGL,iBAAiB,EAAlC;AACA,UAAMM,MAAM,GAAGL,eAAe,EAA9B;AACA,UAAMM,MAAM,GAAGL,qBAAqB,CAAE,UAAF,EAAcG,QAAd,EAAwBC,MAAxB,CAApC;AAEA,UAAMZ,IAAI,GAAGa,MAAM,GAAGH,eAAe,CAAEG,MAAF,CAAlB,GAA+B,EAAlD;AAEA,WAAO;AAAEb,MAAAA,IAAF;AAAQI,MAAAA,QAAQ,EAAES;AAAlB,KAAP;AACA,GAbY,EAaV,EAbU,CAHb;;AAkBA,MAAK,CAAEZ,KAAF,IAAW,CAAEC,WAAlB,EAAgC;AAC/B,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AAAM,IAAA,SAAS,EAAC,+BAAhB;AAAgD,IAAA,IAAI,EAAGC;AAAvD,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGR,cAAc,CAAEM,KAAF,CADjB,CADD,EAIC,cAAC,eAAD;AAAiB,IAAA,QAAQ,EAAGG;AAA5B,IAJD,CADD,EAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,cAAc,CAAEO,WAAF,CADjB,CAPD,EAUC,cAAC,aAAD,OAVD,CAFD,CADD;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { Icon } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport TemplateActions from './template-actions';\nimport TemplateAreas from './template-areas';\n\nexport default function TemplateCard() {\n\tconst {\n\t\tinfo: { title, description, icon },\n\t\ttemplate,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst record = getEditedEntityRecord( 'postType', postType, postId );\n\n\t\tconst info = record ? getTemplateInfo( record ) : {};\n\n\t\treturn { info, template: record };\n\t}, [] );\n\n\tif ( ! title && ! description ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-site-template-card\">\n\t\t\t<Icon className=\"edit-site-template-card__icon\" icon={ icon } />\n\t\t\t<div className=\"edit-site-template-card__content\">\n\t\t\t\t<div className=\"edit-site-template-card__header\">\n\t\t\t\t\t<h2 className=\"edit-site-template-card__title\">\n\t\t\t\t\t\t{ decodeEntities( title ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<TemplateActions template={ template } />\n\t\t\t\t</div>\n\t\t\t\t<div className=\"edit-site-template-card__description\">\n\t\t\t\t\t{ decodeEntities( description ) }\n\t\t\t\t</div>\n\t\t\t\t<TemplateAreas />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-card/index.js"],"names":["__","useSelect","PanelRow","Icon","store","editorStore","coreStore","decodeEntities","editSiteStore","TemplateActions","TemplateAreas","LastRevision","TemplateCard","info","title","description","icon","template","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","__experimentalGetTemplateInfo","getTemplateInfo","postType","postId","record"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,uBAA/B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SAASH,KAAK,IAAII,aAAlB,QAAuC,gBAAvC;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA,eAAe,SAASC,YAAT,GAAwB;AACtC,QAAM;AACLC,IAAAA,IAAI,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,WAAT;AAAsBC,MAAAA;AAAtB,KADD;AAELC,IAAAA;AAFK,MAGFhB,SAAS,CAAIiB,MAAF,IAAc;AAC5B,UAAM;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CADD;AAyBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelRow, Icon } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../../store';\nimport TemplateActions from './template-actions';\nimport TemplateAreas from './template-areas';\nimport LastRevision from './last-revision';\n\nexport default function TemplateCard() {\n\tconst {\n\t\tinfo: { title, description, icon },\n\t\ttemplate,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst record = getEditedEntityRecord( 'postType', postType, postId );\n\n\t\tconst info = record ? getTemplateInfo( record ) : {};\n\n\t\treturn { info, template: record };\n\t}, [] );\n\n\tif ( ! title && ! description ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"edit-site-template-card\">\n\t\t\t\t<Icon className=\"edit-site-template-card__icon\" icon={ icon } />\n\t\t\t\t<div className=\"edit-site-template-card__content\">\n\t\t\t\t\t<div className=\"edit-site-template-card__header\">\n\t\t\t\t\t\t<h2 className=\"edit-site-template-card__title\">\n\t\t\t\t\t\t\t{ decodeEntities( title ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t<TemplateActions template={ template } />\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"edit-site-template-card__description\">\n\t\t\t\t\t\t{ decodeEntities( description ) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<TemplateAreas />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<PanelRow\n\t\t\t\theader={ __( 'Editing history' ) }\n\t\t\t\tclassName=\"edit-site-template-revisions\"\n\t\t\t>\n\t\t\t\t<LastRevision />\n\t\t\t</PanelRow>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,70 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Button } from '@wordpress/components';
7
+ import { sprintf, _n } from '@wordpress/i18n';
8
+ import { backup } from '@wordpress/icons';
9
+ import { addQueryArgs } from '@wordpress/url';
10
+ import { PostTypeSupportCheck } from '@wordpress/editor';
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+
15
+ import useEditedEntityRecord from '../../use-edited-entity-record';
16
+
17
+ const useRevisionData = () => {
18
+ var _currentTemplate$_lin, _currentTemplate$_lin2, _currentTemplate$_lin3, _currentTemplate$_lin4, _currentTemplate$_lin5, _currentTemplate$_lin6, _currentTemplate$_lin7, _currentTemplate$_lin8;
19
+
20
+ const {
21
+ record: currentTemplate
22
+ } = useEditedEntityRecord();
23
+ const lastRevisionId = (_currentTemplate$_lin = currentTemplate === null || currentTemplate === void 0 ? void 0 : (_currentTemplate$_lin2 = currentTemplate._links) === null || _currentTemplate$_lin2 === void 0 ? void 0 : (_currentTemplate$_lin3 = _currentTemplate$_lin2['predecessor-version']) === null || _currentTemplate$_lin3 === void 0 ? void 0 : (_currentTemplate$_lin4 = _currentTemplate$_lin3[0]) === null || _currentTemplate$_lin4 === void 0 ? void 0 : _currentTemplate$_lin4.id) !== null && _currentTemplate$_lin !== void 0 ? _currentTemplate$_lin : null;
24
+ const revisionsCount = ((_currentTemplate$_lin5 = currentTemplate === null || currentTemplate === void 0 ? void 0 : (_currentTemplate$_lin6 = currentTemplate._links) === null || _currentTemplate$_lin6 === void 0 ? void 0 : (_currentTemplate$_lin7 = _currentTemplate$_lin6['version-history']) === null || _currentTemplate$_lin7 === void 0 ? void 0 : (_currentTemplate$_lin8 = _currentTemplate$_lin7[0]) === null || _currentTemplate$_lin8 === void 0 ? void 0 : _currentTemplate$_lin8.count) !== null && _currentTemplate$_lin5 !== void 0 ? _currentTemplate$_lin5 : 0) + 1;
25
+ return {
26
+ currentTemplate,
27
+ lastRevisionId,
28
+ revisionsCount
29
+ };
30
+ };
31
+
32
+ function PostLastRevisionCheck(_ref) {
33
+ let {
34
+ children
35
+ } = _ref;
36
+ const {
37
+ lastRevisionId,
38
+ revisionsCount
39
+ } = useRevisionData();
40
+
41
+ if (!lastRevisionId || revisionsCount < 2) {
42
+ return null;
43
+ }
44
+
45
+ return createElement(PostTypeSupportCheck, {
46
+ supportKeys: "revisions"
47
+ }, children);
48
+ }
49
+
50
+ const PostLastRevision = () => {
51
+ const {
52
+ lastRevisionId,
53
+ revisionsCount
54
+ } = useRevisionData();
55
+ return createElement(PostLastRevisionCheck, null, createElement(Button, {
56
+ href: addQueryArgs('revision.php', {
57
+ revision: lastRevisionId,
58
+ gutenberg: true
59
+ }),
60
+ className: "edit-site-template-last-revision__title",
61
+ icon: backup
62
+ }, sprintf(
63
+ /* translators: %d: number of revisions */
64
+ _n('%d Revision', '%d Revisions', revisionsCount), revisionsCount)));
65
+ };
66
+
67
+ export default function LastRevision() {
68
+ return createElement(PostLastRevisionCheck, null, createElement(PostLastRevision, null));
69
+ }
70
+ //# sourceMappingURL=last-revision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-card/last-revision.js"],"names":["Button","sprintf","_n","backup","addQueryArgs","PostTypeSupportCheck","useEditedEntityRecord","useRevisionData","record","currentTemplate","lastRevisionId","_links","id","revisionsCount","count","PostLastRevisionCheck","children","PostLastRevision","revision","gutenberg","LastRevision"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,oBAAT,QAAqC,mBAArC;AAEA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AAMC,IAAA,IAAI,EAAGhB;AANR,KAQGF,OAAO;AACR;AACAC,EAAAA,EAAE,CAAE,aAAF,EAAiB,cAAjB,EAAiCW,cAAjC,CAFM,EAGRA,cAHQ,CARV,CADD,CADD;AAkBA,CArBD;;AAuBA,eAAe,SAASO,YAAT,GAAwB;AACtC,SACC,cAAC,qBAAD,QACC,cAAC,gBAAD,OADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { sprintf, _n } from '@wordpress/i18n';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { PostTypeSupportCheck } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\n\nconst useRevisionData = () => {\n\tconst { record: currentTemplate } = useEditedEntityRecord();\n\n\tconst lastRevisionId =\n\t\tcurrentTemplate?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\n\tconst revisionsCount =\n\t\t( currentTemplate?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0 ) +\n\t\t1;\n\n\treturn {\n\t\tcurrentTemplate,\n\t\tlastRevisionId,\n\t\trevisionsCount,\n\t};\n};\n\nfunction PostLastRevisionCheck( { children } ) {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\tif ( ! lastRevisionId || revisionsCount < 2 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"revisions\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nconst PostLastRevision = () => {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<Button\n\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t\tgutenberg: true,\n\t\t\t\t} ) }\n\t\t\t\tclassName=\"edit-site-template-last-revision__title\"\n\t\t\t\ticon={ backup }\n\t\t\t>\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: %d: number of revisions */\n\t\t\t\t\t_n( '%d Revision', '%d Revisions', revisionsCount ),\n\t\t\t\t\trevisionsCount\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</PostLastRevisionCheck>\n\t);\n};\n\nexport default function LastRevision() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostLastRevision />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"]}
@@ -0,0 +1,156 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Modal } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+ import { useState, useEffect, useMemo } from '@wordpress/element';
9
+ import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
10
+ import { useSelect } from '@wordpress/data';
11
+ import { useAsyncList } from '@wordpress/compose';
12
+ import { store as preferencesStore } from '@wordpress/preferences';
13
+ import { parse } from '@wordpress/blocks';
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+
18
+ import { store as editSiteStore } from '../../store';
19
+ import { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';
20
+ import apiFetch from '@wordpress/api-fetch';
21
+ import { addQueryArgs } from '@wordpress/url';
22
+
23
+ function useFallbackTemplateContent(slug) {
24
+ let isCustom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
25
+ const [templateContent, setTemplateContent] = useState('');
26
+ useEffect(() => {
27
+ apiFetch({
28
+ path: addQueryArgs('/wp/v2/templates/lookup', {
29
+ slug,
30
+ is_custom: isCustom,
31
+ ignore_empty: true
32
+ })
33
+ }).then(_ref => {
34
+ let {
35
+ content
36
+ } = _ref;
37
+ return setTemplateContent(content.raw);
38
+ });
39
+ }, [slug]);
40
+ return templateContent;
41
+ }
42
+
43
+ const START_BLANK_TITLE = __('Start blank');
44
+
45
+ function PatternSelection(_ref2) {
46
+ let {
47
+ fallbackContent,
48
+ onChoosePattern,
49
+ postType
50
+ } = _ref2;
51
+ const [,, onChange] = useEntityBlockEditor('postType', postType);
52
+ const blockPatterns = useMemo(() => [{
53
+ name: 'fallback',
54
+ blocks: parse(fallbackContent),
55
+ title: __('Fallback content')
56
+ }, {
57
+ name: 'start-blank',
58
+ blocks: parse('<!-- wp:paragraph --><p></p><!-- /wp:paragraph -->'),
59
+ title: START_BLANK_TITLE
60
+ }], [fallbackContent]);
61
+ const shownBlockPatterns = useAsyncList(blockPatterns);
62
+ return createElement("div", {
63
+ className: "edit-site-start-template-options__pattern-container",
64
+ style: {
65
+ '--wp-edit-site-start-template-options-start-blank': `"${START_BLANK_TITLE}"`
66
+ }
67
+ }, createElement(BlockPatternsList, {
68
+ blockPatterns: blockPatterns,
69
+ shownPatterns: shownBlockPatterns,
70
+ onClickPattern: (pattern, blocks) => {
71
+ onChange('start-blank' === pattern.name ? [] : blocks, {
72
+ selection: undefined
73
+ });
74
+ onChoosePattern();
75
+ }
76
+ }));
77
+ }
78
+
79
+ function StartModal(_ref3) {
80
+ let {
81
+ slug,
82
+ isCustom,
83
+ onClose,
84
+ postType
85
+ } = _ref3;
86
+ const fallbackContent = useFallbackTemplateContent(slug, isCustom);
87
+
88
+ if (!fallbackContent) {
89
+ return null;
90
+ }
91
+
92
+ return createElement(Modal, {
93
+ className: "edit-site-start-template-options__modal",
94
+ title: __('Choose a pattern'),
95
+ closeLabel: __('Cancel'),
96
+ focusOnMount: "firstElement",
97
+ onRequestClose: onClose
98
+ }, createElement("div", {
99
+ className: "edit-site-start-template-options__modal-content"
100
+ }, createElement(PatternSelection, {
101
+ fallbackContent: fallbackContent,
102
+ slug: slug,
103
+ isCustom: isCustom,
104
+ postType: postType,
105
+ onChoosePattern: () => {
106
+ onClose();
107
+ }
108
+ })));
109
+ }
110
+
111
+ const START_TEMPLATE_MODAL_STATES = {
112
+ INITIAL: 'INITIAL',
113
+ CLOSED: 'CLOSED'
114
+ };
115
+ export default function StartTemplateOptions() {
116
+ const [modalState, setModalState] = useState(START_TEMPLATE_MODAL_STATES.INITIAL);
117
+ const {
118
+ shouldOpenModel,
119
+ slug,
120
+ isCustom,
121
+ postType
122
+ } = useSelect(select => {
123
+ const {
124
+ getEditedPostType,
125
+ getEditedPostId
126
+ } = select(editSiteStore);
127
+
128
+ const _postType = getEditedPostType();
129
+
130
+ const postId = getEditedPostId();
131
+ const {
132
+ __experimentalGetDirtyEntityRecords,
133
+ getEditedEntityRecord
134
+ } = select(coreStore);
135
+ const templateRecord = getEditedEntityRecord('postType', _postType, postId);
136
+ const hasDirtyEntityRecords = __experimentalGetDirtyEntityRecords().length > 0;
137
+ return {
138
+ shouldOpenModel: !hasDirtyEntityRecords && '' === templateRecord.content && 'wp_template' === _postType && !select(preferencesStore).get('core/edit-site', 'welcomeGuide'),
139
+ slug: templateRecord.slug,
140
+ isCustom: templateRecord.is_custom,
141
+ postType: _postType
142
+ };
143
+ }, []);
144
+
145
+ if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModel || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) {
146
+ return null;
147
+ }
148
+
149
+ return createElement(StartModal, {
150
+ slug: slug,
151
+ isCustom: isCustom,
152
+ postType: postType,
153
+ onClose: () => setModalState(START_TEMPLATE_MODAL_STATES.CLOSED)
154
+ });
155
+ }
156
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/start-template-options/index.js"],"names":["Modal","__","useState","useEffect","useMemo","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useAsyncList","store","preferencesStore","parse","editSiteStore","coreStore","useEntityBlockEditor","apiFetch","addQueryArgs","useFallbackTemplateContent","slug","isCustom","templateContent","setTemplateContent","path","is_custom","ignore_empty","then","content","raw","START_BLANK_TITLE","PatternSelection","fallbackContent","onChoosePattern","postType","onChange","blockPatterns","name","blocks","title","shownBlockPatterns","pattern","selection","undefined","StartModal","onClose","START_TEMPLATE_MODAL_STATES","INITIAL","CLOSED","StartTemplateOptions","modalState","setModalState","shouldOpenModel","select","getEditedPostType","getEditedPostId","_postType","postId","__experimentalGetDirtyEntityRecords","getEditedEntityRecord","templateRecord","hasDirtyEntityRecords","length","get"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SAASC,+BAA+B,IAAIC,iBAA5C,QAAqE,yBAArE;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;AACA,SAASH,KAAK,IAAII,SAAlB,EAA6BC,oBAA7B,QAAyD,sBAAzD;AACA,OAAOC,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;;AAEA,SAASC,0BAAT,CAAqCC,IAArC,EAA8D;AAAA,MAAnBC,QAAmB,uEAAR,KAAQ;AAC7D,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0CnB,QAAQ,CAAE,EAAF,CAAxD;AAEAC,EAAAA,SAAS,CAAE,MAAM;AAChBY,IAAAA,QAAQ,CAAE;AACTO,MAAAA,IAAI,EAAEN,YAAY,CAAE,yBAAF,EAA6B;AAC9CE,QAAAA,IAD8C;AAE9CK,QAAAA,SAAS,EAAEJ,QAFmC;AAG9CK,QAAAA,YAAY,EAAE;AAHgC,OAA7B;AADT,KAAF,CAAR,CAMIC,IANJ,CAMU;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAmBL,kBAAkB,CAAEK,OAAO,CAACC,GAAV,CAArC;AAAA,KANV;AAOA,GARQ,EAQN,CAAET,I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AA;AAFK,QAGFN,MAAM,CAAEtC,SAAF,CAHV;AAIA,UAAM6C,cAAc,GAAGD,qBAAqB,CAC3C,UAD2C,EAE3CH,SAF2C,EAG3CC,MAH2C,CAA5C;AAMA,UAAMI,qBAAqB,GAC1BH,mCAAmC,GAAGI,MAAtC,GAA+C,CADhD;AAGA,WAAO;AACNV,MAAAA,eAAe,EACd,CAAES,qBAAF,IACA,OAAOD,cAAc,CAAChC,OADtB,IAEA,kBAAkB4B,SAFlB,IAGA,CAAEH,MAAM,CAAEzC,gBAAF,CAAN,CAA2BmD,GAA3B,CACD,gBADC,EAED,cAFC,CALG;AASN3C,MAAAA,IAAI,EAAEwC,cAAc,CAACxC,IATf;AAUNC,MAAAA,QAAQ,EAAEuC,cAAc,CAACnC,SAVnB;AAWNS,MAAAA,QAAQ,EAAEsB;AAXJ,KAAP;AAaA,GAhC6D,EAiC9D,EAjC8D,CAA/D;;AAoCA,MACGN,UAAU,KAAKJ,2BAA2B,CAACC,OAA3C,IACD,CAAEK,eADH,IAEAF,UAAU,KAAKJ,2BAA2B,CAACE,MAH5C,EAIE;AACD,WAAO,IAAP;AACA;;AAED,SACC,cAAC,UAAD;AACC,IAAA,IAAI,EAAG5B,IADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGa,QAHZ;AAIC,IAAA,OAAO,EAAG,MACTiB,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 { __experimentalBlockPatternsList as BlockPatternsList } 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 PatternSelection( { fallbackContent, onChoosePattern, postType } ) {\n\tconst [ , , onChange ] = useEntityBlockEditor( 'postType', postType );\n\tconst blockPatterns = useMemo(\n\t\t() => [\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{\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\t[ fallbackContent ]\n\t);\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"]}