// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; /** * @file MenuBottomSheetActionList.tsx * @input Uses menu data entries and callbacks for selection and drill-in * @output Internal touch-friendly action list shared by DropdownMenu and ContextMenu * @position Shared implementation for menu bottom-sheet presentations */ import type { ReactElement } from 'react'; import * as stylex from "../style-runtime.js"; import { Divider } from "../Divider/index.js"; import { Heading } from "../Heading/index.js"; import { Icon, renderIconSlot } from "../Icon/index.js"; import { List, ListItem } from "../List/index.js"; import "../theme/tokens.stylex.js"; import { colorVars, spacingVars } from "../theme/tokens.stylex.js"; import { rtlStyles } from "../utils/index.js"; import { getInteractionModality } from "../utils/interactionModality.js"; import type { DropdownMenuItemData, DropdownMenuOption } from "./DropdownMenu.js"; const styles = { destructiveAction: { "--_item-label-color": "xufyqxy", "--_item-description-color": "xqlix59", kMwMTN: "xjt36v0", $$css: true as const }, divider: { kqGvvJ: "xsq74q5", $$css: true as const } }; function getItemKey(item: DropdownMenuItemData, index: number): string { return `item-${item.id ?? index}`; } export function MenuBottomSheetActionList({ items, onSelect, onOpenSubmenu }: { items: DropdownMenuOption[]; onSelect: (item: DropdownMenuItemData) => void; onOpenSubmenu: (item: DropdownMenuItemData) => void; }) { const renderItem = (item: DropdownMenuItemData, index: number): ReactElement => { const isSubmenu = item.items != null && item.items.length > 0; const isDestructive = item.variant === 'destructive'; return : item.endContent} isDisabled={item.isDisabled} onClick={event => { if (getInteractionModality() === 'pointer') { (event.currentTarget as HTMLElement).blur(); } if (isSubmenu) { onOpenSubmenu(item); } else { onSelect(item); } }} xstyle={isDestructive && styles.destructiveAction} />; }; return {items.map((option, index) => { if ('type' in option && option.type === 'divider') { return
  • ; } if ('type' in option && option.type === 'section') { return
  • {option.title && {option.title}} {option.items.map(renderItem)}
  • ; } return renderItem(option, index); })}
    ; } MenuBottomSheetActionList.displayName = 'MenuBottomSheetActionList';