neue Homepage auf react basis

This commit is contained in:
2026-08-07 21:39:30 +02:00
parent 164bdd19ad
commit ee89442c04
52191 changed files with 1230242 additions and 58 deletions
+149
View File
@@ -0,0 +1,149 @@
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from "../styles/index.mjs";
import { InternalStandardProps as StandardProps } from "../internal/index.mjs";
import { PaperProps } from "../Paper/index.mjs";
import { PopoverProps } from "../Popover/index.mjs";
import { MenuListProps } from "../MenuList/index.mjs";
import { ModalProps } from "../Modal/index.mjs";
import { BackdropProps } from "../Backdrop/index.mjs";
import { TransitionProps } from "../transitions/types.mjs";
import { MenuClasses } from "./menuClasses.mjs";
import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from "../utils/types.mjs";
export interface MenuRootSlotPropsOverrides {}
export interface MenuPaperSlotPropsOverrides {}
export interface MenuTransitionSlotPropsOverrides {}
export interface MenuListSlotPropsOverrides {}
export interface MenuBackdropSlotPropsOverrides {}
export interface MenuSlots {
/**
* The component used for the popper.
* @default Modal
*/
root: React.ElementType;
/**
* The component used for the paper.
* @default PopoverPaper
*/
paper: React.ElementType;
/**
* The component used for the list.
* @default MenuList
*/
list: React.ElementType;
/**
* The component used for the transition slot.
* @default Grow
*/
transition: React.ElementType;
/**
* The component used for the backdrop slot.
* @default Backdrop
*/
backdrop: React.ElementType;
}
export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<MenuSlots, {
/**
* Props forwarded to the root slot.
* By default, the available props are based on the [Popover](https://mui.com/material-ui/api/popover/#props) component.
*/
root: SlotProps<React.ElementType<ModalProps>, MenuRootSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the paper slot.
* By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
*/
paper: SlotProps<React.ElementType<PaperProps>, MenuPaperSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the list slot.
* By default, the available props are based on the [MenuList](https://mui.com/material-ui/api/menu-list/#props) component.
*/
list: SlotProps<React.ElementType<MenuListProps>, MenuListSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the transition slot.
* By default, the available props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
*/
transition: SlotComponentProps<
// use SlotComponentProps because transition slot does not support `component` and `sx` prop
React.ElementType<TransitionProps>, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the backdrop slot.
* By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
*/
backdrop: SlotProps<React.ElementType<BackdropProps>, MenuBackdropSlotPropsOverrides, MenuOwnerState>;
}>;
export interface MenuProps extends StandardProps<Omit<PopoverProps, 'slots' | 'slotProps'>>, MenuSlotsAndSlotProps {
/**
* An HTML element, or a function that returns one.
* It's used to set the position of the menu.
*/
anchorEl?: PopoverProps['anchorEl'] | undefined;
/**
* If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
* children are not focusable. If you set this prop to `false` focus will be placed
* on the parent modal container. This has severe accessibility implications
* and should only be considered if you manage focus otherwise.
* @default true
*/
autoFocus?: boolean | undefined;
/**
* Menu contents, normally `MenuItem`s.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<MenuClasses> | undefined;
/**
* When opening the menu will not focus the active item but the `[role="menu"]`
* unless `autoFocus` is also set to `false`. Not using the default means not
* following WAI-ARIA authoring practices. Please be considerate about possible
* accessibility implications.
* @default false
*/
disableAutoFocusItem?: boolean | undefined;
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
*/
onClose?: PopoverProps['onClose'] | undefined;
/**
* If `true`, the component is shown.
*/
open: boolean;
/**
* `classes` prop applied to the [`Popover`](https://mui.com/material-ui/api/popover/) element.
*/
PopoverClasses?: PopoverProps['classes'] | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The length of the transition in `ms`, or 'auto'
* @default 'auto'
*/
transitionDuration?: TransitionProps['timeout'] | 'auto' | undefined;
/**
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus.
* @default 'selectedMenu'
*/
variant?: 'menu' | 'selectedMenu' | undefined;
}
export interface MenuOwnerState extends Omit<MenuProps, 'slots' | 'slotProps'> {}
export declare const MenuPaper: React.FC<PaperProps>;
/**
*
* Demos:
*
* - [App Bar](https://mui.com/material-ui/react-app-bar/)
* - [Menu](https://mui.com/material-ui/react-menu/)
*
* API:
*
* - [Menu API](https://mui.com/material-ui/api/menu/)
* - inherits [Popover API](https://mui.com/material-ui/api/popover/)
*/
export default function Menu(props: MenuProps): React.JSX.Element;
+149
View File
@@ -0,0 +1,149 @@
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from "../styles/index.js";
import { InternalStandardProps as StandardProps } from "../internal/index.js";
import { PaperProps } from "../Paper/index.js";
import { PopoverProps } from "../Popover/index.js";
import { MenuListProps } from "../MenuList/index.js";
import { ModalProps } from "../Modal/index.js";
import { BackdropProps } from "../Backdrop/index.js";
import { TransitionProps } from "../transitions/types.js";
import { MenuClasses } from "./menuClasses.js";
import { CreateSlotsAndSlotProps, SlotComponentProps, SlotProps } from "../utils/types.js";
export interface MenuRootSlotPropsOverrides {}
export interface MenuPaperSlotPropsOverrides {}
export interface MenuTransitionSlotPropsOverrides {}
export interface MenuListSlotPropsOverrides {}
export interface MenuBackdropSlotPropsOverrides {}
export interface MenuSlots {
/**
* The component used for the popper.
* @default Modal
*/
root: React.ElementType;
/**
* The component used for the paper.
* @default PopoverPaper
*/
paper: React.ElementType;
/**
* The component used for the list.
* @default MenuList
*/
list: React.ElementType;
/**
* The component used for the transition slot.
* @default Grow
*/
transition: React.ElementType;
/**
* The component used for the backdrop slot.
* @default Backdrop
*/
backdrop: React.ElementType;
}
export type MenuSlotsAndSlotProps = CreateSlotsAndSlotProps<MenuSlots, {
/**
* Props forwarded to the root slot.
* By default, the available props are based on the [Popover](https://mui.com/material-ui/api/popover/#props) component.
*/
root: SlotProps<React.ElementType<ModalProps>, MenuRootSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the paper slot.
* By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
*/
paper: SlotProps<React.ElementType<PaperProps>, MenuPaperSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the list slot.
* By default, the available props are based on the [MenuList](https://mui.com/material-ui/api/menu-list/#props) component.
*/
list: SlotProps<React.ElementType<MenuListProps>, MenuListSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the transition slot.
* By default, the available props are based on the [Grow](https://mui.com/material-ui/api/grow/#props) component.
*/
transition: SlotComponentProps<
// use SlotComponentProps because transition slot does not support `component` and `sx` prop
React.ElementType<TransitionProps>, TransitionProps & MenuTransitionSlotPropsOverrides, MenuOwnerState>;
/**
* Props forwarded to the backdrop slot.
* By default, the available props are based on the [Backdrop](https://mui.com/material-ui/api/backdrop/#props) component.
*/
backdrop: SlotProps<React.ElementType<BackdropProps>, MenuBackdropSlotPropsOverrides, MenuOwnerState>;
}>;
export interface MenuProps extends StandardProps<Omit<PopoverProps, 'slots' | 'slotProps'>>, MenuSlotsAndSlotProps {
/**
* An HTML element, or a function that returns one.
* It's used to set the position of the menu.
*/
anchorEl?: PopoverProps['anchorEl'] | undefined;
/**
* If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
* children are not focusable. If you set this prop to `false` focus will be placed
* on the parent modal container. This has severe accessibility implications
* and should only be considered if you manage focus otherwise.
* @default true
*/
autoFocus?: boolean | undefined;
/**
* Menu contents, normally `MenuItem`s.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<MenuClasses> | undefined;
/**
* When opening the menu will not focus the active item but the `[role="menu"]`
* unless `autoFocus` is also set to `false`. Not using the default means not
* following WAI-ARIA authoring practices. Please be considerate about possible
* accessibility implications.
* @default false
*/
disableAutoFocusItem?: boolean | undefined;
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
*/
onClose?: PopoverProps['onClose'] | undefined;
/**
* If `true`, the component is shown.
*/
open: boolean;
/**
* `classes` prop applied to the [`Popover`](https://mui.com/material-ui/api/popover/) element.
*/
PopoverClasses?: PopoverProps['classes'] | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
/**
* The length of the transition in `ms`, or 'auto'
* @default 'auto'
*/
transitionDuration?: TransitionProps['timeout'] | 'auto' | undefined;
/**
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus.
* @default 'selectedMenu'
*/
variant?: 'menu' | 'selectedMenu' | undefined;
}
export interface MenuOwnerState extends Omit<MenuProps, 'slots' | 'slotProps'> {}
export declare const MenuPaper: React.FC<PaperProps>;
/**
*
* Demos:
*
* - [App Bar](https://mui.com/material-ui/react-app-bar/)
* - [Menu](https://mui.com/material-ui/react-menu/)
*
* API:
*
* - [Menu API](https://mui.com/material-ui/api/menu/)
* - inherits [Popover API](https://mui.com/material-ui/api/popover/)
*/
export default function Menu(props: MenuProps): React.JSX.Element;
+289
View File
@@ -0,0 +1,289 @@
"use strict";
'use client';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.MenuPaper = void 0;
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
var _RtlProvider = require("@mui/system/RtlProvider");
var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
var _MenuList = _interopRequireDefault(require("../MenuList"));
var _Popover = _interopRequireWildcard(require("../Popover"));
var _rootShouldForwardProp = _interopRequireDefault(require("../styles/rootShouldForwardProp"));
var _zeroStyled = require("../zero-styled");
var _DefaultPropsProvider = require("../DefaultPropsProvider");
var _menuClasses = require("./menuClasses");
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
var _jsxRuntime = require("react/jsx-runtime");
const RTL_ORIGIN = {
vertical: 'top',
horizontal: 'right'
};
const LTR_ORIGIN = {
vertical: 'top',
horizontal: 'left'
};
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['root'],
paper: ['paper'],
list: ['list']
};
return (0, _composeClasses.default)(slots, _menuClasses.getMenuUtilityClass, classes);
};
const MenuRoot = (0, _zeroStyled.styled)(_Popover.default, {
shouldForwardProp: prop => (0, _rootShouldForwardProp.default)(prop) || prop === 'classes',
name: 'MuiMenu',
slot: 'Root'
})({});
const MenuPaper = exports.MenuPaper = (0, _zeroStyled.styled)(_Popover.PopoverPaper, {
name: 'MuiMenu',
slot: 'Paper'
})({
// specZ: The maximum height of a simple menu should be one or more rows less than the view
// height. This ensures a tappable area outside of the simple menu with which to dismiss
// the menu.
maxHeight: 'calc(100% - 96px)',
// Add iOS momentum scrolling for iOS < 13.0
WebkitOverflowScrolling: 'touch'
});
const MenuMenuList = (0, _zeroStyled.styled)(_MenuList.default, {
name: 'MuiMenu',
slot: 'List'
})({
// We disable the focus ring for mouse, touch and keyboard users.
outline: 0
});
const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
const props = (0, _DefaultPropsProvider.useDefaultProps)({
props: inProps,
name: 'MuiMenu'
});
const {
autoFocus = true,
children,
className,
disableAutoFocusItem = false,
onClose,
open,
PopoverClasses,
transitionDuration = 'auto',
variant = 'selectedMenu',
slots = {},
slotProps = {},
...other
} = props;
const isRtl = (0, _RtlProvider.useRtl)();
const ownerState = {
...props,
autoFocus,
disableAutoFocusItem,
transitionDuration,
variant
};
const classes = useUtilityClasses(ownerState);
const shouldManageInitialFocus = autoFocus && open; // `&& open` prevents a Menu with `keepMounted={true}` from accidentally stealing focus
const shouldAutoFocusActiveItem = shouldManageInitialFocus && !disableAutoFocusItem;
const menuListActionsRef = React.useRef(null);
const handleEntering = (element, _isAppearing) => {
if (menuListActionsRef.current) {
menuListActionsRef.current.adjustStyleForScrollbar(element, {
direction: isRtl ? 'rtl' : 'ltr'
});
if (shouldManageInitialFocus) {
menuListActionsRef.current.focusInitialTarget?.();
}
}
};
const handleListKeyDown = event => {
if (event.key === 'Tab') {
event.preventDefault();
if (onClose) {
onClose(event, 'tabKeyDown');
}
}
};
const externalForwardedProps = {
slots,
slotProps
};
const rootSlotProps = (0, _useSlotProps.default)({
elementType: slots.root,
externalSlotProps: slotProps.root,
ownerState,
className: [classes.root, className]
});
const [PaperSlot, paperSlotProps] = (0, _useSlot.default)('paper', {
className: classes.paper,
elementType: MenuPaper,
externalForwardedProps,
shouldForwardComponentProp: true,
ownerState
});
const [ListSlot, listSlotProps] = (0, _useSlot.default)('list', {
className: classes.list,
elementType: MenuMenuList,
shouldForwardComponentProp: true,
externalForwardedProps,
getSlotProps: handlers => ({
...handlers,
onKeyDown: event => {
handleListKeyDown(event);
handlers.onKeyDown?.(event);
}
}),
ownerState
});
const resolvedTransitionProps = typeof slotProps.transition === 'function' ? slotProps.transition(ownerState) : slotProps.transition;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuRoot
// `disableAutoFocus={autoFocus}` is NOT a mistake
// - `autoFocus` means `Menu` will control focus and move it into `MenuList` or an active `MenuItem`
// - `disableAutoFocus` means disable `MenuRoot`s underlying `Popover`'s autoFocus handling
// This prevents `MenuList` and `Popover` from fighting each other to control focus.
// (This has nothing to do with DOM `autoFocus`)
, {
disableAutoFocus: autoFocus,
onClose: onClose,
anchorOrigin: {
vertical: 'bottom',
horizontal: isRtl ? 'right' : 'left'
},
transformOrigin: isRtl ? RTL_ORIGIN : LTR_ORIGIN,
slots: {
root: slots.root,
paper: PaperSlot,
backdrop: slots.backdrop,
transition: slots.transition
},
slotProps: {
root: rootSlotProps,
paper: paperSlotProps,
backdrop: typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop,
transition: {
...resolvedTransitionProps,
onEntering: (...args) => {
handleEntering(...args);
resolvedTransitionProps?.onEntering?.(...args);
}
}
},
open: open,
ref: ref,
transitionDuration: transitionDuration,
ownerState: ownerState,
...other,
classes: PopoverClasses,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ListSlot, {
actions: menuListActionsRef,
autoFocus: shouldManageInitialFocus,
autoFocusItem: shouldAutoFocusActiveItem,
variant: variant,
...listSlotProps,
children: children
})
});
});
process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* An HTML element, or a function that returns one.
* It's used to set the position of the menu.
*/
anchorEl: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_HTMLElementType.default, _propTypes.default.func]),
/**
* If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
* children are not focusable. If you set this prop to `false` focus will be placed
* on the parent modal container. This has severe accessibility implications
* and should only be considered if you manage focus otherwise.
* @default true
*/
autoFocus: _propTypes.default.bool,
/**
* Menu contents, normally `MenuItem`s.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
*/
classes: _propTypes.default.object,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* When opening the menu will not focus the active item but the `[role="menu"]`
* unless `autoFocus` is also set to `false`. Not using the default means not
* following WAI-ARIA authoring practices. Please be considerate about possible
* accessibility implications.
* @default false
*/
disableAutoFocusItem: _propTypes.default.bool,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
*/
onClose: _propTypes.default.func,
/**
* If `true`, the component is shown.
*/
open: _propTypes.default.bool.isRequired,
/**
* `classes` prop applied to the [`Popover`](https://mui.com/material-ui/api/popover/) element.
*/
PopoverClasses: _propTypes.default.object,
/**
* The props used for each slot inside.
* @default {}
*/
slotProps: _propTypes.default.shape({
backdrop: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
list: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
paper: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
transition: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: _propTypes.default.shape({
backdrop: _propTypes.default.elementType,
list: _propTypes.default.elementType,
paper: _propTypes.default.elementType,
root: _propTypes.default.elementType,
transition: _propTypes.default.elementType
}),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
/**
* The length of the transition in `ms`, or 'auto'
* @default 'auto'
*/
transitionDuration: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.shape({
appear: _propTypes.default.number,
enter: _propTypes.default.number,
exit: _propTypes.default.number
})]),
/**
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus.
* @default 'selectedMenu'
*/
variant: _propTypes.default.oneOf(['menu', 'selectedMenu'])
} : void 0;
var _default = exports.default = Menu;
+282
View File
@@ -0,0 +1,282 @@
'use client';
import * as React from 'react';
import PropTypes from 'prop-types';
import composeClasses from '@mui/utils/composeClasses';
import HTMLElementType from '@mui/utils/HTMLElementType';
import { useRtl } from '@mui/system/RtlProvider';
import useSlotProps from '@mui/utils/useSlotProps';
import MenuList from "../MenuList/index.mjs";
import Popover, { PopoverPaper } from "../Popover/index.mjs";
import rootShouldForwardProp from "../styles/rootShouldForwardProp.mjs";
import { styled } from "../zero-styled/index.mjs";
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
import { getMenuUtilityClass } from "./menuClasses.mjs";
import useSlot from "../utils/useSlot.mjs";
import { jsx as _jsx } from "react/jsx-runtime";
const RTL_ORIGIN = {
vertical: 'top',
horizontal: 'right'
};
const LTR_ORIGIN = {
vertical: 'top',
horizontal: 'left'
};
const useUtilityClasses = ownerState => {
const {
classes
} = ownerState;
const slots = {
root: ['root'],
paper: ['paper'],
list: ['list']
};
return composeClasses(slots, getMenuUtilityClass, classes);
};
const MenuRoot = styled(Popover, {
shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
name: 'MuiMenu',
slot: 'Root'
})({});
export const MenuPaper = styled(PopoverPaper, {
name: 'MuiMenu',
slot: 'Paper'
})({
// specZ: The maximum height of a simple menu should be one or more rows less than the view
// height. This ensures a tappable area outside of the simple menu with which to dismiss
// the menu.
maxHeight: 'calc(100% - 96px)',
// Add iOS momentum scrolling for iOS < 13.0
WebkitOverflowScrolling: 'touch'
});
const MenuMenuList = styled(MenuList, {
name: 'MuiMenu',
slot: 'List'
})({
// We disable the focus ring for mouse, touch and keyboard users.
outline: 0
});
const Menu = /*#__PURE__*/React.forwardRef(function Menu(inProps, ref) {
const props = useDefaultProps({
props: inProps,
name: 'MuiMenu'
});
const {
autoFocus = true,
children,
className,
disableAutoFocusItem = false,
onClose,
open,
PopoverClasses,
transitionDuration = 'auto',
variant = 'selectedMenu',
slots = {},
slotProps = {},
...other
} = props;
const isRtl = useRtl();
const ownerState = {
...props,
autoFocus,
disableAutoFocusItem,
transitionDuration,
variant
};
const classes = useUtilityClasses(ownerState);
const shouldManageInitialFocus = autoFocus && open; // `&& open` prevents a Menu with `keepMounted={true}` from accidentally stealing focus
const shouldAutoFocusActiveItem = shouldManageInitialFocus && !disableAutoFocusItem;
const menuListActionsRef = React.useRef(null);
const handleEntering = (element, _isAppearing) => {
if (menuListActionsRef.current) {
menuListActionsRef.current.adjustStyleForScrollbar(element, {
direction: isRtl ? 'rtl' : 'ltr'
});
if (shouldManageInitialFocus) {
menuListActionsRef.current.focusInitialTarget?.();
}
}
};
const handleListKeyDown = event => {
if (event.key === 'Tab') {
event.preventDefault();
if (onClose) {
onClose(event, 'tabKeyDown');
}
}
};
const externalForwardedProps = {
slots,
slotProps
};
const rootSlotProps = useSlotProps({
elementType: slots.root,
externalSlotProps: slotProps.root,
ownerState,
className: [classes.root, className]
});
const [PaperSlot, paperSlotProps] = useSlot('paper', {
className: classes.paper,
elementType: MenuPaper,
externalForwardedProps,
shouldForwardComponentProp: true,
ownerState
});
const [ListSlot, listSlotProps] = useSlot('list', {
className: classes.list,
elementType: MenuMenuList,
shouldForwardComponentProp: true,
externalForwardedProps,
getSlotProps: handlers => ({
...handlers,
onKeyDown: event => {
handleListKeyDown(event);
handlers.onKeyDown?.(event);
}
}),
ownerState
});
const resolvedTransitionProps = typeof slotProps.transition === 'function' ? slotProps.transition(ownerState) : slotProps.transition;
return /*#__PURE__*/_jsx(MenuRoot
// `disableAutoFocus={autoFocus}` is NOT a mistake
// - `autoFocus` means `Menu` will control focus and move it into `MenuList` or an active `MenuItem`
// - `disableAutoFocus` means disable `MenuRoot`s underlying `Popover`'s autoFocus handling
// This prevents `MenuList` and `Popover` from fighting each other to control focus.
// (This has nothing to do with DOM `autoFocus`)
, {
disableAutoFocus: autoFocus,
onClose: onClose,
anchorOrigin: {
vertical: 'bottom',
horizontal: isRtl ? 'right' : 'left'
},
transformOrigin: isRtl ? RTL_ORIGIN : LTR_ORIGIN,
slots: {
root: slots.root,
paper: PaperSlot,
backdrop: slots.backdrop,
transition: slots.transition
},
slotProps: {
root: rootSlotProps,
paper: paperSlotProps,
backdrop: typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop,
transition: {
...resolvedTransitionProps,
onEntering: (...args) => {
handleEntering(...args);
resolvedTransitionProps?.onEntering?.(...args);
}
}
},
open: open,
ref: ref,
transitionDuration: transitionDuration,
ownerState: ownerState,
...other,
classes: PopoverClasses,
children: /*#__PURE__*/_jsx(ListSlot, {
actions: menuListActionsRef,
autoFocus: shouldManageInitialFocus,
autoFocusItem: shouldAutoFocusActiveItem,
variant: variant,
...listSlotProps,
children: children
})
});
});
process.env.NODE_ENV !== "production" ? Menu.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* An HTML element, or a function that returns one.
* It's used to set the position of the menu.
*/
anchorEl: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.func]),
/**
* If `true` (Default) will focus the `[role="menu"]` if no focusable child is found. Disabled
* children are not focusable. If you set this prop to `false` focus will be placed
* on the parent modal container. This has severe accessibility implications
* and should only be considered if you manage focus otherwise.
* @default true
*/
autoFocus: PropTypes.bool,
/**
* Menu contents, normally `MenuItem`s.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* When opening the menu will not focus the active item but the `[role="menu"]`
* unless `autoFocus` is also set to `false`. Not using the default means not
* following WAI-ARIA authoring practices. Please be considerate about possible
* accessibility implications.
* @default false
*/
disableAutoFocusItem: PropTypes.bool,
/**
* Callback fired when the component requests to be closed.
*
* @param {object} event The event source of the callback.
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`, `"tabKeyDown"`.
*/
onClose: PropTypes.func,
/**
* If `true`, the component is shown.
*/
open: PropTypes.bool.isRequired,
/**
* `classes` prop applied to the [`Popover`](https://mui.com/material-ui/api/popover/) element.
*/
PopoverClasses: PropTypes.object,
/**
* The props used for each slot inside.
* @default {}
*/
slotProps: PropTypes.shape({
backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: PropTypes.shape({
backdrop: PropTypes.elementType,
list: PropTypes.elementType,
paper: PropTypes.elementType,
root: PropTypes.elementType,
transition: PropTypes.elementType
}),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
/**
* The length of the transition in `ms`, or 'auto'
* @default 'auto'
*/
transitionDuration: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({
appear: PropTypes.number,
enter: PropTypes.number,
exit: PropTypes.number
})]),
/**
* The variant to use. Use `menu` to prevent selected items from impacting the initial focus.
* @default 'selectedMenu'
*/
variant: PropTypes.oneOf(['menu', 'selectedMenu'])
} : void 0;
export default Menu;
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./Menu.mjs";
export * from "./Menu.mjs";
export { default as menuClasses } from "./menuClasses.mjs";
export * from "./menuClasses.mjs";
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./Menu.js";
export * from "./Menu.js";
export { default as menuClasses } from "./menuClasses.js";
export * from "./menuClasses.js";
+35
View File
@@ -0,0 +1,35 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
menuClasses: true
};
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _Menu.default;
}
});
Object.defineProperty(exports, "menuClasses", {
enumerable: true,
get: function () {
return _menuClasses.default;
}
});
var _Menu = _interopRequireDefault(require("./Menu"));
var _menuClasses = _interopRequireWildcard(require("./menuClasses"));
Object.keys(_menuClasses).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _menuClasses[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _menuClasses[key];
}
});
});
+3
View File
@@ -0,0 +1,3 @@
export { default } from "./Menu.mjs";
export { default as menuClasses } from "./menuClasses.mjs";
export * from "./menuClasses.mjs";
+12
View File
@@ -0,0 +1,12 @@
export interface MenuClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the Paper component. */
paper: string;
/** Styles applied to the List component via `MenuList`. */
list: string;
}
export type MenuClassKey = keyof MenuClasses;
export declare function getMenuUtilityClass(slot: string): string;
declare const menuClasses: MenuClasses;
export default menuClasses;
+12
View File
@@ -0,0 +1,12 @@
export interface MenuClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the Paper component. */
paper: string;
/** Styles applied to the List component via `MenuList`. */
list: string;
}
export type MenuClassKey = keyof MenuClasses;
export declare function getMenuUtilityClass(slot: string): string;
declare const menuClasses: MenuClasses;
export default menuClasses;
+15
View File
@@ -0,0 +1,15 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.getMenuUtilityClass = getMenuUtilityClass;
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
function getMenuUtilityClass(slot) {
return (0, _generateUtilityClass.default)('MuiMenu', slot);
}
const menuClasses = (0, _generateUtilityClasses.default)('MuiMenu', ['root', 'paper', 'list']);
var _default = exports.default = menuClasses;
+7
View File
@@ -0,0 +1,7 @@
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';
export function getMenuUtilityClass(slot) {
return generateUtilityClass('MuiMenu', slot);
}
const menuClasses = generateUtilityClasses('MuiMenu', ['root', 'paper', 'list']);
export default menuClasses;