@wordpress/edit-widgets 6.57.0 → 7.1.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 (195) hide show
  1. package/build/blocks/widget-area/edit/index.cjs +106 -116
  2. package/build/blocks/widget-area/edit/index.cjs.map +1 -7
  3. package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
  4. package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
  5. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
  6. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
  7. package/build/blocks/widget-area/index.cjs +40 -44
  8. package/build/blocks/widget-area/index.cjs.map +1 -7
  9. package/build/components/error-boundary/index.cjs +115 -155
  10. package/build/components/error-boundary/index.cjs.map +1 -7
  11. package/build/components/header/document-tools/index.cjs +80 -115
  12. package/build/components/header/document-tools/index.cjs.map +1 -7
  13. package/build/components/header/index.cjs +72 -80
  14. package/build/components/header/index.cjs.map +1 -7
  15. package/build/components/header/undo-redo/redo.cjs +30 -52
  16. package/build/components/header/undo-redo/redo.cjs.map +1 -7
  17. package/build/components/header/undo-redo/undo.cjs +29 -51
  18. package/build/components/header/undo-redo/undo.cjs.map +1 -7
  19. package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
  20. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
  21. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
  22. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
  23. package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
  24. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
  25. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -75
  26. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
  27. package/build/components/keyboard-shortcuts/index.cjs +107 -140
  28. package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
  29. package/build/components/layout/index.cjs +65 -74
  30. package/build/components/layout/index.cjs.map +1 -7
  31. package/build/components/layout/interface.cjs +82 -102
  32. package/build/components/layout/interface.cjs.map +1 -7
  33. package/build/components/layout/unsaved-changes-warning.cjs +44 -48
  34. package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
  35. package/build/components/more-menu/index.cjs +125 -191
  36. package/build/components/more-menu/index.cjs.map +1 -7
  37. package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
  38. package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
  39. package/build/components/notices/index.cjs +19 -39
  40. package/build/components/notices/index.cjs.map +1 -7
  41. package/build/components/save-button/index.cjs +31 -58
  42. package/build/components/save-button/index.cjs.map +1 -7
  43. package/build/components/secondary-sidebar/index.cjs +38 -45
  44. package/build/components/secondary-sidebar/index.cjs.map +1 -7
  45. package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
  46. package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
  47. package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
  48. package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
  49. package/build/components/sidebar/index.cjs +117 -180
  50. package/build/components/sidebar/index.cjs.map +1 -7
  51. package/build/components/sidebar/widget-areas.cjs +43 -85
  52. package/build/components/sidebar/widget-areas.cjs.map +1 -7
  53. package/build/components/welcome-guide/index.cjs +110 -186
  54. package/build/components/welcome-guide/index.cjs.map +1 -7
  55. package/build/components/widget-areas-block-editor-content/index.cjs +59 -63
  56. package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
  57. package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
  58. package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
  59. package/build/constants.cjs +11 -32
  60. package/build/constants.cjs.map +1 -7
  61. package/build/filters/index.cjs +7 -4
  62. package/build/filters/move-to-widget-area.cjs +38 -53
  63. package/build/filters/move-to-widget-area.cjs.map +1 -7
  64. package/build/filters/replace-media-upload.cjs +11 -9
  65. package/build/filters/replace-media-upload.cjs.map +1 -7
  66. package/build/hooks/use-last-selected-widget-area.cjs +28 -49
  67. package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
  68. package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
  69. package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
  70. package/build/index.cjs +96 -97
  71. package/build/index.cjs.map +1 -7
  72. package/build/lock-unlock.cjs +10 -35
  73. package/build/lock-unlock.cjs.map +1 -7
  74. package/build/store/actions.cjs +269 -278
  75. package/build/store/actions.cjs.map +1 -7
  76. package/build/store/constants.cjs +12 -29
  77. package/build/store/constants.cjs.map +1 -7
  78. package/build/store/index.cjs +61 -52
  79. package/build/store/index.cjs.map +1 -7
  80. package/build/store/private-selectors.cjs +11 -32
  81. package/build/store/private-selectors.cjs.map +1 -7
  82. package/build/store/reducer.cjs +107 -88
  83. package/build/store/reducer.cjs.map +1 -7
  84. package/build/store/resolvers.cjs +60 -91
  85. package/build/store/resolvers.cjs.map +1 -7
  86. package/build/store/selectors.cjs +196 -229
  87. package/build/store/selectors.cjs.map +1 -7
  88. package/build/store/transformers.cjs +51 -82
  89. package/build/store/transformers.cjs.map +1 -7
  90. package/build/store/utils.cjs +76 -63
  91. package/build/store/utils.cjs.map +1 -7
  92. package/build-module/blocks/widget-area/edit/index.mjs +82 -94
  93. package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
  94. package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
  95. package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
  96. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
  97. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
  98. package/build-module/blocks/widget-area/index.mjs +12 -15
  99. package/build-module/blocks/widget-area/index.mjs.map +1 -7
  100. package/build-module/components/error-boundary/index.mjs +103 -128
  101. package/build-module/components/error-boundary/index.mjs.map +1 -7
  102. package/build-module/components/header/document-tools/index.mjs +51 -84
  103. package/build-module/components/header/document-tools/index.mjs.map +1 -7
  104. package/build-module/components/header/index.mjs +40 -47
  105. package/build-module/components/header/index.mjs.map +1 -7
  106. package/build-module/components/header/undo-redo/redo.mjs +20 -27
  107. package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
  108. package/build-module/components/header/undo-redo/undo.mjs +19 -26
  109. package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
  110. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
  111. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
  112. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
  113. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
  114. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
  115. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
  116. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -54
  117. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
  118. package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
  119. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
  120. package/build-module/components/layout/index.mjs +29 -40
  121. package/build-module/components/layout/index.mjs.map +1 -7
  122. package/build-module/components/layout/interface.mjs +53 -76
  123. package/build-module/components/layout/interface.mjs.map +1 -7
  124. package/build-module/components/layout/unsaved-changes-warning.mjs +37 -26
  125. package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
  126. package/build-module/components/more-menu/index.mjs +95 -162
  127. package/build-module/components/more-menu/index.mjs.map +1 -7
  128. package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
  129. package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
  130. package/build-module/components/notices/index.mjs +12 -17
  131. package/build-module/components/notices/index.mjs.map +1 -7
  132. package/build-module/components/save-button/index.mjs +23 -35
  133. package/build-module/components/save-button/index.mjs.map +1 -7
  134. package/build-module/components/secondary-sidebar/index.mjs +15 -20
  135. package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
  136. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
  137. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
  138. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
  139. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
  140. package/build-module/components/sidebar/index.mjs +96 -162
  141. package/build-module/components/sidebar/index.mjs.map +1 -7
  142. package/build-module/components/sidebar/widget-areas.mjs +30 -57
  143. package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
  144. package/build-module/components/welcome-guide/index.mjs +103 -164
  145. package/build-module/components/welcome-guide/index.mjs.map +1 -7
  146. package/build-module/components/widget-areas-block-editor-content/index.mjs +35 -44
  147. package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
  148. package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
  149. package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
  150. package/build-module/constants.mjs +5 -7
  151. package/build-module/constants.mjs.map +1 -7
  152. package/build-module/filters/index.mjs +0 -2
  153. package/build-module/filters/move-to-widget-area.mjs +28 -48
  154. package/build-module/filters/move-to-widget-area.mjs.map +1 -7
  155. package/build-module/filters/replace-media-upload.mjs +5 -8
  156. package/build-module/filters/replace-media-upload.mjs.map +1 -7
  157. package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
  158. package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
  159. package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
  160. package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
  161. package/build-module/index.mjs +62 -79
  162. package/build-module/index.mjs.map +1 -7
  163. package/build-module/lock-unlock.mjs +5 -10
  164. package/build-module/lock-unlock.mjs.map +1 -7
  165. package/build-module/store/actions.mjs +250 -247
  166. package/build-module/store/actions.mjs.map +1 -7
  167. package/build-module/store/constants.mjs +7 -5
  168. package/build-module/store/constants.mjs.map +1 -7
  169. package/build-module/store/index.mjs +18 -16
  170. package/build-module/store/index.mjs.map +1 -7
  171. package/build-module/store/private-selectors.mjs +5 -7
  172. package/build-module/store/private-selectors.mjs.map +1 -7
  173. package/build-module/store/reducer.mjs +95 -58
  174. package/build-module/store/reducer.mjs.map +1 -7
  175. package/build-module/store/resolvers.mjs +52 -71
  176. package/build-module/store/resolvers.mjs.map +1 -7
  177. package/build-module/store/selectors.mjs +178 -199
  178. package/build-module/store/selectors.mjs.map +1 -7
  179. package/build-module/store/transformers.mjs +44 -56
  180. package/build-module/store/transformers.mjs.map +1 -7
  181. package/build-module/store/utils.mjs +64 -32
  182. package/build-module/store/utils.mjs.map +1 -7
  183. package/build-style/style-rtl.css +12 -12
  184. package/build-style/style.css +12 -12
  185. package/package.json +35 -36
  186. package/src/components/header/index.jsx +2 -2
  187. package/src/components/layout/interface.jsx +4 -1
  188. package/src/components/layout/style.scss +11 -0
  189. package/src/components/notices/style.scss +2 -2
  190. package/src/components/sidebar/index.jsx +18 -18
  191. package/src/components/welcome-guide/index.jsx +4 -2
  192. package/src/components/widget-areas-block-editor-content/index.jsx +4 -3
  193. package/CHANGELOG.md +0 -325
  194. package/build/filters/index.cjs.map +0 -7
  195. package/build-module/filters/index.mjs.map +0 -7
@@ -1,194 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
1
7
  var __create = Object.create;
2
8
  var __defProp = Object.defineProperty;
3
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
11
  var __getProtoOf = Object.getPrototypeOf;
6
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
13
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
18
22
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_element = require("@wordpress/element");
28
+ let _wordpress_i18n = require("@wordpress/i18n");
29
+ let _wordpress_interface = require("@wordpress/interface");
30
+ let _wordpress_block_editor = require("@wordpress/block-editor");
31
+ let _wordpress_icons = require("@wordpress/icons");
32
+ let _wordpress_components = require("@wordpress/components");
33
+ let _wordpress_data = require("@wordpress/data");
34
+ let react_jsx_runtime = require("react/jsx-runtime");
35
+ let __widget_areas_jsx = require("./widget-areas.cjs");
36
+ __widget_areas_jsx = __toESM(__widget_areas_jsx);
37
+ let ______store_index_js = require("../../store/index.cjs");
38
+ let ______lock_unlock_js = require("../../lock-unlock.cjs");
29
39
  // packages/edit-widgets/src/components/sidebar/index.jsx
30
- var sidebar_exports = {};
31
- __export(sidebar_exports, {
32
- default: () => Sidebar
33
- });
34
- module.exports = __toCommonJS(sidebar_exports);
35
- var import_element = require("@wordpress/element");
36
- var import_i18n = require("@wordpress/i18n");
37
- var import_interface = require("@wordpress/interface");
38
- var import_block_editor = require("@wordpress/block-editor");
39
- var import_icons = require("@wordpress/icons");
40
- var import_components = require("@wordpress/components");
41
- var import_data = require("@wordpress/data");
42
- var import_widget_areas = __toESM(require("./widget-areas.cjs"));
43
- var import_store = require("../../store/index.cjs");
44
- var import_lock_unlock = require("../../lock-unlock.cjs");
45
- var import_jsx_runtime = require("react/jsx-runtime");
46
- var SIDEBAR_ACTIVE_BY_DEFAULT = true;
47
- var BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
48
- var WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
49
- var { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
40
+ const SIDEBAR_ACTIVE_BY_DEFAULT = true;
41
+ const BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
42
+ const WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
43
+ const { Tabs: WCTabs } = (0, ______lock_unlock_js.unlock)(_wordpress_components.privateApis);
50
44
  function SidebarHeader({ selectedWidgetAreaBlock }) {
51
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs.TabList, { children: [
52
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, import_i18n.__)("Widget Areas") }),
53
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: (0, import_i18n.__)("Block") })
54
- ] });
45
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(WCTabs.TabList, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs.Tab, {
46
+ tabId: WIDGET_AREAS_IDENTIFIER,
47
+ children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, _wordpress_i18n.__)("Widget Areas")
48
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs.Tab, {
49
+ tabId: BLOCK_INSPECTOR_IDENTIFIER,
50
+ children: (0, _wordpress_i18n.__)("Block")
51
+ })] });
55
52
  }
56
- function SidebarContent({
57
- hasSelectedNonAreaBlock,
58
- currentArea,
59
- isGeneralSidebarOpen,
60
- selectedWidgetAreaBlock
61
- }) {
62
- const { enableComplementaryArea } = (0, import_data.useDispatch)(import_interface.store);
63
- (0, import_element.useEffect)(() => {
64
- if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
65
- enableComplementaryArea(
66
- "core/edit-widgets",
67
- BLOCK_INSPECTOR_IDENTIFIER
68
- );
69
- }
70
- if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
71
- enableComplementaryArea(
72
- "core/edit-widgets",
73
- WIDGET_AREAS_IDENTIFIER
74
- );
75
- }
76
- }, [hasSelectedNonAreaBlock, enableComplementaryArea]);
77
- const tabsContextValue = (0, import_element.useContext)(Tabs.Context);
78
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- import_interface.ComplementaryArea,
80
- {
81
- className: "edit-widgets-sidebar",
82
- header: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
- SidebarHeader,
84
- {
85
- selectedWidgetAreaBlock
86
- }
87
- ) }),
88
- headerClassName: "edit-widgets-sidebar__panel-tabs",
89
- title: (0, import_i18n.__)("Settings"),
90
- closeLabel: (0, import_i18n.__)("Close Settings"),
91
- scope: "core/edit-widgets",
92
- identifier: currentArea,
93
- icon: (0, import_i18n.isRTL)() ? import_icons.drawerLeft : import_icons.drawerRight,
94
- isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
95
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs.Context.Provider, { value: tabsContextValue, children: [
96
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
- Tabs.TabPanel,
98
- {
99
- tabId: WIDGET_AREAS_IDENTIFIER,
100
- focusable: false,
101
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
- import_widget_areas.default,
103
- {
104
- selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id
105
- }
106
- )
107
- }
108
- ),
109
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
- Tabs.TabPanel,
111
- {
112
- tabId: BLOCK_INSPECTOR_IDENTIFIER,
113
- focusable: false,
114
- children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockInspector, {}) : (
115
- // Pretend that Widget Areas are part of the UI by not
116
- // showing the Block Inspector when one is selected.
117
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n.__)("No block selected.") })
118
- )
119
- }
120
- )
121
- ] })
122
- }
123
- );
53
+ function SidebarContent({ hasSelectedNonAreaBlock, currentArea, isGeneralSidebarOpen, selectedWidgetAreaBlock }) {
54
+ const { enableComplementaryArea } = (0, _wordpress_data.useDispatch)(_wordpress_interface.store);
55
+ (0, _wordpress_element.useEffect)(() => {
56
+ if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) enableComplementaryArea("core/edit-widgets", BLOCK_INSPECTOR_IDENTIFIER);
57
+ if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) enableComplementaryArea("core/edit-widgets", WIDGET_AREAS_IDENTIFIER);
58
+ }, [hasSelectedNonAreaBlock, enableComplementaryArea]);
59
+ const tabsContextValue = (0, _wordpress_element.useContext)(WCTabs.Context);
60
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_interface.ComplementaryArea, {
61
+ className: "edit-widgets-sidebar",
62
+ header: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs.Context.Provider, {
63
+ value: tabsContextValue,
64
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarHeader, { selectedWidgetAreaBlock })
65
+ }),
66
+ headerClassName: "edit-widgets-sidebar__panel-tabs",
67
+ title: (0, _wordpress_i18n.__)("Settings"),
68
+ closeLabel: (0, _wordpress_i18n.__)("Close Settings"),
69
+ scope: "core/edit-widgets",
70
+ identifier: currentArea,
71
+ icon: (0, _wordpress_i18n.isRTL)() ? _wordpress_icons.drawerLeft : _wordpress_icons.drawerRight,
72
+ isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
73
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(WCTabs.Context.Provider, {
74
+ value: tabsContextValue,
75
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs.TabPanel, {
76
+ tabId: WIDGET_AREAS_IDENTIFIER,
77
+ focusable: false,
78
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__widget_areas_jsx.default, { selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id })
79
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs.TabPanel, {
80
+ tabId: BLOCK_INSPECTOR_IDENTIFIER,
81
+ focusable: false,
82
+ children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.BlockInspector, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
83
+ className: "block-editor-block-inspector__no-blocks",
84
+ children: (0, _wordpress_i18n.__)("No block selected.")
85
+ })
86
+ })]
87
+ })
88
+ });
124
89
  }
125
90
  function Sidebar() {
126
- const {
127
- currentArea,
128
- hasSelectedNonAreaBlock,
129
- isGeneralSidebarOpen,
130
- selectedWidgetAreaBlock
131
- } = (0, import_data.useSelect)((select) => {
132
- const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(import_block_editor.store);
133
- const { getActiveComplementaryArea } = select(import_interface.store);
134
- const selectedBlock = getSelectedBlock();
135
- const activeArea = getActiveComplementaryArea(import_store.store.name);
136
- let currentSelection = activeArea;
137
- if (!currentSelection) {
138
- if (selectedBlock) {
139
- currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
140
- } else {
141
- currentSelection = WIDGET_AREAS_IDENTIFIER;
142
- }
143
- }
144
- let widgetAreaBlock;
145
- if (selectedBlock) {
146
- if (selectedBlock.name === "core/widget-area") {
147
- widgetAreaBlock = selectedBlock;
148
- } else {
149
- widgetAreaBlock = getBlock(
150
- getBlockParentsByBlockName(
151
- selectedBlock.clientId,
152
- "core/widget-area"
153
- )[0]
154
- );
155
- }
156
- }
157
- return {
158
- currentArea: currentSelection,
159
- hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
160
- isGeneralSidebarOpen: !!activeArea,
161
- selectedWidgetAreaBlock: widgetAreaBlock
162
- };
163
- }, []);
164
- const { enableComplementaryArea } = (0, import_data.useDispatch)(import_interface.store);
165
- const onTabSelect = (0, import_element.useCallback)(
166
- (newSelectedTabId) => {
167
- if (!!newSelectedTabId) {
168
- enableComplementaryArea(
169
- import_store.store.name,
170
- newSelectedTabId
171
- );
172
- }
173
- },
174
- [enableComplementaryArea]
175
- );
176
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
177
- Tabs,
178
- {
179
- selectedTabId: isGeneralSidebarOpen ? currentArea : null,
180
- onSelect: onTabSelect,
181
- selectOnMove: false,
182
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
- SidebarContent,
184
- {
185
- hasSelectedNonAreaBlock,
186
- currentArea,
187
- isGeneralSidebarOpen,
188
- selectedWidgetAreaBlock
189
- }
190
- )
191
- }
192
- );
91
+ const { currentArea, hasSelectedNonAreaBlock, isGeneralSidebarOpen, selectedWidgetAreaBlock } = (0, _wordpress_data.useSelect)((select) => {
92
+ const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(_wordpress_block_editor.store);
93
+ const { getActiveComplementaryArea } = select(_wordpress_interface.store);
94
+ const selectedBlock = getSelectedBlock();
95
+ const activeArea = getActiveComplementaryArea(______store_index_js.store.name);
96
+ let currentSelection = activeArea;
97
+ if (!currentSelection) {
98
+ if (selectedBlock) currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
99
+ else currentSelection = WIDGET_AREAS_IDENTIFIER;
100
+ }
101
+ let widgetAreaBlock;
102
+ if (selectedBlock) {
103
+ if (selectedBlock.name === "core/widget-area") widgetAreaBlock = selectedBlock;
104
+ else widgetAreaBlock = getBlock(getBlockParentsByBlockName(selectedBlock.clientId, "core/widget-area")[0]);
105
+ }
106
+ return {
107
+ currentArea: currentSelection,
108
+ hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
109
+ isGeneralSidebarOpen: !!activeArea,
110
+ selectedWidgetAreaBlock: widgetAreaBlock
111
+ };
112
+ }, []);
113
+ const { enableComplementaryArea } = (0, _wordpress_data.useDispatch)(_wordpress_interface.store);
114
+ const onTabSelect = (0, _wordpress_element.useCallback)((newSelectedTabId) => {
115
+ if (!!newSelectedTabId) enableComplementaryArea(______store_index_js.store.name, newSelectedTabId);
116
+ }, [enableComplementaryArea]);
117
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WCTabs, {
118
+ selectedTabId: isGeneralSidebarOpen ? currentArea : null,
119
+ onSelect: onTabSelect,
120
+ selectOnMove: false,
121
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarContent, {
122
+ hasSelectedNonAreaBlock,
123
+ currentArea,
124
+ isGeneralSidebarOpen,
125
+ selectedWidgetAreaBlock
126
+ })
127
+ });
193
128
  }
194
- //# sourceMappingURL=index.cjs.map
129
+ exports.default = Sidebar;
130
+
131
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/sidebar/index.jsx"],
4
- "sourcesContent": ["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<Tabs.TabList>\n\t\t\t<Tabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</Tabs.Tab>\n\t\t\t<Tabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</Tabs.Tab>\n\t\t</Tabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmD;AACnD,kBAA0B;AAC1B,uBAGO;AACP,0BAGO;AACP,mBAAwC;AACxC,wBAAqD;AACrD,kBAAuC;AAMvC,0BAAwB;AACxB,mBAA0C;AAC1C,yBAAuB;AAMrB;AAbF,IAAM,4BAA4B;AAClC,IAAM,6BAA6B;AAGnC,IAAM,0BAA0B;AAKhC,IAAM,EAAE,KAAK,QAAI,2BAAQ,kBAAAA,WAAsB;AAE/C,SAAS,cAAe,EAAE,wBAAwB,GAAI;AACrD,SACC,6CAAC,KAAK,SAAL,EACA;AAAA,gDAAC,KAAK,KAAL,EAAS,OAAQ,yBACf,oCACC,wBAAwB,WAAW,WACnC,gBAAI,cAAe,GACvB;AAAA,IACA,4CAAC,KAAK,KAAL,EAAS,OAAQ,4BACf,8BAAI,OAAQ,GACf;AAAA,KACD;AAEF;AAEA,SAAS,eAAgB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,wBAAwB,QAAI,yBAAa,iBAAAC,KAAe;AAEhE,gCAAW,MAAM;AAChB,QACC,2BACA,gBAAgB,2BAChB,sBACC;AACD;AAAA,QACC;AAAA,QACA;AAAA,MACD;AAAA,IACD;AACA,QACC,CAAE,2BACF,gBAAgB,8BAChB,sBACC;AACD;AAAA,QACC;AAAA,QACA;AAAA,MACD;AAA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B,IAAK;AAErE,QAAI,mBAAmB;AACvB,QAAK,CAAE,kBAAmB;AACzB,UAAK,eAAgB;AACpB,2BAAmB;AAAA,MACpB,OAAO;AACN,2BAAmB;AAAA,MACpB;AAAA,IACD;AAEA,QAAI;AACJ,QAAK,eAAgB;AACpB,UAAK,cAAc,SAAS,oBAAqB;AAChD,0BAAkB;AAAA,MACnB,OAAO;AACN,0BAAkB;AAAA,UACjB;AAAA,YACC,cAAc;AAAA,YACd;AAAA,UACD,EAAG,CAAE;AAAA,QACN;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,MACN,aAAa;AAAA,MACb,yBAAyB,CAAC,EACzB,iBAAiB,cAAc,SAAS;AAAA,MAEzC,sBAAsB,CAAC,CAAE;AAAA,MACzB,yBAAyB;AAAA,IAC1B;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,wBAAwB,QAAI,yBAAa,iBAAAH,KAAe;AAMhE,QAAM,kBAAc;AAAA,IACnB,CAAE,qBAAsB;AACvB,UAAK,CAAC,CAAE,kBAAmB;AAC1B;AAAA,UACC,aAAAG,MAAiB;AAAA,UACjB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,uBAAwB;AAAA,EAC3B;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MAMA,eAAgB,uBAAuB,cAAc;AAAA,MACrD,UAAW;AAAA,MACX,cAAe;AAAA,MAEf;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
6
- "names": ["componentsPrivateApis", "interfaceStore", "WidgetAreas", "blockEditorStore", "editWidgetsStore"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["unlock","componentsPrivateApis","__","useDispatch","interfaceStore","useContext","ComplementaryArea","isRTL","drawerLeft","drawerRight","WidgetAreas","BlockInspector","useSelect","blockEditorStore","editWidgetsStore","useCallback"],"sources":["../../../src/components/sidebar/index.jsx"],"sourcesContent":["import { useEffect, useContext, useCallback } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tComplementaryArea,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nconst SIDEBAR_ACTIVE_BY_DEFAULT = true;\nconst BLOCK_INSPECTOR_IDENTIFIER = 'edit-widgets/block-inspector';\n// Widget areas were once called block areas, so use 'edit-widgets/block-areas'\n// for backwards compatibility.\nconst WIDGET_AREAS_IDENTIFIER = 'edit-widgets/block-areas';\nimport WidgetAreas from './widget-areas';\nimport { store as editWidgetsStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs: WCTabs } = unlock( componentsPrivateApis );\n\nfunction SidebarHeader( { selectedWidgetAreaBlock } ) {\n\treturn (\n\t\t<WCTabs.TabList>\n\t\t\t<WCTabs.Tab tabId={ WIDGET_AREAS_IDENTIFIER }>\n\t\t\t\t{ selectedWidgetAreaBlock\n\t\t\t\t\t? selectedWidgetAreaBlock.attributes.name\n\t\t\t\t\t: __( 'Widget Areas' ) }\n\t\t\t</WCTabs.Tab>\n\t\t\t<WCTabs.Tab tabId={ BLOCK_INSPECTOR_IDENTIFIER }>\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</WCTabs.Tab>\n\t\t</WCTabs.TabList>\n\t);\n}\n\nfunction SidebarContent( {\n\thasSelectedNonAreaBlock,\n\tcurrentArea,\n\tisGeneralSidebarOpen,\n\tselectedWidgetAreaBlock,\n} ) {\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\thasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === WIDGET_AREAS_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tBLOCK_INSPECTOR_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\t! hasSelectedNonAreaBlock &&\n\t\t\tcurrentArea === BLOCK_INSPECTOR_IDENTIFIER &&\n\t\t\tisGeneralSidebarOpen\n\t\t) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\tWIDGET_AREAS_IDENTIFIER\n\t\t\t);\n\t\t}\n\t\t// We're intentionally leaving `currentArea` and `isGeneralSidebarOpen`\n\t\t// out of the dep array because we want this effect to run based on\n\t\t// block selection changes, not sidebar state changes.\n\t}, [ hasSelectedNonAreaBlock, enableComplementaryArea ] );\n\n\tconst tabsContextValue = useContext( WCTabs.Context );\n\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tclassName=\"edit-widgets-sidebar\"\n\t\t\theader={\n\t\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SidebarHeader\n\t\t\t\t\t\tselectedWidgetAreaBlock={ selectedWidgetAreaBlock }\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.Context.Provider>\n\t\t\t}\n\t\t\theaderClassName=\"edit-widgets-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\tscope=\"core/edit-widgets\"\n\t\t\tidentifier={ currentArea }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<WCTabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ WIDGET_AREAS_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<WidgetAreas\n\t\t\t\t\t\tselectedWidgetAreaId={\n\t\t\t\t\t\t\tselectedWidgetAreaBlock?.attributes.id\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t\t<WCTabs.TabPanel\n\t\t\t\t\ttabId={ BLOCK_INSPECTOR_IDENTIFIER }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t{ hasSelectedNonAreaBlock ? (\n\t\t\t\t\t\t<BlockInspector />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t// Pretend that Widget Areas are part of the UI by not\n\t\t\t\t\t\t// showing the Block Inspector when one is selected.\n\t\t\t\t\t\t<span className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t\t{ __( 'No block selected.' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</WCTabs.TabPanel>\n\t\t\t</WCTabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\nexport default function Sidebar() {\n\tconst {\n\t\tcurrentArea,\n\t\thasSelectedNonAreaBlock,\n\t\tisGeneralSidebarOpen,\n\t\tselectedWidgetAreaBlock,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSelectedBlock, getBlock, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\n\t\tconst selectedBlock = getSelectedBlock();\n\n\t\tconst activeArea = getActiveComplementaryArea( editWidgetsStore.name );\n\n\t\tlet currentSelection = activeArea;\n\t\tif ( ! currentSelection ) {\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tcurrentSelection = BLOCK_INSPECTOR_IDENTIFIER;\n\t\t\t} else {\n\t\t\t\tcurrentSelection = WIDGET_AREAS_IDENTIFIER;\n\t\t\t}\n\t\t}\n\n\t\tlet widgetAreaBlock;\n\t\tif ( selectedBlock ) {\n\t\t\tif ( selectedBlock.name === 'core/widget-area' ) {\n\t\t\t\twidgetAreaBlock = selectedBlock;\n\t\t\t} else {\n\t\t\t\twidgetAreaBlock = getBlock(\n\t\t\t\t\tgetBlockParentsByBlockName(\n\t\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\t\t'core/widget-area'\n\t\t\t\t\t)[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tcurrentArea: currentSelection,\n\t\t\thasSelectedNonAreaBlock: !! (\n\t\t\t\tselectedBlock && selectedBlock.name !== 'core/widget-area'\n\t\t\t),\n\t\t\tisGeneralSidebarOpen: !! activeArea,\n\t\t\tselectedWidgetAreaBlock: widgetAreaBlock,\n\t\t};\n\t}, [] );\n\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\t// `newSelectedTabId` could technically be falsy if no tab is selected (i.e.\n\t// the initial render) or when we don't want a tab displayed (i.e. the\n\t// sidebar is closed). These cases should both be covered by the `!!` check\n\t// below, so we shouldn't need any additional falsy handling.\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\tenableComplementaryArea(\n\t\t\t\t\teditWidgetsStore.name,\n\t\t\t\t\tnewSelectedTabId\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ enableComplementaryArea ]\n\t);\n\n\treturn (\n\t\t<WCTabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop. Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isGeneralSidebarOpen ? currentArea : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\thasSelectedNonAreaBlock={ hasSelectedNonAreaBlock }\n\t\t\t\tcurrentArea={ currentArea }\n\t\t\t\tisGeneralSidebarOpen={ isGeneralSidebarOpen }\n\t\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B;EAErB;EAEA,IAAI;EACJ,IAAK,eAAgB;GACpB,IAAK,cAAc,SAAS,oBAC3B,kBAAkB;QAElB,kBAAkB,SACjB,2BACC,cAAc,UACd,kBACD,CAAC,CAAE,EACJ;EAEF;EAEA,OAAO;GACN,aAAa;GACb,yBAAyB,CAAC,EACzB,iBAAiB,cAAc,SAAS;GAEzC,sBAAsB,CAAC,CAAE;GACzB,yBAAyB;EAC1B;CACD,GAAG,CAAC,CAAE;CAEN,MAAM,EAAE,6BAAA,GAA4BX,gBAAAA,YAAAA,CAAaC,qBAAAA,KAAe;CAMhE,MAAM,eAAA,GAAcW,mBAAAA,YAAAA,EACjB,qBAAsB;EACvB,IAAK,CAAC,CAAE,kBACP,wBACCD,qBAAAA,MAAiB,MACjB,gBACD;CAEF,GACA,CAAE,uBAAwB,CAC3B;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAMC,eAAgB,uBAAuB,cAAc;EACrD,UAAW;EACX,cAAe;EAEf,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GAC2B;GACZ;GACS;GACG;EAC1B,CAAA;CACM,CAAA;AAEV"}
@@ -1,88 +1,46 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/edit-widgets/src/components/sidebar/widget-areas.jsx
20
- var widget_areas_exports = {};
21
- __export(widget_areas_exports, {
22
- default: () => WidgetAreas
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
23
5
  });
24
- module.exports = __toCommonJS(widget_areas_exports);
25
- var import_data = require("@wordpress/data");
26
- var import_element = require("@wordpress/element");
27
- var import_icons = require("@wordpress/icons");
28
- var import_block_editor = require("@wordpress/block-editor");
29
- var import_components = require("@wordpress/components");
30
- var import_i18n = require("@wordpress/i18n");
31
- var import_url = require("@wordpress/url");
32
- var import_dom = require("@wordpress/dom");
33
- var import_store = require("../../store/index.cjs");
34
- var import_jsx_runtime = require("react/jsx-runtime");
6
+ let _wordpress_data = require("@wordpress/data");
7
+ let _wordpress_element = require("@wordpress/element");
8
+ let _wordpress_icons = require("@wordpress/icons");
9
+ let _wordpress_block_editor = require("@wordpress/block-editor");
10
+ let _wordpress_components = require("@wordpress/components");
11
+ let _wordpress_i18n = require("@wordpress/i18n");
12
+ let _wordpress_url = require("@wordpress/url");
13
+ let _wordpress_dom = require("@wordpress/dom");
14
+ let ______store_index_js = require("../../store/index.cjs");
15
+ let react_jsx_runtime = require("react/jsx-runtime");
16
+ // packages/edit-widgets/src/components/sidebar/widget-areas.jsx
35
17
  function WidgetAreas({ selectedWidgetAreaId }) {
36
- const widgetAreas = (0, import_data.useSelect)(
37
- (select) => select(import_store.store).getWidgetAreas(),
38
- []
39
- );
40
- const selectedWidgetArea = (0, import_element.useMemo)(
41
- () => selectedWidgetAreaId && widgetAreas?.find(
42
- (widgetArea) => widgetArea.id === selectedWidgetAreaId
43
- ),
44
- [selectedWidgetAreaId, widgetAreas]
45
- );
46
- let description;
47
- if (!selectedWidgetArea) {
48
- description = (0, import_i18n.__)(
49
- // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
50
- "Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer."
51
- );
52
- } else if (selectedWidgetAreaId === "wp_inactive_widgets") {
53
- description = (0, import_i18n.__)(
54
- "Blocks in this Widget Area will not be displayed in your site."
55
- );
56
- } else {
57
- description = selectedWidgetArea.description;
58
- }
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "edit-widgets-widget-areas__top-container", children: [
60
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.layout }),
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
- "p",
64
- {
65
- dangerouslySetInnerHTML: {
66
- __html: (0, import_dom.safeHTML)(description)
67
- }
68
- }
69
- ),
70
- widgetAreas?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_i18n.__)(
71
- "Your theme does not contain any Widget Areas."
72
- ) }),
73
- !selectedWidgetArea && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
- import_components.Button,
75
- {
76
- __next40pxDefaultSize: true,
77
- href: (0, import_url.addQueryArgs)("customize.php", {
78
- "autofocus[panel]": "widgets",
79
- return: window.location.pathname
80
- }),
81
- variant: "tertiary",
82
- children: (0, import_i18n.__)("Manage with live preview")
83
- }
84
- )
85
- ] })
86
- ] }) });
18
+ const widgetAreas = (0, _wordpress_data.useSelect)((select) => select(______store_index_js.store).getWidgetAreas(), []);
19
+ const selectedWidgetArea = (0, _wordpress_element.useMemo)(() => selectedWidgetAreaId && widgetAreas?.find((widgetArea) => widgetArea.id === selectedWidgetAreaId), [selectedWidgetAreaId, widgetAreas]);
20
+ let description;
21
+ if (!selectedWidgetArea) description = (0, _wordpress_i18n.__)("Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.");
22
+ else if (selectedWidgetAreaId === "wp_inactive_widgets") description = (0, _wordpress_i18n.__)("Blocks in this Widget Area will not be displayed in your site.");
23
+ else description = selectedWidgetArea.description;
24
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
25
+ className: "edit-widgets-widget-areas",
26
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
27
+ className: "edit-widgets-widget-areas__top-container",
28
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.BlockIcon, { icon: _wordpress_icons.layout }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
29
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { dangerouslySetInnerHTML: { __html: (0, _wordpress_dom.safeHTML)(description) } }),
30
+ widgetAreas?.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: (0, _wordpress_i18n.__)("Your theme does not contain any Widget Areas.") }),
31
+ !selectedWidgetArea && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
32
+ __next40pxDefaultSize: true,
33
+ href: (0, _wordpress_url.addQueryArgs)("customize.php", {
34
+ "autofocus[panel]": "widgets",
35
+ return: window.location.pathname
36
+ }),
37
+ variant: "tertiary",
38
+ children: (0, _wordpress_i18n.__)("Manage with live preview")
39
+ })
40
+ ] })]
41
+ })
42
+ });
87
43
  }
88
- //# sourceMappingURL=widget-areas.cjs.map
44
+ exports.default = WidgetAreas;
45
+
46
+ //# sourceMappingURL=widget-areas.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/sidebar/widget-areas.jsx"],
4
- "sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { layout } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { safeHTML } from '@wordpress/dom';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t<div>\n\t\t\t\t\t<p\n\t\t\t\t\t\t// Use `dangerouslySetInnerHTML` to keep backwards\n\t\t\t\t\t\t// compatibility. Basic markup in the description is an\n\t\t\t\t\t\t// established feature of WordPress.\n\t\t\t\t\t\t// @see https://github.com/WordPress/gutenberg/issues/33106\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: safeHTML( description ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,qBAAwB;AACxB,mBAAuB;AACvB,0BAA0B;AAC1B,wBAAuB;AACvB,kBAAmB;AACnB,iBAA6B;AAC7B,iBAAyB;AACzB,mBAA0C;AAkCtC;AAhCW,SAAR,YAA8B,EAAE,qBAAqB,GAAI;AAC/D,QAAM,kBAAc;AAAA,IACnB,CAAE,WAAY,OAAQ,aAAAA,KAAiB,EAAE,eAAe;AAAA,IACxD,CAAC;AAAA,EACF;AAEA,QAAM,yBAAqB;AAAA,IAC1B,MACC,wBACA,aAAa;AAAA,MACZ,CAAE,eAAgB,WAAW,OAAO;AAAA,IACrC;AAAA,IACD,CAAE,sBAAsB,WAAY;AAAA,EACrC;AAEA,MAAI;AACJ,MAAK,CAAE,oBAAqB;AAC3B,sBAAc;AAAA;AAAA,MAEb;AAAA,IACD;AAAA,EACD,WAAY,yBAAyB,uBAAwB;AAC5D,sBAAc;AAAA,MACb;AAAA,IACD;AAAA,EACD,OAAO;AACN,kBAAc,mBAAmB;AAAA,EAClC;AAEA,SACC,4CAAC,SAAI,WAAU,6BACd,uDAAC,SAAI,WAAU,4CACd;AAAA,gDAAC,iCAAU,MAAO,qBAAS;AAAA,IAC3B,6CAAC,SACA;AAAA;AAAA,QAAC;AAAA;AAAA,UAKA,yBAA0B;AAAA,YACzB,YAAQ,qBAAU,WAAY;AAAA,UAC/B;AAAA;AAAA,MACD;AAAA,MACE,aAAa,WAAW,KACzB,4CAAC,OACE;AAAA,QACD;AAAA,MACD,GACD;AAAA,MAEC,CAAE,sBACH;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,UAAO,yBAAc,iBAAiB;AAAA,YACrC,oBAAoB;AAAA,YACpB,QAAQ,OAAO,SAAS;AAAA,UACzB,CAAE;AAAA,UACF,SAAQ;AAAA,UAEN,8BAAI,0BAA2B;AAAA;AAAA,MAClC;AAAA,OAEF;AAAA,KACD,GACD;AAEF;",
6
- "names": ["editWidgetsStore"]
7
- }
1
+ {"version":3,"file":"widget-areas.cjs","names":["useSelect","editWidgetsStore","useMemo","__","BlockIcon","layout","safeHTML","Button","addQueryArgs"],"sources":["../../../src/components/sidebar/widget-areas.jsx"],"sourcesContent":["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { layout } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { safeHTML } from '@wordpress/dom';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t<div>\n\t\t\t\t\t<p\n\t\t\t\t\t\t// Use `dangerouslySetInnerHTML` to keep backwards\n\t\t\t\t\t\t// compatibility. Basic markup in the description is an\n\t\t\t\t\t\t// established feature of WordPress.\n\t\t\t\t\t\t// @see https://github.com/WordPress/gutenberg/issues/33106\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: safeHTML( description ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;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