@itwin/core-frontend
Version:
iTwin.js frontend components
254 lines • 12.1 kB
TypeScript
/** @packageDocumentation
* @module Notifications
*/
import { BeDuration } from "@itwin/core-bentley";
import { Point2d, XAndY } from "@itwin/core-geometry";
import { DisplayMessageType, MessagePresenter, MessageSeverity, RelativePosition } from "@itwin/appui-abstract";
import { ToolAssistanceInstructions } from "./tools/ToolAssistance";
/** Describes the type and behavior of a [[NotifyMessageDetails]].
* @public
* @extensions
*/
export declare enum OutputMessageType {
/** Temporary message box displays at the top or bottom of the screen then disappears automatically. */
Toast = 0,
/** Message box displays near the cursor over a Viewport and is closed by calling `closePointerMessage`. */
Pointer = 1,
/** Message box displays at the top or bottom of the screen and contains a Close button. */
Sticky = 2,
/** Message box displays near an input field and contains a Close button. */
InputField = 3,
/** Modal message box. */
Alert = 4
}
/** Classifies a [[NotifyMessageDetails]] by its level of importance.
* @public
* @extensions
*/
export declare enum OutputMessagePriority {
None = 0,
Success = 1,
Error = 10,
Warning = 11,
Info = 12,
Debug = 13,
Fatal = 17
}
/** Describes the alert behavior of a [[NotifyMessageDetails]].
* @public
* @extensions
*/
export declare enum OutputMessageAlert {
None = 0,
Dialog = 1,
Balloon = 2
}
/** Reason for ending the activity message via endActivityMessage
* @public
* @extensions
*/
export declare enum ActivityMessageEndReason {
Completed = 0,
Cancelled = 1
}
/** Describes the set of buttons displayed in a message box opened using [[NotificationManager.openMessageBox]].
* @public
* @extensions
*/
export declare enum MessageBoxType {
OkCancel = 0,
Ok = 1,
LargeOk = 2,
MediumAlert = 3,
YesNoCancel = 4,
YesNo = 5
}
/** Describes the icon displayed in a messagebox opened using [[NotificationManager.openMessageBox]].
* @public
* @extensions
*/
export declare enum MessageBoxIconType {
NoSymbol = 0,// Means Don't draw Symbol
Information = 1,// Lower Case i
Question = 2,// Question Mark
Warning = 3,// Exclamation Point
Critical = 4,// Stop Sign
Success = 5
}
/** Describes the possible return values produced when the user clicks a button in a messagebox opened using [[NotificationManager.openMessageBox]].
* @public
* @extensions
*/
export declare enum MessageBoxValue {
Apply = 1,
Reset = 2,
Ok = 3,
Cancel = 4,
Default = 5,
Yes = 6,
No = 7,
Retry = 8,
Stop = 9,
Help = 10,
YesToAll = 11,
NoToAll = 12
}
/** Describes the behavior of a tooltip created using [[NotificationManager.openToolTip]].
* @public
* @extensions
*/
export interface ToolTipOptions {
duration?: BeDuration;
placement?: string;
}
/** Describes a message to be displayed to the user.
* @public
* @extensions
*/
export declare class NotifyMessageDetails {
priority: OutputMessagePriority;
briefMessage: HTMLElement | string;
detailedMessage?: (HTMLElement | string) | undefined;
msgType: OutputMessageType;
openAlert: OutputMessageAlert;
displayTime: BeDuration;
viewport?: HTMLElement;
inputField?: HTMLElement;
displayPoint?: Point2d;
relativePosition: RelativePosition;
/** Constructor
* @param priority The priority this message should be accorded by the NotificationManager.
* @param briefMessage A short message that conveys the simplest explanation of the issue.
* @param detailedMessage An optional comprehensive message that explains the issue in detail and potentially offers a solution.
* @param msgType The type of message. Defaults to Toast.
* @param openAlert Whether an alert box should be displayed or not, and if so what kind.
*/
constructor(priority: OutputMessagePriority, briefMessage: HTMLElement | string, detailedMessage?: (HTMLElement | string) | undefined, msgType?: OutputMessageType, openAlert?: OutputMessageAlert);
/** Set OutputMessageType.Pointer message details.
* @param viewport Viewport over which to display the Pointer type message.
* @param displayPoint Point at which to display the Pointer type message.
* @param relativePosition Position relative to displayPoint at which to display the Pointer type message.
*/
setPointerTypeDetails(viewport: HTMLElement, displayPoint: XAndY, relativePosition?: RelativePosition): void;
/** Set OutputMessageType.InputField message details.
* @param inputField Input field to which the message pertains. The message will be shown just below this input field element.
*/
setInputFieldTypeDetails(inputField: HTMLElement): void;
}
/** Specifies the details of an activity message to be displayed to the user.
* @public
* @extensions
*/
export declare class ActivityMessageDetails {
showProgressBar: boolean;
showPercentInMessage: boolean;
supportsCancellation: boolean;
showDialogInitially: boolean;
wasCancelled: boolean;
/**
* @param showProgressBar Indicates whether to show the progress bar in the activity message dialog.
* @param showPercentInMessage Indicates whether to show the percentage complete in the activity message text.
* @param supportsCancellation Indicates whether to show the Cancel button, giving the user the ability to cancel the operation.
* @param showDialogInitially Indicates whether to show the activity message dialog initially. User can click status bar to open it.
*/
constructor(showProgressBar: boolean, showPercentInMessage: boolean, supportsCancellation: boolean, showDialogInitially?: boolean);
/** Called from NotificationAdmin when the user cancels the activity. */
onActivityCancelled(): void;
/** Called from NotificationAdmin when the activity completes successfully. */
onActivityCompleted(): void;
}
/** The NotificationManager controls the interaction with the user for prompts, error messages, and alert dialogs.
* Implementations of the NotificationManager may present the information in different ways. For example, in
* non-interactive sessions, these messages may be saved to a log file or simply discarded.
* @public
* @extensions
*/
export declare class NotificationManager implements MessagePresenter {
readonly toolTipLocation: Point2d;
/** Output a prompt, given a localization key.
* @param key The key of the localized string with the prompt message.
*/
outputPromptByKey(key: string): void;
/** Output a localized prompt to the user. A 'prompt' indicates an action the user should take to proceed.
* @param _prompt The localized string with the prompt message.
*/
outputPrompt(_prompt: string): void;
/** Output a message and/or alert to the user. */
outputMessage(_message: NotifyMessageDetails): void;
/** Output a MessageBox and wait for response from the user.
* @param _mbType The MessageBox type.
* @param _message The message to display.
* @param _icon The MessageBox icon type.
* @return the response from the user.
*/
openMessageBox(_mbType: MessageBoxType, _message: HTMLElement | string, _icon: MessageBoxIconType): Promise<MessageBoxValue>;
/**
* Set up for activity messages.
* @param _details The activity message details.
* @return true if the message was displayed, false if an invalid priority is specified.
*/
setupActivityMessage(_details: ActivityMessageDetails): boolean;
/**
* Output an activity message to the user.
* @param _messageText The message text.
* @param _percentComplete The percentage of completion.
* @return true if the message was displayed, false if the message could not be displayed.
*/
outputActivityMessage(_messageText: HTMLElement | string, _percentComplete: number): boolean;
/**
* End an activity message.
* @param _reason The reason for the end of the Activity Message.
* @return true if the message was ended successfully, false if the activityMessage could not be ended.
*/
endActivityMessage(_reason: ActivityMessageEndReason): boolean;
/** Return true if _showTooltip has an implementation and will display a tooltip. */
get isToolTipSupported(): boolean;
/** Return true if the tooltip is currently open. */
get isToolTipOpen(): boolean;
/** Implement to display a tooltip message at the specified location. */
protected _showToolTip(_htmlElement: HTMLElement, _message: HTMLElement | string, _location?: XAndY, _options?: ToolTipOptions): void;
/** Show a tooltip window. Saves tooltip location for AccuSnap to test if cursor has moved far enough away to close tooltip.
* @param htmlElement The HTMLElement that anchors the toolTip.
* @param message What to display inside the ToolTip. May be a string or an HTMLElement.
* @param location An optional location, relative to the origin of _htmlElement, for the ToolTip. If undefined, center of `htmlElement`
* @param options Options that supply additional information about how the ToolTip should function.
* @note If message is an HTMLElement, the notification manager will display the HTMLElement verbatim. This can represent a security
* risk if any part the element is created from user input. Applications should be careful to *sanitize* any such input before
* creating an HTMLElement to pass to this method.
*/
openToolTip(htmlElement: HTMLElement, message: HTMLElement | string, location?: XAndY, options?: ToolTipOptions): void;
/** Clear the tooltip if it is currently open. */
clearToolTip(): void;
/** Update message position created with [[OutputMessageType.Pointer]].
* @param displayPoint Point at which to display the Pointer type message.
* @param relativePosition Position relative to displayPoint at which to display the Pointer type message.
*/
updatePointerMessage(_displayPoint: XAndY, _relativePosition?: RelativePosition): void;
/** Close message created with [[OutputMessageType.Pointer]]. */
closePointerMessage(): void;
/** Close message created with [[OutputMessageType.InputField]]. */
closeInputFieldMessage(): void;
/** Setup tool assistance instructions for a tool. The instructions include the main instruction, which includes the current prompt.
* @param instructions The tool assistance instructions.
*/
setToolAssistance(instructions: ToolAssistanceInstructions | undefined): void;
/**
* Displays a notification message.
* @param severity The severity of the message.
* @param briefMessage A short message that conveys the simplest explanation of the issue.
* @param detailedMessage An optional comprehensive message that explains the issue in detail and potentially offers a solution.
* @param messageType The type of message. Defaults to Toast.
*/
displayMessage(severity: MessageSeverity, briefMessage: HTMLElement | string, detailedMessage?: HTMLElement | string, messageType?: DisplayMessageType): void;
/**
* Displays an input field notification message.
* @param inputField Input field to which the message pertains. The message will be shown just below this input field element.
* @param severity The severity of the message.
* @param briefMessage A short message that conveys the simplest explanation of the issue.
* @param detailedMessage An optional comprehensive message that explains the issue in detail and potentially offers a solution.
*/
displayInputFieldMessage(inputField: HTMLElement, severity: MessageSeverity, briefMessage: HTMLElement | string, detailedMessage?: HTMLElement | string): void;
private convertSeverityToPriority;
private convertMessageType;
}
//# sourceMappingURL=NotificationManager.d.ts.map