1 | import * as React from 'react';
|
2 | import { OverridableStringUnion } from '@mui/types';
|
3 | import { SxProps } from '@mui/system';
|
4 | import { IconButtonProps, InternalStandardProps as StandardProps, SvgIconProps, Theme } from '..';
|
5 | import { PaperProps } from '../Paper';
|
6 | import { AlertClasses } from './alertClasses';
|
7 | import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
8 |
|
9 | export type AlertColor = 'success' | 'info' | 'warning' | 'error';
|
10 |
|
11 | export interface AlertPropsVariantOverrides {}
|
12 | export interface AlertPropsColorOverrides {}
|
13 | export interface AlertCloseButtonSlotPropsOverrides {}
|
14 | export interface AlertCloseIconSlotPropsOverrides {}
|
15 |
|
16 | export interface AlertSlots {
|
17 | /**
|
18 | * The component that renders the close button.
|
19 | * @default IconButton
|
20 | */
|
21 | closeButton: React.ElementType;
|
22 | /**
|
23 | * The component that renders the close icon.
|
24 | * @default svg
|
25 | */
|
26 | closeIcon: React.ElementType;
|
27 | }
|
28 |
|
29 | export type AlertSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
30 | AlertSlots,
|
31 | {
|
32 | closeButton: SlotProps<
|
33 | React.ElementType<IconButtonProps>,
|
34 | AlertCloseButtonSlotPropsOverrides,
|
35 | AlertOwnerState
|
36 | >;
|
37 | closeIcon: SlotProps<
|
38 | React.ElementType<SvgIconProps>,
|
39 | AlertCloseIconSlotPropsOverrides,
|
40 | AlertOwnerState
|
41 | >;
|
42 | }
|
43 | >;
|
44 |
|
45 | export interface AlertProps extends StandardProps<PaperProps, 'variant'>, AlertSlotsAndSlotProps {
|
46 | /**
|
47 | * The action to display. It renders after the message, at the end of the alert.
|
48 | */
|
49 | action?: React.ReactNode;
|
50 | /**
|
51 | * Override or extend the styles applied to the component.
|
52 | */
|
53 | classes?: Partial<AlertClasses>;
|
54 | /**
|
55 | * Override the default label for the *close popup* icon button.
|
56 | *
|
57 | * For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
|
58 | * @default 'Close'
|
59 | */
|
60 | closeText?: string;
|
61 | /**
|
62 | * The color of the component. Unless provided, the value is taken from the `severity` prop.
|
63 | * It supports both default and custom theme colors, which can be added as shown in the
|
64 | * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
65 | */
|
66 | color?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides>;
|
67 | /**
|
68 | * The components used for each slot inside.
|
69 | *
|
70 | * @deprecated use the `slots` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
71 | *
|
72 | * @default {}
|
73 | */
|
74 | components?: {
|
75 | CloseButton?: React.ElementType;
|
76 | CloseIcon?: React.ElementType;
|
77 | };
|
78 | /**
|
79 | * The extra props for the slot components.
|
80 | * You can override the existing props or add new ones.
|
81 | *
|
82 | * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
83 | *
|
84 | * @default {}
|
85 | */
|
86 | componentsProps?: {
|
87 | closeButton?: IconButtonProps;
|
88 | closeIcon?: SvgIconProps;
|
89 | };
|
90 | /**
|
91 | * The severity of the alert. This defines the color and icon used.
|
92 | * @default 'success'
|
93 | */
|
94 | severity?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides>;
|
95 | /**
|
96 | * Override the icon displayed before the children.
|
97 | * Unless provided, the icon is mapped to the value of the `severity` prop.
|
98 | * Set to `false` to remove the `icon`.
|
99 | */
|
100 | icon?: React.ReactNode;
|
101 | /**
|
102 | * The ARIA role attribute of the element.
|
103 | * @default 'alert'
|
104 | */
|
105 | role?: string;
|
106 | /**
|
107 | * The component maps the `severity` prop to a range of different icons,
|
108 | * for instance success to `<SuccessOutlined>`.
|
109 | * If you wish to change this mapping, you can provide your own.
|
110 | * Alternatively, you can use the `icon` prop to override the icon displayed.
|
111 | */
|
112 | iconMapping?: Partial<
|
113 | Record<OverridableStringUnion<AlertColor, AlertPropsColorOverrides>, React.ReactNode>
|
114 | >;
|
115 | /**
|
116 | * Callback fired when the component requests to be closed.
|
117 | * When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
|
118 | * @param {React.SyntheticEvent} event The event source of the callback.
|
119 | */
|
120 | onClose?: (event: React.SyntheticEvent) => void;
|
121 | /**
|
122 | * The variant to use.
|
123 | * @default 'standard'
|
124 | */
|
125 | variant?: OverridableStringUnion<'standard' | 'filled' | 'outlined', AlertPropsVariantOverrides>;
|
126 | /**
|
127 | * The system prop that allows defining system overrides as well as additional CSS styles.
|
128 | */
|
129 | sx?: SxProps<Theme>;
|
130 | }
|
131 |
|
132 | export interface AlertOwnerState extends AlertProps {}
|
133 |
|
134 | /**
|
135 | *
|
136 | * Demos:
|
137 | *
|
138 | * - [Alert](https://mui.com/material-ui/react-alert/)
|
139 | *
|
140 | * API:
|
141 | *
|
142 | * - [Alert API](https://mui.com/material-ui/api/alert/)
|
143 | * - inherits [Paper API](https://mui.com/material-ui/api/paper/)
|
144 | */
|
145 | export default function Alert(props: AlertProps): React.JSX.Element;
|