import * as React from 'react'; import { DrawerProps, PopupProps, QAProps } from '@gravity-ui/uikit'; import { RenderContentType } from '../Content'; import { LogoProps, MenuGroup, MenuItem, OpenModalSubscriber, TopAlertProps } from '../types'; import { AsideHeaderContextType } from './AsideHeaderContext'; import { AsideHeaderMenuDensity } from './density'; export interface PanelItemProps extends DrawerProps { id: string; } export interface LayoutProps { compact: boolean; /** Animate compact layout changes. @default true */ compactTransition?: boolean; className?: string; topAlert?: TopAlertProps; /** * Menu item density. `compact` reduces item height, icon size, spacing, and aside width * without changing navigation behavior. * @default 'default' */ menuDensity?: AsideHeaderMenuDensity; } interface EditMenuProps { onOpenEditMode?: () => void; onToggleMenuItem?: (changedItem: AsideHeaderItem) => void; onResetSettingsToDefault?: () => void; enableSorting?: boolean; onChangeItemsOrder?: (changedItem: AsideHeaderItem, oldIndex: number, newIndex: number) => void; /** * Fired when visibility of a menu group is toggled from the All pages panel (pin on group header). * Use with `onMenuGroupsChanged` / controlled `menuGroups`. */ onToggleMenuGroup?: (changedGroup: MenuGroup) => void; } /** * Menu overflow behavior for menu items. * - `collapse` — extra menu items collapse under a "More" popup (default). * - `scroll` — all menu items remain visible inside a scrollable column with a native thin scrollbar. * * The distinction applies to menu items only: quick access and the menu always share a single * scroll container that scrolls when the column does not fit the available height. In compact * mode menu items still fall back to `collapse` regardless of this value. */ export type AsideHeaderMenuOverflow = 'collapse' | 'scroll'; interface AsideHeaderGeneralProps extends QAProps { logo?: LogoProps; className?: string; collapseTitle?: string; expandTitle?: string; menuMoreTitle?: string; /** * @see AsideHeaderMenuOverflow * @default 'collapse' */ menuOverflow?: AsideHeaderMenuOverflow; topAlert?: TopAlertProps; customBackground?: React.ReactNode; customBackgroundClassName?: string; hideCollapseButton?: boolean; renderContent?: RenderContentType; renderFooter?: (data: { size: number; compact: boolean; asideRef: React.RefObject; }) => React.ReactNode; collapseButtonWrapper?: (defaultButton: React.ReactNode, data: { compact: boolean; onChangeCompact?: (compact: boolean) => void; }) => React.ReactNode; editMenuProps?: EditMenuProps; onClosePanel?: () => void; onChangeCompact?: (compact: boolean) => void; onMenuMoreClick?: () => void; onAllPagesClick?: () => void; openModalSubscriber?: (subscriber: OpenModalSubscriber) => void; aboveMenuContent?: React.ReactNode; } interface AsideHeaderDefaultProps { panelItems?: PanelItemProps[]; subheaderItems?: AsideHeaderItem[]; menuItems?: AsideHeaderItem[]; menuGroups?: MenuGroup[]; /** * Shows icons for child items in inline groups and group popups. * @default true */ menuGroupNestedIcons?: boolean; /** * Called only from **All pages** edit mode when the user toggles visibility of a **menu group** (group header pin), updating `menuGroup.hidden`. * Use with controlled `menuGroups`; not emitted for programmatic `menuGroups` changes outside All pages. */ onMenuGroupsChanged?: (menuGroups: MenuGroup[]) => void; defaultMenuItems?: AsideHeaderItem[]; onMenuItemsChanged?: (items: AsideHeaderItem[]) => void; /** * Enables the quick access section and pin controls for eligible leaf menu items. * The state remains controlled by `menuItems`; use `onQuickAccessChange` to update it. * @default false */ enableQuickAccess?: boolean; /** * Keeps the active item highlighted in the main menu when the same item is also * rendered in quick access. * @default false */ quickAccessHighlightInMainMenu?: boolean; /** * Called when a user pins or unpins an eligible leaf item. The library does not * mutate `menuItems`; the consumer should provide the updated controlled value. */ onQuickAccessChange?: (item: AsideHeaderItem, quickAccess: boolean) => void; headerDecoration?: boolean; /** Hides header/footer separators and their spacing; scroll-edge indicators remain visible * while content is hidden beyond the respective edge. @default false */ hideSectionDividers?: boolean; /** * When provided, the map is the source of truth for which menu groups are collapsed * in inline (`menuOverflow: 'scroll'`) layout. Keys are `MenuGroup.id`, values mean collapsed. */ collapsedMenuGroupIds?: Record; /** * Initial collapsed state for groups when `collapsedMenuGroupIds` is not controlled. */ defaultCollapsedMenuGroupIds?: Record; /** * Called when the user toggles a group in inline layout. The parent should update * `collapsedMenuGroupIds` when using controlled mode. */ onToggleMenuGroupCollapsed?: (groupId: string) => void; } export type AsideHeaderInnerProps = AsideHeaderGeneralProps & AsideHeaderDefaultProps & AsideHeaderContextType; export interface AsideHeaderProps extends AsideHeaderGeneralProps, LayoutProps, Partial { } export declare enum InnerPanels { AllPages = "all-pages" } /** Menu item id for the All pages row (same value as {@link InnerPanels.AllPages}). */ export declare const ALL_PAGES_ID = InnerPanels.AllPages; export interface AsideHeaderItem extends MenuItem { /** * Shows an eligible leaf item in the quick access section when quick access is enabled. */ quickAccess?: boolean; enableTooltip?: boolean; onItemClick?: (item: AsideHeaderItem, collapsed: boolean, event: React.MouseEvent) => void; bringForward?: boolean; compact?: boolean; /** * @deprecated Use itemWrapper instead for popup functionality */ popupVisible?: PopupProps['open']; /** * Floating element anchor ref object * * @deprecated Use itemWrapper instead for popup functionality */ popupRef?: React.RefObject; /** * @deprecated Use itemWrapper instead for popup functionality */ popupPlacement?: PopupProps['placement']; /** * @deprecated Use itemWrapper instead for popup functionality */ popupOffset?: PopupProps['offset']; /** * @deprecated Use itemWrapper instead for popup functionality */ popupKeepMounted?: PopupProps['keepMounted']; /** * @deprecated Use itemWrapper instead for popup functionality */ renderPopupContent?: () => React.ReactNode; /** * This callback will be called when Escape key pressed on keyboard, or click outside was made * This behaviour could be disabled with `disableEscapeKeyDown` * and `disableOutsideClick` options * * @deprecated Use itemWrapper instead for popup functionality */ onOpenChangePopup?: PopupProps['onOpenChange']; } export {};