PluginProbe
Gutenberg / 12.1.0
Gutenberg v12.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / edit-navigation / index.js

index.js in Gutenberg 12.1.0, at build/edit-navigation/index.js

5,046 lines 168.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 4184:
5 /***/ (function(module, exports) {
6
7 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 Copyright (c) 2018 Jed Watson.
9 Licensed under the MIT License (MIT), see
10 http://jedwatson.github.io/classnames
11 */
12 /* global define */
13
14 (function () {
15 'use strict';
16
17 var hasOwn = {}.hasOwnProperty;
18
19 function classNames() {
20 var classes = [];
21
22 for (var i = 0; i < arguments.length; i++) {
23 var arg = arguments[i];
24 if (!arg) continue;
25
26 var argType = typeof arg;
27
28 if (argType === 'string' || argType === 'number') {
29 classes.push(arg);
30 } else if (Array.isArray(arg)) {
31 if (arg.length) {
32 var inner = classNames.apply(null, arg);
33 if (inner) {
34 classes.push(inner);
35 }
36 }
37 } else if (argType === 'object') {
38 if (arg.toString === Object.prototype.toString) {
39 for (var key in arg) {
40 if (hasOwn.call(arg, key) && arg[key]) {
41 classes.push(key);
42 }
43 }
44 } else {
45 classes.push(arg.toString());
46 }
47 }
48 }
49
50 return classes.join(' ');
51 }
52
53 if ( true && module.exports) {
54 classNames.default = classNames;
55 module.exports = classNames;
56 } else if (true) {
57 // register as 'classnames', consistent with npm package name
58 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
59 return classNames;
60 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
61 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
62 } else {}
63 }());
64
65
66 /***/ })
67
68 /******/ });
69 /************************************************************************/
70 /******/ // The module cache
71 /******/ var __webpack_module_cache__ = {};
72 /******/
73 /******/ // The require function
74 /******/ function __webpack_require__(moduleId) {
75 /******/ // Check if module is in cache
76 /******/ var cachedModule = __webpack_module_cache__[moduleId];
77 /******/ if (cachedModule !== undefined) {
78 /******/ return cachedModule.exports;
79 /******/ }
80 /******/ // Create a new module (and put it into the cache)
81 /******/ var module = __webpack_module_cache__[moduleId] = {
82 /******/ // no module.id needed
83 /******/ // no module.loaded needed
84 /******/ exports: {}
85 /******/ };
86 /******/
87 /******/ // Execute the module function
88 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
89 /******/
90 /******/ // Return the exports of the module
91 /******/ return module.exports;
92 /******/ }
93 /******/
94 /************************************************************************/
95 /******/ /* webpack/runtime/compat get default export */
96 /******/ !function() {
97 /******/ // getDefaultExport function for compatibility with non-harmony modules
98 /******/ __webpack_require__.n = function(module) {
99 /******/ var getter = module && module.__esModule ?
100 /******/ function() { return module['default']; } :
101 /******/ function() { return module; };
102 /******/ __webpack_require__.d(getter, { a: getter });
103 /******/ return getter;
104 /******/ };
105 /******/ }();
106 /******/
107 /******/ /* webpack/runtime/define property getters */
108 /******/ !function() {
109 /******/ // define getter functions for harmony exports
110 /******/ __webpack_require__.d = function(exports, definition) {
111 /******/ for(var key in definition) {
112 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
113 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
114 /******/ }
115 /******/ }
116 /******/ };
117 /******/ }();
118 /******/
119 /******/ /* webpack/runtime/hasOwnProperty shorthand */
120 /******/ !function() {
121 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
122 /******/ }();
123 /******/
124 /******/ /* webpack/runtime/make namespace object */
125 /******/ !function() {
126 /******/ // define __esModule on exports
127 /******/ __webpack_require__.r = function(exports) {
128 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
129 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
130 /******/ }
131 /******/ Object.defineProperty(exports, '__esModule', { value: true });
132 /******/ };
133 /******/ }();
134 /******/
135 /************************************************************************/
136 var __webpack_exports__ = {};
137 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
138 !function() {
139 "use strict";
140 // ESM COMPAT FLAG
141 __webpack_require__.r(__webpack_exports__);
142
143 // EXPORTS
144 __webpack_require__.d(__webpack_exports__, {
145 "__unstableCreateMenuPreloadingMiddleware": function() { return /* reexport */ createMenuPreloadingMiddleware; },
146 "initialize": function() { return /* binding */ initialize; }
147 });
148
149 // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/resolvers.js
150 var resolvers_namespaceObject = {};
151 __webpack_require__.r(resolvers_namespaceObject);
152 __webpack_require__.d(resolvers_namespaceObject, {
153 "getNavigationPostForMenu": function() { return getNavigationPostForMenu; }
154 });
155
156 // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/selectors.js
157 var selectors_namespaceObject = {};
158 __webpack_require__.r(selectors_namespaceObject);
159 __webpack_require__.d(selectors_namespaceObject, {
160 "getNavigationPostForMenu": function() { return selectors_getNavigationPostForMenu; },
161 "getSelectedMenuId": function() { return getSelectedMenuId; },
162 "hasResolvedNavigationPost": function() { return hasResolvedNavigationPost; },
163 "isInserterOpened": function() { return isInserterOpened; }
164 });
165
166 // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/actions.js
167 var actions_namespaceObject = {};
168 __webpack_require__.r(actions_namespaceObject);
169 __webpack_require__.d(actions_namespaceObject, {
170 "saveNavigationPost": function() { return saveNavigationPost; },
171 "setIsInserterOpened": function() { return setIsInserterOpened; },
172 "setSelectedMenuId": function() { return setSelectedMenuId; }
173 });
174
175 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
176 var store_actions_namespaceObject = {};
177 __webpack_require__.r(store_actions_namespaceObject);
178 __webpack_require__.d(store_actions_namespaceObject, {
179 "disableComplementaryArea": function() { return disableComplementaryArea; },
180 "enableComplementaryArea": function() { return enableComplementaryArea; },
181 "pinItem": function() { return pinItem; },
182 "setFeatureDefaults": function() { return setFeatureDefaults; },
183 "setFeatureValue": function() { return setFeatureValue; },
184 "toggleFeature": function() { return toggleFeature; },
185 "unpinItem": function() { return unpinItem; }
186 });
187
188 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
189 var store_selectors_namespaceObject = {};
190 __webpack_require__.r(store_selectors_namespaceObject);
191 __webpack_require__.d(store_selectors_namespaceObject, {
192 "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
193 "isFeatureActive": function() { return isFeatureActive; },
194 "isItemPinned": function() { return isItemPinned; }
195 });
196
197 ;// CONCATENATED MODULE: external ["wp","element"]
198 var external_wp_element_namespaceObject = window["wp"]["element"];
199 ;// CONCATENATED MODULE: external ["wp","blocks"]
200 var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
201 ;// CONCATENATED MODULE: external ["wp","blockLibrary"]
202 var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
203 ;// CONCATENATED MODULE: external ["wp","data"]
204 var external_wp_data_namespaceObject = window["wp"]["data"];
205 ;// CONCATENATED MODULE: external ["wp","coreData"]
206 var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
207 ;// CONCATENATED MODULE: external ["wp","i18n"]
208 var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
209 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/constants/index.js
210 /**
211 * "Kind" of the menu post.
212 *
213 * @type {string}
214 */
215 const MENU_KIND = 'root';
216 /**
217 * "post type" of the menu post.
218 *
219 * @type {string}
220 */
221
222 const MENU_POST_TYPE = 'menu';
223 /**
224 * "Kind" of the navigation post.
225 *
226 * @type {string}
227 */
228
229 const NAVIGATION_POST_KIND = 'root';
230 /**
231 * "post type" of the navigation post.
232 *
233 * @type {string}
234 */
235
236 const NAVIGATION_POST_POST_TYPE = 'navigationPost';
237 /**
238 * The scope name of the editor's complementary area.
239 *
240 * @type {string}
241 */
242
243 const SIDEBAR_SCOPE = 'core/edit-navigation';
244 /**
245 * The identifier of the editor's menu complementary area.
246 *
247 * @type {string}
248 */
249
250 const SIDEBAR_MENU = 'edit-navigation/menu';
251 /**
252 * The identifier of the editor's block complementary area.
253 *
254 * @type {string}
255 */
256
257 const SIDEBAR_BLOCK = 'edit-navigation/block-inspector';
258 /**
259 * The string identifier for the menu item's "target" attribute indicating
260 * the menu item link should open in a new tab.
261 *
262 * @type {string}
263 */
264
265 const NEW_TAB_TARGET_ATTRIBUTE = '_blank';
266 //# sourceMappingURL=index.js.map
267 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/reducer.js
268 /**
269 * WordPress dependencies
270 */
271
272 /**
273 * Reducer keeping track of selected menu ID.
274 *
275 * @param {number} state Current state.
276 * @param {Object} action Dispatched action.
277 * @return {Object} Updated state.
278 */
279
280 function selectedMenuId() {
281 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
282 let action = arguments.length > 1 ? arguments[1] : undefined;
283
284 switch (action.type) {
285 case 'SET_SELECTED_MENU_ID':
286 return action.menuId;
287 }
288
289 return state;
290 }
291 /**
292 * Reducer tracking whether the inserter is open.
293 *
294 * @param {boolean|Object} state Current state.
295 * @param {Object} action Dispatched action.
296 * @param {string} action.type String indicating action type.
297 * @param {boolean} action.value Flag indicating whether the panel should be open/close.
298 */
299
300 function blockInserterPanel() {
301 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
302 let action = arguments.length > 1 ? arguments[1] : undefined;
303
304 switch (action.type) {
305 case 'SET_IS_INSERTER_OPENED':
306 return action.value;
307 }
308
309 return state;
310 }
311
312 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
313 selectedMenuId,
314 blockInserterPanel
315 }));
316 //# sourceMappingURL=reducer.js.map
317 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/utils.js
318 /**
319 * A WP nav_menu_item object.
320 * For more documentation on the individual fields present on a menu item please see:
321 * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789
322 *
323 * Changes made here should also be mirrored in packages/block-library/src/navigation/map-menu-items-to-blocks.js.
324 *
325 * @typedef WPNavMenuItem
326 *
327 * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.
328 * @property {Array} xfn the XFN relationships expressed in the link of this menu item.
329 * @property {Array} classes the HTML class attributes for this menu item.
330 * @property {string} attr_title the HTML title attribute for this menu item.
331 * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.
332 * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
333 * @property {string} description The description of this menu item.
334 * @property {string} url The URL to which this menu item points.
335 * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.
336 * @property {string} target The target attribute of the link element for this menu item.
337 */
338
339 /**
340 * Builds an ID for a new navigation post.
341 *
342 * @param {number} menuId Menu id.
343 * @return {string} An ID.
344 */
345 const buildNavigationPostId = menuId => `navigation-post-${menuId}`;
346 /**
347 * Builds a query to resolve menu items.
348 *
349 * @param {number} menuId Menu id.
350 * @return {Object} Query.
351 */
352
353 function menuItemsQuery(menuId) {
354 return {
355 menus: menuId,
356 per_page: -1
357 };
358 }
359 /**
360 * Get the internal record id from block.
361 *
362 * @typedef {Object} Attributes
363 * @property {string} __internalRecordId The internal record id.
364 * @typedef {Object} Block
365 * @property {Attributes} attributes The attributes of the block.
366 *
367 * @param {Block} block The block.
368 * @return {string} The internal record id.
369 */
370
371 function getRecordIdFromBlock(block) {
372 return block.attributes.__internalRecordId;
373 }
374 /**
375 * Add internal record id to block's attributes.
376 *
377 * @param {Block} block The block.
378 * @param {string} recordId The record id.
379 * @return {Block} The updated block.
380 */
381
382 function addRecordIdToBlock(block, recordId) {
383 return { ...block,
384 attributes: { ...(block.attributes || {}),
385 __internalRecordId: recordId
386 }
387 };
388 }
389 /**
390 * Checks if a given block should be persisted as a menu item.
391 *
392 * @param {Object} block Block to check.
393 * @return {boolean} True if a given block should be persisted as a menu item, false otherwise.
394 */
395
396 const isBlockSupportedInNav = block => ['core/navigation-link', 'core/navigation-submenu'].includes(block.name);
397 //# sourceMappingURL=utils.js.map
398 ;// CONCATENATED MODULE: external "lodash"
399 var external_lodash_namespaceObject = window["lodash"];
400 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/transform.js
401 /**
402 * External dependencies
403 */
404
405 /**
406 * WordPress dependencies
407 */
408
409
410 /**
411 * Internal dependencies
412 */
413
414
415
416 /**
417 * A WP nav_menu_item object.
418 * For more documentation on the individual fields present on a menu item please see:
419 * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789
420 *
421 * Changes made here should also be mirrored in packages/edit-navigation/src/store/utils.js.
422 *
423 * @typedef WPNavMenuItem
424 *
425 * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.
426 * @property {Array} xfn the XFN relationships expressed in the link of this menu item.
427 * @property {Array} classes the HTML class attributes for this menu item.
428 * @property {string} attr_title the HTML title attribute for this menu item.
429 * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.
430 * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
431 * @property {string} description The description of this menu item.
432 * @property {string} url The URL to which this menu item points.
433 * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.
434 * @property {string} target The target attribute of the link element for this menu item.
435 */
436
437 function blockToMenuItem(block, menuItem, parentId, blockPosition, menuId) {
438 menuItem = (0,external_lodash_namespaceObject.omit)(menuItem, 'menus', 'meta', '_links');
439 menuItem.content = (0,external_lodash_namespaceObject.get)(menuItem.content, 'raw', menuItem.content);
440 let attributes;
441
442 if (isBlockSupportedInNav(block)) {
443 attributes = blockAttributesToMenuItem(block.attributes);
444 } else {
445 attributes = {
446 type: 'block',
447 content: (0,external_wp_blocks_namespaceObject.serialize)(block)
448 };
449 }
450
451 return { ...menuItem,
452 ...attributes,
453 content: attributes.content || '',
454 id: getRecordIdFromBlock(block),
455 menu_order: blockPosition + 1,
456 menus: menuId,
457 parent: !parentId ? 0 : parentId,
458 status: 'publish'
459 };
460 }
461 /**
462 * Convert block attributes to menu item fields.
463 *
464 * Note that nav_menu_item has defaults provided in Core so in the case of undefined Block attributes
465 * we need only include a subset of values in the knowledge that the defaults will be provided in Core.
466 *
467 * See: https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L438.
468 *
469 * @param {Object} blockAttributes the block attributes of the block to be converted into menu item fields.
470 * @param {string} blockAttributes.label the visual name of the block shown in the UI.
471 * @param {string} blockAttributes.url the URL for the link.
472 * @param {string} blockAttributes.description a link description.
473 * @param {string} blockAttributes.rel the XFN relationship expressed in the link of this menu item.
474 * @param {string} blockAttributes.className the custom CSS classname attributes for this block.
475 * @param {string} blockAttributes.title the HTML title attribute for the block's link.
476 * @param {string} blockAttributes.type the type of variation of the block used (eg: 'Post', 'Custom', 'Category'...etc).
477 * @param {number} blockAttributes.id the ID of the entity optionally associated with the block's link (eg: the Post ID).
478 * @param {string} blockAttributes.kind the family of objects originally represented, such as 'post-type' or 'taxonomy'.
479 * @param {boolean} blockAttributes.opensInNewTab whether or not the block's link should open in a new tab.
480 * @return {WPNavMenuItem} the menu item (converted from block attributes).
481 */
482
483 const blockAttributesToMenuItem = _ref => {
484 var _type;
485
486 let {
487 label = '',
488 url = '',
489 description,
490 rel,
491 className,
492 title: blockTitleAttr,
493 type,
494 id,
495 kind,
496 opensInNewTab
497 } = _ref;
498
499 // For historical reasons, the `core/navigation-link` variation type is `tag`
500 // whereas WP Core expects `post_tag` as the `object` type.
501 // To avoid writing a block migration we perform a conversion here.
502 // See also inverse equivalent in `menuItemToBlockAttributes`.
503 if (type && type === 'tag') {
504 type = 'post_tag';
505 }
506
507 return {
508 title: label,
509 url,
510 ...((description === null || description === void 0 ? void 0 : description.length) && {
511 description
512 }),
513 ...((rel === null || rel === void 0 ? void 0 : rel.length) && {
514 xfn: rel === null || rel === void 0 ? void 0 : rel.trim().split(' ')
515 }),
516 ...((className === null || className === void 0 ? void 0 : className.length) && {
517 classes: className === null || className === void 0 ? void 0 : className.trim().split(' ')
518 }),
519 ...((blockTitleAttr === null || blockTitleAttr === void 0 ? void 0 : blockTitleAttr.length) && {
520 attr_title: blockTitleAttr
521 }),
522 ...(((_type = type) === null || _type === void 0 ? void 0 : _type.length) && {
523 object: type
524 }),
525 ...((kind === null || kind === void 0 ? void 0 : kind.length) && {
526 type: kind === null || kind === void 0 ? void 0 : kind.replace('-', '_')
527 }),
528 // Only assign object_id if it's a entity type (ie: not "custom").
529 ...(id && 'custom' !== type && {
530 object_id: id
531 }),
532 target: opensInNewTab ? NEW_TAB_TARGET_ATTRIBUTE : ''
533 };
534 };
535 /**
536 * Convert a flat menu item structure to a nested blocks structure.
537 *
538 * @param {Object[]} menuItems An array of menu items.
539 *
540 * @return {WPBlock[]} An array of blocks.
541 */
542
543 function menuItemsToBlocks(menuItems) {
544 if (!menuItems) {
545 return null;
546 }
547
548 const menuTree = createDataTree(menuItems);
549 return mapMenuItemsToBlocks(menuTree);
550 }
551 /**
552 * A recursive function that maps menu item nodes to blocks.
553 *
554 * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.
555 * @return {Object} Object containing innerBlocks and mapping.
556 */
557
558 function mapMenuItemsToBlocks(menuItems) {
559 // The menuItem should be in menu_order sort order.
560 const sortedItems = (0,external_lodash_namespaceObject.sortBy)(menuItems, 'menu_order');
561 const blocks = sortedItems.map(menuItem => {
562 var _menuItem$children;
563
564 if (menuItem.type === 'block') {
565 const [block] = (0,external_wp_blocks_namespaceObject.parse)(menuItem.content.raw);
566
567 if (!block) {
568 return (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
569 content: menuItem.content
570 });
571 }
572
573 return block;
574 }
575
576 const attributes = menuItemToBlockAttributes(menuItem); // If there are children recurse to build those nested blocks.
577
578 const nestedBlocks = (_menuItem$children = menuItem.children) !== null && _menuItem$children !== void 0 && _menuItem$children.length ? mapMenuItemsToBlocks(menuItem.children) : []; // Create a submenu block when there are inner blocks, or just a link
579 // for a standalone item.
580
581 const itemBlockName = nestedBlocks !== null && nestedBlocks !== void 0 && nestedBlocks.length ? 'core/navigation-submenu' : 'core/navigation-link'; // Create block with nested "innerBlocks".
582
583 return (0,external_wp_blocks_namespaceObject.createBlock)(itemBlockName, attributes, nestedBlocks);
584 });
585 return (0,external_lodash_namespaceObject.zip)(blocks, sortedItems).map(_ref2 => {
586 let [block, menuItem] = _ref2;
587 return addRecordIdToBlock(block, menuItem.id);
588 });
589 } // A few parameters are using snake case, let's embrace that for convenience:
590
591 /* eslint-disable camelcase */
592
593 /**
594 * Convert block attributes to menu item.
595 *
596 * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
597 * @return {Object} the block attributes converted from the WPNavMenuItem item.
598 */
599
600
601 function menuItemToBlockAttributes(_ref3) {
602 var _object;
603
604 let {
605 title: menuItemTitleField,
606 xfn,
607 classes,
608 attr_title,
609 object,
610 object_id,
611 description,
612 url,
613 type: menuItemTypeField,
614 target
615 } = _ref3;
616
617 // For historical reasons, the `core/navigation-link` variation type is `tag`
618 // whereas WP Core expects `post_tag` as the `object` type.
619 // To avoid writing a block migration we perform a conversion here.
620 // See also inverse equivalent in `blockAttributesToMenuItem`.
621 if (object && object === 'post_tag') {
622 object = 'tag';
623 }
624
625 return {
626 label: (menuItemTitleField === null || menuItemTitleField === void 0 ? void 0 : menuItemTitleField.rendered) || '',
627 ...(((_object = object) === null || _object === void 0 ? void 0 : _object.length) && {
628 type: object
629 }),
630 kind: (menuItemTypeField === null || menuItemTypeField === void 0 ? void 0 : menuItemTypeField.replace('_', '-')) || 'custom',
631 url: url || '',
632 ...((xfn === null || xfn === void 0 ? void 0 : xfn.length) && xfn.join(' ').trim() && {
633 rel: xfn.join(' ').trim()
634 }),
635 ...((classes === null || classes === void 0 ? void 0 : classes.length) && classes.join(' ').trim() && {
636 className: classes.join(' ').trim()
637 }),
638 ...((attr_title === null || attr_title === void 0 ? void 0 : attr_title.length) && {
639 title: attr_title
640 }),
641 ...(object_id && 'custom' !== object && {
642 id: object_id
643 }),
644 ...((description === null || description === void 0 ? void 0 : description.length) && {
645 description
646 }),
647 ...(target === NEW_TAB_TARGET_ATTRIBUTE && {
648 opensInNewTab: true
649 })
650 };
651 }
652 /* eslint-enable camelcase */
653
654 /**
655 * Creates a nested, hierarchical tree representation from unstructured data that
656 * has an inherent relationship defined between individual items.
657 *
658 * For example, by default, each element in the dataset should have an `id` and
659 * `parent` property where the `parent` property indicates a relationship between
660 * the current item and another item with a matching `id` properties.
661 *
662 * This is useful for building linked lists of data from flat data structures.
663 *
664 * @param {Array} dataset linked data to be rearranged into a hierarchical tree based on relational fields.
665 * @param {string} id the property which uniquely identifies each entry within the array.
666 * @param {*} relation the property which identifies how the current item is related to other items in the data (if at all).
667 * @return {Array} a nested array of parent/child relationships
668 */
669
670 function createDataTree(dataset) {
671 let id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
672 let relation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'parent';
673 const hashTable = Object.create(null);
674 const dataTree = [];
675
676 for (const data of dataset) {
677 hashTable[data[id]] = { ...data,
678 children: []
679 };
680 }
681
682 for (const data of dataset) {
683 if (data[relation]) {
684 hashTable[data[relation]] = hashTable[data[relation]] || {};
685 hashTable[data[relation]].children = hashTable[data[relation]].children || [];
686 hashTable[data[relation]].children.push(hashTable[data[id]]);
687 } else {
688 dataTree.push(hashTable[data[id]]);
689 }
690 }
691
692 return dataTree;
693 }
694 //# sourceMappingURL=transform.js.map
695 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/resolvers.js
696 /**
697 * WordPress dependencies
698 */
699
700
701 /**
702 * Internal dependencies
703 */
704
705
706
707
708 /**
709 * Creates a "stub" navigation post reflecting the contents of menu with id=menuId. The
710 * post is meant as a convenient to only exists in runtime and should never be saved. It
711 * enables a convenient way of editing the navigation by using a regular post editor.
712 *
713 * Fetches all menu items, converts them into blocks, and hydrates a new post with them.
714 *
715 * @param {number} menuId The id of menu to create a post from
716 * @return {void}
717 */
718
719 const getNavigationPostForMenu = menuId => async _ref => {
720 let {
721 registry,
722 dispatch
723 } = _ref;
724
725 if (!menuId) {
726 return;
727 }
728
729 const stubPost = createStubPost(menuId); // Persist an empty post to warm up the state
730
731 dispatch(persistPost(stubPost)); // Dispatch startResolution to skip the execution of the real getEntityRecord resolver - it would
732 // issue an http request and fail.
733
734 const args = [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, stubPost.id];
735 registry.dispatch(external_wp_coreData_namespaceObject.store).startResolution('getEntityRecord', args); // Now let's create a proper one hydrated using actual menu items
736
737 const menuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems(menuItemsQuery(menuId));
738 const navigationBlock = createNavigationBlock(menuItems); // Persist the actual post containing the navigation block
739
740 const builtPost = createStubPost(menuId, navigationBlock);
741 dispatch(persistPost(builtPost)); // Dispatch finishResolution to conclude startResolution dispatched earlier
742
743 registry.dispatch(external_wp_coreData_namespaceObject.store).finishResolution('getEntityRecord', args);
744 };
745
746 const createStubPost = function (menuId) {
747 let navigationBlock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
748 const id = buildNavigationPostId(menuId);
749 return {
750 id,
751 slug: id,
752 status: 'draft',
753 type: 'page',
754 blocks: navigationBlock ? [navigationBlock] : [],
755 meta: {
756 menuId
757 }
758 };
759 };
760
761 const persistPost = post => _ref2 => {
762 let {
763 registry
764 } = _ref2;
765 registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, {
766 id: post.id
767 }, false);
768 };
769 /**
770 * Converts an adjacency list of menuItems into a navigation block.
771 *
772 * @param {Array} menuItems a list of menu items
773 * @return {Object} Navigation block
774 */
775
776
777 function createNavigationBlock(menuItems) {
778 const innerBlocks = menuItemsToBlocks(menuItems);
779 return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
780 orientation: 'vertical'
781 }, innerBlocks);
782 }
783 //# sourceMappingURL=resolvers.js.map
784 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/selectors.js
785 /**
786 * WordPress dependencies
787 */
788
789
790 /**
791 * Internal dependencies
792 */
793
794
795
796 /**
797 * Returns the selected menu ID.
798 *
799 * @param {Object} state Global application state.
800 * @return {number} The selected menu ID.
801 */
802
803 function getSelectedMenuId(state) {
804 var _state$selectedMenuId;
805
806 return (_state$selectedMenuId = state.selectedMenuId) !== null && _state$selectedMenuId !== void 0 ? _state$selectedMenuId : null;
807 }
808 /**
809 * Returns a "stub" navigation post reflecting the contents of menu with id=menuId. The
810 * post is meant as a convenient to only exists in runtime and should never be saved. It
811 * enables a convenient way of editing the navigation by using a regular post editor.
812 *
813 * Related resolver fetches all menu items, converts them into blocks, and hydrates a new post with them.
814 *
815 * @param {number} menuId The id of menu to create a post from.
816 * @return {null|Object} Post once the resolver fetches it, otherwise null
817 */
818
819 const selectors_getNavigationPostForMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => {
820 // When the record is unavailable, calling getEditedEntityRecord triggers a http
821 // request via it's related resolver. Let's return nothing until getNavigationPostForMenu
822 // resolver marks the record as resolved.
823 if (!hasResolvedNavigationPost(state, menuId)) {
824 return null;
825 }
826
827 return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId));
828 });
829 /**
830 * Returns true if the navigation post related to menuId was already resolved.
831 *
832 * @param {number} menuId The id of menu.
833 * @return {boolean} True if the navigation post related to menuId was already resolved, false otherwise.
834 */
835
836 const hasResolvedNavigationPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => {
837 return select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecord', [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId)]);
838 });
839 /**
840 * Returns true if the inserter is opened.
841 *
842 * @param {Object} state Global application state.
843 * @return {boolean} Whether the inserter is opened.
844 */
845
846 function isInserterOpened() {
847 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
848 return !!(state !== null && state !== void 0 && state.blockInserterPanel);
849 }
850 //# sourceMappingURL=selectors.js.map
851 ;// CONCATENATED MODULE: external ["wp","notices"]
852 var external_wp_notices_namespaceObject = window["wp"]["notices"];
853 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/constants.js
854 /**
855 * Module Constants
856 */
857 const STORE_NAME = 'core/edit-navigation';
858 //# sourceMappingURL=constants.js.map
859 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/actions.js
860 /**
861 * External dependencies
862 */
863
864 /**
865 * WordPress dependencies
866 */
867
868
869
870
871 /**
872 * Internal dependencies
873 */
874
875
876
877
878
879 /**
880 * Returns an action object used to select menu.
881 *
882 * @param {number} menuId The menu ID.
883 * @return {Object} Action object.
884 */
885
886 function setSelectedMenuId(menuId) {
887 return {
888 type: 'SET_SELECTED_MENU_ID',
889 menuId
890 };
891 }
892 /**
893 * Converts all the blocks into menu items and submits a batch request to save everything at once.
894 *
895 * @param {Object} post A navigation post to process
896 * @return {Function} An action creator
897 */
898
899 const saveNavigationPost = post => async _ref => {
900 let {
901 registry,
902 dispatch
903 } = _ref;
904 const lock = await registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableAcquireStoreLock(STORE_NAME, ['savingMenu'], {
905 exclusive: true
906 });
907
908 try {
909 const menuId = post.meta.menuId; // Save menu
910
911 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord('root', 'menu', menuId);
912 const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'menu', menuId);
913
914 if (error) {
915 throw new Error(error.message);
916 } // Save menu items
917
918
919 const updatedBlocks = await dispatch(batchSaveMenuItems(post.blocks[0], menuId)); // Clear "stub" navigation post edits to avoid a false "dirty" state.
920
921 registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, undefined);
922 const updatedPost = { ...post,
923 blocks: [updatedBlocks]
924 };
925 registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, updatedPost, undefined);
926 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Navigation saved.'), {
927 type: 'snackbar'
928 });
929 } catch (saveError) {
930 const errorMessage = saveError ? (0,external_wp_i18n_namespaceObject.sprintf)(
931 /* translators: %s: The text of an error message (potentially untranslated). */
932 (0,external_wp_i18n_namespaceObject.__)("Unable to save: '%s'"), saveError.message) : (0,external_wp_i18n_namespaceObject.__)('Unable to save: An error ocurred.');
933 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
934 type: 'snackbar'
935 });
936 } finally {
937 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableReleaseStoreLock(lock);
938 }
939 };
940 /**
941 * Executes appropriate insert, update, and delete operations to turn the current
942 * menu (with id=menuId) into one represented by the passed navigation block.
943 *
944 * @param {Object} navigationBlock The navigation block representing the desired state of the menu.
945 * @param {number} menuId Menu Id to process.
946 * @return {Function} An action creator
947 */
948
949 const batchSaveMenuItems = (navigationBlock, menuId) => async _ref2 => {
950 let {
951 dispatch,
952 registry
953 } = _ref2;
954 // Make sure all the existing menu items are available before proceeding
955 const oldMenuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems({
956 menus: menuId,
957 per_page: -1
958 }); // Insert placeholders for new menu items to have an ID to work with.
959 // We need that in case these new items have any children. If so,
960 // we need to provide a parent id that we don't have yet.
961
962 const navBlockWithRecordIds = await dispatch(batchInsertPlaceholderMenuItems(navigationBlock)); // Update menu items. This is separate from deleting, because there
963 // are no consistency guarantees and we don't want to delete something
964 // that was a parent node before another node takes it place.
965
966 const navBlockAfterUpdates = await dispatch(batchUpdateMenuItems(navBlockWithRecordIds, menuId)); // Delete menu items
967
968 const deletedIds = (0,external_lodash_namespaceObject.difference)(oldMenuItems.map(_ref3 => {
969 let {
970 id
971 } = _ref3;
972 return id;
973 }), blocksTreeToList(navBlockAfterUpdates).map(getRecordIdFromBlock));
974 await dispatch(batchDeleteMenuItems(deletedIds));
975 return navBlockAfterUpdates;
976 };
977 /**
978 * Creates a menu item for every block that doesn't have an associated menuItem.
979 * Sends a batch request with one POST /wp/v2/menu-items for every created menu item.
980 *
981 * @param {Object} navigationBlock A navigation block to find created menu items in.
982 * @return {Function} An action creator
983 */
984
985
986 const batchInsertPlaceholderMenuItems = navigationBlock => async _ref4 => {
987 let {
988 registry
989 } = _ref4;
990 const blocksWithoutRecordId = blocksTreeToList(navigationBlock).filter(block => isBlockSupportedInNav(block) && !getRecordIdFromBlock(block));
991 const tasks = blocksWithoutRecordId.map(() => _ref5 => {
992 let {
993 saveEntityRecord
994 } = _ref5;
995 return saveEntityRecord('root', 'menuItem', {
996 title: (0,external_wp_i18n_namespaceObject.__)('Menu item'),
997 url: '#placeholder',
998 menu_order: 1
999 });
1000 });
1001 const results = await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Return an updated navigation block with all the IDs in
1002
1003 const blockToResult = new Map((0,external_lodash_namespaceObject.zip)(blocksWithoutRecordId, results));
1004 return mapBlocksTree(navigationBlock, block => {
1005 if (!blockToResult.has(block)) {
1006 return block;
1007 }
1008
1009 return addRecordIdToBlock(block, blockToResult.get(block).id);
1010 });
1011 };
1012 /**
1013 * Updates every menu item where a related block has changed.
1014 * Sends a batch request with one PUT /wp/v2/menu-items for every updated menu item.
1015 *
1016 * @param {Object} navigationBlock A navigation block to find updated menu items in.
1017 * @param {number} menuId Menu ID.
1018 * @return {Function} An action creator
1019 */
1020
1021
1022 const batchUpdateMenuItems = (navigationBlock, menuId) => async _ref6 => {
1023 let {
1024 registry
1025 } = _ref6;
1026 const allMenuItems = blocksTreeToAnnotatedList(navigationBlock);
1027 const unsupportedMenuItems = allMenuItems.filter(_ref7 => {
1028 let {
1029 block
1030 } = _ref7;
1031 return !isBlockSupportedInNav(block);
1032 }).map(_ref8 => {
1033 let {
1034 block
1035 } = _ref8;
1036 return block.name;
1037 });
1038
1039 if (unsupportedMenuItems.length) {
1040 window.console.warn((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of block (i.e. core/legacy-widget)
1041 (0,external_wp_i18n_namespaceObject.__)('The following blocks haven\'t been saved because they are not supported: "%s".'), unsupportedMenuItems.join('", "')));
1042 }
1043
1044 const updatedMenuItems = allMenuItems // Filter out unsupported blocks
1045 .filter(_ref9 => {
1046 let {
1047 block
1048 } = _ref9;
1049 return isBlockSupportedInNav(block);
1050 }) // Transform the blocks into menu items
1051 .map(_ref10 => {
1052 let {
1053 block,
1054 parentBlock,
1055 childIndex
1056 } = _ref10;
1057 return blockToMenuItem(block, registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block)), getRecordIdFromBlock(parentBlock), childIndex, menuId);
1058 }) // Filter out menu items without any edits
1059 .filter(menuItem => {
1060 // Update an existing entity record.
1061 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('root', 'menuItem', menuItem.id, menuItem, {
1062 undoIgnore: true
1063 });
1064 return registry.select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('root', 'menuItem', menuItem.id);
1065 }); // Map the edited menu items to batch tasks
1066
1067 const tasks = updatedMenuItems.map(menuItem => _ref11 => {
1068 let {
1069 saveEditedEntityRecord
1070 } = _ref11;
1071 return saveEditedEntityRecord('root', 'menuItem', menuItem.id);
1072 });
1073 await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Throw on failure. @TODO failures should be thrown in core-data
1074
1075 updatedMenuItems.forEach(menuItem => {
1076 const failure = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'menuItem', menuItem.id);
1077
1078 if (failure) {
1079 throw new Error(failure.message);
1080 }
1081 }); // Return an updated navigation block reflecting the changes persisted in the batch update.
1082
1083 return mapBlocksTree(navigationBlock, block => {
1084 if (!isBlockSupportedInNav(block)) {
1085 return block;
1086 }
1087
1088 const updatedMenuItem = registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block));
1089 return addRecordIdToBlock({ ...block,
1090 attributes: menuItemToBlockAttributes(updatedMenuItem)
1091 }, updatedMenuItem.id);
1092 });
1093 };
1094 /**
1095 * Deletes multiple menu items.
1096 * Sends a batch request with one DELETE /wp/v2/menu-items for every deleted menu item.
1097 *
1098 * @param {Object} deletedIds A list of menu item ids to delete
1099 * @return {Function} An action creator
1100 */
1101
1102
1103 const batchDeleteMenuItems = deletedIds => async _ref12 => {
1104 let {
1105 registry
1106 } = _ref12;
1107 const deleteBatch = deletedIds.map(id => async _ref13 => {
1108 let {
1109 deleteEntityRecord
1110 } = _ref13;
1111 const success = await deleteEntityRecord('root', 'menuItem', id, {
1112 force: true
1113 }); // @TODO failures should be thrown in core-data
1114
1115 if (!success) {
1116 throw new Error(id);
1117 }
1118
1119 return success;
1120 });
1121 return await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(deleteBatch);
1122 };
1123 /**
1124 * Turns a recursive list of blocks into a flat list of blocks annotated with
1125 * their child index and parent block.
1126 *
1127 * @param {Object} parentBlock A parent block to flatten
1128 * @return {Object} A flat list of blocks, annotated by their index and parent ID, consisting
1129 * of all the input blocks and all the inner blocks in the tree.
1130 */
1131
1132
1133 function blocksTreeToAnnotatedList(parentBlock) {
1134 return (parentBlock.innerBlocks || []).flatMap((innerBlock, index) => [{
1135 block: innerBlock,
1136 parentBlock,
1137 childIndex: index
1138 }].concat(blocksTreeToAnnotatedList(innerBlock)));
1139 }
1140
1141 function blocksTreeToList(parentBlock) {
1142 return blocksTreeToAnnotatedList(parentBlock).map(_ref14 => {
1143 let {
1144 block
1145 } = _ref14;
1146 return block;
1147 });
1148 }
1149 /**
1150 * Maps one tree of blocks into another tree by invoking a callback on every node.
1151 *
1152 * @param {Object} block The root of the mapped tree.
1153 * @param {Function} callback The callback to invoke.
1154 * @param {Object} parentBlock Internal. The current parent block.
1155 * @param {number} idx Internal. The current child index.
1156 * @return {Object} A mapped tree.
1157 */
1158
1159
1160 function mapBlocksTree(block, callback) {
1161 let parentBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1162 let idx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1163 return { ...callback(block, parentBlock, idx),
1164 innerBlocks: (block.innerBlocks || []).map((innerBlock, index) => mapBlocksTree(innerBlock, callback, block, index))
1165 };
1166 }
1167 /**
1168 * Returns an action object used to open/close the inserter.
1169 *
1170 * @param {boolean|Object} value Whether the inserter should be
1171 * opened (true) or closed (false).
1172 * To specify an insertion point,
1173 * use an object.
1174 * @param {string} value.rootClientId The root client ID to insert at.
1175 * @param {number} value.insertionIndex The index to insert at.
1176 *
1177 * @return {Object} Action object.
1178 */
1179
1180
1181 function setIsInserterOpened(value) {
1182 return {
1183 type: 'SET_IS_INSERTER_OPENED',
1184 value
1185 };
1186 }
1187 //# sourceMappingURL=actions.js.map
1188 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/index.js
1189 /**
1190 * WordPress dependencies
1191 */
1192
1193 /**
1194 * Internal dependencies
1195 */
1196
1197
1198
1199
1200
1201
1202 /**
1203 * Block editor data store configuration.
1204 *
1205 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
1206 *
1207 * @type {Object}
1208 */
1209
1210 const storeConfig = {
1211 reducer: reducer,
1212 selectors: selectors_namespaceObject,
1213 resolvers: resolvers_namespaceObject,
1214 actions: actions_namespaceObject,
1215 persist: ['selectedMenuId'],
1216 __experimentalUseThunks: true
1217 };
1218 /**
1219 * Store definition for the edit navigation namespace.
1220 *
1221 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1222 *
1223 * @type {Object}
1224 */
1225
1226 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); // Once we build a more generic persistence plugin that works across types of stores
1227 // we'd be able to replace this with a register call.
1228
1229 (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, storeConfig);
1230 //# sourceMappingURL=index.js.map
1231 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1232 function _extends() {
1233 _extends = Object.assign || function (target) {
1234 for (var i = 1; i < arguments.length; i++) {
1235 var source = arguments[i];
1236
1237 for (var key in source) {
1238 if (Object.prototype.hasOwnProperty.call(source, key)) {
1239 target[key] = source[key];
1240 }
1241 }
1242 }
1243
1244 return target;
1245 };
1246
1247 return _extends.apply(this, arguments);
1248 }
1249 ;// CONCATENATED MODULE: external ["wp","hooks"]
1250 var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1251 ;// CONCATENATED MODULE: external ["wp","compose"]
1252 var external_wp_compose_namespaceObject = window["wp"]["compose"];
1253 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1254 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1255 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-custom-appender.js
1256
1257
1258
1259 /**
1260 * WordPress dependencies
1261 */
1262
1263
1264
1265
1266
1267 function CustomAppender() {
1268 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InnerBlocks.ButtonBlockAppender, {
1269 isToggle: true
1270 });
1271 }
1272
1273 function EnhancedNavigationBlock(_ref) {
1274 let {
1275 blockEdit: BlockEdit,
1276 ...props
1277 } = _ref;
1278 const clientId = props.clientId;
1279 const {
1280 noBlockSelected,
1281 isSelected,
1282 isImmediateParentOfSelectedBlock,
1283 selectedBlockHasDescendants
1284 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1285 var _getClientIdsOfDescen;
1286
1287 const {
1288 getClientIdsOfDescendants,
1289 hasSelectedInnerBlock,
1290 getSelectedBlockClientId
1291 } = select(external_wp_blockEditor_namespaceObject.store);
1292
1293 const _isImmediateParentOfSelectedBlock = hasSelectedInnerBlock(clientId, false);
1294
1295 const selectedBlockId = getSelectedBlockClientId();
1296
1297 const _selectedBlockHasDescendants = !!((_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockId])) !== null && _getClientIdsOfDescen !== void 0 && _getClientIdsOfDescen.length);
1298
1299 return {
1300 isSelected: selectedBlockId === clientId,
1301 noBlockSelected: !selectedBlockId,
1302 isImmediateParentOfSelectedBlock: _isImmediateParentOfSelectedBlock,
1303 selectedBlockHasDescendants: _selectedBlockHasDescendants
1304 };
1305 }, [clientId]);
1306 const customAppender = noBlockSelected || isSelected || isImmediateParentOfSelectedBlock && !selectedBlockHasDescendants ? CustomAppender : false;
1307 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
1308 customAppender: customAppender
1309 }));
1310 }
1311
1312 const addNavigationEditorCustomAppender = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
1313 if (props.name !== 'core/navigation') {
1314 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
1315 } // Use a separate component so that `useSelect` only run on the navigation block.
1316
1317
1318 return (0,external_wp_element_namespaceObject.createElement)(EnhancedNavigationBlock, _extends({
1319 blockEdit: BlockEdit
1320 }, props));
1321 }, 'withNavigationEditorCustomAppender');
1322 /* harmony default export */ var add_navigation_editor_custom_appender = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-custom-appender', addNavigationEditorCustomAppender));
1323 //# sourceMappingURL=add-navigation-editor-custom-appender.js.map
1324 ;// CONCATENATED MODULE: external ["wp","components"]
1325 var external_wp_components_namespaceObject = window["wp"]["components"];
1326 ;// CONCATENATED MODULE: external ["wp","primitives"]
1327 var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1328 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
1329
1330
1331 /**
1332 * WordPress dependencies
1333 */
1334
1335 const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1336 viewBox: "0 0 24 24",
1337 xmlns: "http://www.w3.org/2000/svg"
1338 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1339 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
1340 }));
1341 /* harmony default export */ var chevron_down = (chevronDown);
1342 //# sourceMappingURL=chevron-down.js.map
1343 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity.js
1344 /**
1345 * WordPress dependencies
1346 */
1347
1348
1349 /**
1350 * Internal dependencies
1351 */
1352
1353
1354 function useMenuEntity(menuId) {
1355 const {
1356 editEntityRecord
1357 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
1358 const menuEntityData = [MENU_KIND, MENU_POST_TYPE, menuId];
1359 const {
1360 editedMenu,
1361 hasLoadedEditedMenu
1362 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1363 return {
1364 editedMenu: menuId && select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(...menuEntityData),
1365 hasLoadedEditedMenu: select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEditedEntityRecord', [...menuEntityData])
1366 };
1367 }, [menuId]);
1368 return {
1369 editedMenu,
1370 menuEntityData,
1371 editMenuEntityRecord: editEntityRecord,
1372 hasLoadedEditedMenu
1373 };
1374 }
1375 //# sourceMappingURL=use-menu-entity.js.map
1376 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity-prop.js
1377 /**
1378 * WordPress dependencies
1379 */
1380
1381 /**
1382 * Internal dependencies
1383 */
1384
1385
1386 /**
1387 * Returns the value and setter for the specified
1388 * property of the menu.
1389 *
1390 * @param {string} prop A Property name.
1391 * @param {string} menuId A menu ID.
1392 *
1393 * @return {[*, Function]} A tuple where the first item is the
1394 * property value and the second is the
1395 * setter.
1396 */
1397
1398 function useMenuEntityProp(prop, menuId) {
1399 return (0,external_wp_coreData_namespaceObject.useEntityProp)(MENU_KIND, MENU_POST_TYPE, prop, menuId);
1400 }
1401 //# sourceMappingURL=use-menu-entity-prop.js.map
1402 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor.js
1403 /**
1404 * WordPress dependencies
1405 */
1406
1407
1408
1409
1410
1411 /**
1412 * Internal dependencies
1413 */
1414
1415
1416
1417
1418
1419 const getMenusData = select => {
1420 const selectors = select('core');
1421 const params = {
1422 per_page: -1
1423 };
1424 return {
1425 menus: selectors.getMenus(params),
1426 hasLoadedMenus: selectors.hasFinishedResolution('getMenus', [params])
1427 };
1428 };
1429
1430 function useNavigationEditor() {
1431 var _menus$find;
1432
1433 const {
1434 deleteMenu: _deleteMenu
1435 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
1436 const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId();
1437 const [hasFinishedInitialLoad, setHasFinishedInitialLoad] = (0,external_wp_element_namespaceObject.useState)(false);
1438 const {
1439 editedMenu,
1440 hasLoadedEditedMenu
1441 } = useMenuEntity(selectedMenuId);
1442 const {
1443 menus,
1444 hasLoadedMenus
1445 } = (0,external_wp_data_namespaceObject.useSelect)(getMenusData, []);
1446 /**
1447 * If the Menu being edited has been requested from API and it has
1448 * no values then it has been deleted so reset the selected menu ID.
1449 */
1450
1451 (0,external_wp_element_namespaceObject.useEffect)(() => {
1452 var _Object$keys;
1453
1454 if (hasLoadedEditedMenu && !((_Object$keys = Object.keys(editedMenu)) !== null && _Object$keys !== void 0 && _Object$keys.length)) {
1455 setSelectedMenuId(null);
1456 }
1457 }, [hasLoadedEditedMenu, editedMenu]);
1458 const {
1459 createErrorNotice,
1460 createInfoNotice
1461 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
1462 const isMenuBeingDeleted = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).isDeletingEntityRecord('root', 'menu', selectedMenuId), [selectedMenuId]);
1463 const selectedMenuName = (menus === null || menus === void 0 ? void 0 : (_menus$find = menus.find(_ref => {
1464 let {
1465 id
1466 } = _ref;
1467 return id === selectedMenuId;
1468 })) === null || _menus$find === void 0 ? void 0 : _menus$find.name) || '';
1469 (0,external_wp_element_namespaceObject.useEffect)(() => {
1470 if (hasLoadedMenus) {
1471 setHasFinishedInitialLoad(true);
1472 }
1473 }, [hasLoadedMenus]);
1474 const navigationPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
1475 if (!selectedMenuId) {
1476 return;
1477 }
1478
1479 return select(store).getNavigationPostForMenu(selectedMenuId);
1480 }, [selectedMenuId]);
1481
1482 const deleteMenu = async () => {
1483 const didDeleteMenu = await _deleteMenu(selectedMenuId, {
1484 force: true
1485 });
1486
1487 if (didDeleteMenu) {
1488 setSelectedMenuId(null);
1489 createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu.
1490 (0,external_wp_i18n_namespaceObject.__)('"%s" menu has been deleted'), selectedMenuName), {
1491 type: 'snackbar',
1492 isDismissible: true
1493 });
1494 } else {
1495 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Menu deletion unsuccessful'));
1496 }
1497 };
1498
1499 return {
1500 menus,
1501 hasLoadedMenus,
1502 hasFinishedInitialLoad,
1503 selectedMenuId,
1504 navigationPost,
1505 isMenuBeingDeleted,
1506 selectMenu: setSelectedMenuId,
1507 deleteMenu,
1508 isMenuSelected: !!selectedMenuId
1509 };
1510 }
1511 //# sourceMappingURL=use-navigation-editor.js.map
1512 ;// CONCATENATED MODULE: external ["wp","dom"]
1513 var external_wp_dom_namespaceObject = window["wp"]["dom"];
1514 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-notifications.js
1515 /**
1516 * WordPress dependencies
1517 */
1518
1519
1520
1521
1522
1523 /**
1524 * Internal dependencies
1525 */
1526
1527
1528 function useMenuNotifications(menuId) {
1529 const {
1530 createErrorNotice
1531 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
1532 const lastDeleteError = (0,external_wp_data_namespaceObject.useSelect)(select => {
1533 return select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError(MENU_KIND, MENU_POST_TYPE, menuId);
1534 }, [menuId]);
1535 (0,external_wp_element_namespaceObject.useEffect)(() => {
1536 if (lastDeleteError) {
1537 createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastDeleteError === null || lastDeleteError === void 0 ? void 0 : lastDeleteError.message), {
1538 id: 'edit-navigation-error'
1539 });
1540 }
1541 }, [lastDeleteError]);
1542 }
1543 //# sourceMappingURL=use-menu-notifications.js.map
1544 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-selected-menu-id.js
1545 /**
1546 * WordPress dependencies
1547 */
1548
1549 /**
1550 * Internal dependencies
1551 */
1552
1553
1554 /**
1555 * Returns selected menu ID and the setter.
1556 *
1557 * @return {[number, Function]} A tuple where first item is the
1558 * selected menu ID and second is
1559 * the setter.
1560 */
1561
1562 function useSelectedMenuId() {
1563 const selectedMenuId = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSelectedMenuId(), []);
1564 const {
1565 setSelectedMenuId
1566 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1567 return [selectedMenuId, setSelectedMenuId];
1568 }
1569 //# sourceMappingURL=use-selected-menu-id.js.map
1570 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
1571 var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
1572 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
1573 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-locations.js
1574 /**
1575 * WordPress dependencies
1576 */
1577
1578
1579 /**
1580 * External dependencies
1581 */
1582
1583
1584 /**
1585 * Internal dependencies
1586 */
1587
1588
1589
1590 const locationsForMenuId = (menuLocationsByName, id) => Object.values(menuLocationsByName).filter(_ref => {
1591 let {
1592 menu
1593 } = _ref;
1594 return menu === id;
1595 }).map(_ref2 => {
1596 let {
1597 name
1598 } = _ref2;
1599 return name;
1600 });
1601
1602 function useMenuLocations() {
1603 const [menuLocationsByName, setMenuLocationsByName] = (0,external_wp_element_namespaceObject.useState)(null);
1604 const [menuId] = useSelectedMenuId();
1605 const {
1606 editMenuEntityRecord,
1607 menuEntityData
1608 } = useMenuEntity(menuId);
1609 (0,external_wp_element_namespaceObject.useEffect)(() => {
1610 let isMounted = true;
1611
1612 const fetchMenuLocationsByName = async () => {
1613 const newMenuLocationsByName = await external_wp_apiFetch_default()({
1614 method: 'GET',
1615 path: '/wp/v2/menu-locations'
1616 });
1617
1618 if (isMounted) {
1619 setMenuLocationsByName(newMenuLocationsByName);
1620 }
1621 };
1622
1623 fetchMenuLocationsByName();
1624 return () => isMounted = false;
1625 }, []);
1626 const assignMenuToLocation = (0,external_wp_element_namespaceObject.useCallback)(async (locationName, newMenuId) => {
1627 const oldMenuId = menuLocationsByName[locationName].menu;
1628 const newMenuLocationsByName = (0,external_lodash_namespaceObject.merge)(menuLocationsByName, {
1629 [locationName]: {
1630 menu: newMenuId
1631 }
1632 });
1633 setMenuLocationsByName(newMenuLocationsByName);
1634 const activeMenuId = newMenuId || oldMenuId;
1635 editMenuEntityRecord(...menuEntityData, {
1636 locations: locationsForMenuId(newMenuLocationsByName, activeMenuId)
1637 });
1638 }, [menuLocationsByName]);
1639
1640 const toggleMenuLocationAssignment = (locationName, newMenuId) => {
1641 const idToSet = menuLocationsByName[locationName].menu === newMenuId ? 0 : newMenuId;
1642 assignMenuToLocation(locationName, idToSet);
1643 };
1644
1645 const menuLocations = (0,external_wp_element_namespaceObject.useMemo)(() => Object.values(menuLocationsByName || {}), [menuLocationsByName]);
1646 return {
1647 menuLocations,
1648 assignMenuToLocation,
1649 toggleMenuLocationAssignment
1650 };
1651 }
1652 //# sourceMappingURL=use-menu-locations.js.map
1653 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor-root-block.js
1654 /**
1655 * WordPress dependencies
1656 */
1657
1658
1659 /**
1660 * Internal dependencies
1661 */
1662
1663 const useNavigationEditorRootBlock = () => {
1664 return (0,external_wp_data_namespaceObject.useSelect)(select => {
1665 const {
1666 getBlockOrder
1667 } = select(external_wp_blockEditor_namespaceObject.store);
1668 const lockedNavigationBlock = getBlockOrder()[0];
1669 return {
1670 navBlockClientId: lockedNavigationBlock,
1671 lastNavBlockItemIndex: getBlockOrder(lockedNavigationBlock).length
1672 };
1673 }, []);
1674 };
1675
1676 /* harmony default export */ var use_navigation_editor_root_block = (useNavigationEditorRootBlock);
1677 //# sourceMappingURL=use-navigation-editor-root-block.js.map
1678 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/index.js
1679 /**
1680 * WordPress dependencies
1681 */
1682
1683
1684 const untitledMenu = (0,external_wp_i18n_namespaceObject.__)('(untitled menu)');
1685 const IsMenuNameControlFocusedContext = (0,external_wp_element_namespaceObject.createContext)();
1686
1687
1688
1689
1690
1691
1692
1693 //# sourceMappingURL=index.js.map
1694 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/use-navigation-entities.js
1695 /**
1696 * WordPress dependencies
1697 */
1698
1699
1700 /**
1701 * @typedef {Object} NavigationEntitiesData
1702 * @property {Array|undefined} pages - a collection of WP Post entity objects of post type "Page".
1703 * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving.
1704 * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving.
1705 * @property {Array|undefined} menus - a collection of Menu entity objects.
1706 * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving.
1707 * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving.
1708 * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId.
1709 * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving.
1710 * @property {boolean} hasPages - indicates whether there is currently any data for pages.
1711 * @property {boolean} hasMenus - indicates whether there is currently any data for menus.
1712 */
1713
1714 /**
1715 * Manages fetching and resolution state for all entities required
1716 * for the Navigation block.
1717 *
1718 * @param {number} menuId the menu for which to retrieve menuItem data.
1719 * @return { NavigationEntitiesData } the entity data.
1720 */
1721
1722 function useNavigationEntities(menuId) {
1723 return { ...usePageEntities(),
1724 ...useMenuEntities(),
1725 ...useMenuItemEntities(menuId)
1726 };
1727 }
1728
1729 function useMenuEntities() {
1730 const {
1731 menus,
1732 isResolvingMenus,
1733 hasResolvedMenus
1734 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1735 const {
1736 getMenus,
1737 isResolving,
1738 hasFinishedResolution
1739 } = select(external_wp_coreData_namespaceObject.store);
1740 const menusParameters = [{
1741 per_page: -1
1742 }];
1743 return {
1744 menus: getMenus(...menusParameters),
1745 isResolvingMenus: isResolving('getMenus', menusParameters),
1746 hasResolvedMenus: hasFinishedResolution('getMenus', menusParameters)
1747 };
1748 }, []);
1749 return {
1750 menus,
1751 isResolvingMenus,
1752 hasResolvedMenus,
1753 hasMenus: !!(hasResolvedMenus && menus !== null && menus !== void 0 && menus.length)
1754 };
1755 }
1756
1757 function useMenuItemEntities(menuId) {
1758 const {
1759 menuItems,
1760 hasResolvedMenuItems
1761 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1762 const {
1763 getMenuItems,
1764 hasFinishedResolution
1765 } = select(external_wp_coreData_namespaceObject.store);
1766 const hasSelectedMenu = menuId !== undefined;
1767 const menuItemsParameters = hasSelectedMenu ? [{
1768 menus: menuId,
1769 per_page: -1
1770 }] : undefined;
1771 return {
1772 menuItems: hasSelectedMenu ? getMenuItems(...menuItemsParameters) : undefined,
1773 hasResolvedMenuItems: hasSelectedMenu ? hasFinishedResolution('getMenuItems', menuItemsParameters) : false
1774 };
1775 }, [menuId]);
1776 return {
1777 menuItems,
1778 hasResolvedMenuItems
1779 };
1780 }
1781
1782 function usePageEntities() {
1783 const {
1784 pages,
1785 isResolvingPages,
1786 hasResolvedPages
1787 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1788 const {
1789 getEntityRecords,
1790 isResolving,
1791 hasFinishedResolution
1792 } = select(external_wp_coreData_namespaceObject.store);
1793 const pagesParameters = ['postType', 'page', {
1794 parent: 0,
1795 order: 'asc',
1796 orderby: 'id',
1797 per_page: -1
1798 }];
1799 return {
1800 pages: getEntityRecords(...pagesParameters) || null,
1801 isResolvingPages: isResolving('getEntityRecords', pagesParameters),
1802 hasResolvedPages: hasFinishedResolution('getEntityRecords', pagesParameters)
1803 };
1804 }, []);
1805 return {
1806 pages,
1807 isResolvingPages,
1808 hasResolvedPages,
1809 hasPages: !!(hasResolvedPages && pages !== null && pages !== void 0 && pages.length)
1810 };
1811 }
1812 //# sourceMappingURL=use-navigation-entities.js.map
1813 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/index.js
1814
1815
1816 /**
1817 * WordPress dependencies
1818 */
1819
1820
1821
1822
1823
1824 /**
1825 * Internal dependencies
1826 */
1827
1828
1829
1830
1831 /**
1832 * Convert pages to blocks.
1833 *
1834 * @param {Object[]} pages An array of pages.
1835 *
1836 * @return {WPBlock[]} An array of blocks.
1837 */
1838
1839 function convertPagesToBlocks(pages) {
1840 if (!(pages !== null && pages !== void 0 && pages.length)) {
1841 return null;
1842 }
1843
1844 return pages.map(_ref => {
1845 let {
1846 title,
1847 type,
1848 link: url,
1849 id
1850 } = _ref;
1851 return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation-link', {
1852 type,
1853 id,
1854 url,
1855 label: !title.rendered ? (0,external_wp_i18n_namespaceObject.__)('(no title)') : title.rendered,
1856 opensInNewTab: false
1857 });
1858 });
1859 }
1860
1861 const TOGGLE_PROPS = {
1862 variant: 'tertiary'
1863 };
1864 const POPOVER_PROPS = {
1865 position: 'bottom center'
1866 };
1867
1868 function BlockPlaceholder(_ref2, ref) {
1869 let {
1870 onCreate
1871 } = _ref2;
1872 const [selectedMenu, setSelectedMenu] = (0,external_wp_element_namespaceObject.useState)();
1873 const [isCreatingFromMenu, setIsCreatingFromMenu] = (0,external_wp_element_namespaceObject.useState)(false);
1874 const [selectedMenuId] = useSelectedMenuId();
1875 const [menuName] = useMenuEntityProp('name', selectedMenuId);
1876 const {
1877 isResolvingPages,
1878 menus,
1879 isResolvingMenus,
1880 menuItems,
1881 hasResolvedMenuItems,
1882 pages,
1883 hasPages,
1884 hasMenus
1885 } = useNavigationEntities(selectedMenu);
1886 const isLoading = isResolvingPages || isResolvingMenus;
1887 const createFromMenu = (0,external_wp_element_namespaceObject.useCallback)(() => {
1888 const {
1889 innerBlocks: blocks
1890 } = menuItemsToBlocks(menuItems);
1891 const selectNavigationBlock = true;
1892 onCreate(blocks, selectNavigationBlock);
1893 }, [menuItems, menuItemsToBlocks, onCreate]);
1894
1895 const onCreateFromMenu = () => {
1896 // If we have menu items, create the block right away.
1897 if (hasResolvedMenuItems) {
1898 createFromMenu();
1899 return;
1900 } // Otherwise, create the block when resolution finishes.
1901
1902
1903 setIsCreatingFromMenu(true);
1904 };
1905
1906 const onCreateEmptyMenu = () => {
1907 onCreate([]);
1908 };
1909
1910 const onCreateAllPages = () => {
1911 const blocks = convertPagesToBlocks(pages);
1912 const selectNavigationBlock = true;
1913 onCreate(blocks, selectNavigationBlock);
1914 };
1915
1916 (0,external_wp_element_namespaceObject.useEffect)(() => {
1917 // If the user selected a menu but we had to wait for menu items to
1918 // finish resolving, then create the block once resolution finishes.
1919 if (isCreatingFromMenu && hasResolvedMenuItems) {
1920 createFromMenu();
1921 setIsCreatingFromMenu(false);
1922 }
1923 }, [isCreatingFromMenu, hasResolvedMenuItems]);
1924 const selectableMenus = menus === null || menus === void 0 ? void 0 : menus.filter(menu => menu.id !== selectedMenuId);
1925 const hasSelectableMenus = !!(selectableMenus !== null && selectableMenus !== void 0 && selectableMenus.length);
1926 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
1927 className: "edit-navigation-block-placeholder",
1928 label: menuName,
1929 instructions: (0,external_wp_i18n_namespaceObject.__)('This menu is empty. You can start blank and choose what to add,' + ' add your existing pages, or add the content of another menu.')
1930 }, (0,external_wp_element_namespaceObject.createElement)("div", {
1931 className: "edit-navigation-block-placeholder__controls"
1932 }, isLoading && (0,external_wp_element_namespaceObject.createElement)("div", {
1933 ref: ref
1934 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), !isLoading && (0,external_wp_element_namespaceObject.createElement)("div", {
1935 ref: ref,
1936 className: "edit-navigation-block-placeholder__actions"
1937 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1938 variant: "tertiary",
1939 onClick: onCreateEmptyMenu
1940 }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), hasPages ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1941 variant: hasMenus ? 'tertiary' : 'primary',
1942 onClick: onCreateAllPages
1943 }, (0,external_wp_i18n_namespaceObject.__)('Add all pages')) : undefined, hasSelectableMenus ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
1944 text: (0,external_wp_i18n_namespaceObject.__)('Copy existing menu'),
1945 icon: chevron_down,
1946 toggleProps: TOGGLE_PROPS,
1947 popoverProps: POPOVER_PROPS
1948 }, _ref3 => {
1949 let {
1950 onClose
1951 } = _ref3;
1952 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, selectableMenus.map(menu => {
1953 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
1954 onClick: () => {
1955 setSelectedMenu(menu.id);
1956 onCreateFromMenu();
1957 },
1958 onClose: onClose,
1959 key: menu.id
1960 }, menu.name);
1961 }));
1962 }) : undefined)));
1963 }
1964
1965 /* harmony default export */ var block_placeholder = ((0,external_wp_element_namespaceObject.forwardRef)(BlockPlaceholder));
1966 //# sourceMappingURL=index.js.map
1967 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-placeholder.js
1968
1969
1970
1971 /**
1972 * WordPress dependencies
1973 */
1974
1975
1976 /**
1977 * Internal dependencies
1978 */
1979
1980
1981 const addNavigationEditorPlaceholder = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
1982 if (props.name !== 'core/navigation') {
1983 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
1984 }
1985
1986 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
1987 customPlaceholder: block_placeholder
1988 }));
1989 }, 'withNavigationEditorPlaceholder');
1990 /* harmony default export */ var add_navigation_editor_placeholder = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-placeholder', addNavigationEditorPlaceholder));
1991 //# sourceMappingURL=add-navigation-editor-placeholder.js.map
1992 // EXTERNAL MODULE: ./node_modules/classnames/index.js
1993 var classnames = __webpack_require__(4184);
1994 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
1995 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
1996
1997
1998 /**
1999 * WordPress dependencies
2000 */
2001
2002 const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2003 xmlns: "http://www.w3.org/2000/svg",
2004 viewBox: "0 0 24 24"
2005 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2006 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
2007 }));
2008 /* harmony default export */ var library_check = (check);
2009 //# sourceMappingURL=check.js.map
2010 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
2011
2012
2013 /**
2014 * WordPress dependencies
2015 */
2016
2017 const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2018 xmlns: "http://www.w3.org/2000/svg",
2019 viewBox: "0 0 24 24"
2020 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2021 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
2022 }));
2023 /* harmony default export */ var star_filled = (starFilled);
2024 //# sourceMappingURL=star-filled.js.map
2025 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
2026
2027
2028 /**
2029 * WordPress dependencies
2030 */
2031
2032 const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2033 xmlns: "http://www.w3.org/2000/svg",
2034 viewBox: "0 0 24 24"
2035 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2036 fillRule: "evenodd",
2037 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
2038 clipRule: "evenodd"
2039 }));
2040 /* harmony default export */ var star_empty = (starEmpty);
2041 //# sourceMappingURL=star-empty.js.map
2042 ;// CONCATENATED MODULE: external ["wp","viewport"]
2043 var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
2044 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
2045
2046
2047 /**
2048 * WordPress dependencies
2049 */
2050
2051 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2052 xmlns: "http://www.w3.org/2000/svg",
2053 viewBox: "0 0 24 24"
2054 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2055 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
2056 }));
2057 /* harmony default export */ var close_small = (closeSmall);
2058 //# sourceMappingURL=close-small.js.map
2059 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
2060 /**
2061 * External dependencies
2062 */
2063
2064 /**
2065 * WordPress dependencies
2066 */
2067
2068
2069 /**
2070 * Reducer to keep tract of the active area per scope.
2071 *
2072 * @param {boolean} state Previous state.
2073 * @param {Object} action Action object.
2074 * @param {string} action.type Action type.
2075 * @param {string} action.itemType Type of item.
2076 * @param {string} action.scope Item scope.
2077 * @param {string} action.item Item name.
2078 *
2079 * @return {Object} Updated state.
2080 */
2081
2082 function singleEnableItems() {
2083 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2084 let {
2085 type,
2086 itemType,
2087 scope,
2088 item
2089 } = arguments.length > 1 ? arguments[1] : undefined;
2090
2091 if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) {
2092 return state;
2093 }
2094
2095 return { ...state,
2096 [itemType]: { ...state[itemType],
2097 [scope]: item || null
2098 }
2099 };
2100 }
2101 /**
2102 * Reducer keeping track of the "pinned" items per scope.
2103 *
2104 * @param {boolean} state Previous state.
2105 * @param {Object} action Action object.
2106 * @param {string} action.type Action type.
2107 * @param {string} action.itemType Type of item.
2108 * @param {string} action.scope Item scope.
2109 * @param {string} action.item Item name.
2110 * @param {boolean} action.isEnable Whether the item is pinned.
2111 *
2112 * @return {Object} Updated state.
2113 */
2114
2115 function multipleEnableItems() {
2116 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2117 let {
2118 type,
2119 itemType,
2120 scope,
2121 item,
2122 isEnable
2123 } = arguments.length > 1 ? arguments[1] : undefined;
2124
2125 if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || (0,external_lodash_namespaceObject.get)(state, [itemType, scope, item]) === isEnable) {
2126 return state;
2127 }
2128
2129 const currentTypeState = state[itemType] || {};
2130 const currentScopeState = currentTypeState[scope] || {};
2131 return { ...state,
2132 [itemType]: { ...currentTypeState,
2133 [scope]: { ...currentScopeState,
2134 [item]: isEnable || false
2135 }
2136 }
2137 };
2138 }
2139 /**
2140 * Reducer returning the defaults for user preferences.
2141 *
2142 * This is kept intentionally separate from the preferences
2143 * themselves so that defaults are not persisted.
2144 *
2145 * @param {Object} state Current state.
2146 * @param {Object} action Dispatched action.
2147 *
2148 * @return {Object} Updated state.
2149 */
2150
2151 const preferenceDefaults = (0,external_wp_data_namespaceObject.combineReducers)({
2152 features() {
2153 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2154 let action = arguments.length > 1 ? arguments[1] : undefined;
2155
2156 if (action.type === 'SET_FEATURE_DEFAULTS') {
2157 const {
2158 scope,
2159 defaults
2160 } = action;
2161 return { ...state,
2162 [scope]: { ...state[scope],
2163 ...defaults
2164 }
2165 };
2166 }
2167
2168 return state;
2169 }
2170
2171 });
2172 /**
2173 * Reducer returning the user preferences.
2174 *
2175 * @param {Object} state Current state.
2176 * @param {Object} action Dispatched action.
2177 *
2178 * @return {Object} Updated state.
2179 */
2180
2181 const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
2182 features() {
2183 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2184 let action = arguments.length > 1 ? arguments[1] : undefined;
2185
2186 if (action.type === 'SET_FEATURE_VALUE') {
2187 const {
2188 scope,
2189 featureName,
2190 value
2191 } = action;
2192 return { ...state,
2193 [scope]: { ...state[scope],
2194 [featureName]: value
2195 }
2196 };
2197 }
2198
2199 return state;
2200 }
2201
2202 });
2203 const enableItems = (0,external_wp_data_namespaceObject.combineReducers)({
2204 singleEnableItems,
2205 multipleEnableItems
2206 });
2207 /* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2208 enableItems,
2209 preferenceDefaults,
2210 preferences
2211 }));
2212 //# sourceMappingURL=reducer.js.map
2213 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
2214 /**
2215 * Returns an action object used in signalling that an active area should be changed.
2216 *
2217 * @param {string} itemType Type of item.
2218 * @param {string} scope Item scope.
2219 * @param {string} item Item identifier.
2220 *
2221 * @return {Object} Action object.
2222 */
2223 function setSingleEnableItem(itemType, scope, item) {
2224 return {
2225 type: 'SET_SINGLE_ENABLE_ITEM',
2226 itemType,
2227 scope,
2228 item
2229 };
2230 }
2231 /**
2232 * Returns an action object used in signalling that a complementary item should be enabled.
2233 *
2234 * @param {string} scope Complementary area scope.
2235 * @param {string} area Area identifier.
2236 *
2237 * @return {Object} Action object.
2238 */
2239
2240
2241 function enableComplementaryArea(scope, area) {
2242 return setSingleEnableItem('complementaryArea', scope, area);
2243 }
2244 /**
2245 * Returns an action object used in signalling that the complementary area of a given scope should be disabled.
2246 *
2247 * @param {string} scope Complementary area scope.
2248 *
2249 * @return {Object} Action object.
2250 */
2251
2252 function disableComplementaryArea(scope) {
2253 return setSingleEnableItem('complementaryArea', scope, undefined);
2254 }
2255 /**
2256 * Returns an action object to make an area enabled/disabled.
2257 *
2258 * @param {string} itemType Type of item.
2259 * @param {string} scope Item scope.
2260 * @param {string} item Item identifier.
2261 * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
2262 *
2263 * @return {Object} Action object.
2264 */
2265
2266 function setMultipleEnableItem(itemType, scope, item, isEnable) {
2267 return {
2268 type: 'SET_MULTIPLE_ENABLE_ITEM',
2269 itemType,
2270 scope,
2271 item,
2272 isEnable
2273 };
2274 }
2275 /**
2276 * Returns an action object used in signalling that an item should be pinned.
2277 *
2278 * @param {string} scope Item scope.
2279 * @param {string} itemId Item identifier.
2280 *
2281 * @return {Object} Action object.
2282 */
2283
2284
2285 function pinItem(scope, itemId) {
2286 return setMultipleEnableItem('pinnedItems', scope, itemId, true);
2287 }
2288 /**
2289 * Returns an action object used in signalling that an item should be unpinned.
2290 *
2291 * @param {string} scope Item scope.
2292 * @param {string} itemId Item identifier.
2293 *
2294 * @return {Object} Action object.
2295 */
2296
2297 function unpinItem(scope, itemId) {
2298 return setMultipleEnableItem('pinnedItems', scope, itemId, false);
2299 }
2300 /**
2301 * Returns an action object used in signalling that a feature should be toggled.
2302 *
2303 * @param {string} scope The feature scope (e.g. core/edit-post).
2304 * @param {string} featureName The feature name.
2305 */
2306
2307 function toggleFeature(scope, featureName) {
2308 return function (_ref) {
2309 let {
2310 select,
2311 dispatch
2312 } = _ref;
2313 const currentValue = select.isFeatureActive(scope, featureName);
2314 dispatch.setFeatureValue(scope, featureName, !currentValue);
2315 };
2316 }
2317 /**
2318 * Returns an action object used in signalling that a feature should be set to
2319 * a true or false value
2320 *
2321 * @param {string} scope The feature scope (e.g. core/edit-post).
2322 * @param {string} featureName The feature name.
2323 * @param {boolean} value The value to set.
2324 *
2325 * @return {Object} Action object.
2326 */
2327
2328 function setFeatureValue(scope, featureName, value) {
2329 return {
2330 type: 'SET_FEATURE_VALUE',
2331 scope,
2332 featureName,
2333 value: !!value
2334 };
2335 }
2336 /**
2337 * Returns an action object used in signalling that defaults should be set for features.
2338 *
2339 * @param {string} scope The feature scope (e.g. core/edit-post).
2340 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
2341 *
2342 * @return {Object} Action object.
2343 */
2344
2345 function setFeatureDefaults(scope, defaults) {
2346 return {
2347 type: 'SET_FEATURE_DEFAULTS',
2348 scope,
2349 defaults
2350 };
2351 }
2352 //# sourceMappingURL=actions.js.map
2353 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
2354 /**
2355 * External dependencies
2356 */
2357
2358 /**
2359 * Returns the item that is enabled in a given scope.
2360 *
2361 * @param {Object} state Global application state.
2362 * @param {string} itemType Type of item.
2363 * @param {string} scope Item scope.
2364 *
2365 * @return {?string|null} The item that is enabled in the passed scope and type.
2366 */
2367
2368 function getSingleEnableItem(state, itemType, scope) {
2369 return (0,external_lodash_namespaceObject.get)(state.enableItems.singleEnableItems, [itemType, scope]);
2370 }
2371 /**
2372 * Returns the complementary area that is active in a given scope.
2373 *
2374 * @param {Object} state Global application state.
2375 * @param {string} scope Item scope.
2376 *
2377 * @return {string} The complementary area that is active in the given scope.
2378 */
2379
2380
2381 function getActiveComplementaryArea(state, scope) {
2382 return getSingleEnableItem(state, 'complementaryArea', scope);
2383 }
2384 /**
2385 * Returns a boolean indicating if an item is enabled or not in a given scope.
2386 *
2387 * @param {Object} state Global application state.
2388 * @param {string} itemType Type of item.
2389 * @param {string} scope Scope.
2390 * @param {string} item Item to check.
2391 *
2392 * @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
2393 */
2394
2395 function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
2396 return (0,external_lodash_namespaceObject.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
2397 }
2398 /**
2399 * Returns a boolean indicating if an item is pinned or not.
2400 *
2401 * @param {Object} state Global application state.
2402 * @param {string} scope Scope.
2403 * @param {string} item Item to check.
2404 *
2405 * @return {boolean} True if the item is pinned and false otherwise.
2406 */
2407
2408
2409 function isItemPinned(state, scope, item) {
2410 return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false;
2411 }
2412 /**
2413 * Returns a boolean indicating whether a feature is active for a particular
2414 * scope.
2415 *
2416 * @param {Object} state The store state.
2417 * @param {string} scope The scope of the feature (e.g. core/edit-post).
2418 * @param {string} featureName The name of the feature.
2419 *
2420 * @return {boolean} Is the feature enabled?
2421 */
2422
2423 function isFeatureActive(state, scope, featureName) {
2424 var _state$preferences$fe, _state$preferenceDefa;
2425
2426 const featureValue = (_state$preferences$fe = state.preferences.features[scope]) === null || _state$preferences$fe === void 0 ? void 0 : _state$preferences$fe[featureName];
2427 const defaultedFeatureValue = featureValue !== undefined ? featureValue : (_state$preferenceDefa = state.preferenceDefaults.features[scope]) === null || _state$preferenceDefa === void 0 ? void 0 : _state$preferenceDefa[featureName];
2428 return !!defaultedFeatureValue;
2429 }
2430 //# sourceMappingURL=selectors.js.map
2431 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
2432 /**
2433 * The identifier for the data store.
2434 *
2435 * @type {string}
2436 */
2437 const constants_STORE_NAME = 'core/interface';
2438 //# sourceMappingURL=constants.js.map
2439 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
2440 /**
2441 * WordPress dependencies
2442 */
2443
2444 /**
2445 * Internal dependencies
2446 */
2447
2448
2449
2450
2451
2452 /**
2453 * Store definition for the interface namespace.
2454 *
2455 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
2456 *
2457 * @type {Object}
2458 */
2459
2460 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
2461 reducer: store_reducer,
2462 actions: store_actions_namespaceObject,
2463 selectors: store_selectors_namespaceObject,
2464 persist: ['enableItems', 'preferences'],
2465 __experimentalUseThunks: true
2466 }); // Once we build a more generic persistence plugin that works across types of stores
2467 // we'd be able to replace this with a register call.
2468
2469 (0,external_wp_data_namespaceObject.registerStore)(constants_STORE_NAME, {
2470 reducer: store_reducer,
2471 actions: store_actions_namespaceObject,
2472 selectors: store_selectors_namespaceObject,
2473 persist: ['enableItems', 'preferences'],
2474 __experimentalUseThunks: true
2475 });
2476 //# sourceMappingURL=index.js.map
2477 ;// CONCATENATED MODULE: external ["wp","plugins"]
2478 var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
2479 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
2480 /**
2481 * WordPress dependencies
2482 */
2483
2484 /* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
2485 return {
2486 icon: ownProps.icon || context.icon,
2487 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
2488 };
2489 }));
2490 //# sourceMappingURL=index.js.map
2491 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
2492
2493
2494
2495 /**
2496 * External dependencies
2497 */
2498
2499 /**
2500 * WordPress dependencies
2501 */
2502
2503
2504
2505 /**
2506 * Internal dependencies
2507 */
2508
2509
2510
2511
2512 function ComplementaryAreaToggle(_ref) {
2513 let {
2514 as = external_wp_components_namespaceObject.Button,
2515 scope,
2516 identifier,
2517 icon,
2518 selectedIcon,
2519 ...props
2520 } = _ref;
2521 const ComponentToUse = as;
2522 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getActiveComplementaryArea(scope) === identifier, [identifier]);
2523 const {
2524 enableComplementaryArea,
2525 disableComplementaryArea
2526 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2527 return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({
2528 icon: selectedIcon && isSelected ? selectedIcon : icon,
2529 onClick: () => {
2530 if (isSelected) {
2531 disableComplementaryArea(scope);
2532 } else {
2533 enableComplementaryArea(scope, identifier);
2534 }
2535 }
2536 }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
2537 }
2538
2539 /* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
2540 //# sourceMappingURL=index.js.map
2541 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
2542
2543
2544
2545 /**
2546 * External dependencies
2547 */
2548
2549 /**
2550 * WordPress dependencies
2551 */
2552
2553
2554 /**
2555 * Internal dependencies
2556 */
2557
2558
2559
2560 const ComplementaryAreaHeader = _ref => {
2561 let {
2562 smallScreenTitle,
2563 children,
2564 className,
2565 toggleButtonProps
2566 } = _ref;
2567 const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
2568 icon: close_small
2569 }, toggleButtonProps));
2570 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
2571 className: "components-panel__header interface-complementary-area-header__small"
2572 }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
2573 className: "interface-complementary-area-header__small-title"
2574 }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
2575 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
2576 tabIndex: -1
2577 }, children, toggleButton));
2578 };
2579
2580 /* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
2581 //# sourceMappingURL=index.js.map
2582 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
2583
2584
2585
2586 /**
2587 * External dependencies
2588 */
2589
2590 /**
2591 * WordPress dependencies
2592 */
2593
2594
2595
2596
2597 function ActionItemSlot(_ref) {
2598 let {
2599 name,
2600 as: Component = external_wp_components_namespaceObject.ButtonGroup,
2601 fillProps = {},
2602 bubblesVirtually,
2603 ...props
2604 } = _ref;
2605 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
2606 name: name,
2607 bubblesVirtually: bubblesVirtually,
2608 fillProps: fillProps
2609 }, fills => {
2610 if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
2611 return null;
2612 } // Special handling exists for backward compatibility.
2613 // It ensures that menu items created by plugin authors aren't
2614 // duplicated with automatically injected menu items coming
2615 // from pinnable plugin sidebars.
2616 // @see https://github.com/WordPress/gutenberg/issues/14457
2617
2618
2619 const initializedByPlugins = [];
2620 external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
2621 let {
2622 props: {
2623 __unstableExplicitMenuItem,
2624 __unstableTarget
2625 }
2626 } = _ref2;
2627
2628 if (__unstableTarget && __unstableExplicitMenuItem) {
2629 initializedByPlugins.push(__unstableTarget);
2630 }
2631 });
2632 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
2633 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
2634 return null;
2635 }
2636
2637 return child;
2638 });
2639 return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
2640 });
2641 }
2642
2643 function ActionItem(_ref3) {
2644 let {
2645 name,
2646 as: Component = external_wp_components_namespaceObject.Button,
2647 onClick,
2648 ...props
2649 } = _ref3;
2650 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
2651 name: name
2652 }, _ref4 => {
2653 let {
2654 onClick: fpOnClick
2655 } = _ref4;
2656 return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({
2657 onClick: onClick || fpOnClick ? function () {
2658 (onClick || external_lodash_namespaceObject.noop)(...arguments);
2659 (fpOnClick || external_lodash_namespaceObject.noop)(...arguments);
2660 } : undefined
2661 }, props));
2662 });
2663 }
2664
2665 ActionItem.Slot = ActionItemSlot;
2666 /* harmony default export */ var action_item = (ActionItem);
2667 //# sourceMappingURL=index.js.map
2668 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
2669
2670
2671
2672 /**
2673 * External dependencies
2674 */
2675
2676 /**
2677 * WordPress dependencies
2678 */
2679
2680
2681
2682 /**
2683 * Internal dependencies
2684 */
2685
2686
2687
2688
2689 const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
2690 // They are removed so they don't leak to DOM elements.
2691 // @see https://github.com/WordPress/gutenberg/issues/14457
2692 (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
2693
2694 function ComplementaryAreaMoreMenuItem(_ref) {
2695 let {
2696 scope,
2697 target,
2698 __unstableExplicitMenuItem,
2699 ...props
2700 } = _ref;
2701 return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
2702 as: toggleProps => {
2703 return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({
2704 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
2705 __unstableTarget: `${scope}/${target}`,
2706 as: PluginsMenuItem,
2707 name: `${scope}/plugin-more-menu`
2708 }, toggleProps));
2709 },
2710 role: "menuitemcheckbox",
2711 selectedIcon: library_check,
2712 name: target,
2713 scope: scope
2714 }, props));
2715 }
2716 //# sourceMappingURL=index.js.map
2717 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
2718
2719
2720
2721 /**
2722 * External dependencies
2723 */
2724
2725
2726 /**
2727 * WordPress dependencies
2728 */
2729
2730
2731
2732 function PinnedItems(_ref) {
2733 let {
2734 scope,
2735 ...props
2736 } = _ref;
2737 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({
2738 name: `PinnedItems/${scope}`
2739 }, props));
2740 }
2741
2742 function PinnedItemsSlot(_ref2) {
2743 let {
2744 scope,
2745 className,
2746 ...props
2747 } = _ref2;
2748 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
2749 name: `PinnedItems/${scope}`
2750 }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
2751 className: classnames_default()(className, 'interface-pinned-items')
2752 }, fills));
2753 }
2754
2755 PinnedItems.Slot = PinnedItemsSlot;
2756 /* harmony default export */ var pinned_items = (PinnedItems);
2757 //# sourceMappingURL=index.js.map
2758 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
2759
2760
2761
2762 /**
2763 * External dependencies
2764 */
2765
2766 /**
2767 * WordPress dependencies
2768 */
2769
2770
2771
2772
2773
2774
2775
2776 /**
2777 * Internal dependencies
2778 */
2779
2780
2781
2782
2783
2784
2785
2786
2787 function ComplementaryAreaSlot(_ref) {
2788 let {
2789 scope,
2790 ...props
2791 } = _ref;
2792 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
2793 name: `ComplementaryArea/${scope}`
2794 }, props));
2795 }
2796
2797 function ComplementaryAreaFill(_ref2) {
2798 let {
2799 scope,
2800 children,
2801 className
2802 } = _ref2;
2803 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
2804 name: `ComplementaryArea/${scope}`
2805 }, (0,external_wp_element_namespaceObject.createElement)("div", {
2806 className: className
2807 }, children));
2808 }
2809
2810 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
2811 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2812 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2813 const {
2814 enableComplementaryArea,
2815 disableComplementaryArea
2816 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2817 (0,external_wp_element_namespaceObject.useEffect)(() => {
2818 // If the complementary area is active and the editor is switching from a big to a small window size.
2819 if (isActive && isSmall && !previousIsSmall.current) {
2820 // Disable the complementary area.
2821 disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
2822
2823 shouldOpenWhenNotSmall.current = true;
2824 } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
2825 // and we are going from a small to big window size.
2826 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
2827 // Remove the flag indicating the complementary area should be enabled.
2828 shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
2829
2830 enableComplementaryArea(scope, identifier);
2831 } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
2832 // remove the flag.
2833 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
2834 shouldOpenWhenNotSmall.current = false;
2835 }
2836
2837 if (isSmall !== previousIsSmall.current) {
2838 previousIsSmall.current = isSmall;
2839 }
2840 }, [isActive, isSmall, scope, identifier, activeArea]);
2841 }
2842
2843 function ComplementaryArea(_ref3) {
2844 let {
2845 children,
2846 className,
2847 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
2848 identifier,
2849 header,
2850 headerClassName,
2851 icon,
2852 isPinnable = true,
2853 panelClassName,
2854 scope,
2855 name,
2856 smallScreenTitle,
2857 title,
2858 toggleShortcut,
2859 isActiveByDefault,
2860 showIconLabels = false
2861 } = _ref3;
2862 const {
2863 isActive,
2864 isPinned,
2865 activeArea,
2866 isSmall,
2867 isLarge
2868 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2869 const {
2870 getActiveComplementaryArea,
2871 isItemPinned
2872 } = select(store_store);
2873
2874 const _activeArea = getActiveComplementaryArea(scope);
2875
2876 return {
2877 isActive: _activeArea === identifier,
2878 isPinned: isItemPinned(scope, identifier),
2879 activeArea: _activeArea,
2880 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
2881 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
2882 };
2883 }, [identifier, scope]);
2884 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
2885 const {
2886 enableComplementaryArea,
2887 disableComplementaryArea,
2888 pinItem,
2889 unpinItem
2890 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2891 (0,external_wp_element_namespaceObject.useEffect)(() => {
2892 if (isActiveByDefault && activeArea === undefined && !isSmall) {
2893 enableComplementaryArea(scope, identifier);
2894 }
2895 }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
2896 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
2897 scope: scope
2898 }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
2899 scope: scope,
2900 identifier: identifier,
2901 isPressed: isActive && (!showIconLabels || isLarge),
2902 "aria-expanded": isActive,
2903 label: title,
2904 icon: showIconLabels ? library_check : icon,
2905 showTooltip: !showIconLabels,
2906 variant: showIconLabels ? 'tertiary' : undefined
2907 })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
2908 target: name,
2909 scope: scope,
2910 icon: icon
2911 }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
2912 className: classnames_default()('interface-complementary-area', className),
2913 scope: scope
2914 }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
2915 className: headerClassName,
2916 closeLabel: closeLabel,
2917 onClose: () => disableComplementaryArea(scope),
2918 smallScreenTitle: smallScreenTitle,
2919 toggleButtonProps: {
2920 label: closeLabel,
2921 shortcut: toggleShortcut,
2922 scope,
2923 identifier
2924 }
2925 }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
2926 className: "interface-complementary-area__pin-unpin-item",
2927 icon: isPinned ? star_filled : star_empty,
2928 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
2929 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
2930 isPressed: isPinned,
2931 "aria-expanded": isPinned
2932 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
2933 className: panelClassName
2934 }, children)));
2935 }
2936
2937 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
2938 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
2939 /* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
2940 //# sourceMappingURL=index.js.map
2941 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
2942
2943
2944
2945 /**
2946 * External dependencies
2947 */
2948
2949 /**
2950 * WordPress dependencies
2951 */
2952
2953 /**
2954 * WordPress dependencies
2955 */
2956
2957
2958
2959
2960
2961
2962 function useHTMLClass(className) {
2963 (0,external_wp_element_namespaceObject.useEffect)(() => {
2964 const element = document && document.querySelector(`html:not(.${className})`);
2965
2966 if (!element) {
2967 return;
2968 }
2969
2970 element.classList.toggle(className);
2971 return () => {
2972 element.classList.toggle(className);
2973 };
2974 }, [className]);
2975 }
2976
2977 function InterfaceSkeleton(_ref, ref) {
2978 let {
2979 footer,
2980 header,
2981 sidebar,
2982 secondarySidebar,
2983 notices,
2984 content,
2985 drawer,
2986 actions,
2987 labels,
2988 className,
2989 shortcuts
2990 } = _ref;
2991 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
2992 useHTMLClass('interface-interface-skeleton__html-container');
2993 const defaultLabels = {
2994 /* translators: accessibility text for the nav bar landmark region. */
2995 drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
2996
2997 /* translators: accessibility text for the top bar landmark region. */
2998 header: (0,external_wp_i18n_namespaceObject.__)('Header'),
2999
3000 /* translators: accessibility text for the content landmark region. */
3001 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
3002
3003 /* translators: accessibility text for the secondary sidebar landmark region. */
3004 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
3005
3006 /* translators: accessibility text for the settings landmark region. */
3007 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
3008
3009 /* translators: accessibility text for the publish landmark region. */
3010 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
3011
3012 /* translators: accessibility text for the footer landmark region. */
3013 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
3014 };
3015 const mergedLabels = { ...defaultLabels,
3016 ...labels
3017 };
3018 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, {
3019 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
3020 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
3021 }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
3022 className: "interface-interface-skeleton__drawer",
3023 role: "region",
3024 "aria-label": mergedLabels.drawer,
3025 tabIndex: "-1"
3026 }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
3027 className: "interface-interface-skeleton__editor"
3028 }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
3029 className: "interface-interface-skeleton__header",
3030 role: "region",
3031 "aria-label": mergedLabels.header,
3032 tabIndex: "-1"
3033 }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
3034 className: "interface-interface-skeleton__body"
3035 }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
3036 className: "interface-interface-skeleton__secondary-sidebar",
3037 role: "region",
3038 "aria-label": mergedLabels.secondarySidebar,
3039 tabIndex: "-1"
3040 }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
3041 className: "interface-interface-skeleton__notices"
3042 }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
3043 className: "interface-interface-skeleton__content",
3044 role: "region",
3045 "aria-label": mergedLabels.body,
3046 tabIndex: "-1"
3047 }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
3048 className: "interface-interface-skeleton__sidebar",
3049 role: "region",
3050 "aria-label": mergedLabels.sidebar,
3051 tabIndex: "-1"
3052 }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
3053 className: "interface-interface-skeleton__actions",
3054 role: "region",
3055 "aria-label": mergedLabels.actions,
3056 tabIndex: "-1"
3057 }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
3058 className: "interface-interface-skeleton__footer",
3059 role: "region",
3060 "aria-label": mergedLabels.footer,
3061 tabIndex: "-1"
3062 }, footer));
3063 }
3064
3065 /* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
3066 //# sourceMappingURL=index.js.map
3067 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
3068
3069
3070 /**
3071 * WordPress dependencies
3072 */
3073
3074 const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3075 xmlns: "http://www.w3.org/2000/svg",
3076 viewBox: "0 0 24 24"
3077 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3078 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
3079 }));
3080 /* harmony default export */ var more_vertical = (moreVertical);
3081 //# sourceMappingURL=more-vertical.js.map
3082 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
3083
3084
3085 /**
3086 * External dependencies
3087 */
3088
3089 /**
3090 * WordPress dependencies
3091 */
3092
3093
3094
3095
3096 function MoreMenuDropdown(_ref) {
3097 let {
3098 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
3099 className,
3100
3101 /* translators: button label text should, if possible, be under 16 characters. */
3102 label = (0,external_wp_i18n_namespaceObject.__)('Options'),
3103 popoverProps,
3104 toggleProps,
3105 children
3106 } = _ref;
3107 return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
3108 className: classnames_default()('interface-more-menu-dropdown', className),
3109 icon: more_vertical,
3110 label: label,
3111 popoverProps: {
3112 position: 'bottom left',
3113 ...popoverProps,
3114 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
3115 },
3116 toggleProps: {
3117 tooltipPosition: 'bottom',
3118 ...toggleProps
3119 }
3120 }, onClose => children(onClose));
3121 }
3122 //# sourceMappingURL=index.js.map
3123 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
3124
3125
3126
3127
3128
3129
3130
3131
3132 //# sourceMappingURL=index.js.map
3133 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
3134
3135
3136 //# sourceMappingURL=index.js.map
3137 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
3138 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
3139 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-display/index.js
3140
3141
3142 /**
3143 * WordPress dependencies
3144 */
3145
3146
3147
3148
3149
3150
3151
3152 /**
3153 * Internal dependencies
3154 */
3155
3156
3157
3158 function NameDisplay() {
3159 const {
3160 enableComplementaryArea
3161 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3162 const [menuId] = useSelectedMenuId();
3163 const [name] = useMenuEntityProp('name', menuId);
3164 const [, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext);
3165 const menuName = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name !== null && name !== void 0 ? name : untitledMenu);
3166 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
3167 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu.
3168 (0,external_wp_i18n_namespaceObject.__)(`Edit menu name: %s`), menuName),
3169 onClick: () => {
3170 enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
3171 setIsMenuNameEditFocused(true);
3172 }
3173 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
3174 limit: 24,
3175 ellipsizeMode: "tail",
3176 truncate: true
3177 }, menuName))));
3178 }
3179 //# sourceMappingURL=index.js.map
3180 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-menu-name-editor.js
3181
3182
3183 /**
3184 * WordPress dependencies
3185 */
3186
3187 /**
3188 * Internal dependencies
3189 */
3190
3191
3192
3193 const addMenuNameEditor = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
3194 if (props.name !== 'core/navigation') {
3195 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
3196 }
3197
3198 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(NameDisplay, null), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props));
3199 }, 'withMenuName');
3200 /* harmony default export */ var add_menu_name_editor = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-menu-name', addMenuNameEditor));
3201 //# sourceMappingURL=add-menu-name-editor.js.map
3202 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/disable-inserting-non-navigation-blocks.js
3203 /**
3204 * WordPress dependencies
3205 */
3206
3207 /**
3208 * External dependencies
3209 */
3210
3211
3212
3213 function disableInsertingNonNavigationBlocks(settings, name) {
3214 if (!['core/navigation', 'core/navigation-link', 'core/navigation-submenu'].includes(name)) {
3215 (0,external_lodash_namespaceObject.set)(settings, ['supports', 'inserter'], false);
3216 }
3217
3218 return settings;
3219 }
3220
3221 /* harmony default export */ var disable_inserting_non_navigation_blocks = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/disable-inserting-non-navigation-blocks', disableInsertingNonNavigationBlocks));
3222 //# sourceMappingURL=disable-inserting-non-navigation-blocks.js.map
3223 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-edit-unsupported-features.js
3224
3225
3226
3227 /**
3228 * WordPress dependencies
3229 */
3230
3231
3232 const removeNavigationBlockEditUnsupportedFeatures = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
3233 if (props.name !== 'core/navigation') {
3234 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
3235 }
3236
3237 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
3238 hasSubmenuIndicatorSetting: false,
3239 hasItemJustificationControls: false,
3240 hasColorSettings: false
3241 }));
3242 }, 'removeNavigationBlockEditUnsupportedFeatures');
3243 /* harmony default export */ var remove_edit_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/remove-navigation-block-edit-unsupported-features', removeNavigationBlockEditUnsupportedFeatures));
3244 //# sourceMappingURL=remove-edit-unsupported-features.js.map
3245 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-settings-unsupported-features.js
3246 /**
3247 * WordPress dependencies
3248 */
3249
3250
3251 function removeNavigationBlockSettingsUnsupportedFeatures(settings, name) {
3252 if (name !== 'core/navigation') {
3253 return settings;
3254 }
3255
3256 return { ...settings,
3257 supports: {
3258 customClassName: false,
3259 html: false,
3260 inserter: true
3261 },
3262 // Remove any block variations.
3263 variations: undefined
3264 };
3265 }
3266
3267 /* harmony default export */ var remove_settings_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/remove-navigation-block-settings-unsupported-features', removeNavigationBlockSettingsUnsupportedFeatures));
3268 //# sourceMappingURL=remove-settings-unsupported-features.js.map
3269 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/index.js
3270 /**
3271 * Internal dependencies
3272 */
3273
3274
3275
3276
3277
3278
3279 const addFilters = shouldAddDisableInsertingNonNavigationBlocksFilter => {
3280 add_navigation_editor_custom_appender();
3281 add_navigation_editor_placeholder();
3282 add_menu_name_editor();
3283
3284 if (shouldAddDisableInsertingNonNavigationBlocksFilter) {
3285 disable_inserting_non_navigation_blocks();
3286 }
3287
3288 remove_edit_unsupported_features();
3289 remove_settings_unsupported_features();
3290 };
3291 //# sourceMappingURL=index.js.map
3292 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
3293 var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
3294 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/add-menu/index.js
3295
3296
3297 /**
3298 * External dependencies
3299 */
3300
3301 /**
3302 * WordPress dependencies
3303 */
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313 /**
3314 * Internal dependencies
3315 */
3316
3317
3318
3319 function AddMenu(_ref) {
3320 let {
3321 className,
3322 onCreate,
3323 titleText,
3324 helpText,
3325 focusInputOnMount = false,
3326 noticeUI,
3327 noticeOperations
3328 } = _ref;
3329 const inputRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)(focusInputOnMount);
3330 const [menuName, setMenuName] = (0,external_wp_element_namespaceObject.useState)('');
3331 const [isCreatingMenu, setIsCreatingMenu] = (0,external_wp_element_namespaceObject.useState)(false);
3332 const {
3333 createInfoNotice
3334 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3335 const {
3336 saveMenu
3337 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
3338 const {
3339 createErrorNotice,
3340 removeAllNotices
3341 } = noticeOperations;
3342 const lastSaveError = (0,external_wp_data_namespaceObject.useSelect)(select => {
3343 return select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError(MENU_KIND, MENU_POST_TYPE);
3344 }, []);
3345 (0,external_wp_element_namespaceObject.useEffect)(() => {
3346 if (lastSaveError) {
3347 createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastSaveError === null || lastSaveError === void 0 ? void 0 : lastSaveError.message));
3348 }
3349 }, [lastSaveError]);
3350
3351 const createMenu = async event => {
3352 event.preventDefault();
3353
3354 if (!menuName.length || isCreatingMenu) {
3355 return;
3356 }
3357
3358 setIsCreatingMenu(true); // Remove any existing notices.
3359
3360 removeAllNotices();
3361 const menu = await saveMenu({
3362 name: menuName
3363 });
3364 setIsCreatingMenu(false);
3365
3366 if (menu) {
3367 createInfoNotice((0,external_wp_i18n_namespaceObject.__)('Menu created'), {
3368 type: 'snackbar',
3369 isDismissible: true
3370 });
3371
3372 if (onCreate) {
3373 onCreate(menu.id);
3374 }
3375 }
3376 };
3377
3378 return (0,external_wp_element_namespaceObject.createElement)("form", {
3379 className: classnames_default()('edit-navigation-add-menu', className),
3380 onSubmit: createMenu
3381 }, noticeUI, titleText && (0,external_wp_element_namespaceObject.createElement)("h3", {
3382 className: "edit-navigation-add-menu__title"
3383 }, titleText), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
3384 ref: inputRef,
3385 label: (0,external_wp_i18n_namespaceObject.__)('Menu name'),
3386 value: menuName,
3387 onChange: setMenuName,
3388 help: helpText
3389 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3390 className: "edit-navigation-add-menu__create-menu-button",
3391 type: "submit",
3392 variant: "primary",
3393 disabled: !menuName.length,
3394 isBusy: isCreatingMenu
3395 /* Button is disabled but still focusable */
3396 ,
3397 "aria-disabled": !menuName.length || isCreatingMenu
3398 }, (0,external_wp_i18n_namespaceObject.__)('Create menu')));
3399 }
3400
3401 /* harmony default export */ var add_menu = ((0,external_wp_components_namespaceObject.withNotices)(AddMenu));
3402 //# sourceMappingURL=index.js.map
3403 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/menu-switcher/index.js
3404
3405
3406 /**
3407 * External dependencies
3408 */
3409
3410 /**
3411 * WordPress dependencies
3412 */
3413
3414
3415
3416
3417
3418 /**
3419 * Internal dependencies
3420 */
3421
3422
3423 function MenuSwitcher(_ref) {
3424 let {
3425 menus,
3426 selectedMenuId,
3427 onSelectMenu = external_lodash_namespaceObject.noop
3428 } = _ref;
3429 const [isModalVisible, setIsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false);
3430
3431 const openModal = () => setIsModalVisible(true);
3432
3433 const closeModal = () => setIsModalVisible(false);
3434
3435 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
3436 value: selectedMenuId,
3437 onSelect: onSelectMenu,
3438 choices: menus.map(_ref2 => {
3439 let {
3440 id,
3441 name
3442 } = _ref2;
3443 return {
3444 value: id,
3445 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name),
3446 'aria-label': (0,external_wp_i18n_namespaceObject.sprintf)(
3447 /* translators: %s: The name of a menu. */
3448 (0,external_wp_i18n_namespaceObject.__)("Switch to '%s'"), name)
3449 };
3450 })
3451 })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
3452 hideSeparator: true
3453 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3454 className: "edit-navigation-menu-switcher__new-button",
3455 onClick: openModal
3456 }, (0,external_wp_i18n_namespaceObject.__)('Create a new menu')), isModalVisible && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
3457 title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'),
3458 className: "edit-navigation-menu-switcher__modal",
3459 onRequestClose: closeModal
3460 }, (0,external_wp_element_namespaceObject.createElement)(add_menu, {
3461 onCreate: menuId => {
3462 closeModal();
3463 onSelectMenu(menuId);
3464 },
3465 helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.')
3466 }))));
3467 }
3468 //# sourceMappingURL=index.js.map
3469 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unselected-menu-state.js
3470
3471
3472 /**
3473 * WordPress dependencies
3474 */
3475
3476
3477 /**
3478 * Internal dependencies
3479 */
3480
3481
3482
3483 function UnselectedMenuState(_ref) {
3484 let {
3485 onCreate,
3486 onSelectMenu,
3487 menus
3488 } = _ref;
3489 const showMenuSwitcher = (menus === null || menus === void 0 ? void 0 : menus.length) > 0;
3490 return (0,external_wp_element_namespaceObject.createElement)("div", {
3491 className: "edit-navigation-empty-state"
3492 }, showMenuSwitcher && (0,external_wp_element_namespaceObject.createElement)("h4", null, (0,external_wp_i18n_namespaceObject.__)('Choose a menu to edit:')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, showMenuSwitcher ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, null, (0,external_wp_element_namespaceObject.createElement)(MenuSwitcher, {
3493 onSelectMenu: onSelectMenu,
3494 menus: menus
3495 })) : (0,external_wp_element_namespaceObject.createElement)(add_menu, {
3496 onCreate: onCreate,
3497 titleText: (0,external_wp_i18n_namespaceObject.__)('Create your first menu'),
3498 helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'),
3499 focusInputOnMount: true
3500 }))));
3501 }
3502 //# sourceMappingURL=unselected-menu-state.js.map
3503 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/error-boundary/index.js
3504
3505
3506 /**
3507 * WordPress dependencies
3508 */
3509
3510
3511
3512
3513
3514 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
3515 constructor() {
3516 super(...arguments);
3517 this.reboot = this.reboot.bind(this);
3518 this.state = {
3519 error: null
3520 };
3521 }
3522
3523 componentDidCatch(error) {
3524 this.setState({
3525 error
3526 });
3527 }
3528
3529 reboot() {
3530 if (this.props.onError) {
3531 this.props.onError();
3532 }
3533 }
3534
3535 render() {
3536 const {
3537 error
3538 } = this.state;
3539
3540 if (!error) {
3541 return this.props.children;
3542 }
3543
3544 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
3545 className: "navigation-editor-error-boundary",
3546 actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3547 key: "recovery",
3548 onClick: this.reboot,
3549 variant: "secondary"
3550 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery'))]
3551 }, (0,external_wp_i18n_namespaceObject.__)('The navigation editor has encountered an unexpected error.'));
3552 }
3553
3554 }
3555
3556 /* harmony default export */ var error_boundary = (ErrorBoundary);
3557 //# sourceMappingURL=index.js.map
3558 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/shortcuts.js
3559 /**
3560 * WordPress dependencies
3561 */
3562
3563
3564
3565
3566
3567
3568 function NavigationEditorShortcuts(_ref) {
3569 let {
3570 saveBlocks
3571 } = _ref;
3572 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/save-menu', event => {
3573 event.preventDefault();
3574 saveBlocks();
3575 });
3576 const {
3577 redo,
3578 undo
3579 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
3580 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/undo', event => {
3581 undo();
3582 event.preventDefault();
3583 });
3584 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/redo', event => {
3585 redo();
3586 event.preventDefault();
3587 });
3588 return null;
3589 }
3590
3591 function RegisterNavigationEditorShortcuts() {
3592 const {
3593 registerShortcut
3594 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
3595 (0,external_wp_element_namespaceObject.useEffect)(() => {
3596 registerShortcut({
3597 name: 'core/edit-navigation/save-menu',
3598 category: 'global',
3599 description: (0,external_wp_i18n_namespaceObject.__)('Save the navigation currently being edited.'),
3600 keyCombination: {
3601 modifier: 'primary',
3602 character: 's'
3603 }
3604 });
3605 registerShortcut({
3606 name: 'core/edit-navigation/undo',
3607 category: 'global',
3608 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
3609 keyCombination: {
3610 modifier: 'primary',
3611 character: 'z'
3612 }
3613 });
3614 registerShortcut({
3615 name: 'core/edit-navigation/redo',
3616 category: 'global',
3617 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
3618 keyCombination: {
3619 modifier: 'primaryShift',
3620 character: 'z'
3621 }
3622 });
3623 }, [registerShortcut]);
3624 return null;
3625 }
3626
3627 NavigationEditorShortcuts.Register = RegisterNavigationEditorShortcuts;
3628 /* harmony default export */ var shortcuts = (NavigationEditorShortcuts);
3629 //# sourceMappingURL=shortcuts.js.map
3630 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js
3631
3632
3633 /**
3634 * WordPress dependencies
3635 */
3636
3637 const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3638 xmlns: "http://www.w3.org/2000/svg",
3639 viewBox: "0 0 24 24"
3640 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3641 fillRule: "evenodd",
3642 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
3643 clipRule: "evenodd"
3644 }));
3645 /* harmony default export */ var library_cog = (cog);
3646 //# sourceMappingURL=cog.js.map
3647 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/sidebar-header.js
3648
3649
3650 /**
3651 * WordPress dependencies
3652 */
3653
3654
3655
3656
3657 /**
3658 * Internal dependencies
3659 */
3660
3661
3662 function SidebarHeader(_ref) {
3663 let {
3664 sidebarName
3665 } = _ref;
3666 const {
3667 enableComplementaryArea
3668 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3669
3670 const openMenuSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
3671
3672 const openBlockSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK);
3673
3674 const [menuAriaLabel, menuActiveClass] = sidebarName === SIDEBAR_MENU ? // translators: ARIA label for the Menu sidebar tab, selected.
3675 [(0,external_wp_i18n_namespaceObject.__)('Menu (selected)'), 'is-active'] : // translators: ARIA label for the Menu Settings Sidebar tab, not selected.
3676 [(0,external_wp_i18n_namespaceObject.__)('Menu'), ''];
3677 const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
3678 [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
3679 [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
3680 /* Use a list so screen readers will announce how many tabs there are. */
3681
3682 return (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3683 onClick: openMenuSettings,
3684 className: `edit-navigation-sidebar__panel-tab ${menuActiveClass}`,
3685 "aria-label": menuAriaLabel // translators: Data label for the Menu Settings Sidebar tab.
3686 ,
3687 "data-label": (0,external_wp_i18n_namespaceObject.__)('Menu')
3688 }, // translators: Text label for the Menu Settings Sidebar tab.
3689 (0,external_wp_i18n_namespaceObject.__)('Menu'))), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3690 onClick: openBlockSettings,
3691 className: `edit-navigation-sidebar__panel-tab ${blockActiveClass}`,
3692 "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
3693 ,
3694 "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
3695 }, // translators: Text label for the Block Settings Sidebar tab.
3696 (0,external_wp_i18n_namespaceObject.__)('Block'))));
3697 }
3698 //# sourceMappingURL=sidebar-header.js.map
3699 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-editor/index.js
3700
3701
3702 /**
3703 * WordPress dependencies
3704 */
3705
3706
3707
3708
3709 /**
3710 * Internal dependencies
3711 */
3712
3713
3714 function NameEditor() {
3715 const [isMenuNameEditFocused, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext);
3716 const [menuId] = useSelectedMenuId();
3717 const [name, setName] = useMenuEntityProp('name', menuId);
3718 const inputRef = (0,external_wp_element_namespaceObject.useRef)();
3719 (0,external_wp_element_namespaceObject.useEffect)(() => {
3720 if (isMenuNameEditFocused) inputRef.current.focus();
3721 }, [isMenuNameEditFocused]);
3722 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
3723 ref: inputRef,
3724 help: (0,external_wp_i18n_namespaceObject.__)('A short, descriptive name used to refer to this menu elsewhere.'),
3725 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
3726 onBlur: () => setIsMenuNameEditFocused(false),
3727 className: "edit-navigation-name-editor__text-control",
3728 value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name || ''),
3729 onChange: setName
3730 });
3731 }
3732 //# sourceMappingURL=index.js.map
3733 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/auto-add-pages.js
3734
3735
3736 /**
3737 * WordPress dependencies
3738 */
3739
3740
3741 /**
3742 * Internal dependencies
3743 */
3744
3745
3746 function AutoAddPages(_ref) {
3747 let {
3748 menuId
3749 } = _ref;
3750 const [autoAddPages, setAutoAddPages] = useMenuEntityProp('auto_add', menuId);
3751 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
3752 label: (0,external_wp_i18n_namespaceObject.__)('Add new pages'),
3753 help: (0,external_wp_i18n_namespaceObject.__)('Automatically add published top-level pages to this menu.'),
3754 checked: autoAddPages !== null && autoAddPages !== void 0 ? autoAddPages : false,
3755 onChange: setAutoAddPages
3756 });
3757 }
3758 //# sourceMappingURL=auto-add-pages.js.map
3759 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/menu-settings.js
3760
3761
3762 /**
3763 * WordPress dependencies
3764 */
3765
3766
3767 /**
3768 * Internal dependencies
3769 */
3770
3771
3772
3773 function MenuSettings(_ref) {
3774 let {
3775 menuId
3776 } = _ref;
3777 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3778 title: (0,external_wp_i18n_namespaceObject.__)('Menu settings')
3779 }, (0,external_wp_element_namespaceObject.createElement)(NameEditor, null), (0,external_wp_element_namespaceObject.createElement)(AutoAddPages, {
3780 menuId: menuId
3781 }));
3782 }
3783 //# sourceMappingURL=menu-settings.js.map
3784 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/manage-locations.js
3785
3786
3787 /**
3788 * WordPress dependencies
3789 */
3790
3791
3792
3793
3794
3795
3796
3797 /**
3798 * Internal dependencies
3799 */
3800
3801
3802 function ManageLocations(_ref) {
3803 let {
3804 menus,
3805 selectedMenuId,
3806 onSelectMenu
3807 } = _ref;
3808 const {
3809 menuLocations,
3810 assignMenuToLocation,
3811 toggleMenuLocationAssignment
3812 } = useMenuLocations();
3813 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
3814
3815 const openModal = () => setIsModalOpen(true);
3816
3817 const closeModal = () => setIsModalOpen(false);
3818
3819 const {
3820 createSuccessNotice,
3821 createErrorNotice
3822 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3823
3824 const validateBatchResponse = batchResponse => {
3825 if (batchResponse.failed) {
3826 return false;
3827 }
3828
3829 const errorResponses = batchResponse.responses.filter(response => {
3830 return 200 > response.status || 300 <= response.status;
3831 });
3832 return 1 > errorResponses.length;
3833 };
3834
3835 const handleUpdateMenuLocations = async () => {
3836 const method = 'POST';
3837 const batchRequests = menus.map(_ref2 => {
3838 let {
3839 id
3840 } = _ref2;
3841 const locations = menuLocations.filter(menuLocation => menuLocation.menu === id).map(menuLocation => menuLocation.name);
3842 return {
3843 path: `/wp/v2/menus/${id}`,
3844 body: {
3845 locations
3846 },
3847 method
3848 };
3849 });
3850 const batchResponse = await external_wp_apiFetch_default()({
3851 path: 'batch/v1',
3852 data: {
3853 validation: 'require-all-validate',
3854 requests: batchRequests
3855 },
3856 method
3857 });
3858 const isSuccess = validateBatchResponse(batchResponse);
3859
3860 if (isSuccess) {
3861 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Menu locations have been updated.'), {
3862 type: 'snackbar'
3863 });
3864 closeModal();
3865 return;
3866 }
3867
3868 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('An error occurred while trying to update menu locations.'), {
3869 type: 'snackbar'
3870 });
3871 };
3872
3873 if (!menuLocations || !(menus !== null && menus !== void 0 && menus.length)) {
3874 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null);
3875 }
3876
3877 if (!menuLocations.length) {
3878 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3879 title: (0,external_wp_i18n_namespaceObject.__)('Theme locations')
3880 }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('There are no available menu locations.')));
3881 }
3882
3883 const themeLocationCountTextMain = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations.
3884 (0,external_wp_i18n_namespaceObject.__)('Your current theme provides %d different locations to place menu.'), menuLocations.length);
3885 const themeLocationCountTextModal = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations.
3886 (0,external_wp_i18n_namespaceObject.__)('Your current theme supports %d different locations. Select which menu appears in each location.'), menuLocations.length);
3887 const menusWithSelection = menuLocations.map(_ref3 => {
3888 let {
3889 name,
3890 description,
3891 menu
3892 } = _ref3;
3893 const menuOnLocation = menus.filter(_ref4 => {
3894 let {
3895 id
3896 } = _ref4;
3897 return ![0, selectedMenuId].includes(id);
3898 }).find(_ref5 => {
3899 let {
3900 id
3901 } = _ref5;
3902 return id === menu;
3903 });
3904 return (0,external_wp_element_namespaceObject.createElement)("li", {
3905 key: name,
3906 className: "edit-navigation-manage-locations__checklist-item"
3907 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
3908 className: "edit-navigation-manage-locations__menu-location-checkbox",
3909 checked: menu === selectedMenuId,
3910 onChange: () => toggleMenuLocationAssignment(name, selectedMenuId),
3911 label: description,
3912 help: menuOnLocation && (0,external_wp_i18n_namespaceObject.sprintf)( // translators: menu name.
3913 (0,external_wp_i18n_namespaceObject.__)('Currently using %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuOnLocation.name))
3914 }));
3915 });
3916 const menuLocationCard = menuLocations.map(menuLocation => (0,external_wp_element_namespaceObject.createElement)("div", {
3917 key: menuLocation.name,
3918 className: "edit-navigation-manage-locations__menu-entry"
3919 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
3920 key: menuLocation.name,
3921 className: "edit-navigation-manage-locations__select-menu",
3922 label: menuLocation.description,
3923 labelPosition: "top",
3924 value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuLocation.menu),
3925 options: [{
3926 value: 0,
3927 label: (0,external_wp_i18n_namespaceObject.__)('Select a Menu'),
3928 key: 0
3929 }, ...menus.map(_ref6 => {
3930 let {
3931 id,
3932 name
3933 } = _ref6;
3934 return {
3935 key: id,
3936 value: id,
3937 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name)
3938 };
3939 })],
3940 onChange: menuId => {
3941 assignMenuToLocation(menuLocation.name, Number(menuId));
3942 }
3943 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3944 variant: "secondary",
3945 style: {
3946 visibility: !!menuLocation.menu ? 'visible' : 'hidden'
3947 },
3948 className: "edit-navigation-manage-locations__edit-button",
3949 onClick: () => (closeModal(), onSelectMenu(menuLocation.menu))
3950 }, (0,external_wp_i18n_namespaceObject.__)('Edit'))));
3951 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3952 title: (0,external_wp_i18n_namespaceObject.__)('Theme locations')
3953 }, (0,external_wp_element_namespaceObject.createElement)("div", {
3954 className: "edit-navigation-manage-locations__theme-location-text-main"
3955 }, themeLocationCountTextMain), (0,external_wp_element_namespaceObject.createElement)("ul", {
3956 className: "edit-navigation-manage-locations__checklist"
3957 }, menusWithSelection), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3958 variant: "secondary",
3959 className: "edit-navigation-manage-locations__open-menu-locations-modal-button",
3960 "aria-expanded": isModalOpen,
3961 onClick: openModal
3962 }, (0,external_wp_i18n_namespaceObject.__)('Manage locations')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
3963 className: "edit-navigation-manage-locations__modal",
3964 title: (0,external_wp_i18n_namespaceObject.__)('Manage locations'),
3965 onRequestClose: closeModal
3966 }, (0,external_wp_element_namespaceObject.createElement)("div", {
3967 className: "edit-navigation-manage-locations__theme-location-text-modal"
3968 }, themeLocationCountTextModal), menuLocationCard, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3969 className: "edit-navigation-manage-locations__save-button",
3970 variant: "primary",
3971 onClick: handleUpdateMenuLocations
3972 }, (0,external_wp_i18n_namespaceObject.__)('Update'))));
3973 }
3974 //# sourceMappingURL=manage-locations.js.map
3975 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/delete-menu.js
3976
3977
3978 /**
3979 * WordPress dependencies
3980 */
3981
3982
3983 function DeleteMenu(_ref) {
3984 let {
3985 onDeleteMenu,
3986 isMenuBeingDeleted
3987 } = _ref;
3988 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3989 className: "edit-navigation-inspector-additions__delete-menu-button",
3990 variant: "secondary",
3991 isDestructive: true,
3992 isBusy: isMenuBeingDeleted,
3993 onClick: () => {
3994 if ( // eslint-disable-next-line no-alert
3995 window.confirm((0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this navigation? This action cannot be undone.'))) {
3996 onDeleteMenu();
3997 }
3998 }
3999 }, (0,external_wp_i18n_namespaceObject.__)('Delete menu')));
4000 }
4001 //# sourceMappingURL=delete-menu.js.map
4002 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/index.js
4003
4004
4005 /**
4006 * WordPress dependencies
4007 */
4008
4009
4010
4011
4012
4013
4014
4015 /**
4016 * Internal dependencies
4017 */
4018
4019
4020
4021
4022
4023
4024 function Sidebar(_ref) {
4025 let {
4026 menuId,
4027 menus,
4028 isMenuBeingDeleted,
4029 onDeleteMenu,
4030 onSelectMenu
4031 } = _ref;
4032 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
4033 const {
4034 sidebar,
4035 hasBlockSelection,
4036 hasSidebarEnabled
4037 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4038 const _sidebar = select(store_store).getActiveComplementaryArea(SIDEBAR_SCOPE);
4039
4040 const _hasSidebarEnabled = [SIDEBAR_MENU, SIDEBAR_BLOCK].includes(_sidebar);
4041
4042 return {
4043 sidebar: _sidebar,
4044 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
4045 hasSidebarEnabled: _hasSidebarEnabled
4046 };
4047 }, []);
4048 const {
4049 enableComplementaryArea
4050 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4051 (0,external_wp_element_namespaceObject.useEffect)(() => {
4052 if (!hasSidebarEnabled) {
4053 return;
4054 }
4055
4056 if (hasBlockSelection) {
4057 enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK);
4058 } else {
4059 enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
4060 }
4061 }, [hasBlockSelection, hasSidebarEnabled]);
4062 let sidebarName = sidebar;
4063
4064 if (!hasSidebarEnabled) {
4065 sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_MENU;
4066 }
4067
4068 return (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
4069 className: "edit-navigation-sidebar"
4070 /* translators: button label text should, if possible, be under 16 characters. */
4071 ,
4072 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
4073 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'),
4074 scope: SIDEBAR_SCOPE,
4075 identifier: sidebarName,
4076 icon: library_cog,
4077 isActiveByDefault: isLargeViewport,
4078 header: (0,external_wp_element_namespaceObject.createElement)(SidebarHeader, {
4079 sidebarName: sidebarName
4080 }),
4081 headerClassName: "edit-navigation-sidebar__panel-tabs",
4082 isPinnable: true
4083 }, sidebarName === SIDEBAR_MENU && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MenuSettings, {
4084 menuId: menuId
4085 }), (0,external_wp_element_namespaceObject.createElement)(ManageLocations, {
4086 menus: menus,
4087 selectedMenuId: menuId,
4088 onSelectMenu: onSelectMenu
4089 }), (0,external_wp_element_namespaceObject.createElement)(DeleteMenu, {
4090 onDeleteMenu: onDeleteMenu,
4091 isMenuBeingDeleted: isMenuBeingDeleted
4092 })), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null));
4093 }
4094 //# sourceMappingURL=index.js.map
4095 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/menu-actions.js
4096
4097
4098 /**
4099 * WordPress dependencies
4100 */
4101
4102
4103
4104
4105
4106 /**
4107 * Internal dependencies
4108 */
4109
4110
4111
4112 function MenuActions(_ref) {
4113 let {
4114 menus,
4115 isLoading
4116 } = _ref;
4117 const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId();
4118 const [menuName] = useMenuEntityProp('name', selectedMenuId); // The title ref is passed to the popover as the anchorRef so that the
4119 // dropdown is centered over the whole title area rather than just one
4120 // part of it.
4121
4122 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
4123
4124 if (isLoading) {
4125 return (0,external_wp_element_namespaceObject.createElement)("div", {
4126 className: "edit-navigation-menu-actions"
4127 }, (0,external_wp_i18n_namespaceObject.__)('Loading…'));
4128 }
4129
4130 return (0,external_wp_element_namespaceObject.createElement)("div", {
4131 className: "edit-navigation-menu-actions"
4132 }, (0,external_wp_element_namespaceObject.createElement)("div", {
4133 ref: titleRef,
4134 className: "edit-navigation-menu-actions__subtitle-wrapper"
4135 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
4136 size: "body",
4137 className: "edit-navigation-menu-actions__subtitle",
4138 as: "h2",
4139 limit: 24,
4140 ellipsizeMode: "tail",
4141 truncate: true
4142 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuName)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
4143 icon: chevron_down,
4144 toggleProps: {
4145 label: (0,external_wp_i18n_namespaceObject.__)('Switch menu'),
4146 className: 'edit-navigation-menu-actions__switcher-toggle',
4147 showTooltip: false,
4148 __experimentalIsFocusable: true
4149 },
4150 popoverProps: {
4151 className: 'edit-navigation-menu-actions__switcher-dropdown',
4152 position: 'bottom center',
4153 anchorRef: titleRef.current
4154 }
4155 }, _ref2 => {
4156 let {
4157 onClose
4158 } = _ref2;
4159 return (0,external_wp_element_namespaceObject.createElement)(MenuSwitcher, {
4160 menus: menus,
4161 selectedMenuId: selectedMenuId,
4162 onSelectMenu: menuId => {
4163 setSelectedMenuId(menuId);
4164 onClose();
4165 }
4166 });
4167 })));
4168 }
4169 //# sourceMappingURL=menu-actions.js.map
4170 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/new-button.js
4171
4172
4173 /**
4174 * WordPress dependencies
4175 */
4176
4177
4178
4179 /**
4180 * Internal dependencies
4181 */
4182
4183
4184
4185 function NewButton() {
4186 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
4187 const [, setSelectedMenuId] = useSelectedMenuId();
4188 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4189 variant: "tertiary",
4190 onClick: () => setIsModalOpen(true)
4191 }, (0,external_wp_i18n_namespaceObject.__)('New menu')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4192 title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'),
4193 className: "edit-navigation-menu-switcher__modal",
4194 onRequestClose: () => setIsModalOpen(false)
4195 }, (0,external_wp_element_namespaceObject.createElement)(add_menu, {
4196 helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'),
4197 onCreate: menuId => {
4198 setIsModalOpen(false);
4199 setSelectedMenuId(menuId);
4200 }
4201 })));
4202 }
4203 //# sourceMappingURL=new-button.js.map
4204 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/save-button.js
4205
4206
4207 /**
4208 * WordPress dependencies
4209 */
4210
4211
4212
4213
4214 /**
4215 * Internal dependencies
4216 */
4217
4218
4219 function SaveButton(_ref) {
4220 let {
4221 navigationPost
4222 } = _ref;
4223 const {
4224 isDirty
4225 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4226 const {
4227 __experimentalGetDirtyEntityRecords
4228 } = select(external_wp_coreData_namespaceObject.store);
4229
4230 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4231
4232 return {
4233 isDirty: dirtyEntityRecords.length > 0
4234 };
4235 }, []);
4236 const {
4237 saveNavigationPost
4238 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4239 const disabled = !isDirty || !navigationPost;
4240 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4241 className: "edit-navigation-toolbar__save-button",
4242 variant: "primary",
4243 onClick: () => {
4244 saveNavigationPost(navigationPost);
4245 },
4246 disabled: disabled
4247 }, (0,external_wp_i18n_namespaceObject.__)('Save'));
4248 }
4249 //# sourceMappingURL=save-button.js.map
4250 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
4251
4252
4253 /**
4254 * WordPress dependencies
4255 */
4256
4257 const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4258 xmlns: "http://www.w3.org/2000/svg",
4259 viewBox: "0 0 24 24"
4260 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4261 d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"
4262 }));
4263 /* harmony default export */ var library_undo = (undo);
4264 //# sourceMappingURL=undo.js.map
4265 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
4266
4267
4268 /**
4269 * WordPress dependencies
4270 */
4271
4272 const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4273 xmlns: "http://www.w3.org/2000/svg",
4274 viewBox: "0 0 24 24"
4275 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4276 d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"
4277 }));
4278 /* harmony default export */ var library_redo = (redo);
4279 //# sourceMappingURL=redo.js.map
4280 ;// CONCATENATED MODULE: external ["wp","keycodes"]
4281 var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
4282 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/undo-button.js
4283
4284
4285 /**
4286 * WordPress dependencies
4287 */
4288
4289
4290
4291
4292
4293
4294 function UndoButton() {
4295 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
4296 const {
4297 undo
4298 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4299 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
4300 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
4301 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4302 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
4303 // button, because it will remove focus for keyboard users.
4304 // See: https://github.com/WordPress/gutenberg/issues/3486
4305 ,
4306 "aria-disabled": !hasUndo,
4307 onClick: hasUndo ? undo : undefined
4308 });
4309 }
4310 //# sourceMappingURL=undo-button.js.map
4311 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/redo-button.js
4312
4313
4314 /**
4315 * WordPress dependencies
4316 */
4317
4318
4319
4320
4321
4322
4323 function RedoButton() {
4324 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
4325 const {
4326 redo
4327 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4328 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
4329 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
4330 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
4331 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this
4332 // button, because it will remove focus for keyboard users.
4333 // See: https://github.com/WordPress/gutenberg/issues/3486
4334 ,
4335 "aria-disabled": !hasRedo,
4336 onClick: hasRedo ? redo : undefined
4337 });
4338 }
4339 //# sourceMappingURL=redo-button.js.map
4340 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
4341
4342
4343 /**
4344 * WordPress dependencies
4345 */
4346
4347 const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4348 xmlns: "http://www.w3.org/2000/svg",
4349 viewBox: "0 0 24 24"
4350 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4351 d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
4352 }));
4353 /* harmony default export */ var library_plus = (plus);
4354 //# sourceMappingURL=plus.js.map
4355 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/inserter-toggle.js
4356
4357
4358 /**
4359 * WordPress dependencies
4360 */
4361
4362
4363
4364
4365
4366 /**
4367 * Internal dependencies
4368 */
4369
4370
4371
4372
4373 function InserterToggle() {
4374 const {
4375 navBlockClientId
4376 } = use_navigation_editor_root_block();
4377 const {
4378 isInserterOpened,
4379 hasInserterItems
4380 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4381 return {
4382 hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId),
4383 isInserterOpened: select(store).isInserterOpened()
4384 };
4385 }, [navBlockClientId]);
4386 const {
4387 setIsInserterOpened
4388 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4389 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
4390 as: external_wp_components_namespaceObject.Button,
4391 className: "edit-navigation-header-inserter-toggle",
4392 variant: "primary",
4393 isPressed: isInserterOpened,
4394 onMouseDown: event => {
4395 event.preventDefault();
4396 },
4397 onClick: () => setIsInserterOpened(!isInserterOpened),
4398 icon: library_plus
4399 /* translators: button label text should, if possible, be under 16
4400 characters. */
4401 ,
4402 label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'),
4403 disabled: !hasInserterItems
4404 });
4405 }
4406
4407 /* harmony default export */ var inserter_toggle = (InserterToggle);
4408 //# sourceMappingURL=inserter-toggle.js.map
4409 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
4410
4411
4412 /**
4413 * WordPress dependencies
4414 */
4415
4416 const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4417 xmlns: "http://www.w3.org/2000/svg",
4418 viewBox: "0 0 24 24"
4419 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4420 d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
4421 }));
4422 /* harmony default export */ var library_external = (external);
4423 //# sourceMappingURL=external.js.map
4424 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/more-menu.js
4425
4426
4427 /**
4428 * WordPress dependencies
4429 */
4430
4431
4432
4433
4434 function MoreMenu() {
4435 return (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, () => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4436 label: (0,external_wp_i18n_namespaceObject.__)('Tools')
4437 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4438 role: "menuitem",
4439 icon: library_external,
4440 href: "https://github.com/WordPress/gutenberg/tree/trunk/packages/edit-navigation/docs/user-documentation.md",
4441 target: "_blank",
4442 rel: "noopener noreferrer"
4443 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4444 as: "span"
4445 },
4446 /* translators: accessibility text */
4447 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')))));
4448 }
4449 //# sourceMappingURL=more-menu.js.map
4450 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/index.js
4451
4452
4453 /**
4454 * WordPress dependencies
4455 */
4456
4457
4458
4459
4460 /**
4461 * Internal dependencies
4462 */
4463
4464
4465
4466
4467
4468
4469
4470
4471 function Header(_ref) {
4472 let {
4473 isMenuSelected,
4474 menus,
4475 isPending,
4476 navigationPost
4477 } = _ref;
4478 const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
4479
4480 if (!isMenuSelected) {
4481 return (0,external_wp_element_namespaceObject.createElement)("div", {
4482 className: "edit-navigation-header"
4483 }, (0,external_wp_element_namespaceObject.createElement)("div", {
4484 className: "edit-navigation-header__toolbar-wrapper"
4485 }, (0,external_wp_element_namespaceObject.createElement)("h1", {
4486 className: "edit-navigation-header__title"
4487 }, (0,external_wp_i18n_namespaceObject.__)('Navigation'))));
4488 }
4489
4490 return (0,external_wp_element_namespaceObject.createElement)("div", {
4491 className: "edit-navigation-header"
4492 }, (0,external_wp_element_namespaceObject.createElement)("div", {
4493 className: "edit-navigation-header__toolbar-wrapper"
4494 }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)("h1", {
4495 className: "edit-navigation-header__title"
4496 }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
4497 className: "edit-navigation-header__toolbar",
4498 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools')
4499 }, (0,external_wp_element_namespaceObject.createElement)(inserter_toggle, null), isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null)))), (0,external_wp_element_namespaceObject.createElement)(MenuActions, {
4500 menus: menus,
4501 isLoading: isPending
4502 }), (0,external_wp_element_namespaceObject.createElement)("div", {
4503 className: "edit-navigation-header__actions"
4504 }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(NewButton, null), (0,external_wp_element_namespaceObject.createElement)(SaveButton, {
4505 navigationPost: navigationPost
4506 }), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
4507 scope: "core/edit-navigation"
4508 }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null)));
4509 }
4510 //# sourceMappingURL=index.js.map
4511 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/notices/index.js
4512
4513
4514 /**
4515 * External dependencies
4516 */
4517
4518 /**
4519 * WordPress dependencies
4520 */
4521
4522
4523
4524
4525 function EditNavigationNotices() {
4526 const {
4527 removeNotice
4528 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4529 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
4530 const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4531 isDismissible: true,
4532 type: 'default'
4533 });
4534 const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4535 isDismissible: false,
4536 type: 'default'
4537 });
4538 const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4539 type: 'snackbar'
4540 });
4541 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
4542 notices: nonDismissibleNotices,
4543 className: "edit-navigation-notices__notice-list"
4544 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
4545 notices: dismissibleNotices,
4546 className: "edit-navigation-notices__notice-list",
4547 onRemove: removeNotice
4548 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, {
4549 notices: snackbarNotices,
4550 className: "edit-navigation-notices__snackbar-list",
4551 onRemove: removeNotice
4552 }));
4553 }
4554 //# sourceMappingURL=index.js.map
4555 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/editor/index.js
4556
4557
4558 /**
4559 * WordPress dependencies
4560 */
4561
4562
4563 function Editor(_ref) {
4564 let {
4565 isPending
4566 } = _ref;
4567 return (0,external_wp_element_namespaceObject.createElement)("div", {
4568 className: "edit-navigation-editor"
4569 }, isPending ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null) : (0,external_wp_element_namespaceObject.createElement)("div", {
4570 className: "editor-styles-wrapper"
4571 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ObserveTyping, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, null)))));
4572 }
4573 //# sourceMappingURL=index.js.map
4574 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
4575
4576
4577 /**
4578 * WordPress dependencies
4579 */
4580
4581 const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4582 xmlns: "http://www.w3.org/2000/svg",
4583 viewBox: "0 0 24 24"
4584 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4585 d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
4586 }));
4587 /* harmony default export */ var library_close = (close_close);
4588 //# sourceMappingURL=close.js.map
4589 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/inserter-sidebar/index.js
4590
4591
4592
4593 /**
4594 * WordPress dependencies
4595 */
4596
4597
4598
4599
4600
4601 /**
4602 * Internal dependencies
4603 */
4604
4605
4606
4607 const SHOW_PREVIEWS = false;
4608
4609 function InserterSidebar() {
4610 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
4611 const {
4612 navBlockClientId,
4613 lastNavBlockItemIndex
4614 } = use_navigation_editor_root_block();
4615 const {
4616 hasInserterItems,
4617 selectedBlockClientId
4618 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4619 var _select$getSelectedBl;
4620
4621 return {
4622 hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId),
4623 selectedBlockClientId: (_select$getSelectedBl = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlock()) === null || _select$getSelectedBl === void 0 ? void 0 : _select$getSelectedBl.clientId
4624 };
4625 }, [navBlockClientId]);
4626 const {
4627 setIsInserterOpened
4628 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4629 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
4630 onClose: () => setIsInserterOpened(false)
4631 }); // Only concerned with whether there are items to display. If not then
4632 // we shouldn't render.
4633
4634 if (!hasInserterItems) {
4635 return null;
4636 }
4637
4638 const shouldInsertInNavBlock = !selectedBlockClientId || navBlockClientId === selectedBlockClientId;
4639 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
4640 ref: inserterDialogRef
4641 }, inserterDialogProps, {
4642 className: "edit-navigation-layout__inserter-panel"
4643 }), (0,external_wp_element_namespaceObject.createElement)("div", {
4644 className: "edit-navigation-layout__inserter-panel-header"
4645 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4646 icon: library_close,
4647 onClick: () => setIsInserterOpened(false)
4648 })), (0,external_wp_element_namespaceObject.createElement)("div", {
4649 className: "edit-navigation-layout__inserter-panel-content"
4650 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary // If the root Nav block is selected then any items inserted by the
4651 // global inserter should append after the last nav item. Otherwise
4652 // simply allow default Gutenberg behaviour.
4653 , {
4654 rootClientId: shouldInsertInNavBlock ? navBlockClientId : undefined // If set, insertion will be into the block with this ID.
4655 ,
4656 __experimentalInsertionIndex: // If set, insertion will be into this explicit position.
4657 shouldInsertInNavBlock ? lastNavBlockItemIndex : undefined,
4658 shouldFocusBlock: isMobileViewport,
4659 showInserterHelpPanel: SHOW_PREVIEWS
4660 })));
4661 }
4662
4663 /* harmony default export */ var inserter_sidebar = (InserterSidebar);
4664 //# sourceMappingURL=index.js.map
4665 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unsaved-changes-warning.js
4666 /**
4667 * WordPress dependencies
4668 */
4669
4670
4671
4672
4673 /**
4674 * Warns the user if there are unsaved changes before leaving the editor.
4675 *
4676 * This is a duplicate of the component implemented in the editor package.
4677 * Duplicated here as edit-navigation doesn't depend on editor.
4678 *
4679 * @return {WPComponent} The component.
4680 */
4681
4682 function UnsavedChangesWarning() {
4683 const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => {
4684 const {
4685 __experimentalGetDirtyEntityRecords
4686 } = select(external_wp_coreData_namespaceObject.store);
4687
4688 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4689
4690 return dirtyEntityRecords.length > 0;
4691 }, []);
4692 (0,external_wp_element_namespaceObject.useEffect)(() => {
4693 /**
4694 * Warns the user if there are unsaved changes before leaving the editor.
4695 *
4696 * @param {Event} event `beforeunload` event.
4697 *
4698 * @return {?string} Warning prompt message, if unsaved changes exist.
4699 */
4700 const warnIfUnsavedChanges = event => {
4701 if (isDirty) {
4702 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
4703 return event.returnValue;
4704 }
4705 };
4706
4707 window.addEventListener('beforeunload', warnIfUnsavedChanges);
4708 return () => {
4709 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
4710 };
4711 }, [isDirty]);
4712 return null;
4713 }
4714 //# sourceMappingURL=unsaved-changes-warning.js.map
4715 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/index.js
4716
4717
4718 /**
4719 * WordPress dependencies
4720 */
4721
4722
4723
4724
4725
4726
4727
4728
4729 /**
4730 * Internal dependencies
4731 */
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745 const interfaceLabels = {
4746 /* translators: accessibility text for the navigation screen top bar landmark region. */
4747 header: (0,external_wp_i18n_namespaceObject.__)('Navigation top bar'),
4748
4749 /* translators: accessibility text for the navigation screen content landmark region. */
4750 body: (0,external_wp_i18n_namespaceObject.__)('Navigation menu blocks'),
4751
4752 /* translators: accessibility text for the navigation screen settings landmark region. */
4753 sidebar: (0,external_wp_i18n_namespaceObject.__)('Navigation settings'),
4754 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block library')
4755 };
4756 function Layout(_ref) {
4757 let {
4758 blockEditorSettings
4759 } = _ref;
4760 const contentAreaRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseBlockSelectionClearer)();
4761 const [isMenuNameControlFocused, setIsMenuNameControlFocused] = (0,external_wp_element_namespaceObject.useState)(false);
4762 const {
4763 saveNavigationPost
4764 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4765
4766 const savePost = () => saveNavigationPost(navigationPost);
4767
4768 const {
4769 menus,
4770 hasLoadedMenus,
4771 hasFinishedInitialLoad,
4772 selectedMenuId,
4773 navigationPost,
4774 isMenuBeingDeleted,
4775 selectMenu,
4776 deleteMenu,
4777 isMenuSelected
4778 } = useNavigationEditor();
4779 const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, {
4780 id: navigationPost === null || navigationPost === void 0 ? void 0 : navigationPost.id
4781 });
4782 const {
4783 hasSidebarEnabled,
4784 isInserterOpened
4785 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
4786 hasSidebarEnabled: !!select(store_store).getActiveComplementaryArea('core/edit-navigation'),
4787 isInserterOpened: select(store).isInserterOpened()
4788 }), []);
4789 (0,external_wp_element_namespaceObject.useEffect)(() => {
4790 if (!selectedMenuId && menus !== null && menus !== void 0 && menus.length) {
4791 selectMenu(menus[0].id);
4792 }
4793 }, [selectedMenuId, menus]);
4794 useMenuNotifications(selectedMenuId);
4795 const hasMenus = !!(menus !== null && menus !== void 0 && menus.length);
4796 const isBlockEditorReady = !!(hasMenus && navigationPost && isMenuSelected);
4797 return (0,external_wp_element_namespaceObject.createElement)(error_boundary, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4798 hidden: !isMenuBeingDeleted,
4799 className: 'edit-navigation-layout__overlay'
4800 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(shortcuts, {
4801 saveBlocks: savePost
4802 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
4803 value: blocks,
4804 onInput: onInput,
4805 onChange: onChange,
4806 settings: { ...blockEditorSettings,
4807 templateLock: 'all'
4808 },
4809 useSubRegistry: false
4810 }, (0,external_wp_element_namespaceObject.createElement)(IsMenuNameControlFocusedContext.Provider, {
4811 value: (0,external_wp_element_namespaceObject.useMemo)(() => [isMenuNameControlFocused, setIsMenuNameControlFocused], [isMenuNameControlFocused])
4812 }, (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
4813 className: "edit-navigation-layout",
4814 labels: interfaceLabels,
4815 header: (0,external_wp_element_namespaceObject.createElement)(Header, {
4816 isMenuSelected: isMenuSelected,
4817 isPending: !hasLoadedMenus,
4818 menus: menus,
4819 navigationPost: navigationPost
4820 }),
4821 content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(EditNavigationNotices, null), !hasFinishedInitialLoad && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), !isMenuSelected && hasFinishedInitialLoad && (0,external_wp_element_namespaceObject.createElement)(UnselectedMenuState, {
4822 onSelectMenu: selectMenu,
4823 onCreate: selectMenu,
4824 menus: menus
4825 }), isBlockEditorReady && (0,external_wp_element_namespaceObject.createElement)("div", {
4826 className: "edit-navigation-layout__content-area",
4827 ref: contentAreaRef
4828 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(Editor, {
4829 isPending: !hasLoadedMenus
4830 })))),
4831 sidebar: hasSidebarEnabled && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
4832 scope: "core/edit-navigation"
4833 }),
4834 secondarySidebar: isInserterOpened && (0,external_wp_element_namespaceObject.createElement)(inserter_sidebar, null)
4835 }), isMenuSelected && (0,external_wp_element_namespaceObject.createElement)(Sidebar, {
4836 menus: menus,
4837 menuId: selectedMenuId,
4838 onSelectMenu: selectMenu,
4839 onDeleteMenu: deleteMenu,
4840 isMenuBeingDeleted: isMenuBeingDeleted
4841 })), (0,external_wp_element_namespaceObject.createElement)(UnsavedChangesWarning, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null))));
4842 }
4843 //# sourceMappingURL=index.js.map
4844 ;// CONCATENATED MODULE: external ["wp","url"]
4845 var external_wp_url_namespaceObject = window["wp"]["url"];
4846 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/utils/index.js
4847 /**
4848 * WordPress dependencies
4849 */
4850
4851 /**
4852 * The purpose of this function is to create a middleware that is responsible for preloading menu-related data.
4853 * It uses data that is returned from the /wp/v2/menus endpoint for requests
4854 * to the /wp/v2/menu/<menuId> endpoint, because the data is the same.
4855 * This way, we can avoid making additional REST API requests.
4856 * This middleware can be removed if/when we implement caching at the wordpress/core-data level.
4857 *
4858 * @param {Object} preloadedData
4859 * @return {Function} Preloading middleware.
4860 */
4861
4862 function createMenuPreloadingMiddleware(preloadedData) {
4863 const cache = Object.keys(preloadedData).reduce((result, path) => {
4864 result[(0,external_wp_url_namespaceObject.normalizePath)(path)] = preloadedData[path];
4865 return result;
4866 },
4867 /** @type {Record<string, any>} */
4868 {});
4869 let menusDataLoaded = false;
4870 let menuDataLoaded = false;
4871 return (options, next) => {
4872 var _Object$keys, _cache$key;
4873
4874 const {
4875 parse = true
4876 } = options;
4877
4878 if ('string' !== typeof options.path) {
4879 return next(options);
4880 }
4881
4882 const method = options.method || 'GET';
4883
4884 if ('GET' !== method) {
4885 return next(options);
4886 }
4887
4888 const path = (0,external_wp_url_namespaceObject.normalizePath)(options.path);
4889
4890 if (!menusDataLoaded && cache[path]) {
4891 menusDataLoaded = true;
4892 return sendSuccessResponse(cache[path], parse);
4893 }
4894
4895 if (menuDataLoaded) {
4896 return next(options);
4897 }
4898
4899 const matches = path.match(/^\/wp\/v2\/menus\/(\d+)\?context=edit$/);
4900
4901 if (!matches) {
4902 return next(options);
4903 }
4904
4905 const key = (_Object$keys = Object.keys(cache)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
4906 const menuData = (_cache$key = cache[key]) === null || _cache$key === void 0 ? void 0 : _cache$key.body;
4907
4908 if (!menuData) {
4909 return next(options);
4910 }
4911
4912 const menuId = parseInt(matches[1]);
4913 const menu = menuData.filter(_ref => {
4914 let {
4915 id
4916 } = _ref;
4917 return id === menuId;
4918 });
4919
4920 if (menu.length > 0) {
4921 menuDataLoaded = true; // We don't have headers because we "emulate" this request
4922
4923 return sendSuccessResponse({
4924 body: menu[0],
4925 headers: {}
4926 }, parse);
4927 }
4928
4929 return next(options);
4930 };
4931 }
4932 /**
4933 * This is a helper function that sends a success response.
4934 *
4935 * @param {Object} responseData An object with the menu data
4936 * @param {boolean} parse A boolean that controls whether to send a response or just the response data
4937 * @return {Object} Resolved promise
4938 */
4939
4940 function sendSuccessResponse(responseData, parse) {
4941 return Promise.resolve(parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
4942 status: 200,
4943 statusText: 'OK',
4944 headers: responseData.headers
4945 }));
4946 }
4947 //# sourceMappingURL=index.js.map
4948 ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/index.js
4949
4950
4951 /**
4952 * WordPress dependencies
4953 */
4954
4955
4956
4957
4958
4959
4960 /**
4961 * Internal dependencies
4962 */
4963
4964
4965
4966
4967
4968
4969 function NavEditor(_ref) {
4970 let {
4971 settings
4972 } = _ref;
4973 const {
4974 setIsInserterOpened
4975 } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Allows the QuickInserter to toggle the sidebar inserter.
4976 // This is marked as experimental to give time for the quick inserter to mature.
4977
4978 const __experimentalSetIsInserterOpened = setIsInserterOpened; // Provide link suggestions handler to fetch search results for Link UI.
4979
4980 const __experimentalFetchLinkSuggestions = (search, searchOptions) => {
4981 // Bump the default number of suggestions.
4982 // See https://github.com/WordPress/gutenberg/issues/34283.
4983 searchOptions.perPage = 10;
4984 return (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings);
4985 };
4986
4987 const editorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => {
4988 return { ...settings,
4989 __experimentalFetchLinkSuggestions,
4990 __experimentalSetIsInserterOpened,
4991 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData
4992 };
4993 }, [settings, __experimentalFetchLinkSuggestions, __experimentalSetIsInserterOpened]);
4994 return (0,external_wp_element_namespaceObject.createElement)(Layout, {
4995 blockEditorSettings: editorSettings
4996 });
4997 }
4998 /**
4999 * Setup and registration of editor.
5000 *
5001 * @param {Object} settings blockEditor settings.
5002 */
5003
5004
5005 function setUpEditor(settings) {
5006 addFilters(!settings.blockNavMenus); // Set up the navigation post entity.
5007
5008 (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).addEntities([{
5009 kind: NAVIGATION_POST_KIND,
5010 name: NAVIGATION_POST_POST_TYPE,
5011 transientEdits: {
5012 blocks: true,
5013 selection: true
5014 },
5015 label: (0,external_wp_i18n_namespaceObject.__)('Navigation Post'),
5016 __experimentalNoFetch: true
5017 }]);
5018
5019 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
5020
5021 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
5022
5023 if (true) {
5024 (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)();
5025 }
5026 }
5027 /**
5028 * Initalise and render editor into DOM.
5029 *
5030 * @param {string} id ID of HTML element into which the editor will be rendered.
5031 * @param {Object} settings blockEditor settings.
5032 */
5033
5034
5035 function initialize(id, settings) {
5036 setUpEditor(settings);
5037 (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(NavEditor, {
5038 settings: settings
5039 }), document.getElementById(id));
5040 }
5041
5042 //# sourceMappingURL=index.js.map
5043 }();
5044 (window.wp = window.wp || {}).editNavigation = __webpack_exports__;
5045 /******/ })()
5046 ;