@itwin/core-react 4.2.0 → 4.3.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/core-react/_geometry.scss +3 -3
- package/lib/cjs/core-react/_math.scss +3 -3
- package/lib/cjs/core-react/_typography.scss +3 -3
- package/lib/cjs/core-react/autosuggest/AutoSuggest.scss +3 -3
- package/lib/cjs/core-react/badge/Badge.scss +3 -3
- package/lib/cjs/core-react/badge/NewBadge.scss +3 -3
- package/lib/cjs/core-react/base/base.scss +3 -3
- package/lib/cjs/core-react/base/index.scss +3 -3
- package/lib/cjs/core-react/classes.scss +3 -3
- package/lib/cjs/core-react/colorthemes.scss +3 -3
- package/lib/cjs/core-react/colorvariables.scss +3 -3
- package/lib/cjs/core-react/contextmenu/ContextMenu.scss +3 -3
- package/lib/cjs/core-react/dialog/Dialog.d.ts +3 -10
- package/lib/cjs/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.js +69 -166
- package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.scss +59 -217
- package/lib/cjs/core-react/expandable/index.scss +3 -3
- package/lib/cjs/core-react/expandable/list.scss +3 -3
- package/lib/cjs/core-react/icons/SvgPath.scss +3 -3
- package/lib/cjs/core-react/icons/WebFontIcon.scss +3 -3
- package/lib/cjs/core-react/icons/index.scss +3 -3
- package/lib/cjs/core-react/icons/mixins.scss +3 -3
- package/lib/cjs/core-react/icons/variables.scss +3 -3
- package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.scss +3 -3
- package/lib/cjs/core-react/index.scss +3 -3
- package/lib/cjs/core-react/inputs/index.scss +3 -3
- package/lib/cjs/core-react/inputs/input-label.scss +3 -3
- package/lib/cjs/core-react/inputs/input.scss +3 -3
- package/lib/cjs/core-react/inputs/numberinput/NumberInput.scss +3 -3
- package/lib/cjs/core-react/inputs/variables.scss +3 -3
- package/lib/cjs/core-react/listbox/Listbox.scss +3 -3
- package/lib/cjs/core-react/loading/LoadingPrompt.scss +3 -3
- package/lib/cjs/core-react/loading/LoadingSpinner.scss +3 -3
- package/lib/cjs/core-react/loading/index.scss +3 -3
- package/lib/cjs/core-react/loading/mixins.scss +3 -3
- package/lib/cjs/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.js +2 -2
- package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/cjs/core-react/messagebox/MessageBox.scss +3 -3
- package/lib/cjs/core-react/popup/Popup.scss +3 -3
- package/lib/cjs/core-react/radialmenu/RadialMenu.scss +3 -3
- package/lib/cjs/core-react/searchbox/SearchBox.scss +3 -3
- package/lib/cjs/core-react/settings/SettingsContainer.scss +3 -3
- package/lib/cjs/core-react/style/baseline.scss +3 -3
- package/lib/cjs/core-react/style/index.scss +3 -3
- package/lib/cjs/core-react/style/opacity.scss +3 -3
- package/lib/cjs/core-react/tabs/index.scss +3 -3
- package/lib/cjs/core-react/tabs/tabs.scss +3 -3
- package/lib/cjs/core-react/tabs/vertical.scss +3 -3
- package/lib/cjs/core-react/text/FilteredText.scss +3 -3
- package/lib/cjs/core-react/text/block.scss +3 -3
- package/lib/cjs/core-react/text/body.scss +3 -3
- package/lib/cjs/core-react/text/index.scss +3 -3
- package/lib/cjs/core-react/text/mixins.scss +3 -3
- package/lib/cjs/core-react/tree/ExpansionToggle.scss +3 -3
- package/lib/cjs/core-react/tree/Placeholder.scss +3 -3
- package/lib/cjs/core-react/tree/Tree.scss +3 -3
- package/lib/esm/core-react/_geometry.scss +3 -3
- package/lib/esm/core-react/_math.scss +3 -3
- package/lib/esm/core-react/_typography.scss +3 -3
- package/lib/esm/core-react/autosuggest/AutoSuggest.scss +3 -3
- package/lib/esm/core-react/badge/Badge.scss +3 -3
- package/lib/esm/core-react/badge/NewBadge.scss +3 -3
- package/lib/esm/core-react/base/base.scss +3 -3
- package/lib/esm/core-react/base/index.scss +3 -3
- package/lib/esm/core-react/classes.scss +3 -3
- package/lib/esm/core-react/colorthemes.scss +3 -3
- package/lib/esm/core-react/colorvariables.scss +3 -3
- package/lib/esm/core-react/contextmenu/ContextMenu.scss +3 -3
- package/lib/esm/core-react/dialog/Dialog.d.ts +3 -10
- package/lib/esm/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.js +68 -165
- package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.scss +59 -217
- package/lib/esm/core-react/expandable/index.scss +3 -3
- package/lib/esm/core-react/expandable/list.scss +3 -3
- package/lib/esm/core-react/icons/SvgPath.scss +3 -3
- package/lib/esm/core-react/icons/WebFontIcon.scss +3 -3
- package/lib/esm/core-react/icons/index.scss +3 -3
- package/lib/esm/core-react/icons/mixins.scss +3 -3
- package/lib/esm/core-react/icons/variables.scss +3 -3
- package/lib/esm/core-react/imagecheckbox/ImageCheckBox.scss +3 -3
- package/lib/esm/core-react/index.scss +3 -3
- package/lib/esm/core-react/inputs/index.scss +3 -3
- package/lib/esm/core-react/inputs/input-label.scss +3 -3
- package/lib/esm/core-react/inputs/input.scss +3 -3
- package/lib/esm/core-react/inputs/numberinput/NumberInput.scss +3 -3
- package/lib/esm/core-react/inputs/variables.scss +3 -3
- package/lib/esm/core-react/listbox/Listbox.scss +3 -3
- package/lib/esm/core-react/loading/LoadingPrompt.scss +3 -3
- package/lib/esm/core-react/loading/LoadingSpinner.scss +3 -3
- package/lib/esm/core-react/loading/index.scss +3 -3
- package/lib/esm/core-react/loading/mixins.scss +3 -3
- package/lib/esm/core-react/messagebox/MessageBox.d.ts.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.js +2 -2
- package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/esm/core-react/messagebox/MessageBox.scss +3 -3
- package/lib/esm/core-react/popup/Popup.scss +3 -3
- package/lib/esm/core-react/radialmenu/RadialMenu.scss +3 -3
- package/lib/esm/core-react/searchbox/SearchBox.scss +3 -3
- package/lib/esm/core-react/settings/SettingsContainer.scss +3 -3
- package/lib/esm/core-react/style/baseline.scss +3 -3
- package/lib/esm/core-react/style/index.scss +3 -3
- package/lib/esm/core-react/style/opacity.scss +3 -3
- package/lib/esm/core-react/tabs/index.scss +3 -3
- package/lib/esm/core-react/tabs/tabs.scss +3 -3
- package/lib/esm/core-react/tabs/vertical.scss +3 -3
- package/lib/esm/core-react/text/FilteredText.scss +3 -3
- package/lib/esm/core-react/text/block.scss +3 -3
- package/lib/esm/core-react/text/body.scss +3 -3
- package/lib/esm/core-react/text/index.scss +3 -3
- package/lib/esm/core-react/text/mixins.scss +3 -3
- package/lib/esm/core-react/tree/ExpansionToggle.scss +3 -3
- package/lib/esm/core-react/tree/Placeholder.scss +3 -3
- package/lib/esm/core-react/tree/Tree.scss +3 -3
- package/package.json +3 -3
- package/lib/cjs/core-react/dialog/SimpleDialog.d.ts +0 -68
- package/lib/cjs/core-react/dialog/SimpleDialog.d.ts.map +0 -1
- package/lib/cjs/core-react/dialog/SimpleDialog.js +0 -51
- package/lib/cjs/core-react/dialog/SimpleDialog.js.map +0 -1
- package/lib/esm/core-react/dialog/SimpleDialog.d.ts +0 -68
- package/lib/esm/core-react/dialog/SimpleDialog.d.ts.map +0 -1
- package/lib/esm/core-react/dialog/SimpleDialog.js +0 -47
- package/lib/esm/core-react/dialog/SimpleDialog.js.map +0 -1
|
@@ -11,10 +11,8 @@ import * as React from "react";
|
|
|
11
11
|
import { DialogButtonType, SpecialKey } from "@itwin/appui-abstract";
|
|
12
12
|
import { DivWithOutsideClick } from "../base/DivWithOutsideClick";
|
|
13
13
|
import { UiCore } from "../UiCore";
|
|
14
|
-
import {
|
|
14
|
+
import { Dialog as BaseDialog } from "@itwin/itwinui-react";
|
|
15
15
|
import { Button } from "@itwin/itwinui-react";
|
|
16
|
-
import { Icon } from "../icons/IconComponent";
|
|
17
|
-
import { SvgClose } from "@itwin/itwinui-icons-react";
|
|
18
16
|
// cspell:ignore focustrap
|
|
19
17
|
/** Enum for dialog alignment
|
|
20
18
|
* @public
|
|
@@ -40,28 +38,7 @@ class Dialog extends React.Component {
|
|
|
40
38
|
super(props);
|
|
41
39
|
this._parentDocument = document;
|
|
42
40
|
this._containerRef = React.createRef();
|
|
43
|
-
/** Keep title bar of movable Dialog at least partially visible */
|
|
44
41
|
// istanbul ignore next
|
|
45
|
-
this._handleAppWindowResize = () => {
|
|
46
|
-
if (!this._containerRef.current || !this.props.movable)
|
|
47
|
-
return;
|
|
48
|
-
const parentWindow = this.getParentWindow();
|
|
49
|
-
const { x, y } = this.state;
|
|
50
|
-
let newX;
|
|
51
|
-
let newY;
|
|
52
|
-
if (undefined !== y && undefined !== x) {
|
|
53
|
-
if (y > parentWindow.innerHeight - 32)
|
|
54
|
-
newY = parentWindow.innerHeight - 32;
|
|
55
|
-
if (x > parentWindow.innerWidth - 32)
|
|
56
|
-
newX = parentWindow.innerWidth - 32;
|
|
57
|
-
}
|
|
58
|
-
if (newX !== undefined || newY !== undefined)
|
|
59
|
-
this.setState({
|
|
60
|
-
x: newX !== undefined ? newX : x,
|
|
61
|
-
y: newY !== undefined ? newY : y,
|
|
62
|
-
positionSet: true,
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
42
|
this.handleRefSet = (containerDiv) => {
|
|
66
43
|
if (containerDiv)
|
|
67
44
|
this._parentDocument = containerDiv.ownerDocument;
|
|
@@ -97,29 +74,11 @@ class Dialog extends React.Component {
|
|
|
97
74
|
const parentWindow = this.getParentWindow();
|
|
98
75
|
parentWindow.addEventListener("pointermove", this._handlePointerMove, true);
|
|
99
76
|
};
|
|
100
|
-
this._handleStartMove = (event) => {
|
|
101
|
-
if (!this.props.movable)
|
|
102
|
-
return;
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
// istanbul ignore else
|
|
105
|
-
if (this._containerRef.current) {
|
|
106
|
-
const rect = this._containerRef.current.getBoundingClientRect();
|
|
107
|
-
const grabOffsetX = event.clientX - rect.left;
|
|
108
|
-
const grabOffsetY = event.clientY - rect.top;
|
|
109
|
-
this.setState({
|
|
110
|
-
grabOffsetX,
|
|
111
|
-
grabOffsetY,
|
|
112
|
-
moving: true,
|
|
113
|
-
});
|
|
114
|
-
const parentWindow = this.getParentWindow();
|
|
115
|
-
parentWindow.addEventListener("pointermove", this._handlePointerMove, true);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
77
|
this._handlePointerMove = (event) => {
|
|
119
|
-
|
|
120
|
-
|
|
78
|
+
// istanbul ignore next
|
|
79
|
+
if (!this.props.resizable || !this._containerRef.current)
|
|
121
80
|
return;
|
|
122
|
-
const { minWidth, maxWidth, minHeight, maxHeight
|
|
81
|
+
const { minWidth, maxWidth, minHeight, maxHeight } = this.props;
|
|
123
82
|
let { x, y, width, height } = this.state;
|
|
124
83
|
// istanbul ignore else
|
|
125
84
|
if (x === undefined) {
|
|
@@ -130,57 +89,34 @@ class Dialog extends React.Component {
|
|
|
130
89
|
(x = rect.left),
|
|
131
90
|
(y = rect.top);
|
|
132
91
|
}
|
|
133
|
-
if (this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
width = Math.min(width, maxWidth);
|
|
142
|
-
}
|
|
143
|
-
if (this.state.downResizing) {
|
|
144
|
-
const pointerY = event.clientY;
|
|
145
|
-
height = pointerY - y;
|
|
146
|
-
// istanbul ignore else
|
|
147
|
-
if (typeof minHeight === "number")
|
|
148
|
-
height = Math.max(height, minHeight);
|
|
149
|
-
if (maxHeight !== undefined && typeof maxHeight === "number")
|
|
150
|
-
height = Math.min(height, maxHeight);
|
|
151
|
-
}
|
|
152
|
-
this.setState({ width, height });
|
|
92
|
+
if (this.state.rightResizing) {
|
|
93
|
+
const pointerX = event.clientX;
|
|
94
|
+
width = pointerX - x;
|
|
95
|
+
// istanbul ignore else
|
|
96
|
+
if (typeof minWidth === "number")
|
|
97
|
+
width = Math.max(width, minWidth);
|
|
98
|
+
if (maxWidth !== undefined && typeof maxWidth === "number")
|
|
99
|
+
width = Math.min(width, maxWidth);
|
|
153
100
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
y = event.view.innerHeight - 32;
|
|
163
|
-
if (x > event.view.innerWidth - 32)
|
|
164
|
-
x = event.view.innerWidth - 32;
|
|
165
|
-
if (width) {
|
|
166
|
-
if (x < 0 - width + 32)
|
|
167
|
-
x = 0 - width + 32;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
this.setState({ x, y, positionSet: true });
|
|
101
|
+
if (this.state.downResizing) {
|
|
102
|
+
const pointerY = event.clientY;
|
|
103
|
+
height = pointerY - y;
|
|
104
|
+
// istanbul ignore else
|
|
105
|
+
if (typeof minHeight === "number")
|
|
106
|
+
height = Math.max(height, minHeight);
|
|
107
|
+
if (maxHeight !== undefined && typeof maxHeight === "number")
|
|
108
|
+
height = Math.min(height, maxHeight);
|
|
171
109
|
}
|
|
110
|
+
this.setState({ width, height });
|
|
172
111
|
};
|
|
173
112
|
this._handlePointerUp = (_event) => {
|
|
174
|
-
if (!this.props.
|
|
113
|
+
if (!this.props.resizable)
|
|
175
114
|
return;
|
|
176
115
|
// istanbul ignore else
|
|
177
116
|
if (this._containerRef.current) {
|
|
178
117
|
this.setState({
|
|
179
118
|
rightResizing: false,
|
|
180
119
|
downResizing: false,
|
|
181
|
-
moving: false,
|
|
182
|
-
grabOffsetX: 0,
|
|
183
|
-
grabOffsetY: 0,
|
|
184
120
|
});
|
|
185
121
|
}
|
|
186
122
|
const parentWindow = this.getParentWindow();
|
|
@@ -189,10 +125,6 @@ class Dialog extends React.Component {
|
|
|
189
125
|
this.state = {
|
|
190
126
|
rightResizing: false,
|
|
191
127
|
downResizing: false,
|
|
192
|
-
moving: false,
|
|
193
|
-
grabOffsetX: 0,
|
|
194
|
-
grabOffsetY: 0,
|
|
195
|
-
positionSet: props.x !== undefined || props.y !== undefined,
|
|
196
128
|
};
|
|
197
129
|
}
|
|
198
130
|
getParentWindow() {
|
|
@@ -204,118 +136,89 @@ class Dialog extends React.Component {
|
|
|
204
136
|
parentWindow.removeEventListener("pointerup", this._handlePointerUp, true);
|
|
205
137
|
parentWindow.removeEventListener("pointermove", this._handlePointerMove, true);
|
|
206
138
|
this._parentDocument.removeEventListener("keyup", this._handleKeyUp, true);
|
|
207
|
-
parentWindow.addEventListener("resize", this._handleAppWindowResize);
|
|
208
139
|
}
|
|
209
140
|
componentDidMount() {
|
|
210
141
|
const parentWindow = this.getParentWindow();
|
|
211
142
|
parentWindow.addEventListener("pointerup", this._handlePointerUp, true);
|
|
212
143
|
this._parentDocument.addEventListener("keyup", this._handleKeyUp, true);
|
|
213
|
-
parentWindow.addEventListener("resize", this._handleAppWindowResize);
|
|
214
144
|
}
|
|
215
145
|
render() {
|
|
216
146
|
const { opened, title, footer, buttonCluster, onClose, onEscape, onOutsideClick, minWidth, minHeight, x, y, width, height, maxHeight, maxWidth, backgroundStyle, titleStyle, footerStyle, style, contentStyle, contentClassName, modal, resizable, movable, className, alignment, inset, trapFocus, modelessId, onModelessPointerDown, hideHeader, header, ...props } = this.props;
|
|
147
|
+
let initialOffset = {};
|
|
148
|
+
if (x || y) {
|
|
149
|
+
initialOffset = {
|
|
150
|
+
left: x ?? 0,
|
|
151
|
+
top: y ?? 0,
|
|
152
|
+
transform: "none",
|
|
153
|
+
};
|
|
154
|
+
}
|
|
217
155
|
const containerStyle = {
|
|
156
|
+
...initialOffset,
|
|
218
157
|
margin: "",
|
|
219
|
-
left: x,
|
|
220
|
-
top: y,
|
|
221
158
|
width,
|
|
222
159
|
height,
|
|
223
160
|
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
// istanbul ignore else
|
|
232
|
-
if (this.state.y !== undefined) {
|
|
233
|
-
containerStyle.marginTop = "0";
|
|
234
|
-
containerStyle.marginBottom = "0";
|
|
235
|
-
containerStyle.top = this.state.y;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (this.state.width !== undefined || this.state.height !== undefined) {
|
|
239
|
-
// istanbul ignore else
|
|
240
|
-
if (this.state.width !== undefined)
|
|
241
|
-
containerStyle.width = this.state.width;
|
|
242
|
-
// istanbul ignore else
|
|
243
|
-
if (this.state.height !== undefined)
|
|
244
|
-
containerStyle.height = this.state.height;
|
|
245
|
-
}
|
|
161
|
+
// istanbul ignore else
|
|
162
|
+
if (this.state.width !== undefined)
|
|
163
|
+
containerStyle.width = this.state.width;
|
|
164
|
+
// istanbul ignore else
|
|
165
|
+
if (this.state.height !== undefined)
|
|
166
|
+
containerStyle.height = this.state.height;
|
|
246
167
|
const minMaxStyle = {
|
|
247
168
|
minWidth,
|
|
248
169
|
minHeight,
|
|
249
170
|
maxWidth,
|
|
250
171
|
maxHeight,
|
|
251
172
|
};
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const divStyle = {
|
|
256
|
-
...backgroundStyle,
|
|
257
|
-
...style,
|
|
173
|
+
const dialogBaseContainerStyle = {
|
|
174
|
+
...containerStyle,
|
|
175
|
+
...minMaxStyle,
|
|
258
176
|
};
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
React.createElement(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
React.createElement(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
React.createElement("div", { className: classnames("core-dialog-
|
|
271
|
-
React.createElement("div", { className: classnames("core-dialog-
|
|
272
|
-
React.createElement("div", { className: classnames("core-dialog-drag", "core-dialog-drag-bottom-right", { "core-dialog-drag-enabled": resizable }), "data-testid": "core-dialog-drag-bottom-right", onPointerDown: this._handleStartResizeDownRight }))))))));
|
|
177
|
+
const buttons = this.getFooterButtons(buttonCluster, "high-visibility", true);
|
|
178
|
+
return (React.createElement(BaseDialog, { isOpen: opened, onClose: onClose, closeOnExternalClick: false, closeOnEsc: false, style: style, className: classnames("core-dialog", className), isDraggable: movable, trapFocus: trapFocus && /* istanbul ignore next */ modal, preventDocumentScroll: true, "data-testid": "core-dialog-root", ...props },
|
|
179
|
+
modal && React.createElement(BaseDialog.Backdrop, { style: backgroundStyle }),
|
|
180
|
+
React.createElement(DivWithOutsideClick, { onOutsideClick: onOutsideClick },
|
|
181
|
+
React.createElement(BaseDialog.Main, { ref: this._containerRef, className: classnames("core-dialog-main", alignment && this.getCSSClassNameFromAlignment(alignment)), "data-testid": "core-dialog-container", style: dialogBaseContainerStyle, onPointerDown: this._handleContainerPointerDown },
|
|
182
|
+
!hideHeader &&
|
|
183
|
+
(header || (React.createElement(BaseDialog.TitleBar, { titleText: title, style: titleStyle, "data-testid": "core-dialog-head" }))),
|
|
184
|
+
React.createElement(BaseDialog.Content, { className: contentClassName, style: { padding: inset ? undefined : 0, ...contentStyle } }, this.props.children),
|
|
185
|
+
footer || (React.createElement(BaseDialog.ButtonBar, { style: footerStyle }, buttons)),
|
|
186
|
+
resizable && (React.createElement(React.Fragment, null,
|
|
187
|
+
React.createElement("div", { className: classnames("core-dialog-resize-bar", "core-drag-right"), onPointerDown: this._handleStartResizeRight, "data-testid": "core-dialog-drag-right" }),
|
|
188
|
+
React.createElement("div", { className: classnames("core-dialog-resize-bar", "core-drag-bottom-right"), onPointerDown: this._handleStartResizeDownRight, "data-testid": "core-dialog-drag-bottom-right" }),
|
|
189
|
+
React.createElement("div", { className: classnames("core-dialog-resize-bar", "core-drag-bottom"), onPointerDown: this._handleStartResizeDown, "data-testid": "core-dialog-drag-bottom" })))))));
|
|
273
190
|
}
|
|
274
191
|
getCSSClassNameFromAlignment(alignment) {
|
|
275
|
-
let className = "";
|
|
276
|
-
// Drop the alignment CSS class if the Dialog has been sized or moved.
|
|
277
|
-
if (this.state.positionSet)
|
|
278
|
-
return "";
|
|
279
|
-
// istanbul ignore next
|
|
280
|
-
if (!alignment)
|
|
281
|
-
alignment = DialogAlignment.Center;
|
|
282
192
|
switch (alignment) {
|
|
283
193
|
case DialogAlignment.TopLeft:
|
|
284
|
-
|
|
285
|
-
break;
|
|
194
|
+
return "core-align-top-left";
|
|
286
195
|
case DialogAlignment.Top:
|
|
287
|
-
|
|
288
|
-
break;
|
|
196
|
+
return "core-align-top";
|
|
289
197
|
case DialogAlignment.TopRight:
|
|
290
|
-
|
|
291
|
-
break;
|
|
198
|
+
return "core-align-top-right";
|
|
292
199
|
case DialogAlignment.Left:
|
|
293
|
-
|
|
294
|
-
break;
|
|
200
|
+
return "core-align-left";
|
|
295
201
|
case DialogAlignment.Center:
|
|
296
|
-
|
|
297
|
-
break;
|
|
202
|
+
return "core-align-center";
|
|
298
203
|
case DialogAlignment.Right:
|
|
299
|
-
|
|
300
|
-
break;
|
|
204
|
+
return "core-align-right";
|
|
301
205
|
case DialogAlignment.BottomLeft:
|
|
302
|
-
|
|
303
|
-
break;
|
|
206
|
+
return "core-align-bottom-left";
|
|
304
207
|
case DialogAlignment.Bottom:
|
|
305
|
-
|
|
306
|
-
break;
|
|
208
|
+
return "core-align-bottom";
|
|
307
209
|
case DialogAlignment.BottomRight:
|
|
308
|
-
|
|
309
|
-
break;
|
|
210
|
+
return "core-align-bottom-right";
|
|
310
211
|
}
|
|
311
|
-
return className;
|
|
312
212
|
}
|
|
313
|
-
getFooterButtons(buttonCluster,
|
|
213
|
+
getFooterButtons(buttonCluster,
|
|
214
|
+
/* istanbul ignore next */ primaryStyleType = "cta",
|
|
215
|
+
/* istanbul ignore next */ noCoreButtonClasses = false) {
|
|
314
216
|
if (buttonCluster === undefined)
|
|
315
217
|
return undefined;
|
|
316
218
|
const buttons = [];
|
|
317
219
|
buttonCluster.forEach((button, index) => {
|
|
318
220
|
let buttonText = "";
|
|
221
|
+
// istanbul ignore next
|
|
319
222
|
let buttonClass = classnames(!noCoreButtonClasses && "core-dialog-button", !noCoreButtonClasses && `dialog-button-${button.type}`, button.className);
|
|
320
223
|
let usePrimaryStyleType = false;
|
|
321
224
|
switch (button.type) {
|
|
@@ -365,9 +268,9 @@ class Dialog extends React.Component {
|
|
|
365
268
|
}
|
|
366
269
|
}
|
|
367
270
|
Dialog.defaultProps = {
|
|
368
|
-
alignment: DialogAlignment.Center,
|
|
369
271
|
minWidth: 300,
|
|
370
|
-
minHeight:
|
|
272
|
+
minHeight: 135,
|
|
273
|
+
maxWidth: "100%",
|
|
371
274
|
width: "50%",
|
|
372
275
|
hideHeader: false,
|
|
373
276
|
resizable: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,0BAA0B;AAE1B;;GAEG;AACH,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,uCAAoB,CAAA;IACpB,8BAAW,CAAA;IACX,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,kCAAe,CAAA;IACf,6CAA0B,CAAA;IA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M;gBACR,KAAK,gBAAgB,CAAC,QAAQ;oBAC5B,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;oBACjD,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;oBAC1D,mBAAmB,GAAG,IAAI,CAAC;oBAC3B,MAAM;aACT;YAED,IAAI,MAAM,CAAC,KAAK;gBAAE,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;YAE5C,OAAO,CAAC,IAAI,CACV,oBAAC,MAAM,IACL,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAC7D,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,EACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;;AA3Ya,mBAAY,GAAyB;IACjD,SAAS,EAAE,eAAe,CAAC,MAAM;IACjC,QAAQ,EAAE,GAAG;IACb,SAAS,EAAE,GAAG;IACd,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,KAAK;CACjB,AAXyB,CAWxB;SAdS,MAAM","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./Dialog.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType, SpecialKey } from \"@itwin/appui-abstract\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport { UiCore } from \"../UiCore\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { FocusTrap } from \"../focustrap/FocusTrap\";\nimport type { ButtonProps } from \"@itwin/itwinui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgClose } from \"@itwin/itwinui-icons-react\";\n\n// cspell:ignore focustrap\n\n/** Enum for dialog alignment\n * @public\n */\nexport enum DialogAlignment {\n TopLeft = \"top-left\",\n Top = \"top\",\n TopRight = \"top-right\",\n Left = \"left\",\n Center = \"center\",\n Right = \"right\",\n BottomLeft = \"bottom-left\",\n Bottom = \"bottom\",\n BottomRight = \"bottom-right\",\n}\n\n/** Properties for the [[Dialog]] component\n * @public\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. Default: DialogAlignment.Center */\n alignment?: DialogAlignment;\n /** Initial x/left position of dialog in px. */\n x?: number;\n /** Initial y/top position of dialog in px. */\n y?: number;\n\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for Esc key */\n onEscape?: () => void;\n /** Triggered when a click is triggered outside of this dialog. */\n onOutsideClick?: (event: MouseEvent) => any;\n\n /** Initial width of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: \"50%\" */\n width?: string | number;\n /** Initial height of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n height?: string | number;\n /** Minimum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 300px */\n minWidth?: string | number;\n /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100px */\n minHeight?: string | number;\n /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxWidth?: string | number;\n /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxHeight?: string | number;\n\n /** Whether to show background overlay. Default: true.\n * @note Modeless dialogs require an id and an implementation of onModelessPointerDown.\n */\n modal?: boolean;\n /** An id for a modeless dialog */\n modelessId?: string;\n /** Pointer Down event handler when modeless (modal = false) */\n onModelessPointerDown?: (event: React.PointerEvent, id: string) => void;\n\n /** Custom CSS Style for overlay */\n backgroundStyle?: React.CSSProperties;\n /** Custom CSS Style for title */\n titleStyle?: React.CSSProperties;\n /** Custom CSS Style for footer */\n footerStyle?: React.CSSProperties;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n}\n\n/** @internal */\ninterface DialogState {\n rightResizing: boolean;\n downResizing: boolean;\n moving: boolean;\n grabOffsetX: number;\n grabOffsetY: number;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n positionSet: boolean;\n}\n\n/**\n * Dialog React component with optional resizing and dragging functionality\n * @public\n */\nexport class Dialog extends React.Component<DialogProps, DialogState> {\n private _parentDocument = document;\n private _containerRef = React.createRef<HTMLDivElement>();\n public static defaultProps: Partial<DialogProps> = {\n alignment: DialogAlignment.Center,\n minWidth: 300,\n minHeight: 100,\n width: \"50%\",\n hideHeader: false,\n resizable: false,\n movable: false,\n modal: true,\n inset: true,\n trapFocus: false,\n };\n\n /** @internal */\n public override readonly state: Readonly<DialogState>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n rightResizing: false,\n downResizing: false,\n moving: false,\n grabOffsetX: 0,\n grabOffsetY: 0,\n positionSet: props.x !== undefined || props.y !== undefined,\n };\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this._parentDocument.defaultView ?? window;\n }\n\n public override componentWillUnmount(): void {\n const parentWindow = this.getParentWindow();\n parentWindow.removeEventListener(\"pointerup\", this._handlePointerUp, true);\n parentWindow.removeEventListener(\n \"pointermove\",\n this._handlePointerMove,\n true\n );\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n parentWindow.addEventListener(\"resize\", this._handleAppWindowResize);\n }\n\n /** Keep title bar of movable Dialog at least partially visible */\n // istanbul ignore next\n private _handleAppWindowResize = (): void => {\n if (!this._containerRef.current || !this.props.movable) return;\n\n const parentWindow = this.getParentWindow();\n const { x, y } = this.state;\n let newX: number | undefined;\n let newY: number | undefined;\n\n if (undefined !== y && undefined !== x) {\n if (y > parentWindow.innerHeight - 32)\n newY = parentWindow.innerHeight - 32;\n if (x > parentWindow.innerWidth - 32) newX = parentWindow.innerWidth - 32;\n }\n\n if (newX !== undefined || newY !== undefined)\n this.setState({\n x: newX !== undefined ? newX : x,\n y: newY !== undefined ? newY : y,\n positionSet: true,\n });\n };\n\n public override componentDidMount(): void {\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointerup\", this._handlePointerUp, true);\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\n parentWindow.addEventListener(\"resize\", this._handleAppWindowResize);\n }\n\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n ...props\n } = this.props;\n\n const containerStyle: React.CSSProperties = {\n margin: \"\",\n left: x,\n top: y,\n width,\n height,\n };\n\n if (this.state.x !== undefined || this.state.y !== undefined) {\n // istanbul ignore else\n if (this.state.x !== undefined) {\n containerStyle.marginLeft = \"0\";\n containerStyle.marginRight = \"0\";\n containerStyle.left = this.state.x;\n }\n // istanbul ignore else\n if (this.state.y !== undefined) {\n containerStyle.marginTop = \"0\";\n containerStyle.marginBottom = \"0\";\n containerStyle.top = this.state.y;\n }\n }\n\n if (this.state.width !== undefined || this.state.height !== undefined) {\n // istanbul ignore else\n if (this.state.width !== undefined)\n containerStyle.width = this.state.width;\n // istanbul ignore else\n if (this.state.height !== undefined)\n containerStyle.height = this.state.height;\n }\n\n const minMaxStyle: React.CSSProperties = {\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n };\n\n const buttons = this.getFooterButtons(buttonCluster);\n\n const footerElement: React.ReactNode =\n footer ||\n (buttons && buttons.length > 0 && (\n <div className={\"core-dialog-buttons\"}>{buttons}</div>\n ));\n\n const divStyle: React.CSSProperties = {\n ...backgroundStyle,\n ...style,\n };\n\n const headerElement = header || (\n <div\n className={classnames(\n \"core-dialog-head\",\n { \"core-dialog-movable\": movable },\n { \"core-dialog-modal\": modal }\n )}\n data-testid=\"core-dialog-head\"\n onPointerDown={this._handleStartMove}\n >\n <div\n className={\"core-dialog-title\"}\n data-testid=\"core-dialog-title\"\n style={titleStyle}\n >\n {title}\n </div>\n <button\n className={\"core-focus-trap-ignore-initial core-dialog-close icon\"}\n data-testid=\"core-dialog-close\"\n onClick={onClose}\n >\n <Icon iconSpec={<SvgClose />} />\n </button>\n </div>\n );\n\n return (\n <div\n ref={this.handleRefSet}\n className={classnames(\n \"core-dialog\",\n !modal && \"core-dialog-hidden\",\n opened && \"core-dialog-opened\",\n className\n )}\n style={divStyle}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {opened && (\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <FocusTrap\n active={trapFocus && modal}\n returnFocusOnDeactivate={true}\n >\n <div\n className={classnames(\n \"core-dialog-container\",\n this.getCSSClassNameFromAlignment(alignment)\n )}\n style={{ ...containerStyle, ...minMaxStyle }}\n data-testid=\"core-dialog-container\"\n onPointerDown={this._handleContainerPointerDown}\n >\n <div\n className={\"core-dialog-area\"}\n ref={this._containerRef}\n style={minMaxStyle}\n >\n {!hideHeader && headerElement}\n <div\n className={classnames(\n \"core-dialog-content\",\n { \"core-dialog-content-no-inset\": !inset },\n contentClassName\n )}\n style={contentStyle}\n >\n {this.props.children}\n </div>\n {footerElement && (\n <div className={\"core-dialog-footer\"} style={footerStyle}>\n {footerElement}\n </div>\n )}\n <div\n className={classnames(\n \"core-dialog-drag\",\n \"core-dialog-drag-right\",\n { \"core-dialog-drag-enabled\": resizable }\n )}\n data-testid=\"core-dialog-drag-right\"\n onPointerDown={this._handleStartResizeRight}\n />\n <div\n className={classnames(\n \"core-dialog-drag\",\n \"core-dialog-drag-bottom-mid\",\n { \"core-dialog-drag-enabled\": resizable }\n )}\n data-testid=\"core-dialog-drag-bottom\"\n onPointerDown={this._handleStartResizeDown}\n />\n <div\n className={classnames(\n \"core-dialog-drag\",\n \"core-dialog-drag-bottom-right\",\n { \"core-dialog-drag-enabled\": resizable }\n )}\n data-testid=\"core-dialog-drag-bottom-right\"\n onPointerDown={this._handleStartResizeDownRight}\n />\n </div>\n </div>\n </FocusTrap>\n </DivWithOutsideClick>\n )}\n </div>\n );\n }\n\n private getCSSClassNameFromAlignment(alignment?: DialogAlignment): string {\n let className = \"\";\n\n // Drop the alignment CSS class if the Dialog has been sized or moved.\n if (this.state.positionSet) return \"\";\n\n // istanbul ignore next\n if (!alignment) alignment = DialogAlignment.Center;\n\n switch (alignment) {\n case DialogAlignment.TopLeft:\n className = \"core-dialog-top-left\";\n break;\n case DialogAlignment.Top:\n className = \"core-dialog-top\";\n break;\n case DialogAlignment.TopRight:\n className = \"core-dialog-top-right\";\n break;\n case DialogAlignment.Left:\n className = \"core-dialog-left\";\n break;\n case DialogAlignment.Center:\n className = \"core-dialog-center\";\n break;\n case DialogAlignment.Right:\n className = \"core-dialog-right\";\n break;\n case DialogAlignment.BottomLeft:\n className = \"core-dialog-bottom-left\";\n break;\n case DialogAlignment.Bottom:\n className = \"core-dialog-bottom\";\n break;\n case DialogAlignment.BottomRight:\n className = \"core-dialog-bottom-right\";\n break;\n }\n\n return className;\n }\n\n protected getFooterButtons(\n buttonCluster: DialogButtonDef[] | undefined,\n primaryStyleType: ButtonProps[\"styleType\"] = \"cta\",\n noCoreButtonClasses: boolean = false\n ): React.ReactNode[] | undefined {\n if (buttonCluster === undefined) return undefined;\n\n const buttons: React.ReactNode[] = [];\n buttonCluster.forEach((button: DialogButtonDef, index: number) => {\n let buttonText = \"\";\n let buttonClass = classnames(\n !noCoreButtonClasses && \"core-dialog-button\",\n !noCoreButtonClasses && `dialog-button-${button.type}`,\n button.className\n );\n let usePrimaryStyleType = false;\n\n switch (button.type) {\n case DialogButtonType.OK:\n buttonText = UiCore.translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = UiCore.translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = UiCore.translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = UiCore.translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = UiCore.translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = UiCore.translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = UiCore.translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = UiCore.translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n if (button.label) buttonText = button.label;\n\n buttons.push(\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n key={index.toString()}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === SpecialKey.Escape &&\n this.props.opened &&\n this.props.onEscape\n ) {\n this.props.onEscape();\n }\n };\n\n protected _handleContainerPointerDown = (event: React.PointerEvent): void => {\n if (!this.props.modal) {\n if (this.props.onModelessPointerDown && this.props.modelessId)\n this.props.onModelessPointerDown(event, this.props.modelessId);\n }\n };\n\n private _handleStartResizeRight = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ rightResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handleStartResizeDown = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ downResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handleStartResizeDownRight = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ downResizing: true, rightResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handleStartMove = (event: React.PointerEvent): void => {\n if (!this.props.movable) return;\n\n event.preventDefault();\n // istanbul ignore else\n if (this._containerRef.current) {\n const rect = this._containerRef.current.getBoundingClientRect();\n const grabOffsetX = event.clientX - rect.left;\n const grabOffsetY = event.clientY - rect.top;\n this.setState({\n grabOffsetX,\n grabOffsetY,\n moving: true,\n });\n\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\n \"pointermove\",\n this._handlePointerMove,\n true\n );\n }\n };\n\n private _handlePointerMove = (event: PointerEvent): void => {\n if (\n (!this.props.resizable && !this.props.movable) ||\n !this._containerRef.current\n )\n return;\n\n const { minWidth, maxWidth, minHeight, maxHeight, movable } = this.props;\n let { x, y, width, height } = this.state;\n\n // istanbul ignore else\n if (x === undefined) {\n // if x is undefined, so is y, width, and height\n const rect = this._containerRef.current.getBoundingClientRect();\n (width = rect.width),\n (height = rect.height),\n (x = rect.left),\n (y = rect.top);\n }\n\n if (this.props.resizable) {\n if (this.state.rightResizing) {\n const pointerX = event.clientX;\n width = pointerX - x;\n // istanbul ignore else\n if (typeof minWidth === \"number\") width = Math.max(width, minWidth);\n if (maxWidth !== undefined && typeof maxWidth === \"number\")\n width = Math.min(width, maxWidth);\n }\n\n if (this.state.downResizing) {\n const pointerY = event.clientY;\n height = pointerY - y!;\n // istanbul ignore else\n if (typeof minHeight === \"number\") height = Math.max(height, minHeight);\n if (maxHeight !== undefined && typeof maxHeight === \"number\")\n height = Math.min(height, maxHeight);\n }\n\n this.setState({ width, height });\n }\n\n // istanbul ignore next\n if (movable && this.state.moving) {\n x = event.clientX - this.state.grabOffsetX;\n y = event.clientY - this.state.grabOffsetY;\n if (y < 0) y = 0;\n if (event.view) {\n if (y > event.view.innerHeight - 32) y = event.view.innerHeight - 32;\n if (x > event.view.innerWidth - 32) x = event.view.innerWidth - 32;\n if (width) {\n if (x < 0 - width + 32) x = 0 - width + 32;\n }\n }\n\n this.setState({ x, y, positionSet: true });\n }\n };\n\n private _handlePointerUp = (_event: PointerEvent): void => {\n if (!this.props.movable && !this.props.resizable) return;\n\n // istanbul ignore else\n if (this._containerRef.current) {\n this.setState({\n rightResizing: false,\n downResizing: false,\n moving: false,\n grabOffsetX: 0,\n grabOffsetY: 0,\n });\n }\n\n const parentWindow = this.getParentWindow();\n parentWindow.removeEventListener(\n \"pointermove\",\n this._handlePointerMove,\n true\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,eAAe,CAAC;AACvB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,0BAA0B;AAE1B;;GAEG;AACH,MAAM,CAAN,IAAY,eAUX;AAVD,WAAY,eAAe;IACzB,uCAAoB,CAAA;IACpB,8BAAW,CAAA;IACX,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,kCAAe,CAAA;IACf,6CAA0B,CAAA;IAC1B,oCAAiB,CAAA;IACjB,+CAA4B,CAAA;AAC9B,CAAC,EAVW,eAAe,KAAf,eAAe,QAU1B;AAyFD;;;GAGG;AACH,MAAa,MAAO,SAAQ,KAAK,CAAC,SAAmC;IAmBnE,YAAY,KAAkB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;QAnBP,oBAAe,GAAG,QAAQ,CAAC;QAC3B,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QA+C1D,uBAAuB;QAChB,iBAAY,GAAG,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;oBACxB,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;oBAC7C,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;oBAC1D,mBAAmB,GAAG,IAAI,CAAC;oBAC3B,MAAM;gBACR,KAAK,gBAAgB,CAAC,QAAQ;oBAC5B,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;oBACjD,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;oBAC1D,mBAAmB,GAAG,IAAI,CAAC;oBAC3B,MAAM;aACT;YAED,IAAI,MAAM,CAAC,KAAK;gBAAE,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;YAE5C,OAAO,CAAC,IAAI,CACV,oBAAC,MAAM,IACL,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EACzB,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EAC7D,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,EACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;;AA9Sa,mBAAY,GAAyB;IACjD,QAAQ,EAAE,GAAG;IACb,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,KAAK;CACjB,AAXyB,CAWxB;SAdS,MAAM","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./Dialog.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType, SpecialKey } from \"@itwin/appui-abstract\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport { UiCore } from \"../UiCore\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { Dialog as BaseDialog } from \"@itwin/itwinui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport type { ButtonProps } from \"@itwin/itwinui-react\";\n\n// cspell:ignore focustrap\n\n/** Enum for dialog alignment\n * @public\n */\nexport enum DialogAlignment {\n TopLeft = \"top-left\",\n Top = \"top\",\n TopRight = \"top-right\",\n Left = \"left\",\n Center = \"center\",\n Right = \"right\",\n BottomLeft = \"bottom-left\",\n Bottom = \"bottom\",\n BottomRight = \"bottom-right\",\n}\n\n/** Properties for the [[Dialog]] component\n * @public\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. */\n alignment?: DialogAlignment;\n /** Initial x/left position of dialog in px. */\n x?: number;\n /** Initial y/top position of dialog in px. */\n y?: number;\n\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for Esc key */\n onEscape?: () => void;\n /** Triggered when a click is triggered outside of this dialog. */\n onOutsideClick?: (event: MouseEvent) => any;\n\n /** Initial width of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: \"50%\" */\n width?: string | number;\n /** Initial height of dialog. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n height?: string | number;\n /** Minimum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 300px */\n minWidth?: string | number;\n /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 135px */\n minHeight?: string | number;\n /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100% */\n maxWidth?: string | number;\n /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxHeight?: string | number;\n\n /** Whether to show background overlay. Default: true.\n * @note Modeless dialogs require an id and an implementation of onModelessPointerDown.\n */\n modal?: boolean;\n /** An id for a modeless dialog */\n modelessId?: string;\n /** Pointer Down event handler when modeless (modal = false) */\n onModelessPointerDown?: (event: React.PointerEvent, id: string) => void;\n\n /** Custom CSS Style for overlay */\n backgroundStyle?: React.CSSProperties;\n /** Custom CSS Style for title */\n titleStyle?: React.CSSProperties;\n /** Custom CSS Style for footer */\n footerStyle?: React.CSSProperties;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n}\n\n/** @internal */\ninterface DialogState {\n rightResizing: boolean;\n downResizing: boolean;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n}\n\n/**\n * Dialog React component with optional resizing and dragging functionality\n * @public\n */\nexport class Dialog extends React.Component<DialogProps, DialogState> {\n private _parentDocument = document;\n private _containerRef = React.createRef<HTMLDivElement>();\n public static defaultProps: Partial<DialogProps> = {\n minWidth: 300,\n minHeight: 135,\n maxWidth: \"100%\",\n width: \"50%\",\n hideHeader: false,\n resizable: false,\n movable: false,\n modal: true,\n inset: true,\n trapFocus: false,\n };\n\n /** @internal */\n public override readonly state: Readonly<DialogState>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n rightResizing: false,\n downResizing: false,\n };\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this._parentDocument.defaultView ?? window;\n }\n\n public override componentWillUnmount(): void {\n const parentWindow = this.getParentWindow();\n parentWindow.removeEventListener(\"pointerup\", this._handlePointerUp, true);\n parentWindow.removeEventListener(\n \"pointermove\",\n this._handlePointerMove,\n true\n );\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n public override componentDidMount(): void {\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointerup\", this._handlePointerUp, true);\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n // istanbul ignore next\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n ...props\n } = this.props;\n\n let initialOffset: React.CSSProperties = {};\n if (x || y) {\n initialOffset = {\n left: x ?? 0,\n top: y ?? 0,\n transform: \"none\",\n };\n }\n\n const containerStyle: React.CSSProperties = {\n ...initialOffset,\n margin: \"\",\n width,\n height,\n };\n\n // istanbul ignore else\n if (this.state.width !== undefined) containerStyle.width = this.state.width;\n // istanbul ignore else\n if (this.state.height !== undefined)\n containerStyle.height = this.state.height;\n\n const minMaxStyle: React.CSSProperties = {\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n };\n const dialogBaseContainerStyle: React.CSSProperties = {\n ...containerStyle,\n ...minMaxStyle,\n };\n\n const buttons = this.getFooterButtons(\n buttonCluster,\n \"high-visibility\",\n true\n );\n\n return (\n <BaseDialog\n isOpen={opened}\n onClose={onClose}\n closeOnExternalClick={false}\n closeOnEsc={false}\n style={style}\n className={classnames(\"core-dialog\", className)}\n isDraggable={movable}\n trapFocus={trapFocus && /* istanbul ignore next */ modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <BaseDialog.Main\n ref={this._containerRef}\n className={classnames(\n \"core-dialog-main\",\n alignment && this.getCSSClassNameFromAlignment(alignment)\n )}\n data-testid=\"core-dialog-container\"\n style={dialogBaseContainerStyle}\n onPointerDown={this._handleContainerPointerDown}\n >\n {!hideHeader &&\n (header || (\n <BaseDialog.TitleBar\n titleText={title}\n style={titleStyle}\n data-testid=\"core-dialog-head\"\n />\n ))}\n <BaseDialog.Content\n className={contentClassName}\n style={{ padding: inset ? undefined : 0, ...contentStyle }}\n >\n {this.props.children}\n </BaseDialog.Content>\n {footer || (\n <BaseDialog.ButtonBar style={footerStyle}>\n {buttons}\n </BaseDialog.ButtonBar>\n )}\n {resizable && (\n <>\n <div\n className={classnames(\n \"core-dialog-resize-bar\",\n \"core-drag-right\"\n )}\n onPointerDown={this._handleStartResizeRight}\n data-testid=\"core-dialog-drag-right\"\n />\n <div\n className={classnames(\n \"core-dialog-resize-bar\",\n \"core-drag-bottom-right\"\n )}\n onPointerDown={this._handleStartResizeDownRight}\n data-testid=\"core-dialog-drag-bottom-right\"\n />\n <div\n className={classnames(\n \"core-dialog-resize-bar\",\n \"core-drag-bottom\"\n )}\n onPointerDown={this._handleStartResizeDown}\n data-testid=\"core-dialog-drag-bottom\"\n />\n </>\n )}\n </BaseDialog.Main>\n </DivWithOutsideClick>\n </BaseDialog>\n );\n }\n\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n case DialogAlignment.Top:\n return \"core-align-top\";\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n case DialogAlignment.Left:\n return \"core-align-left\";\n case DialogAlignment.Center:\n return \"core-align-center\";\n case DialogAlignment.Right:\n return \"core-align-right\";\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n protected getFooterButtons(\n buttonCluster: DialogButtonDef[] | undefined,\n /* istanbul ignore next */ primaryStyleType: ButtonProps[\"styleType\"] = \"cta\",\n /* istanbul ignore next */ noCoreButtonClasses: boolean = false\n ): React.ReactNode[] | undefined {\n if (buttonCluster === undefined) return undefined;\n\n const buttons: React.ReactNode[] = [];\n buttonCluster.forEach((button: DialogButtonDef, index: number) => {\n let buttonText = \"\";\n // istanbul ignore next\n let buttonClass = classnames(\n !noCoreButtonClasses && \"core-dialog-button\",\n !noCoreButtonClasses && `dialog-button-${button.type}`,\n button.className\n );\n let usePrimaryStyleType = false;\n\n switch (button.type) {\n case DialogButtonType.OK:\n buttonText = UiCore.translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = UiCore.translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = UiCore.translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = UiCore.translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = UiCore.translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = UiCore.translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = UiCore.translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = UiCore.translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n if (button.label) buttonText = button.label;\n\n buttons.push(\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n key={index.toString()}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === SpecialKey.Escape &&\n this.props.opened &&\n this.props.onEscape\n ) {\n this.props.onEscape();\n }\n };\n\n protected _handleContainerPointerDown = (event: React.PointerEvent): void => {\n if (!this.props.modal) {\n if (this.props.onModelessPointerDown && this.props.modelessId)\n this.props.onModelessPointerDown(event, this.props.modelessId);\n }\n };\n\n private _handleStartResizeRight = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ rightResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handleStartResizeDown = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ downResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handleStartResizeDownRight = (event: React.PointerEvent): void => {\n event.preventDefault();\n this.setState({ downResizing: true, rightResizing: true });\n const parentWindow = this.getParentWindow();\n parentWindow.addEventListener(\"pointermove\", this._handlePointerMove, true);\n };\n\n private _handlePointerMove = (event: PointerEvent): void => {\n // istanbul ignore next\n if (!this.props.resizable || !this._containerRef.current) return;\n\n const { minWidth, maxWidth, minHeight, maxHeight } = this.props;\n let { x, y, width, height } = this.state;\n\n // istanbul ignore else\n if (x === undefined) {\n // if x is undefined, so is y, width, and height\n const rect = this._containerRef.current.getBoundingClientRect();\n (width = rect.width),\n (height = rect.height),\n (x = rect.left),\n (y = rect.top);\n }\n\n if (this.state.rightResizing) {\n const pointerX = event.clientX;\n width = pointerX - x;\n // istanbul ignore else\n if (typeof minWidth === \"number\") width = Math.max(width, minWidth);\n if (maxWidth !== undefined && typeof maxWidth === \"number\")\n width = Math.min(width, maxWidth);\n }\n\n if (this.state.downResizing) {\n const pointerY = event.clientY;\n height = pointerY - y!;\n // istanbul ignore else\n if (typeof minHeight === \"number\") height = Math.max(height, minHeight);\n if (maxHeight !== undefined && typeof maxHeight === \"number\")\n height = Math.min(height, maxHeight);\n }\n\n this.setState({ width, height });\n };\n\n private _handlePointerUp = (_event: PointerEvent): void => {\n if (!this.props.resizable) return;\n\n // istanbul ignore else\n if (this._containerRef.current) {\n this.setState({\n rightResizing: false,\n downResizing: false,\n });\n }\n\n const parentWindow = this.getParentWindow();\n parentWindow.removeEventListener(\n \"pointermove\",\n this._handlePointerMove,\n true\n );\n };\n}\n"]}
|