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
+158
View File
@@ -0,0 +1,158 @@
import * as React from 'react';
import { OverridableStringUnion } from '@mui/types';
import { SxProps } from '@mui/system';
import { SvgIconProps } from "../SvgIcon/index.mjs";
import { Theme } from "../styles/index.mjs";
import { InternalStandardProps as StandardProps } from "../internal/index.mjs";
import { IconButtonProps } from "../IconButton/index.mjs";
import { PaperProps } from "../Paper/index.mjs";
import { AlertClasses } from "./alertClasses.mjs";
import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.mjs";
export type AlertColor = 'success' | 'info' | 'warning' | 'error';
export interface AlertPropsVariantOverrides {}
export interface AlertPropsColorOverrides {}
export interface AlertRootSlotPropsOverrides {}
export interface AlertIconSlotPropsOverrides {}
export interface AlertMessageSlotPropsOverrides {}
export interface AlertActionSlotPropsOverrides {}
export interface AlertCloseButtonSlotPropsOverrides {}
export interface AlertCloseIconSlotPropsOverrides {}
export interface AlertSlots {
/**
* The component that renders the root slot.
* @default Paper
*/
root: React.ElementType;
/**
* The component that renders the icon slot.
* @default div
*/
icon: React.ElementType;
/**
* The component that renders the message slot.
* @default div
*/
message: React.ElementType;
/**
* The component that renders the action slot.
* @default div
*/
action: React.ElementType;
/**
* The component that renders the close button.
* @default IconButton
*/
closeButton: React.ElementType;
/**
* The component that renders the close icon.
* @default svg
*/
closeIcon: React.ElementType;
}
export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps<AlertSlots, {
/**
* Props forwarded to the root slot.
* By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
*/
root: SlotProps<React.ElementType<PaperProps>, AlertRootSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the icon slot.
* By default, the available props are based on a div element.
*/
icon: SlotProps<'div', AlertIconSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the message slot.
* By default, the available props are based on a div element.
*/
message: SlotProps<'div', AlertMessageSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the action slot.
* By default, the available props are based on a div element.
*/
action: SlotProps<'div', AlertActionSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the closeButton slot.
* By default, the available props are based on the [IconButton](https://mui.com/material-ui/api/icon-button/#props) component.
*/
closeButton: SlotProps<React.ElementType<IconButtonProps>, AlertCloseButtonSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the closeIcon slot.
* By default, the available props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
*/
closeIcon: SlotProps<React.ElementType<SvgIconProps>, AlertCloseIconSlotPropsOverrides, AlertOwnerState>;
}>;
export interface AlertProps extends StandardProps<PaperProps, 'variant'>, AlertSlotsAndSlotProps {
/**
* The action to display. It renders after the message, at the end of the alert.
*/
action?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<AlertClasses> | undefined;
/**
* Override the default label for the *close popup* icon button.
*
* For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
* @default 'Close'
*/
closeText?: string | undefined;
/**
* The color of the component. Unless provided, the value is taken from the `severity` prop.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
*/
color?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
/**
* The severity of the alert. This defines the color and icon used.
* @default 'success'
*/
severity?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
/**
* Override the icon displayed before the children.
* Unless provided, the icon is mapped to the value of the `severity` prop.
* Set to `false` to remove the `icon`.
*/
icon?: React.ReactNode;
/**
* The ARIA role attribute of the element.
* @default 'alert'
*/
role?: string | undefined;
/**
* The component maps the `severity` prop to a range of different icons,
* for instance success to `<SuccessOutlined>`.
* If you wish to change this mapping, you can provide your own.
* Alternatively, you can use the `icon` prop to override the icon displayed.
*/
iconMapping?: Partial<Record<OverridableStringUnion<AlertColor, AlertPropsColorOverrides>, React.ReactNode>> | undefined;
/**
* Callback fired when the component requests to be closed.
* When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
* @param {React.SyntheticEvent} event The event source of the callback.
*/
onClose?: ((event: React.SyntheticEvent) => void) | undefined;
/**
* The variant to use.
* @default 'standard'
*/
variant?: OverridableStringUnion<'standard' | 'filled' | 'outlined', AlertPropsVariantOverrides> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface AlertOwnerState extends AlertProps {}
/**
*
* Demos:
*
* - [Alert](https://mui.com/material-ui/react-alert/)
*
* API:
*
* - [Alert API](https://mui.com/material-ui/api/alert/)
* - inherits [Paper API](https://mui.com/material-ui/api/paper/)
*/
export default function Alert(props: AlertProps): React.JSX.Element;
+158
View File
@@ -0,0 +1,158 @@
import * as React from 'react';
import { OverridableStringUnion } from '@mui/types';
import { SxProps } from '@mui/system';
import { SvgIconProps } from "../SvgIcon/index.js";
import { Theme } from "../styles/index.js";
import { InternalStandardProps as StandardProps } from "../internal/index.js";
import { IconButtonProps } from "../IconButton/index.js";
import { PaperProps } from "../Paper/index.js";
import { AlertClasses } from "./alertClasses.js";
import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
export type AlertColor = 'success' | 'info' | 'warning' | 'error';
export interface AlertPropsVariantOverrides {}
export interface AlertPropsColorOverrides {}
export interface AlertRootSlotPropsOverrides {}
export interface AlertIconSlotPropsOverrides {}
export interface AlertMessageSlotPropsOverrides {}
export interface AlertActionSlotPropsOverrides {}
export interface AlertCloseButtonSlotPropsOverrides {}
export interface AlertCloseIconSlotPropsOverrides {}
export interface AlertSlots {
/**
* The component that renders the root slot.
* @default Paper
*/
root: React.ElementType;
/**
* The component that renders the icon slot.
* @default div
*/
icon: React.ElementType;
/**
* The component that renders the message slot.
* @default div
*/
message: React.ElementType;
/**
* The component that renders the action slot.
* @default div
*/
action: React.ElementType;
/**
* The component that renders the close button.
* @default IconButton
*/
closeButton: React.ElementType;
/**
* The component that renders the close icon.
* @default svg
*/
closeIcon: React.ElementType;
}
export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps<AlertSlots, {
/**
* Props forwarded to the root slot.
* By default, the available props are based on the [Paper](https://mui.com/material-ui/api/paper/#props) component.
*/
root: SlotProps<React.ElementType<PaperProps>, AlertRootSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the icon slot.
* By default, the available props are based on a div element.
*/
icon: SlotProps<'div', AlertIconSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the message slot.
* By default, the available props are based on a div element.
*/
message: SlotProps<'div', AlertMessageSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the action slot.
* By default, the available props are based on a div element.
*/
action: SlotProps<'div', AlertActionSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the closeButton slot.
* By default, the available props are based on the [IconButton](https://mui.com/material-ui/api/icon-button/#props) component.
*/
closeButton: SlotProps<React.ElementType<IconButtonProps>, AlertCloseButtonSlotPropsOverrides, AlertOwnerState>;
/**
* Props forwarded to the closeIcon slot.
* By default, the available props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
*/
closeIcon: SlotProps<React.ElementType<SvgIconProps>, AlertCloseIconSlotPropsOverrides, AlertOwnerState>;
}>;
export interface AlertProps extends StandardProps<PaperProps, 'variant'>, AlertSlotsAndSlotProps {
/**
* The action to display. It renders after the message, at the end of the alert.
*/
action?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<AlertClasses> | undefined;
/**
* Override the default label for the *close popup* icon button.
*
* For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
* @default 'Close'
*/
closeText?: string | undefined;
/**
* The color of the component. Unless provided, the value is taken from the `severity` prop.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
*/
color?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
/**
* The severity of the alert. This defines the color and icon used.
* @default 'success'
*/
severity?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
/**
* Override the icon displayed before the children.
* Unless provided, the icon is mapped to the value of the `severity` prop.
* Set to `false` to remove the `icon`.
*/
icon?: React.ReactNode;
/**
* The ARIA role attribute of the element.
* @default 'alert'
*/
role?: string | undefined;
/**
* The component maps the `severity` prop to a range of different icons,
* for instance success to `<SuccessOutlined>`.
* If you wish to change this mapping, you can provide your own.
* Alternatively, you can use the `icon` prop to override the icon displayed.
*/
iconMapping?: Partial<Record<OverridableStringUnion<AlertColor, AlertPropsColorOverrides>, React.ReactNode>> | undefined;
/**
* Callback fired when the component requests to be closed.
* When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
* @param {React.SyntheticEvent} event The event source of the callback.
*/
onClose?: ((event: React.SyntheticEvent) => void) | undefined;
/**
* The variant to use.
* @default 'standard'
*/
variant?: OverridableStringUnion<'standard' | 'filled' | 'outlined', AlertPropsVariantOverrides> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface AlertOwnerState extends AlertProps {}
/**
*
* Demos:
*
* - [Alert](https://mui.com/material-ui/react-alert/)
*
* API:
*
* - [Alert API](https://mui.com/material-ui/api/alert/)
* - inherits [Paper API](https://mui.com/material-ui/api/paper/)
*/
export default function Alert(props: AlertProps): React.JSX.Element;
+357
View File
@@ -0,0 +1,357 @@
"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 = void 0;
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
var _zeroStyled = require("../zero-styled");
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
var _DefaultPropsProvider = require("../DefaultPropsProvider");
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
var _createSimplePaletteValueFilter = _interopRequireDefault(require("../utils/createSimplePaletteValueFilter"));
var _Paper = _interopRequireDefault(require("../Paper"));
var _alertClasses = _interopRequireWildcard(require("./alertClasses"));
var _IconButton = _interopRequireDefault(require("../IconButton"));
var _SuccessOutlined = _interopRequireDefault(require("../internal/svg-icons/SuccessOutlined"));
var _ReportProblemOutlined = _interopRequireDefault(require("../internal/svg-icons/ReportProblemOutlined"));
var _ErrorOutline = _interopRequireDefault(require("../internal/svg-icons/ErrorOutline"));
var _InfoOutlined = _interopRequireDefault(require("../internal/svg-icons/InfoOutlined"));
var _Close = _interopRequireDefault(require("../internal/svg-icons/Close"));
var _jsxRuntime = require("react/jsx-runtime");
const useUtilityClasses = ownerState => {
const {
variant,
color,
severity,
classes
} = ownerState;
const slots = {
root: ['root', `color${(0, _capitalize.default)(color || severity)}`, `${variant}`],
icon: ['icon'],
message: ['message'],
action: ['action']
};
return (0, _composeClasses.default)(slots, _alertClasses.getAlertUtilityClass, classes);
};
const AlertRoot = (0, _zeroStyled.styled)(_Paper.default, {
name: 'MuiAlert',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, styles[ownerState.variant]];
}
})((0, _memoTheme.default)(({
theme
}) => {
const getColor = theme.palette.mode === 'light' ? theme.darken : theme.lighten;
const getBackgroundColor = theme.palette.mode === 'light' ? theme.lighten : theme.darken;
return {
...theme.typography.body2,
backgroundColor: 'transparent',
display: 'flex',
padding: '6px 16px',
variants: [...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)(['light'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'standard'
},
style: {
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
backgroundColor: theme.vars ? theme.vars.palette.Alert[`${color}StandardBg`] : getBackgroundColor(theme.palette[color].light, 0.9),
[`& .${_alertClasses.default.icon}`]: theme.vars ? {
color: theme.vars.palette.Alert[`${color}IconColor`]
} : {
color: theme.palette[color].main
}
}
})), ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)(['light'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'outlined'
},
style: {
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
border: `1px solid ${(theme.vars || theme).palette[color].light}`,
[`& .${_alertClasses.default.icon}`]: theme.vars ? {
color: theme.vars.palette.Alert[`${color}IconColor`]
} : {
color: theme.palette[color].main
}
}
})), ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)(['dark'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'filled'
},
style: {
fontWeight: theme.typography.fontWeightMedium,
...(theme.vars ? {
color: theme.vars.palette.Alert[`${color}FilledColor`],
backgroundColor: theme.vars.palette.Alert[`${color}FilledBg`]
} : {
backgroundColor: theme.palette.mode === 'dark' ? theme.palette[color].dark : theme.palette[color].main,
color: theme.palette.getContrastText(theme.palette[color].main)
})
}
}))]
};
}));
const AlertIcon = (0, _zeroStyled.styled)('div', {
name: 'MuiAlert',
slot: 'Icon'
})({
marginRight: 12,
padding: '7px 0',
display: 'flex',
fontSize: 22,
opacity: 0.9
});
const AlertMessage = (0, _zeroStyled.styled)('div', {
name: 'MuiAlert',
slot: 'Message'
})({
padding: '8px 0',
minWidth: 0,
overflow: 'auto'
});
const AlertAction = (0, _zeroStyled.styled)('div', {
name: 'MuiAlert',
slot: 'Action'
})({
display: 'flex',
alignItems: 'flex-start',
padding: '4px 0 0 16px',
marginLeft: 'auto',
marginRight: -8
});
const defaultIconMapping = {
success: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SuccessOutlined.default, {
fontSize: "inherit"
}),
warning: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReportProblemOutlined.default, {
fontSize: "inherit"
}),
error: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorOutline.default, {
fontSize: "inherit"
}),
info: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InfoOutlined.default, {
fontSize: "inherit"
})
};
const Alert = /*#__PURE__*/React.forwardRef(function Alert(inProps, ref) {
const props = (0, _DefaultPropsProvider.useDefaultProps)({
props: inProps,
name: 'MuiAlert'
});
const {
action,
children,
className,
closeText = 'Close',
color,
icon,
iconMapping = defaultIconMapping,
onClose,
role = 'alert',
severity = 'success',
slotProps = {},
slots = {},
variant = 'standard',
...other
} = props;
const ownerState = {
...props,
color,
severity,
variant,
colorSeverity: color || severity
};
const classes = useUtilityClasses(ownerState);
const externalForwardedProps = {
slots,
slotProps
};
const [RootSlot, rootSlotProps] = (0, _useSlot.default)('root', {
ref,
shouldForwardComponentProp: true,
className: (0, _clsx.default)(classes.root, className),
elementType: AlertRoot,
externalForwardedProps: {
...externalForwardedProps,
...other
},
ownerState,
additionalProps: {
role,
elevation: 0
}
});
const [IconSlot, iconSlotProps] = (0, _useSlot.default)('icon', {
className: classes.icon,
elementType: AlertIcon,
externalForwardedProps,
ownerState
});
const [MessageSlot, messageSlotProps] = (0, _useSlot.default)('message', {
className: classes.message,
elementType: AlertMessage,
externalForwardedProps,
ownerState
});
const [ActionSlot, actionSlotProps] = (0, _useSlot.default)('action', {
className: classes.action,
elementType: AlertAction,
externalForwardedProps,
ownerState
});
const [CloseButtonSlot, closeButtonProps] = (0, _useSlot.default)('closeButton', {
elementType: _IconButton.default,
externalForwardedProps,
ownerState
});
const [CloseIconSlot, closeIconProps] = (0, _useSlot.default)('closeIcon', {
elementType: _Close.default,
externalForwardedProps,
ownerState
});
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(RootSlot, {
...rootSlotProps,
children: [icon !== false ? /*#__PURE__*/(0, _jsxRuntime.jsx)(IconSlot, {
...iconSlotProps,
children: icon || iconMapping[severity] || defaultIconMapping[severity]
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageSlot, {
...messageSlotProps,
children: children
}), action != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionSlot, {
...actionSlotProps,
children: action
}) : null, action == null && onClose ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionSlot, {
...actionSlotProps,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseButtonSlot, {
size: "small",
"aria-label": closeText,
title: closeText,
color: "inherit",
onClick: onClose,
...closeButtonProps,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseIconSlot, {
fontSize: "small",
...closeIconProps
})
})
}) : null]
});
});
process.env.NODE_ENV !== "production" ? Alert.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`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The action to display. It renders after the message, at the end of the alert.
*/
action: _propTypes.default.node,
/**
* The content of the component.
*/
children: _propTypes.default.node,
/**
* Override or extend the styles applied to the component.
*/
classes: _propTypes.default.object,
/**
* @ignore
*/
className: _propTypes.default.string,
/**
* Override the default label for the *close popup* icon button.
*
* For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
* @default 'Close'
*/
closeText: _propTypes.default.string,
/**
* The color of the component. Unless provided, the value is taken from the `severity` prop.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
*/
color: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['error', 'info', 'success', 'warning']), _propTypes.default.string]),
/**
* Override the icon displayed before the children.
* Unless provided, the icon is mapped to the value of the `severity` prop.
* Set to `false` to remove the `icon`.
*/
icon: _propTypes.default.node,
/**
* The component maps the `severity` prop to a range of different icons,
* for instance success to `<SuccessOutlined>`.
* If you wish to change this mapping, you can provide your own.
* Alternatively, you can use the `icon` prop to override the icon displayed.
*/
iconMapping: _propTypes.default.shape({
error: _propTypes.default.node,
info: _propTypes.default.node,
success: _propTypes.default.node,
warning: _propTypes.default.node
}),
/**
* Callback fired when the component requests to be closed.
* When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
* @param {React.SyntheticEvent} event The event source of the callback.
*/
onClose: _propTypes.default.func,
/**
* The ARIA role attribute of the element.
* @default 'alert'
*/
role: _propTypes.default.string,
/**
* The severity of the alert. This defines the color and icon used.
* @default 'success'
*/
severity: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['error', 'info', 'success', 'warning']), _propTypes.default.string]),
/**
* The props used for each slot inside.
* @default {}
*/
slotProps: _propTypes.default.shape({
action: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
closeButton: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
closeIcon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
icon: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
message: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]),
root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: _propTypes.default.shape({
action: _propTypes.default.elementType,
closeButton: _propTypes.default.elementType,
closeIcon: _propTypes.default.elementType,
icon: _propTypes.default.elementType,
message: _propTypes.default.elementType,
root: _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 variant to use.
* @default 'standard'
*/
variant: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['filled', 'outlined', 'standard']), _propTypes.default.string])
} : void 0;
var _default = exports.default = Alert;
+350
View File
@@ -0,0 +1,350 @@
'use client';
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import { styled } from "../zero-styled/index.mjs";
import memoTheme from "../utils/memoTheme.mjs";
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
import useSlot from "../utils/useSlot.mjs";
import capitalize from "../utils/capitalize.mjs";
import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.mjs";
import Paper from "../Paper/index.mjs";
import alertClasses, { getAlertUtilityClass } from "./alertClasses.mjs";
import IconButton from "../IconButton/index.mjs";
import SuccessOutlinedIcon from "../internal/svg-icons/SuccessOutlined.mjs";
import ReportProblemOutlinedIcon from "../internal/svg-icons/ReportProblemOutlined.mjs";
import ErrorOutlineIcon from "../internal/svg-icons/ErrorOutline.mjs";
import InfoOutlinedIcon from "../internal/svg-icons/InfoOutlined.mjs";
import CloseIcon from "../internal/svg-icons/Close.mjs";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
variant,
color,
severity,
classes
} = ownerState;
const slots = {
root: ['root', `color${capitalize(color || severity)}`, `${variant}`],
icon: ['icon'],
message: ['message'],
action: ['action']
};
return composeClasses(slots, getAlertUtilityClass, classes);
};
const AlertRoot = styled(Paper, {
name: 'MuiAlert',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, styles[ownerState.variant]];
}
})(memoTheme(({
theme
}) => {
const getColor = theme.palette.mode === 'light' ? theme.darken : theme.lighten;
const getBackgroundColor = theme.palette.mode === 'light' ? theme.lighten : theme.darken;
return {
...theme.typography.body2,
backgroundColor: 'transparent',
display: 'flex',
padding: '6px 16px',
variants: [...Object.entries(theme.palette).filter(createSimplePaletteValueFilter(['light'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'standard'
},
style: {
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
backgroundColor: theme.vars ? theme.vars.palette.Alert[`${color}StandardBg`] : getBackgroundColor(theme.palette[color].light, 0.9),
[`& .${alertClasses.icon}`]: theme.vars ? {
color: theme.vars.palette.Alert[`${color}IconColor`]
} : {
color: theme.palette[color].main
}
}
})), ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter(['light'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'outlined'
},
style: {
color: theme.vars ? theme.vars.palette.Alert[`${color}Color`] : getColor(theme.palette[color].light, 0.6),
border: `1px solid ${(theme.vars || theme).palette[color].light}`,
[`& .${alertClasses.icon}`]: theme.vars ? {
color: theme.vars.palette.Alert[`${color}IconColor`]
} : {
color: theme.palette[color].main
}
}
})), ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter(['dark'])).map(([color]) => ({
props: {
colorSeverity: color,
variant: 'filled'
},
style: {
fontWeight: theme.typography.fontWeightMedium,
...(theme.vars ? {
color: theme.vars.palette.Alert[`${color}FilledColor`],
backgroundColor: theme.vars.palette.Alert[`${color}FilledBg`]
} : {
backgroundColor: theme.palette.mode === 'dark' ? theme.palette[color].dark : theme.palette[color].main,
color: theme.palette.getContrastText(theme.palette[color].main)
})
}
}))]
};
}));
const AlertIcon = styled('div', {
name: 'MuiAlert',
slot: 'Icon'
})({
marginRight: 12,
padding: '7px 0',
display: 'flex',
fontSize: 22,
opacity: 0.9
});
const AlertMessage = styled('div', {
name: 'MuiAlert',
slot: 'Message'
})({
padding: '8px 0',
minWidth: 0,
overflow: 'auto'
});
const AlertAction = styled('div', {
name: 'MuiAlert',
slot: 'Action'
})({
display: 'flex',
alignItems: 'flex-start',
padding: '4px 0 0 16px',
marginLeft: 'auto',
marginRight: -8
});
const defaultIconMapping = {
success: /*#__PURE__*/_jsx(SuccessOutlinedIcon, {
fontSize: "inherit"
}),
warning: /*#__PURE__*/_jsx(ReportProblemOutlinedIcon, {
fontSize: "inherit"
}),
error: /*#__PURE__*/_jsx(ErrorOutlineIcon, {
fontSize: "inherit"
}),
info: /*#__PURE__*/_jsx(InfoOutlinedIcon, {
fontSize: "inherit"
})
};
const Alert = /*#__PURE__*/React.forwardRef(function Alert(inProps, ref) {
const props = useDefaultProps({
props: inProps,
name: 'MuiAlert'
});
const {
action,
children,
className,
closeText = 'Close',
color,
icon,
iconMapping = defaultIconMapping,
onClose,
role = 'alert',
severity = 'success',
slotProps = {},
slots = {},
variant = 'standard',
...other
} = props;
const ownerState = {
...props,
color,
severity,
variant,
colorSeverity: color || severity
};
const classes = useUtilityClasses(ownerState);
const externalForwardedProps = {
slots,
slotProps
};
const [RootSlot, rootSlotProps] = useSlot('root', {
ref,
shouldForwardComponentProp: true,
className: clsx(classes.root, className),
elementType: AlertRoot,
externalForwardedProps: {
...externalForwardedProps,
...other
},
ownerState,
additionalProps: {
role,
elevation: 0
}
});
const [IconSlot, iconSlotProps] = useSlot('icon', {
className: classes.icon,
elementType: AlertIcon,
externalForwardedProps,
ownerState
});
const [MessageSlot, messageSlotProps] = useSlot('message', {
className: classes.message,
elementType: AlertMessage,
externalForwardedProps,
ownerState
});
const [ActionSlot, actionSlotProps] = useSlot('action', {
className: classes.action,
elementType: AlertAction,
externalForwardedProps,
ownerState
});
const [CloseButtonSlot, closeButtonProps] = useSlot('closeButton', {
elementType: IconButton,
externalForwardedProps,
ownerState
});
const [CloseIconSlot, closeIconProps] = useSlot('closeIcon', {
elementType: CloseIcon,
externalForwardedProps,
ownerState
});
return /*#__PURE__*/_jsxs(RootSlot, {
...rootSlotProps,
children: [icon !== false ? /*#__PURE__*/_jsx(IconSlot, {
...iconSlotProps,
children: icon || iconMapping[severity] || defaultIconMapping[severity]
}) : null, /*#__PURE__*/_jsx(MessageSlot, {
...messageSlotProps,
children: children
}), action != null ? /*#__PURE__*/_jsx(ActionSlot, {
...actionSlotProps,
children: action
}) : null, action == null && onClose ? /*#__PURE__*/_jsx(ActionSlot, {
...actionSlotProps,
children: /*#__PURE__*/_jsx(CloseButtonSlot, {
size: "small",
"aria-label": closeText,
title: closeText,
color: "inherit",
onClick: onClose,
...closeButtonProps,
children: /*#__PURE__*/_jsx(CloseIconSlot, {
fontSize: "small",
...closeIconProps
})
})
}) : null]
});
});
process.env.NODE_ENV !== "production" ? Alert.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`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The action to display. It renders after the message, at the end of the alert.
*/
action: PropTypes.node,
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* Override the default label for the *close popup* icon button.
*
* For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
* @default 'Close'
*/
closeText: PropTypes.string,
/**
* The color of the component. Unless provided, the value is taken from the `severity` prop.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'success', 'warning']), PropTypes.string]),
/**
* Override the icon displayed before the children.
* Unless provided, the icon is mapped to the value of the `severity` prop.
* Set to `false` to remove the `icon`.
*/
icon: PropTypes.node,
/**
* The component maps the `severity` prop to a range of different icons,
* for instance success to `<SuccessOutlined>`.
* If you wish to change this mapping, you can provide your own.
* Alternatively, you can use the `icon` prop to override the icon displayed.
*/
iconMapping: PropTypes.shape({
error: PropTypes.node,
info: PropTypes.node,
success: PropTypes.node,
warning: PropTypes.node
}),
/**
* Callback fired when the component requests to be closed.
* When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
* @param {React.SyntheticEvent} event The event source of the callback.
*/
onClose: PropTypes.func,
/**
* The ARIA role attribute of the element.
* @default 'alert'
*/
role: PropTypes.string,
/**
* The severity of the alert. This defines the color and icon used.
* @default 'success'
*/
severity: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['error', 'info', 'success', 'warning']), PropTypes.string]),
/**
* The props used for each slot inside.
* @default {}
*/
slotProps: PropTypes.shape({
action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
closeButton: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
closeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
icon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
message: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: PropTypes.shape({
action: PropTypes.elementType,
closeButton: PropTypes.elementType,
closeIcon: PropTypes.elementType,
icon: PropTypes.elementType,
message: PropTypes.elementType,
root: 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 variant to use.
* @default 'standard'
*/
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
} : void 0;
export default Alert;
+28
View File
@@ -0,0 +1,28 @@
export interface AlertClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the root element if `variant="filled"`. */
filled: string;
/** Styles applied to the root element if `variant="outlined"`. */
outlined: string;
/** Styles applied to the root element if `variant="standard"`. */
standard: string;
/** Styles applied to the root element if `color="success"`. */
colorSuccess: string;
/** Styles applied to the root element if `color="info"`. */
colorInfo: string;
/** Styles applied to the root element if `color="warning"`. */
colorWarning: string;
/** Styles applied to the root element if `color="error"`. */
colorError: string;
/** Styles applied to the icon wrapper element. */
icon: string;
/** Styles applied to the message wrapper element. */
message: string;
/** Styles applied to the action wrapper element if `action` is provided. */
action: string;
}
export type AlertClassKey = keyof AlertClasses;
export declare function getAlertUtilityClass(slot: string): string;
declare const alertClasses: AlertClasses;
export default alertClasses;
+28
View File
@@ -0,0 +1,28 @@
export interface AlertClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the root element if `variant="filled"`. */
filled: string;
/** Styles applied to the root element if `variant="outlined"`. */
outlined: string;
/** Styles applied to the root element if `variant="standard"`. */
standard: string;
/** Styles applied to the root element if `color="success"`. */
colorSuccess: string;
/** Styles applied to the root element if `color="info"`. */
colorInfo: string;
/** Styles applied to the root element if `color="warning"`. */
colorWarning: string;
/** Styles applied to the root element if `color="error"`. */
colorError: string;
/** Styles applied to the icon wrapper element. */
icon: string;
/** Styles applied to the message wrapper element. */
message: string;
/** Styles applied to the action wrapper element if `action` is provided. */
action: string;
}
export type AlertClassKey = keyof AlertClasses;
export declare function getAlertUtilityClass(slot: string): string;
declare const alertClasses: AlertClasses;
export default alertClasses;
+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.getAlertUtilityClass = getAlertUtilityClass;
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
function getAlertUtilityClass(slot) {
return (0, _generateUtilityClass.default)('MuiAlert', slot);
}
const alertClasses = (0, _generateUtilityClasses.default)('MuiAlert', ['root', 'action', 'icon', 'message', 'filled', 'colorSuccess', 'colorInfo', 'colorWarning', 'colorError', 'outlined', 'standard']);
var _default = exports.default = alertClasses;
+7
View File
@@ -0,0 +1,7 @@
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';
export function getAlertUtilityClass(slot) {
return generateUtilityClass('MuiAlert', slot);
}
const alertClasses = generateUtilityClasses('MuiAlert', ['root', 'action', 'icon', 'message', 'filled', 'colorSuccess', 'colorInfo', 'colorWarning', 'colorError', 'outlined', 'standard']);
export default alertClasses;
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./Alert.mjs";
export * from "./Alert.mjs";
export { default as alertClasses } from "./alertClasses.mjs";
export * from "./alertClasses.mjs";
+4
View File
@@ -0,0 +1,4 @@
export { default } from "./Alert.js";
export * from "./Alert.js";
export { default as alertClasses } from "./alertClasses.js";
export * from "./alertClasses.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 = {
alertClasses: true
};
Object.defineProperty(exports, "alertClasses", {
enumerable: true,
get: function () {
return _alertClasses.default;
}
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _Alert.default;
}
});
var _Alert = _interopRequireDefault(require("./Alert"));
var _alertClasses = _interopRequireWildcard(require("./alertClasses"));
Object.keys(_alertClasses).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _alertClasses[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _alertClasses[key];
}
});
});
+3
View File
@@ -0,0 +1,3 @@
export { default } from "./Alert.mjs";
export { default as alertClasses } from "./alertClasses.mjs";
export * from "./alertClasses.mjs";