UNPKG

@wordpress/block-library

Version:
699 lines (686 loc) 30.1 kB
/** * External dependencies */ import clsx from 'clsx'; /** * WordPress dependencies */ import { useCallback, useState, useEffect, useRef, Platform } from '@wordpress/element'; import { InspectorControls, useBlockProps, RecursionProvider, useHasRecursion, store as blockEditorStore, withColors, ContrastChecker, getColorClassName, Warning, __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown, __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients, useBlockEditingMode } from '@wordpress/block-editor'; import { EntityProvider, store as coreStore } from '@wordpress/core-data'; import { useDispatch, useSelect } from '@wordpress/data'; import { __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalVStack as VStack, ToggleControl, Button, Spinner, Notice } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { speak } from '@wordpress/a11y'; import { close, Icon } from '@wordpress/icons'; import { useInstanceId } from '@wordpress/compose'; /** * Internal dependencies */ import useNavigationMenu from '../use-navigation-menu'; import useNavigationEntities from '../use-navigation-entities'; import Placeholder from './placeholder'; import ResponsiveWrapper from './responsive-wrapper'; import NavigationInnerBlocks from './inner-blocks'; import NavigationMenuNameControl from './navigation-menu-name-control'; import UnsavedInnerBlocks from './unsaved-inner-blocks'; import NavigationMenuDeleteControl from './navigation-menu-delete-control'; import useNavigationNotice from './use-navigation-notice'; import OverlayMenuIcon from './overlay-menu-icon'; import OverlayMenuPreview from './overlay-menu-preview'; import useConvertClassicToBlockMenu, { CLASSIC_MENU_CONVERSION_ERROR, CLASSIC_MENU_CONVERSION_PENDING, CLASSIC_MENU_CONVERSION_SUCCESS } from './use-convert-classic-menu-to-block-menu'; import useCreateNavigationMenu from './use-create-navigation-menu'; import { useInnerBlocks } from './use-inner-blocks'; import { detectColors } from './utils'; import ManageMenusButton from './manage-menus-button'; import MenuInspectorControls from './menu-inspector-controls'; import DeletedNavigationWarning from './deleted-navigation-warning'; import AccessibleDescription from './accessible-description'; import AccessibleMenuDescription from './accessible-menu-description'; import { unlock } from '../../lock-unlock'; import { useToolsPanelDropdownMenuProps } from '../../utils/hooks'; import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; function ColorTools({ textColor, setTextColor, backgroundColor, setBackgroundColor, overlayTextColor, setOverlayTextColor, overlayBackgroundColor, setOverlayBackgroundColor, clientId, navRef }) { const [detectedBackgroundColor, setDetectedBackgroundColor] = useState(); const [detectedColor, setDetectedColor] = useState(); const [detectedOverlayBackgroundColor, setDetectedOverlayBackgroundColor] = useState(); const [detectedOverlayColor, setDetectedOverlayColor] = useState(); // Turn on contrast checker for web only since it's not supported on mobile yet. const enableContrastChecking = Platform.OS === 'web'; useEffect(() => { if (!enableContrastChecking) { return; } detectColors(navRef.current, setDetectedColor, setDetectedBackgroundColor); const subMenuElement = navRef.current?.querySelector('[data-type="core/navigation-submenu"] [data-type="core/navigation-link"]'); if (!subMenuElement) { return; } // Only detect submenu overlay colors if they have previously been explicitly set. // This avoids the contrast checker from reporting on inherited submenu colors and // showing the contrast warning twice. if (overlayTextColor.color || overlayBackgroundColor.color) { detectColors(subMenuElement, setDetectedOverlayColor, setDetectedOverlayBackgroundColor); } }, [enableContrastChecking, overlayTextColor.color, overlayBackgroundColor.color, navRef]); const colorGradientSettings = useMultipleOriginColorsAndGradients(); if (!colorGradientSettings.hasColorsOrGradients) { return null; } return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(ColorGradientSettingsDropdown, { __experimentalIsRenderedInSidebar: true, settings: [{ colorValue: textColor.color, label: __('Text'), onColorChange: setTextColor, resetAllFilter: () => setTextColor(), clearable: true, enableAlpha: true }, { colorValue: backgroundColor.color, label: __('Background'), onColorChange: setBackgroundColor, resetAllFilter: () => setBackgroundColor(), clearable: true, enableAlpha: true }, { colorValue: overlayTextColor.color, label: __('Submenu & overlay text'), onColorChange: setOverlayTextColor, resetAllFilter: () => setOverlayTextColor(), clearable: true, enableAlpha: true }, { colorValue: overlayBackgroundColor.color, label: __('Submenu & overlay background'), onColorChange: setOverlayBackgroundColor, resetAllFilter: () => setOverlayBackgroundColor(), clearable: true, enableAlpha: true }], panelId: clientId, ...colorGradientSettings, gradients: [], disableCustomGradients: true }), enableContrastChecking && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(ContrastChecker, { backgroundColor: detectedBackgroundColor, textColor: detectedColor }), /*#__PURE__*/_jsx(ContrastChecker, { backgroundColor: detectedOverlayBackgroundColor, textColor: detectedOverlayColor })] })] }); } function Navigation({ attributes, setAttributes, clientId, isSelected, className, backgroundColor, setBackgroundColor, textColor, setTextColor, overlayBackgroundColor, setOverlayBackgroundColor, overlayTextColor, setOverlayTextColor, // These props are used by the navigation editor to override specific // navigation block settings. hasSubmenuIndicatorSetting = true, customPlaceholder: CustomPlaceholder = null, __unstableLayoutClassNames: layoutClassNames }) { const { openSubmenusOnClick, overlayMenu, showSubmenuIcon, templateLock, layout: { justifyContent, orientation = 'horizontal', flexWrap = 'wrap' } = {}, hasIcon, icon = 'handle' } = attributes; const ref = attributes.ref; const setRef = useCallback(postId => { setAttributes({ ref: postId }); }, [setAttributes]); const recursionId = `navigationMenu/${ref}`; const hasAlreadyRendered = useHasRecursion(recursionId); const blockEditingMode = useBlockEditingMode(); // Preload classic menus, so that they don't suddenly pop-in when viewing // the Select Menu dropdown. const { menus: classicMenus } = useNavigationEntities(); const [showNavigationMenuStatusNotice, hideNavigationMenuStatusNotice] = useNavigationNotice({ name: 'block-library/core/navigation/status' }); const [showClassicMenuConversionNotice, hideClassicMenuConversionNotice] = useNavigationNotice({ name: 'block-library/core/navigation/classic-menu-conversion' }); const [showNavigationMenuPermissionsNotice, hideNavigationMenuPermissionsNotice] = useNavigationNotice({ name: 'block-library/core/navigation/permissions/update' }); const { create: createNavigationMenu, status: createNavigationMenuStatus, error: createNavigationMenuError, value: createNavigationMenuPost, isPending: isCreatingNavigationMenu, isSuccess: createNavigationMenuIsSuccess, isError: createNavigationMenuIsError } = useCreateNavigationMenu(clientId); const createUntitledEmptyNavigationMenu = async () => { await createNavigationMenu(''); }; const { hasUncontrolledInnerBlocks, uncontrolledInnerBlocks, isInnerBlockSelected, innerBlocks } = useInnerBlocks(clientId); const hasSubmenus = !!innerBlocks.find(block => block.name === 'core/navigation-submenu'); const { replaceInnerBlocks, selectBlock, __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore); const [isResponsiveMenuOpen, setResponsiveMenuVisibility] = useState(false); const [overlayMenuPreview, setOverlayMenuPreview] = useState(false); const { hasResolvedNavigationMenus, isNavigationMenuResolved, isNavigationMenuMissing, canUserUpdateNavigationMenu, hasResolvedCanUserUpdateNavigationMenu, canUserDeleteNavigationMenu, hasResolvedCanUserDeleteNavigationMenu, canUserCreateNavigationMenus, isResolvingCanUserCreateNavigationMenus, hasResolvedCanUserCreateNavigationMenus } = useNavigationMenu(ref); const navMenuResolvedButMissing = hasResolvedNavigationMenus && isNavigationMenuMissing; const { convert: convertClassicMenu, status: classicMenuConversionStatus, error: classicMenuConversionError } = useConvertClassicToBlockMenu(createNavigationMenu); const isConvertingClassicMenu = classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING; const handleUpdateMenu = useCallback((menuId, options = { focusNavigationBlock: false }) => { const { focusNavigationBlock } = options; setRef(menuId); if (focusNavigationBlock) { selectBlock(clientId); } }, [selectBlock, clientId, setRef]); const isEntityAvailable = !isNavigationMenuMissing && isNavigationMenuResolved; // If the block has inner blocks, but no menu id, then these blocks are either: // - inserted via a pattern. // - inserted directly via Code View (or otherwise). // - from an older version of navigation block added before the block used a wp_navigation entity. // Consider this state as 'unsaved' and offer an uncontrolled version of inner blocks, // that automatically saves the menu as an entity when changes are made to the inner blocks. const hasUnsavedBlocks = hasUncontrolledInnerBlocks && !isEntityAvailable; const { getNavigationFallbackId } = unlock(useSelect(coreStore)); const navigationFallbackId = !(ref || hasUnsavedBlocks) ? getNavigationFallbackId() : null; useEffect(() => { // If: // - there is an existing menu, OR // - there are existing (uncontrolled) inner blocks // ...then don't request a fallback menu. if (ref || hasUnsavedBlocks || !navigationFallbackId) { return; } /** * This fallback displays (both in editor and on front) * The fallback should not request a save (entity dirty state) * nor to be undoable, hence why it is marked as non persistent */ __unstableMarkNextChangeAsNotPersistent(); setRef(navigationFallbackId); }, [ref, setRef, hasUnsavedBlocks, navigationFallbackId, __unstableMarkNextChangeAsNotPersistent]); const navRef = useRef(); // The standard HTML5 tag for the block wrapper. const TagName = 'nav'; // "placeholder" shown if: // - there is no ref attribute pointing to a Navigation Post. // - there is no classic menu conversion process in progress. // - there is no menu creation process in progress. // - there are no uncontrolled blocks. const isPlaceholder = !ref && !isCreatingNavigationMenu && !isConvertingClassicMenu && hasResolvedNavigationMenus && classicMenus?.length === 0 && !hasUncontrolledInnerBlocks; // "loading" state: // - there is a menu creation process in progress. // - there is a classic menu conversion process in progress. // OR: // - there is a ref attribute pointing to a Navigation Post // - the Navigation Post isn't available (hasn't resolved) yet. const isLoading = !hasResolvedNavigationMenus || isCreatingNavigationMenu || isConvertingClassicMenu || !!(ref && !isEntityAvailable && !isConvertingClassicMenu); const textDecoration = attributes.style?.typography?.textDecoration; const hasBlockOverlay = useSelect(select => select(blockEditorStore).__unstableHasActiveBlockOverlayActive(clientId), [clientId]); const isResponsive = 'never' !== overlayMenu; const blockProps = useBlockProps({ ref: navRef, className: clsx(className, { 'items-justified-right': justifyContent === 'right', 'items-justified-space-between': justifyContent === 'space-between', 'items-justified-left': justifyContent === 'left', 'items-justified-center': justifyContent === 'center', 'is-vertical': orientation === 'vertical', 'no-wrap': flexWrap === 'nowrap', 'is-responsive': isResponsive, 'has-text-color': !!textColor.color || !!textColor?.class, [getColorClassName('color', textColor?.slug)]: !!textColor?.slug, 'has-background': !!backgroundColor.color || backgroundColor.class, [getColorClassName('background-color', backgroundColor?.slug)]: !!backgroundColor?.slug, [`has-text-decoration-${textDecoration}`]: textDecoration, 'block-editor-block-content-overlay': hasBlockOverlay }, layoutClassNames), style: { color: !textColor?.slug && textColor?.color, backgroundColor: !backgroundColor?.slug && backgroundColor?.color } }); const onSelectClassicMenu = async classicMenu => { return convertClassicMenu(classicMenu.id, classicMenu.name, 'draft'); }; const onSelectNavigationMenu = menuId => { handleUpdateMenu(menuId); }; useEffect(() => { hideNavigationMenuStatusNotice(); if (isCreatingNavigationMenu) { speak(__(`Creating Navigation Menu.`)); } if (createNavigationMenuIsSuccess) { handleUpdateMenu(createNavigationMenuPost?.id, { focusNavigationBlock: true }); showNavigationMenuStatusNotice(__(`Navigation Menu successfully created.`)); } if (createNavigationMenuIsError) { showNavigationMenuStatusNotice(__('Failed to create Navigation Menu.')); } }, [createNavigationMenuStatus, createNavigationMenuError, createNavigationMenuPost?.id, createNavigationMenuIsError, createNavigationMenuIsSuccess, isCreatingNavigationMenu, handleUpdateMenu, hideNavigationMenuStatusNotice, showNavigationMenuStatusNotice]); useEffect(() => { hideClassicMenuConversionNotice(); if (classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING) { speak(__('Classic menu importing.')); } if (classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_SUCCESS) { showClassicMenuConversionNotice(__('Classic menu imported successfully.')); handleUpdateMenu(createNavigationMenuPost?.id, { focusNavigationBlock: true }); } if (classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_ERROR) { showClassicMenuConversionNotice(__('Classic menu import failed.')); } }, [classicMenuConversionStatus, classicMenuConversionError, hideClassicMenuConversionNotice, showClassicMenuConversionNotice, createNavigationMenuPost?.id, handleUpdateMenu]); useEffect(() => { if (!isSelected && !isInnerBlockSelected) { hideNavigationMenuPermissionsNotice(); } if (isSelected || isInnerBlockSelected) { if (ref && !navMenuResolvedButMissing && hasResolvedCanUserUpdateNavigationMenu && !canUserUpdateNavigationMenu) { showNavigationMenuPermissionsNotice(__('You do not have permission to edit this Menu. Any changes made will not be saved.')); } if (!ref && hasResolvedCanUserCreateNavigationMenus && !canUserCreateNavigationMenus) { showNavigationMenuPermissionsNotice(__('You do not have permission to create Navigation Menus.')); } } }, [isSelected, isInnerBlockSelected, canUserUpdateNavigationMenu, hasResolvedCanUserUpdateNavigationMenu, canUserCreateNavigationMenus, hasResolvedCanUserCreateNavigationMenus, ref, hideNavigationMenuPermissionsNotice, showNavigationMenuPermissionsNotice, navMenuResolvedButMissing]); const hasManagePermissions = canUserCreateNavigationMenus || canUserUpdateNavigationMenu; const overlayMenuPreviewClasses = clsx('wp-block-navigation__overlay-menu-preview', { open: overlayMenuPreview }); const submenuAccessibilityNotice = !showSubmenuIcon && !openSubmenusOnClick ? __('The current menu options offer reduced accessibility for users and are not recommended. Enabling either "Open on Click" or "Show arrow" offers enhanced accessibility by allowing keyboard users to browse submenus selectively.') : ''; const isFirstRender = useRef(true); // Don't speak on first render. useEffect(() => { if (!isFirstRender.current && submenuAccessibilityNotice) { speak(submenuAccessibilityNotice); } isFirstRender.current = false; }, [submenuAccessibilityNotice]); const overlayMenuPreviewId = useInstanceId(OverlayMenuPreview, `overlay-menu-preview`); const dropdownMenuProps = useToolsPanelDropdownMenuProps(); const stylingInspectorControls = /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(InspectorControls, { children: hasSubmenuIndicatorSetting && /*#__PURE__*/_jsxs(ToolsPanel, { label: __('Display'), resetAll: () => { setAttributes({ showSubmenuIcon: true, openSubmenusOnClick: false, overlayMenu: 'mobile', hasIcon: true, icon: 'handle' }); }, dropdownMenuProps: dropdownMenuProps, children: [isResponsive && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsxs(Button, { __next40pxDefaultSize: true, className: overlayMenuPreviewClasses, onClick: () => { setOverlayMenuPreview(!overlayMenuPreview); }, "aria-label": __('Overlay menu controls'), "aria-controls": overlayMenuPreviewId, "aria-expanded": overlayMenuPreview, children: [hasIcon && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(OverlayMenuIcon, { icon: icon }), /*#__PURE__*/_jsx(Icon, { icon: close })] }), !hasIcon && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx("span", { children: __('Menu') }), /*#__PURE__*/_jsx("span", { children: __('Close') })] })] }), overlayMenuPreview && /*#__PURE__*/_jsx(VStack, { id: overlayMenuPreviewId, spacing: 4, style: { gridColumn: 'span 2' }, children: /*#__PURE__*/_jsx(OverlayMenuPreview, { setAttributes: setAttributes, hasIcon: hasIcon, icon: icon, hidden: !overlayMenuPreview }) })] }), /*#__PURE__*/_jsx(ToolsPanelItem, { hasValue: () => overlayMenu !== 'mobile', label: __('Overlay Menu'), onDeselect: () => setAttributes({ overlayMenu: 'mobile' }), isShownByDefault: true, children: /*#__PURE__*/_jsxs(ToggleGroupControl, { __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: __('Overlay Menu'), "aria-label": __('Configure overlay menu'), value: overlayMenu, help: __('Collapses the navigation options in a menu icon opening an overlay.'), onChange: value => setAttributes({ overlayMenu: value }), isBlock: true, children: [/*#__PURE__*/_jsx(ToggleGroupControlOption, { value: "never", label: __('Off') }), /*#__PURE__*/_jsx(ToggleGroupControlOption, { value: "mobile", label: __('Mobile') }), /*#__PURE__*/_jsx(ToggleGroupControlOption, { value: "always", label: __('Always') })] }) }), hasSubmenus && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx("h3", { className: "wp-block-navigation__submenu-header", children: __('Submenus') }), /*#__PURE__*/_jsx(ToolsPanelItem, { hasValue: () => openSubmenusOnClick, label: __('Open on click'), onDeselect: () => setAttributes({ openSubmenusOnClick: false, showSubmenuIcon: true }), isShownByDefault: true, children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, checked: openSubmenusOnClick, onChange: value => { setAttributes({ openSubmenusOnClick: value, ...(value && { showSubmenuIcon: true }) // Make sure arrows are shown when we toggle this on. }); }, label: __('Open on click') }) }), /*#__PURE__*/_jsx(ToolsPanelItem, { hasValue: () => !showSubmenuIcon, label: __('Show arrow'), onDeselect: () => setAttributes({ showSubmenuIcon: true }), isDisabled: attributes.openSubmenusOnClick, isShownByDefault: true, children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, checked: showSubmenuIcon, onChange: value => { setAttributes({ showSubmenuIcon: value }); }, disabled: attributes.openSubmenusOnClick, label: __('Show arrow') }) }), submenuAccessibilityNotice && /*#__PURE__*/_jsx(Notice, { spokenMessage: null, status: "warning", isDismissible: false, className: "wp-block-navigation__submenu-accessibility-notice", children: submenuAccessibilityNotice })] })] }) }), /*#__PURE__*/_jsx(InspectorControls, { group: "color", children: /*#__PURE__*/_jsx(ColorTools, { textColor: textColor, setTextColor: setTextColor, backgroundColor: backgroundColor, setBackgroundColor: setBackgroundColor, overlayTextColor: overlayTextColor, setOverlayTextColor: setOverlayTextColor, overlayBackgroundColor: overlayBackgroundColor, setOverlayBackgroundColor: setOverlayBackgroundColor, clientId: clientId, navRef: navRef }) })] }); const accessibleDescriptionId = `${clientId}-desc`; const isHiddenByDefault = 'always' === overlayMenu; const isManageMenusButtonDisabled = !hasManagePermissions || !hasResolvedNavigationMenus; if (hasUnsavedBlocks && !isCreatingNavigationMenu) { return /*#__PURE__*/_jsxs(TagName, { ...blockProps, "aria-describedby": !isPlaceholder ? accessibleDescriptionId : undefined, children: [/*#__PURE__*/_jsx(AccessibleDescription, { id: accessibleDescriptionId, children: __('Unsaved Navigation Menu.') }), /*#__PURE__*/_jsx(MenuInspectorControls, { clientId: clientId, createNavigationMenuIsSuccess: createNavigationMenuIsSuccess, createNavigationMenuIsError: createNavigationMenuIsError, currentMenuId: ref, isNavigationMenuMissing: isNavigationMenuMissing, isManageMenusButtonDisabled: isManageMenusButtonDisabled, onCreateNew: createUntitledEmptyNavigationMenu, onSelectClassicMenu: onSelectClassicMenu, onSelectNavigationMenu: onSelectNavigationMenu, isLoading: isLoading, blockEditingMode: blockEditingMode }), blockEditingMode === 'default' && stylingInspectorControls, /*#__PURE__*/_jsx(ResponsiveWrapper, { id: clientId, onToggle: setResponsiveMenuVisibility, isOpen: isResponsiveMenuOpen, hasIcon: hasIcon, icon: icon, isResponsive: isResponsive, isHiddenByDefault: isHiddenByDefault, overlayBackgroundColor: overlayBackgroundColor, overlayTextColor: overlayTextColor, children: /*#__PURE__*/_jsx(UnsavedInnerBlocks, { createNavigationMenu: createNavigationMenu, blocks: uncontrolledInnerBlocks, hasSelection: isSelected || isInnerBlockSelected }) })] }); } // Show a warning if the selected menu is no longer available. // TODO - the user should be able to select a new one? if (ref && isNavigationMenuMissing) { return /*#__PURE__*/_jsxs(TagName, { ...blockProps, children: [/*#__PURE__*/_jsx(MenuInspectorControls, { clientId: clientId, createNavigationMenuIsSuccess: createNavigationMenuIsSuccess, createNavigationMenuIsError: createNavigationMenuIsError, currentMenuId: ref, isNavigationMenuMissing: isNavigationMenuMissing, isManageMenusButtonDisabled: isManageMenusButtonDisabled, onCreateNew: createUntitledEmptyNavigationMenu, onSelectClassicMenu: onSelectClassicMenu, onSelectNavigationMenu: onSelectNavigationMenu, isLoading: isLoading, blockEditingMode: blockEditingMode }), /*#__PURE__*/_jsx(DeletedNavigationWarning, { onCreateNew: createUntitledEmptyNavigationMenu })] }); } if (isEntityAvailable && hasAlreadyRendered) { return /*#__PURE__*/_jsx("div", { ...blockProps, children: /*#__PURE__*/_jsx(Warning, { children: __('Block cannot be rendered inside itself.') }) }); } const PlaceholderComponent = CustomPlaceholder ? CustomPlaceholder : Placeholder; /** * Historically the navigation block has supported custom placeholders. * Even though the current UX tries as hard as possible not to * end up in a placeholder state, the block continues to support * this extensibility point, via a CustomPlaceholder. * When CustomPlaceholder is present it becomes the default fallback * for an empty navigation block, instead of the default fallbacks. * */ if (isPlaceholder && CustomPlaceholder) { return /*#__PURE__*/_jsx(TagName, { ...blockProps, children: /*#__PURE__*/_jsx(PlaceholderComponent, { isSelected: isSelected, currentMenuId: ref, clientId: clientId, canUserCreateNavigationMenus: canUserCreateNavigationMenus, isResolvingCanUserCreateNavigationMenus: isResolvingCanUserCreateNavigationMenus, onSelectNavigationMenu: onSelectNavigationMenu, onSelectClassicMenu: onSelectClassicMenu, onCreateEmpty: createUntitledEmptyNavigationMenu }) }); } return /*#__PURE__*/_jsx(EntityProvider, { kind: "postType", type: "wp_navigation", id: ref, children: /*#__PURE__*/_jsxs(RecursionProvider, { uniqueId: recursionId, children: [/*#__PURE__*/_jsx(MenuInspectorControls, { clientId: clientId, createNavigationMenuIsSuccess: createNavigationMenuIsSuccess, createNavigationMenuIsError: createNavigationMenuIsError, currentMenuId: ref, isNavigationMenuMissing: isNavigationMenuMissing, isManageMenusButtonDisabled: isManageMenusButtonDisabled, onCreateNew: createUntitledEmptyNavigationMenu, onSelectClassicMenu: onSelectClassicMenu, onSelectNavigationMenu: onSelectNavigationMenu, isLoading: isLoading, blockEditingMode: blockEditingMode }), blockEditingMode === 'default' && stylingInspectorControls, blockEditingMode === 'default' && isEntityAvailable && /*#__PURE__*/_jsxs(InspectorControls, { group: "advanced", children: [hasResolvedCanUserUpdateNavigationMenu && canUserUpdateNavigationMenu && /*#__PURE__*/_jsx(NavigationMenuNameControl, {}), hasResolvedCanUserDeleteNavigationMenu && canUserDeleteNavigationMenu && /*#__PURE__*/_jsx(NavigationMenuDeleteControl, { onDelete: () => { replaceInnerBlocks(clientId, []); showNavigationMenuStatusNotice(__('Navigation Menu successfully deleted.')); } }), /*#__PURE__*/_jsx(ManageMenusButton, { disabled: isManageMenusButtonDisabled, className: "wp-block-navigation-manage-menus-button" })] }), /*#__PURE__*/_jsxs(TagName, { ...blockProps, "aria-describedby": !isPlaceholder && !isLoading ? accessibleDescriptionId : undefined, children: [isLoading && !isHiddenByDefault && /*#__PURE__*/_jsx("div", { className: "wp-block-navigation__loading-indicator-container", children: /*#__PURE__*/_jsx(Spinner, { className: "wp-block-navigation__loading-indicator" }) }), (!isLoading || isHiddenByDefault) && /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(AccessibleMenuDescription, { id: accessibleDescriptionId }), /*#__PURE__*/_jsx(ResponsiveWrapper, { id: clientId, onToggle: setResponsiveMenuVisibility, hasIcon: hasIcon, icon: icon, isOpen: isResponsiveMenuOpen, isResponsive: isResponsive, isHiddenByDefault: isHiddenByDefault, overlayBackgroundColor: overlayBackgroundColor, overlayTextColor: overlayTextColor, children: isEntityAvailable && /*#__PURE__*/_jsx(NavigationInnerBlocks, { clientId: clientId, hasCustomPlaceholder: !!CustomPlaceholder, templateLock: templateLock, orientation: orientation }) })] })] })] }) }); } export default withColors({ textColor: 'color' }, { backgroundColor: 'color' }, { overlayBackgroundColor: 'color' }, { overlayTextColor: 'color' })(Navigation); //# sourceMappingURL=index.js.map