import { Component } from 'vue'; import { PvAvatarShape, PvAvatarVariant } from './components/base/PvAvatar/types.ts'; import { PvCounterBadgeVariant } from './components/base/PvCounterBadge/types.ts'; import { PvSize } from './components/base/baseProps'; /** * For interfaces and type aliases shared across multiple components. */ export interface Option { value: string; label: string; } export interface OptionWithIcon extends Option { iconName: string; iconPosition: "left" | "right"; } type MenuActionResolver = { bivarianceHack(option: MenuOption): R; }["bivarianceHack"]; export interface MenuAction { icon: string | MenuActionResolver; isDisabled?: boolean | MenuActionResolver; tooltipText?: string | MenuActionResolver; action?: MenuActionResolver; alwaysShow?: boolean | MenuActionResolver; interactive?: boolean | MenuActionResolver; } export interface MenuOption { id: string; text: string; subText?: string; /** Value of the secondary text which appears on the menu item. Number shows up as a counter badge, string shows up as plain text */ secondaryText?: number | string; /** When true, a spinner takes the place of the secondary text. Takes precedence over secondaryIcon and secondaryText. */ secondaryLoading?: boolean; /** Icon rendered in place of the secondary text. Takes precedence over secondaryText. */ secondaryIcon?: string; subduedText?: string; icon?: string; hoverTitle?: string; /** Explanatory copy surfaced as an info-icon tooltip at the end of the menu item. */ description?: string; /** Optional Datadog RUM action name applied to the interactive menu item. */ rumActionName?: string; /** ARIA popup type for options with custom child content. Defaults to menu. */ popoverRole?: "menu" | "dialog"; companyName?: string; avatar?: { initials?: string; image?: string; icon?: boolean; variant?: PvAvatarVariant; shape?: PvAvatarShape; }; groupingLabel?: string; disabled?: boolean; context?: T; classList?: string[]; action?: MenuAction; searchText?: string; /** UTF-16 ranges overriding queryText highlighting for each line. */ textMatchRanges?: [number, number][]; subTextMatchRanges?: [number, number][]; children?: MenuOption[]; handleSeeMore?: (payload: SeeMoreEvent) => Promise[] | void> | MenuOption[] | void; totalChildCount?: number; defaultExpanded?: boolean; config?: MenuOptionConfig; } export interface MenuOptionConfig { renderer?: Component; action?: MenuAction; variant?: MenuOptionsVariant; disabledVariant?: MenuOptionsDisabledVariant; counterBadgeVariant?: PvCounterBadgeVariant; size?: Extract; /** * Wrap long text onto more lines instead of truncating it behind a hover title. * Use when the text is meant to be read in full, such as facility or provider names. * Avoid when space is tight or the text is secondary, such as codes or IDs. */ wrapText?: boolean; } export interface MenuOptionSelectedEvent { option: MenuOption; event: Event; } export interface SeeMoreEvent { parentId?: string; offset?: number; } export interface SelectionNode { id: string; state: "selected" | "deselected"; children?: SelectionNode[]; } export type MultiSelectState = SelectionNode[]; export declare enum MenuItemType { simple = "simple", checkbox = "checkbox", company = "company", avatar = "avatar", icon = "icon", radio = "radio", checkmark = "checkmark", toggle = "toggle" } export type MenuOptionsVariant = `${MenuItemType}`; export type MenuOptionsDisabledVariant = "default" | "ghost" | null; export {};