@itwin/appui-abstract
Version:
iTwin.js UI abstractions
228 lines • 15.6 kB
TypeScript
/** @packageDocumentation
* @module UiAdmin
*/
import { BeUiEvent } from "@itwin/core-bentley";
import { AbstractMenuItemProps } from "./items/AbstractMenuItemProps";
import { AbstractToolbarProps } from "./items/AbstractToolbarProps";
import { RelativePosition } from "./items/RelativePosition";
import { PropertyDescription } from "./properties/Description";
import { Primitives } from "./properties/PrimitiveTypes";
import { OnCancelFunc, OnItemExecutedFunc, OnNumberCommitFunc, OnValueCommitFunc } from "./utils/callbacks";
import { PropertyRecord } from "./properties/Record";
import { UiDataProvider } from "./dialogs/UiDataProvider";
import { DialogLayoutDataProvider } from "./dialogs/UiLayoutDataProvider";
import { MessagePresenter } from "./notification/MessagePresenter";
interface XAndY {
readonly x: number;
readonly y: number;
}
/** The Generic UI Event args contains information useful for any UI message
* @public
*/
export interface GenericUiEventArgs {
uiComponentId: string;
}
/** Optional props to pass to the Dialog control that is generated.
* @public
*/
export interface DialogProps {
/** Indicates whether the user can resize dialog with cursor. */
resizable?: boolean;
/** Indicates whether the user can move dialog with cursor.*/
movable?: boolean;
/** Initial width of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
width?: string | number;
/** Initial height of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
height?: string | number;
/** Minimum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
minWidth?: string | number;
/** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
minHeight?: string | number;
/** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
maxWidth?: string | number;
/** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
maxHeight?: string | number;
}
/** The GenericUiEvent is the base event class for UI events that target a specific component, as identified in uiComponentId.
* @public
*/
export declare class GenericUiEvent extends BeUiEvent<GenericUiEventArgs> {
}
/** Flags that control enabling/disabling certain UI features
* @public
*/
export interface UiFlags {
/** if true then Ctrl+F2 will show popup key-in palette */
allowKeyinPalette?: boolean;
}
/** The UiAdmin controls various UI components and is callable from IModelApp.uiAdmin in the core-frontend package.
* @public
*/
export declare class UiAdmin {
private _featureFlags;
private static _messagePresenter?;
/** The MessagePresenter used to display messages. */
static get messagePresenter(): MessagePresenter;
static set messagePresenter(mp: MessagePresenter);
get featureFlags(): UiFlags;
updateFeatureFlags(uiFlags: UiFlags): void;
/** @internal */
onInitialized(): void;
/** Get the cursor X and Y position. */
get cursorPosition(): XAndY;
/** Create a PointProps object.
* @deprecated in 4.2.x - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation.
*/
createXAndY(x: number, y: number): XAndY;
/** Determines if focus is set to Home */
get isFocusOnHome(): boolean;
/** Sets focus to Home */
setFocusToHome(): void;
/** Show a context menu at a particular location.
* @param _menuItemsProps Properties of the menu items to display.
* @param _location Location of the context menu, relative to the origin of htmlElement or the window.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the menu was displayed, false if the menu could not be displayed.
*/
showContextMenu(_menuItemsProps: AbstractMenuItemProps[], _location: XAndY, _htmlElement?: HTMLElement): boolean;
/** Show a Toolbar at a particular location.
* @param _toolbarProps Properties of the Toolbar to display.
* @param _location Location of the Toolbar, relative to the origin of htmlElement or the window.
* @param _offset Offset of the Toolbar from the location.
* @param _onItemExecuted Function invoked after a Toolbar item is executed
* @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the Toolbar
* @param _relativePosition Position relative to the given location. Defaults to TopRight.
* @param _htmlElement The HTMLElement that anchors the Toolbar. If undefined, the location is relative to the overall window.
* @return true if the Toolbar was displayed, false if the Toolbar could not be displayed.
*/
showToolbar(_toolbarProps: AbstractToolbarProps, _location: XAndY, _offset: XAndY, _onItemExecuted: OnItemExecutedFunc, _onCancel: OnCancelFunc, _relativePosition?: RelativePosition, _htmlElement?: HTMLElement): boolean;
/** Hides the toolbar. */
hideToolbar(): boolean;
/** Show a menu button at a particular location. A menu button opens a context menu.
* @param _id Id of the menu button. Multiple menu buttons may be displayed.
* @param _menuItemsProps Properties of the menu items to display.
* @param _location Location of the context menu, relative to the origin of htmlElement or the window.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the button was displayed, false if the button could not be displayed.
*/
showMenuButton(_id: string, _menuItemsProps: AbstractMenuItemProps[], _location: XAndY, _htmlElement?: HTMLElement): boolean;
/** Hides a menu button.
* @param _id Id of the menu button. Multiple menu buttons may be displayed.
* @return true if the menu was hidden, false if the menu could not be hidden.
*/
hideMenuButton(_id: string): boolean;
/** Show a calculator at a particular location.
* @param _initialValue Value initially displayed in the calculator.
* @param _resultIcon Icon displayed to the left of the value.
* @param _location Location of the calculator, relative to the origin of htmlElement or the window.
* @param _onCommit Function called when the OK button or the Enter key is pressed.
* @param _onCancel Function called when the Cancel button or the Escape key is pressed.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the calculator was displayed, false if the calculator could not be displayed.
*/
showCalculator(_initialValue: number, _resultIcon: string, _location: XAndY, _onCommit: OnNumberCommitFunc, _onCancel: OnCancelFunc, _htmlElement?: HTMLElement): boolean;
/** Hides the calculator. */
hideCalculator(): boolean;
/** Show an input editor for an angle value at a particular location.
* @param _initialValue Value initially displayed in the editor.
* @param _location Location of the editor, relative to the origin of htmlElement or the window.
* @param _onCommit Function called when the OK button or the Enter key is pressed.
* @param _onCancel Function called when the Cancel button or the Escape key is pressed.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the editor was displayed, false if the editor could not be displayed.
*/
showAngleEditor(_initialValue: number, _location: XAndY, _onCommit: OnNumberCommitFunc, _onCancel: OnCancelFunc, _htmlElement?: HTMLElement): boolean;
/** Show an input editor for a length value at a particular location.
* @param _initialValue Value initially displayed in the editor.
* @param _location Location of the editor, relative to the origin of htmlElement or the window.
* @param _onCommit Function called when the OK button or the Enter key is pressed.
* @param _onCancel Function called when the Cancel button or the Escape key is pressed.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the editor was displayed, false if the editor could not be displayed.
*/
showLengthEditor(_initialValue: number, _location: XAndY, _onCommit: OnNumberCommitFunc, _onCancel: OnCancelFunc, _htmlElement?: HTMLElement): boolean;
/** Show an input editor for a height value at a particular location.
* @param _initialValue Value initially displayed in the editor.
* @param _location Location of the editor, relative to the origin of htmlElement or the window.
* @param _onCommit Function called when the OK button or the Enter key is pressed.
* @param _onCancel Function called when the Cancel button or the Escape key is pressed.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the editor was displayed, false if the editor could not be displayed.
*/
showHeightEditor(_initialValue: number, _location: XAndY, _onCommit: OnNumberCommitFunc, _onCancel: OnCancelFunc, _htmlElement?: HTMLElement): boolean;
/** Show an input editor for a primitive value at a particular location.
* @param _initialValue Value initially displayed in the editor.
* @param _propertyDescription Description of the primitive value property.
* @param _location Location of the editor, relative to the origin of htmlElement or the window.
* @param _onCommit Function called when the OK button or the Enter key is pressed.
* @param _onCancel Function called when the Cancel button or the Escape key is pressed.
* @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window.
* @return true if the editor was displayed, false if the editor could not be displayed.
*/
showInputEditor(_initialValue: Primitives.Value, _propertyDescription: PropertyDescription, _location: XAndY, _onCommit: OnValueCommitFunc, _onCancel: OnCancelFunc, _htmlElement?: HTMLElement): boolean;
/** Hides the input editor. */
hideInputEditor(): boolean;
/** Show an HTML element at a particular location.
* @param _displayElement The HTMLElement to display
* @param _location Location of the tool settings, relative to the origin of anchorElement or the window
* @param _offset Offset of the display element from the location
* @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the display element
* @param _relativePosition Position relative to the given location. Defaults to TopRight.
* @param _anchorElement The HTMLElement that anchors the display element. If undefined, the location is relative to the overall window.
* @return true if the display element was displayed, false if the display element could not be displayed.
*/
showHTMLElement(_displayElement: HTMLElement, _location: XAndY, _offset: XAndY, _onCancel: OnCancelFunc, _relativePosition?: RelativePosition, _anchorElement?: HTMLElement): boolean;
/** Hides the HTML Element. */
hideHTMLElement(): boolean;
/** Show a Card containing content, a title and a toolbar at a particular location.
* @param _content The HTMLElement of the content to display
* @param _title Title to display at the top of the card.
* @param _toolbarProps Properties of the Toolbar to display.
* @param _location Location of the Card, relative to the origin of anchorElement or the window.
* @param _offset Offset of the Card from the location.
* @param _onItemExecuted Function invoked after a Toolbar item is executed
* @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the Card
* @param _relativePosition Position relative to the given location. Defaults to TopRight.
* @param _anchorElement The HTMLElement that anchors the Card. If undefined, the location is relative to the overall window.
* @return true if the Card was displayed, false if the Card could not be displayed.
*/
showCard(_content: HTMLElement, _title: string | PropertyRecord | undefined, _toolbarProps: AbstractToolbarProps | undefined, _location: XAndY, _offset: XAndY, _onItemExecuted: OnItemExecutedFunc, _onCancel: OnCancelFunc, _relativePosition?: RelativePosition, _anchorElement?: HTMLElement): boolean;
/** Hides the Card. */
hideCard(): boolean;
/** Opens a Tool Settings Ui popup at a particular location.
* @param _dataProvider The UiDataProvider for the tool settings
* @param _location Location of the tool settings, relative to the origin of anchorElement or the window
* @param _offset Offset of the tool settings from the location
* @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the tool settings
* @param _relativePosition Position relative to the given location. Defaults to TopRight.
* @param _anchorElement The HTMLElement that anchors the tool settings. If undefined, the location is relative to the overall window.
* @return true if the tool settings were displayed, false if the tool settings could not be displayed.
*/
openToolSettingsPopup(_dataProvider: UiDataProvider, _location: XAndY, _offset: XAndY, _onCancel: OnCancelFunc, _relativePosition?: RelativePosition, _anchorElement?: HTMLElement): boolean;
/** Closes the Tool Settings Ui popup. */
closeToolSettingsPopup(): boolean;
/** Show the Keyin Palette to display all support Tool key-ins.
* @param _htmlElement The HTMLElement that anchors the Keyin Palette. If undefined, the location is relative to the overall window.
* @return true if the Keyin Palette was displayed, false if it could not be displayed.
*/
showKeyinPalette(_htmlElement?: HTMLElement): boolean;
/** Hides the Keyin Palette. */
hideKeyinPalette(): boolean;
/** Send a UI event */
static sendUiEvent(args: GenericUiEventArgs): void;
/** GenericUiEvent */
static readonly onGenericUiEvent: GenericUiEvent;
/** Opens a Dialog and automatically populates it using the properties defined by the UiDataProvider.
* @param _uiDataProvider The DialogLayoutDataProvider for the dialog
* @param _title Specify title for dialog.
* @param _isModal Specify if the dialog is opened as a modal or modeless.
* @param _id Id of the dialog that is used to close it.
* @param _optionalProps Optional props for Dialog construction.
* @return true if the tool settings were displayed, false if the tool settings could not be displayed.
*/
openDialog(_uiDataProvider: DialogLayoutDataProvider, _title: string, _isModal: boolean, _id: string, _optionalProps?: DialogProps): boolean;
/** Closes the Dialog with a given Id. */
closeDialog(_dialogId: string): boolean;
}
export {};
//# sourceMappingURL=UiAdmin.d.ts.map