/* * The MIT License (MIT) * * Copyright (c) 2015 - present Instructure, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import React from 'react' import type { WithDeterministicIdProps } from '@instructure/ui-react-utils' import type { WithStyleProps, ComponentStyle } from '@instructure/emotion' import type { TopNavBarMenuItemsTheme, OtherHTMLAttributes, ChildrenOfType } from '@instructure/shared-types' import type { ItemChild } from '../TopNavBarItem/props' import { TopNavBarMenuItems } from './index' type MenuItemsChild = React.ComponentElement< TopNavBarMenuItemsProps, TopNavBarMenuItems > type TopNavBarMenuItemsOwnProps = { /** * Children of type: ``. * * In __desktop__ mode the items are listed on the navbar. See `renderHiddenItemsMenuTriggerLabel` prop description for overflow logic. * * In __smallViewport__ mode the items are accessible under the main "hamburger" menu. */ children?: ChildrenOfType /** * The `id` of the link to the current page. Marks the item by setting `aria-current="page"` attribute on it and setting its status to 'active'. * * (Note: only non-disabled, `variant="default"` items can be set to current/active.) */ currentPageId?: string /** * In __desktop__ mode, required label for the trigger item of the hidden list items menu. * * When there is not enough room to list all the menu items, * they will be accessible via a dropdown menu at the end of the list. */ renderHiddenItemsMenuTriggerLabel: ( hiddenChildrenCount: number ) => React.ReactNode /** * The screenreader label (`aria-label`) used for the overflow dropdown button. * By default, screenreaders will read the button text (e.g. "4 More"), but * this is usually not descriptive enough for screenreader users. One should * specify a more descriptive label for the button, such as "4 more menu items". */ renderHiddenItemsMenuTriggerAriaLabel?: ( hiddenChildrenCount: number ) => string /** * In __desktop__ mode, 'aria-label' for the `