UNPKG

6.4 kBTypeScriptView Raw
1import * as React from 'react';
2import { BaseButton, Button, IButtonProps } from '../../Button';
3import type { ITheme, IStyle } from '../../Styling';
4import type { IRefObject, IStyleFunctionOrObject } from '../../Utilities';
5import type { IIconProps } from '../../Icon';
6/**
7 * {@docCategory MessageBar}
8 */
9export interface IMessageBar {
10}
11/**
12 * {@docCategory MessageBar}
13 */
14export interface IMessageBarProps extends React.HTMLAttributes<HTMLElement>, React.RefAttributes<HTMLDivElement> {
15 /**
16 * Optional callback to access the IMessageBar interface. Use this instead of ref for accessing
17 * the public methods and properties of the component.
18 */
19 componentRef?: IRefObject<IMessageBar>;
20 /**
21 * The type of MessageBar to render.
22 * @defaultvalue MessageBarType.info
23 */
24 messageBarType?: MessageBarType;
25 /**
26 * The actions you want to show on the other side.
27 */
28 actions?: JSX.Element;
29 /**
30 * A description of the message bar for the benefit of screen readers.
31 * @deprecated Use native prop `aria-label` instead.
32 */
33 ariaLabel?: string;
34 /**
35 * Whether the message bar has a dismiss button and its callback.
36 * If null, we don't show a dismiss button.
37 * @defaultvalue null
38 */
39 onDismiss?: (ev?: React.MouseEvent<HTMLElement | BaseButton | Button>) => any;
40 /**
41 * Determines if the message bar is multi lined.
42 * If false, and the text overflows over buttons or to another line, it is clipped.
43 * @defaultvalue true
44 */
45 isMultiline?: boolean;
46 /**
47 * Aria label on dismiss button if onDismiss is defined.
48 */
49 dismissButtonAriaLabel?: string;
50 /**
51 * Determines if the message bar text is truncated.
52 * If true, a button will render to toggle between a single line view and multiline view.
53 * This prop is for single line message bars with no buttons only in a limited space scenario.
54 * @defaultvalue false
55 */
56 truncated?: boolean;
57 /**
58 * Aria label on overflow button if truncated is defined.
59 * @deprecated Use `expandButtonProps` instead.
60 */
61 overflowButtonAriaLabel?: string;
62 /**
63 * Additional CSS class(es) to apply to the MessageBar.
64 */
65 className?: string;
66 /**
67 * Theme (provided through customization.)
68 */
69 theme?: ITheme;
70 /**
71 * Call to provide customized styling that will layer on top of the variant rules.
72 */
73 styles?: IStyleFunctionOrObject<IMessageBarStyleProps, IMessageBarStyles>;
74 /**
75 * Custom icon prop to replace the dismiss icon.
76 * If unset, default will be the Fabric Clear icon.
77 */
78 dismissIconProps?: IIconProps;
79 /**
80 * Custom icon prop to replace the message bar icon.
81 * If unset, default will be the icon set by messageBarType.
82 */
83 messageBarIconProps?: IIconProps;
84 /**
85 * Button props that can be applied to the expand button of the MessageBar.
86 */
87 expandButtonProps?: IButtonProps;
88 /**
89 * Custom role to apply to the MessageBar.
90 * @defaultvalue `alert` if `messageBarType` is `error`, `blocked`, or `severeWarning`;
91 * or `status` otherwise
92 */
93 role?: 'alert' | 'status' | 'none';
94 /**
95 * By default, MessageBar delay-renders its content within an internal live region to help ensure
96 * it's announced by screen readers. You can disable that behavior by setting this prop to `false`.
97 *
98 * If you set this prop to `false`, to ensure proper announcement you should either:
99 * - If appropriate, ensure that the `role` prop is set to `alert` (this will be done by default
100 * if `messageBarType` is `error`, `blocked`, or `severeWarning`), OR
101 * - Set the `role` prop to `none` (to avoid nested `status` regions), wrap the whole MessageBar
102 * in a `<div role="status">` which is always rendered, and ensure that the MessageBar is
103 * rendered either conditionally or with a delay.
104 * @default true
105 */
106 delayedRender?: boolean;
107}
108/**
109 * {@docCategory MessageBar}
110 */
111export interface IMessageBarStyleProps {
112 /**
113 * Theme (provided through customization).
114 */
115 theme: ITheme;
116 /**
117 * Additional CSS class(es).
118 */
119 className?: string;
120 /**
121 * Type of the MessageBar.
122 */
123 messageBarType?: MessageBarType;
124 /**
125 * Whether the MessageBar contains a dismiss button.
126 */
127 onDismiss?: boolean;
128 /**
129 * Whether the text is truncated.
130 */
131 truncated?: boolean;
132 /**
133 * Whether the MessageBar is rendered in multi line (as opposed to single line) mode.
134 */
135 isMultiline?: boolean;
136 /**
137 * Whether the single line MessageBar is being expanded.
138 */
139 expandSingleLine?: boolean;
140 /**
141 * Whether the MessageBar contains any action elements.
142 */
143 actions?: boolean;
144}
145/**
146 * {@docCategory MessageBar}
147 */
148export interface IMessageBarStyles {
149 /**
150 * Style set for the root element.
151 */
152 root?: IStyle;
153 /**
154 * Style set for the element containing the icon, text, and optional dismiss button.
155 */
156 content?: IStyle;
157 /**
158 * Style set for the element containing the icon.
159 */
160 iconContainer?: IStyle;
161 /**
162 * Style set for the icon.
163 */
164 icon?: IStyle;
165 /**
166 * Style set for the element containing the text.
167 */
168 text?: IStyle;
169 /**
170 * Style set for the text.
171 */
172 innerText?: IStyle;
173 /**
174 * Style set for the optional dismiss button.
175 */
176 dismissal?: IStyle;
177 /**
178 * Style set for the icon used to expand and collapse the MessageBar.
179 */
180 expand?: IStyle;
181 /**
182 * Style set for the element containing the dismiss button.
183 */
184 dismissSingleLine?: IStyle;
185 /**
186 * Style set for the element containing the expand icon.
187 */
188 expandSingleLine?: IStyle;
189 /**
190 * Style set for the optional element containing the action elements.
191 */
192 actions?: IStyle;
193}
194/**
195 * {@docCategory MessageBar}
196 */
197export declare enum MessageBarType {
198 /** Info styled MessageBar */
199 info = 0,
200 /** Error styled MessageBar */
201 error = 1,
202 /** Blocked styled MessageBar */
203 blocked = 2,
204 /** SevereWarning styled MessageBar */
205 severeWarning = 3,
206 /** Success styled MessageBar */
207 success = 4,
208 /** Warning styled MessageBar */
209 warning = 5
210}