import * as React from 'react' import { SubMenu, DropdownMenu } from '@planview/pv-uikit' import type { DropdownTriggerProps, DropdownMenuProps, ButtonProps, } from '@planview/pv-uikit' import type { IconProps } from '@planview/pv-icons' import { ToolbarItem, ToolbarItemCollapsedView, ToolbarItemView, } from '../wrapper' import { WrappingParentContext } from '../utils/context' import type { DisplayOnType } from '../utils' import { DISPLAY_ON_TABLET_PORTRAIT } from '../utils' import type { ToolbarButtonProps } from '../button' import { ToolbarButtonEmpty } from '../button' type TriggerConfig = Omit< ToolbarButtonProps, | 'aria-haspopup' | 'aria-controls' | 'aria-expanded' | 'aria-disabled' | 'children' > & { /** Label of trigger */ label?: string | number /** If button should take up full width of parent container */ fluid?: boolean /** * Element type to render. This needs to be a react component that extends ButtonProps */ elementType?: React.ForwardRefExoticComponent< ToolbarButtonProps & React.RefAttributes > } export type ToolbarDropdownMenuProps = Omit< DropdownMenuProps, 'children' | 'trigger' > & { /** Label when dropdown is rendered as accordion in more menu */ label: string /** Icon when dropdown is rendered as accordion in more menu */ icon?: React.ReactElement /** Must be one or more of the allowed ListItem types */ children: React.ReactNode | React.ReactNode[] /** * Target display of this item. Choose 'phone' to prevent collapsing. */ displayOn?: DisplayOnType /** * Trigger of the dropdown. Union of TriggerConfig and function to return React.JSX.Element **/ trigger: | TriggerConfig | (( props: DropdownTriggerProps ) => React.ReactElement) } type DropdownTriggerElementInternal = React.ForwardRefExoticComponent< ButtonProps & React.RefAttributes > /** * * `import { ToolbarDropdownMenu } from '@planview/pv-toolbar'` * */ export const ToolbarDropdownMenu = React.memo( ({ children, displayOn = DISPLAY_ON_TABLET_PORTRAIT, trigger, ...props }: ToolbarDropdownMenuProps) => ( {() => ( {children} )} {children} ) ) ToolbarDropdownMenu.displayName = 'ToolbarDropdownMenu'