-
Notifications
You must be signed in to change notification settings - Fork 2
/
ModelessDialog.tsx
68 lines (62 loc) · 1.85 KB
/
ModelessDialog.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Dialog
*/
import * as React from "react";
import type { DialogProps } from "@itwin/core-react";
import { Dialog } from "@itwin/core-react";
import { UiFramework } from "../UiFramework";
/** Properties for the [[ModelessDialog]] component
* @public
*/
// eslint-disable-next-line deprecation/deprecation
export interface ModelessDialogProps extends DialogProps {
dialogId: string;
movable?: boolean;
}
/** Modeless Dialog React component uses the Dialog component with a modal={false} prop.
* It controls the z-index to keep the focused dialog above others.
* @public
*/
export class ModelessDialog extends React.Component<ModelessDialogProps> {
constructor(props: ModelessDialogProps) {
super(props);
}
public override render(): React.ReactElement {
const {
dialogId,
style,
modal,
modelessId,
onModelessPointerDown,
...props
} = this.props;
return (
// eslint-disable-next-line deprecation/deprecation
<Dialog
{...props}
modal={false}
modelessId={dialogId}
onModelessPointerDown={(event) =>
UiFramework.dialogs.modeless.handlePointerDownEvent(
event,
dialogId,
this._updateDialog
)
}
style={{
zIndex: UiFramework.dialogs.modeless.getZIndex(dialogId),
...style,
}}
>
{this.props.children}
</Dialog>
);
}
private _updateDialog = () => {
this.forceUpdate();
};
}