UNPKG

@vtex/admin-ui

Version:

> VTEX admin component library

41 lines (40 loc) 1.46 kB
import type { ReactNode } from 'react'; import type { CompositeStateReturn } from 'reakit/Composite'; import { useReducedState } from './useReducedState'; export declare function useSidebarState(): SidebarState; export interface Item { uniqueKey: string | number; expandable: boolean; } export interface SidebarState { /** Checks whether the state is reduced or not */ isReduced: () => boolean; /** Checks whether an item is selected or not */ isSelected: (item: string | number) => boolean; /** The selected item */ selectedItem: Item | null; /** Sets the selected item */ setSelectedItem: (newItem: Item | null) => void; /** Checks whether a sidebar item is expandable or not */ isExpandable: (children: ReactNode) => boolean; /** * Sidebar's layout controller interface. * See `useReducedState` for more information on this. */ layout: ReturnType<typeof useReducedState>; /** * Sidebar's root composite state. * This allows accessible navigation through the Sidebar. */ composite: CompositeStateReturn; /** * It stores the state of the current selected item, making possible to change the current state on item's hover * @private */ selectedItemFallback: Item | null; /** * Sets the selected item fallback * @private */ setSelectedItemFallback: (newItem: Item | null) => void; }