# All files / src/menu Menu.tsx

98.65% Statements 587/595
93.22% Branches 55/59
100% Functions 10/10
98.65% Lines 587/595

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    5961x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    62x
    62x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    3x
    3x
    3x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    29x
    29x
    29x
    29x
    29x
    4x
    4x
    25x
    25x
    29x
    4x
    4x
    4x
    4x
    4x
    4x
    29x
    4x
    4x
    4x
    4x
    4x
    2x
    2x
    2x
    4x
    4x
    4x
    29x
    2x

    2x
    29x
    3x
    1x
    1x
    1x
    1x
    3x
    29x
    29x
    406x
    12x
    12x
    12x
    406x
    33x
    33x
    33x
    33x
    33x
    406x
    21x
    21x
    21x
    406x
    406x
    406x
    59x

    59x
    59x
    3x
    3x
    56x
    59x
    59x
    32x
    32x
    24x
    24x
    24x
    59x
    14x
    59x
    59x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    3x
    2x
    2x
    3x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    105x
    71x
    71x
    34x
    34x
    5x
    5x

    5x
    5x
    5x
    5x
    5x
    5x
    5x
    5x
    5x
    5x
    5x
    5x
    34x
    34x
    34x
    34x
    28x
    28x
    34x
    34x
    34x
    34x
    34x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    406x
    1x
     "use client";
    import { cnb } from "cnbuilder";
    import {
      forwardRef,
      useEffect,
      useRef,
      type CSSProperties,
      type HTMLAttributes,
    } from "react";
    import { type FloatingActionButtonPosition } from "../button/FloatingActionButton.js";
    import { useFocusContainer } from "../focus/useFocusContainer.js";
    import { useUserInteractionMode } from "../interaction/UserInteractionModeProvider.js";
    import { type ListElement, type ListProps } from "../list/List.js";
    import { useAppSize } from "../media-queries/AppSizeProvider.js";
    import { type GetDefaultFocusedIndex } from "../movement/types.js";
    import { Portal } from "../portal/Portal.js";
    import { type CalculateFixedPositionOptions } from "../positioning/types.js";
    import {
      useFixedPositioning,
      type FixedPositioningOptions,
    } from "../positioning/useFixedPositioning.js";
    import { useScrollLock } from "../scroll/useScrollLock.js";
    import {
      useScaleTransition,
      type ScaleTransitionHookOptions,
    } from "../transition/useScaleTransition.js";
    import { type LabelRequiredForA11y, type PropsWithRef } from "../types.js";
    import { useEnsuredId } from "../useEnsuredId.js";
    import {
      MenuConfigurationProvider,
      useMenuConfiguration,
      type MenuConfiguration,
      type MenuOrientationProps,
    } from "./MenuConfigurationProvider.js";
    import { MenuSheet, type MenuSheetConvenienceProps } from "./MenuSheet.js";
    import { MenuWidget } from "./MenuWidget.js";
    import { useMenuBarContext } from "./useMenuBarProvider.js";
    import { getDefaultAnchor } from "./utils.js";

    declare module "react" {
      interface CSSProperties {
        "--rmd-menu-background-color"?: string;
        "--rmd-menu-color"?: string;
        "--rmd-menu-min-width"?: string | number;
        "--rmd-menu-spacing"?: string | number;
      }
    }

    const noop = (): void => {
      // do nothing
    };

    /** @remarks \@since 5.0.0 */
    export type MenuTransitionProps = Omit<
      ScaleTransitionHookOptions<HTMLDivElement>,
      "transitionIn" | "vertical" | "nodeRef"
    >;

    /**
     * @remarks \@since 6.0.0
     */
    export interface MenuConfigurationProps extends CalculateFixedPositionOptions {
      /**
       * @see {@link ScaleTransitionHookOptions.temporary}
       * @defaultValue `true`
       */
      temporary?: boolean;

      /**
       * @defaultValue `false`
       */
      disablePortal?: boolean;

      /**
       * Boolean if the menu should not gain the elevation styles and should only be
       * set to `true` when rendering within a `Sheet`.
       *
       * @defaultValue `false`
       */
      disableElevation?: boolean;

      /**
       * @defaultValue `false`
       */
      disableTransition?: boolean;

      /**
       * @see {@link FixedPositioningOptions.transformOrigin}
       * @defaultValue `true`
       */
      transformOrigin?: boolean;

      /**
       * Boolean if the menu should close if the page is scrolled. The default
       * behavior is to just update the position of the menu relative to the menu
       * button until it can no longer be visible within the viewport.
       *
       * @defaultValue `false`
       */
      closeOnScroll?: boolean;

      /**
       * Boolean if the page should no longer be scrollable while the menu is
       * visible.
       *
       * @defaultValue `false`
       */
      preventScroll?: boolean;

      /**
       * Boolean if the menu should close instead of repositioning itself if the
       * browser window is resized.
       *
       * @defaultValue `false`
       */
      closeOnResize?: boolean;

      /** @see {@link FixedPositioningOptions.getFixedPositionOptions} */
      getFixedPositionOptions?(): CalculateFixedPositionOptions;
    }

    /**
     * @remarks
     * \@since 5.1.0
     * \@since 6.0.0 Renamed from `MenuListProps` to `MenuListConvenienceProps`
     */
    export interface MenuListConvenienceProps {
      /**
       * An optional style to provide to the `List` component that surrounds the
       * `MenuItem` within a `Menu`.
       */
      listStyle?: CSSProperties;

      /**
       * An optional className to provide to the `List` component that surrounds the
       * `MenuItem` within a `Menu`.
       */
      listClassName?: string;

      /**
       * Any additional props to pass to the `List` component that surrounds the
       * `Menu`'s `MenuItem`s.
       */
      listProps?: PropsWithRef<Omit<ListProps, "horizontal">, ListElement>;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export interface MenuConvenienceProps extends MenuConfigurationProps {
      /**
       * This can be used to apply additional props to the `Menu` component.
       *
       * Note: You can override the `style` and `className` using
       * {@link menuStyle} and {@link menuClassName} instead for convenience.
       *
       * @example
       * ```tsx
       * <DropdownMenu
       *   {...props}
       *   menuProps={{
       *     style: {
       *       // custom inline style
       *     },
       *     className: "come-class-name",
       *     getFixedPositionOptions: () => ({
       *       preventOverlap: true,
       *     }),
       *   }}
       * />
       * ```
       */
      menuProps?: PropsWithRef<
        Omit<
          MenuProps,
          | "children"
          | "fixedTo"
          | "visible"
          | "onRequestClose"
          | "getDefaultFocusedIndex"
        >,
        HTMLDivElement
      >;

      /**
       * Convenience prop to apply custom style to the `Menu` component.
       */
      menuStyle?: CSSProperties;

      /**
       * Convenience prop to apply custom class name to the `Menu` component.
       */
      menuClassName?: string;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export type MenuFixedPositioningOptions = Omit<
      FixedPositioningOptions<HTMLElement, HTMLDivElement>,
      "onScroll" | "onResize"
    >;

    /**
     * @remarks
     * \@since 5.0.0
     * \@since 6.0.0 Updated to use the latest Menu, Transition, and Portal API.
     */
    export interface MenuProps
      extends HTMLAttributes<HTMLDivElement>,
        MenuConfiguration,
        MenuConfigurationProps,
        MenuFixedPositioningOptions,
        MenuOrientationProps,
        MenuTransitionProps,
        MenuListConvenienceProps,
        MenuSheetConvenienceProps {
      visible: boolean;
      onRequestClose(): void;

      /**
       * @defaultValue `"menu-" + useId()`
       */
      id?: string;

      /**
       * This is used to set the default focus index when the menu is visible.
       *
       * @internal
       */
      getDefaultFocusedIndex?: GetDefaultFocusedIndex;

      /**
       * Custom style that should be applied to the menu only while not rendered
       * within a sheet since the {@link style} would be applied to both versions.
       */
      menuStyle?: CSSProperties;

      /**
       * Custom class name that should be applied only while not rendered within a
       * sheet.
       */
      menuClassName?: string;

      /**
       * @internal
       *
       * This is only used to update the default anchor when the DropdownMenu's
       * toggle is a floating action button.
       */
      floating?: FloatingActionButtonPosition;
    }

    /**
     * **Client Component**
     *
     * This component should generally only be used to implement context menus with
     * the `useContextMenu` hook. Otherwise, the `DropdownMenu` component should be
     * used.
     *
     * @see The `useContextMenu` hook for an example.
     *
     * @remarks
     * \@since 5.0.0
     * \@since 6.0.0 Updated this component to implement all the `Menu`
     * functionality instead of requiring the `useMenu` hook and `MenuWidget`
     * component. In addition, the `renderAsSheet` behavior has been moved into this
     * implementation so that the `MenuRenderer` is no longer required and context
     * menus can appear as a `Sheet`.
     */
    export const Menu = forwardRef<HTMLDivElement, LabelRequiredForA11y<MenuProps>>(
      function Menu(props, propRef) {
        const {
          id: propId,
          style: propStyle,
          role = "menu",
          children,
          horizontal: _horizontal,
          sheetHeader: _sheetHeader,
          sheetFooter: _sheetFooter,
          renderAsSheet: _renderAsSheet,
          sheetPosition: _sheetPosition,
          sheetVerticalSize: _sheetVerticalSize,
          sheetProps,
          sheetStyle,
          sheetClassName,
          menuStyle,
          menuClassName,
          disableElevation = false,
          temporary = true,
          tabIndex = -1,
          fixedTo,
          className,
          classNames,
          timeout,
          appear,
          enter,
          exit,
          onEnter,
          onEntering = noop,
          onEntered = noop,
          onExit,
          onExiting,
          onExited = noop,
          onKeyDown = noop,
          listProps,
          listStyle,
          listClassName,
          visible,
          onRequestClose,
          floating,
          anchor,
          closeOnResize = false,
          closeOnScroll = false,
          preventScroll = false,
          vwMargin,
          vhMargin,
          xMargin,
          yMargin,
          width,
          transformOrigin = true,
          preventOverlap,
          disableSwapping,
          disableVHBounds,
          initialX,
          initialY,
          getFixedPositionOptions,
          disablePortal: propDisablePortal,
          disableTransition,
          ...remaining
        } = props;
        const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy } =
          props;

        const id = useEnsuredId(propId, "menu");
        const {
          root,
          menubar,
          menuitem,
          activeId,
          animatedOnceRef,
          hoverTimeoutRef,
          disableHoverMode,
        } = useMenuBarContext();
        const {
          horizontal,
          sheetHeader,
          sheetFooter,
          renderAsSheet,
          sheetPosition,
          sheetVerticalSize,
        } = useMenuConfiguration(props);
        const { isPhone } = useAppSize();
        const isSheet =
          renderAsSheet === true || (renderAsSheet === "phone" && isPhone);

        const entered = useRef(false);
        const cancelUnmountFocus = useRef(false);
        const hideWithoutRefocus = (): void => {
          cancelUnmountFocus.current = true;
          onRequestClose();
        };
        const mode = useUserInteractionMode();
        const mouse = mode === "mouse";

        const { eventHandlers, transitionOptions } = useFocusContainer({
          nodeRef: propRef,
          activate: visible,
          onKeyDown(event) {
            onKeyDown(event);

            // when a menu is within a sheet, it should not trigger the custom
            // keyboard behavior
            if (isSheet) {
              return;
            }

            switch (event.key) {
              case "Escape":
                // prevent parent components that have an "Escape" keypress event
                // from being triggered as well
                event.stopPropagation();
                disableHoverMode();
                onRequestClose();
                break;
              case "Tab":
                // since menus are portalled, tab index is kinda broke so just close
                // the menu instead of doing default tab behavior
                event.preventDefault();

                if (!menuitem) {
                  // pressing the tab key should still cascade close all menus
                  event.stopPropagation();
                }
                disableHoverMode();
                onRequestClose();
                break;
              case "ArrowUp":
                if (!root && menuitem && horizontal) {
                  event.stopPropagation();
                  event.preventDefault();
                  onRequestClose();
                }
                break;
              case "ArrowLeft":
                if (!root && menuitem && !horizontal) {
                  event.stopPropagation();
                  event.preventDefault();
                  onRequestClose();
                }
                break;
            }
          },
          onEntering(appearing) {
            onEntering(appearing);
            entered.current = true;
          },
          onEntered(appearing) {
            onEntered(appearing);
            entered.current = true;
            cancelUnmountFocus.current = false;
            animatedOnceRef.current = true;
          },
          onExited() {
            onExited();
            entered.current = false;
          },
          onExiting,
          disableTransition,
          isFocusTypeDisabled(type) {
            if (role === "listbox") {
              return !isSheet;
            }

            if (type === "keyboard") {
              return isSheet;
            }

            const isHoverDisabled = mouse && hoverTimeoutRef.current === 0;
            if (type === "mount") {
              return isHoverDisabled;
            }

            return (
              isHoverDisabled ||
              cancelUnmountFocus.current ||
              (root && !!activeId && id !== activeId)
            );
          },
        });

        const { ref, style, callbacks } = useFixedPositioning({
          ...transitionOptions,
          onEnter,
          style: isSheet ? propStyle : menuStyle,
          fixedTo,
          anchor: getDefaultAnchor({
            anchor,
            menubar,
            floating,
            menuitem: !root && menuitem,
            horizontal,
          }),
          vwMargin,
          vhMargin,
          xMargin,
          yMargin,
          width,
          transformOrigin,
          preventOverlap,
          disableSwapping,
          disableVHBounds,
          initialX,
          initialY,
          getFixedPositionOptions,
          onResize: closeOnResize ? hideWithoutRefocus : undefined,
          onScroll(_event, data) {
            if (!data.visible || closeOnScroll) {
              hideWithoutRefocus();
            }
          },
        });
        const { rendered, disablePortal, elementProps } = useScaleTransition({
          nodeRef: ref,
          className: cnb(!isSheet && menuClassName, className),
          transitionIn: visible,
          vertical: !horizontal,
          temporary,
          timeout: isSheet || disableTransition ? 0 : timeout,
          classNames,
          appear,
          enter,
          exit,
          onExit,
          onExiting: transitionOptions.onExiting,
          exitedHidden: true,
          ...callbacks,
        });
        useScrollLock(visible && preventScroll);

        // need to make sure that the useEffect does not refire for hiding on click
        // events because of the `window.requestAnimationFrame`. It'll make it so
        // that menu items that update state are unable to close when clicked
        const hide = useRef(onRequestClose);
        useEffect(() => {
          hide.current = onRequestClose;
        });
        useEffect(() => {
          if (!visible) {
            return;
          }

          const callback = (event: globalThis.MouseEvent): void => {
            // this is required for when the transition is disabled
            if (!entered.current) {
              return;
            }

            // if the user clicks outside of the menu to close it, the toggle button
            // should not be focused. instead the nearest focusable element from the
            // click event should be focused when Tab or Shift + tab is pressed
            cancelUnmountFocus.current =
              !(event.target instanceof HTMLElement) ||
              !event.target.closest(`[role="${role}"]`);

            // this won't be called if `event.stopPropagation()` is called
            hide.current();
            disableHoverMode();
          };

          // wait an animation frame so the initial click event that caused the menu
          // to become visible does not immediately close the menu
          const frame = window.requestAnimationFrame(() => {
            window.addEventListener("click", callback);
          });

          return () => {
            window.cancelAnimationFrame(frame);
            window.removeEventListener("click", callback);
          };
        }, [disableHoverMode, role, visible]);

        return (
          <MenuConfigurationProvider
            horizontal={horizontal}
            renderAsSheet={renderAsSheet}
            sheetFooter={sheetFooter}
            sheetHeader={sheetHeader}
            sheetPosition={sheetPosition}
            sheetVerticalSize={sheetVerticalSize}
          >
            <MenuSheet
              aria-label={ariaLabel}
              aria-labelledby={ariaLabelledBy as string}
              header={sheetHeader}
              footer={sheetFooter}
              position={sheetPosition}
              verticalSize={sheetVerticalSize}
              visible={visible}
              enabled={isSheet}
              onRequestClose={onRequestClose}
              style={sheetStyle}
              className={sheetClassName}
              disablePortal={propDisablePortal}
              temporary={temporary}
              disableTransition={disableTransition}
              {...sheetProps}
            >
              <Portal disabled={isSheet || (propDisablePortal ?? disablePortal)}>
                {(rendered || isSheet) && (
                  <MenuWidget
                    {...remaining}
                    {...elementProps}
                    {...eventHandlers}
                    id={id}
                    role={role}
                    style={isSheet ? propStyle : style}
                    isSheet={isSheet}
                    tabIndex={tabIndex}
                    horizontal={horizontal}
                    listProps={listProps}
                    listStyle={listStyle}
                    listClassName={listClassName}
                    disableElevation={disableElevation}
                    cancelUnmountFocus={cancelUnmountFocus}
                  >
                    {children}
                  </MenuWidget>
                )}
              </Portal>
            </MenuSheet>
          </MenuConfigurationProvider>
        );
      }
    );