@itwin/core-react 5.18.0 → 5.20.0
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/CHANGELOG.md +4 -0
- package/lib/core-react/UiCore.js +2 -1
- package/lib/core-react/UiCore.js.map +1 -1
- package/lib/core-react/autosuggest/AutoSuggest.js +86 -86
- package/lib/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/core-react/contextmenu/ContextMenu.js +272 -269
- package/lib/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/core-react/contextmenu/ContextMenuItem.js +57 -55
- package/lib/core-react/contextmenu/ContextMenuItem.js.map +1 -1
- package/lib/core-react/contextmenu/ContextSubMenu.js +70 -67
- package/lib/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/core-react/contextmenu/GlobalContextMenu.js +23 -22
- package/lib/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/core-react/contextmenu/TildeFinder.js +52 -52
- package/lib/core-react/contextmenu/TildeFinder.js.map +1 -1
- package/lib/core-react/dialog/Dialog.js +29 -29
- package/lib/core-react/dialog/Dialog.js.map +1 -1
- package/lib/core-react/dialog/GlobalDialog.js +24 -23
- package/lib/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/core-react/expandable/ExpandableList.js +15 -15
- package/lib/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/core-react/focus/ItemKeyboardNavigator.js +7 -3
- package/lib/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
- package/lib/core-react/hocs/withIsPressed.js +14 -17
- package/lib/core-react/hocs/withIsPressed.js.map +1 -1
- package/lib/core-react/hocs/withOnOutsideClick.js +38 -41
- package/lib/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/core-react/hocs/withTimeout.js +2 -5
- package/lib/core-react/hocs/withTimeout.js.map +1 -1
- package/lib/core-react/icons/ConditionalIconItem.js +3 -0
- package/lib/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/core-react/imagecheckbox/ImageCheckBox.js +15 -18
- package/lib/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/core-react/loading/LoadingBar.js +3 -3
- package/lib/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/core-react/loading/LoadingPrompt.js +9 -9
- package/lib/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/core-react/loading/LoadingSpinner.js +3 -3
- package/lib/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/core-react/loading/LoadingStatus.js +4 -4
- package/lib/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/core-react/messagebox/MessageBox.js +6 -6
- package/lib/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/core-react/popup/Popup.js +209 -209
- package/lib/core-react/popup/Popup.js.map +1 -1
- package/lib/core-react/radialmenu/Annulus.js +19 -2
- package/lib/core-react/radialmenu/Annulus.js.map +1 -1
- package/lib/core-react/radialmenu/RadialMenu.js +56 -56
- package/lib/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/core-react/searchbox/SearchBox.js +60 -60
- package/lib/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/core-react/settings/SettingsManager.js +20 -22
- package/lib/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/core-react/tabs/Tabs.js +14 -13
- package/lib/core-react/tabs/Tabs.js.map +1 -1
- package/lib/core-react/tree/Node.js +18 -18
- package/lib/core-react/tree/Node.js.map +1 -1
- package/lib/core-react/tree/Tree.js +1 -4
- package/lib/core-react/tree/Tree.js.map +1 -1
- package/lib/core-react/uistate/LocalStateStorage.js +1 -0
- package/lib/core-react/uistate/LocalStateStorage.js.map +1 -1
- package/lib/core-react/uistate/UiStateEntry.js +5 -0
- package/lib/core-react/uistate/UiStateEntry.js.map +1 -1
- package/lib/core-react/utils/Point.js +2 -0
- package/lib/core-react/utils/Point.js.map +1 -1
- package/lib/core-react/utils/Rectangle.js +4 -0
- package/lib/core-react/utils/Rectangle.js.map +1 -1
- package/lib/core-react/utils/ScrollPositionMaintainer.js +1 -0
- package/lib/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
- package/lib/core-react/utils/Timer.js +5 -2
- package/lib/core-react/utils/Timer.js.map +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAuB/C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;
|
|
1
|
+
{"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAuB/C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IACS,UAAU,CAAkB;IAEX,KAAK,GAA2B;QACvD,cAAc,EAAE,IAAI;KACrB,CAAC;IAEF,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,oBAAoB;QAClC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACrD,UAAU;YACV,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAEO,aAAa,GAAG,CAAC,Q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AE,MAAM,EAAE,IACrD,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY,CACnB,6BAAK,SAAS,EAAC,0BAA0B,EAAC,KAAK,EAAE,gBAAgB;gBAC/D,oBAAC,OAAO,OAAK,KAAK,GAAI,CAClB,EACN,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,uCAAuC,CACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF","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 ContextMenu\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { ContextMenuProps } from \"./ContextMenu.js\";\nimport { ContextMenu } from \"./ContextMenu.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Properties for the [[GlobalContextMenu]] component\n * @public\n * @deprecated in 4.16.0. Props of deprecated {@link GlobalContextMenu} component.\n */\nexport interface GlobalContextMenuProps extends ContextMenuProps {\n /** Unique identifier, to distinguish from other GlobalContextMenu components. Needed only if multiple GlobalContextMenus are used simultaneously. */\n identifier?: string;\n /** Specifies the x/horizontal position on the viewport. */\n x: number | string;\n /** Specifies the y/vertical position on the viewport. */\n y: number | string;\n /** Context menu element. Default: ContextMenu */\n contextMenuComponent?: React.ComponentType<ContextMenuProps>;\n}\n\ninterface GlobalContextMenuState {\n parentDocument: Document | null;\n}\n\n/** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor\n * @public\n * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.\n */\nexport class GlobalContextMenu extends React.PureComponent<\n GlobalContextMenuProps,\n GlobalContextMenuState\n> {\n private _container?: HTMLDivElement;\n\n public override readonly state: GlobalContextMenuState = {\n parentDocument: null,\n };\n\n constructor(props: GlobalContextMenuProps) {\n super(props);\n }\n\n public override componentWillUnmount() {\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-global-context-menu\";\n let rt = parentDocument.getElementById(\n \"core-global-context-menu-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-global-context-menu-root\";\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? parentDocument.body\n ).appendChild(rt);\n }\n rt.appendChild(this._container);\n\n // used to support component rendering in pop-out window\n this.setState({ parentDocument });\n }\n };\n\n public override render(): React.ReactNode {\n const { x, y, identifier, contextMenuComponent, ...props } = this.props;\n const positioningStyle: React.CSSProperties = {\n left: x,\n top: y,\n };\n\n const CtxMenu = contextMenuComponent || ContextMenu;\n\n return (\n <div ref={this._handleRefSet} style={{ display: \"none\" }}>\n {this.state.parentDocument &&\n ReactDOM.createPortal(\n <div className=\"core-context-menu-global\" style={positioningStyle}>\n <CtxMenu {...props} />\n </div>,\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
|
|
@@ -10,66 +10,66 @@ import * as React from "react";
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export class TildeFinder {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return { character: ch.toUpperCase(), node: [s1, n, s2] };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else if (node && typeof node === "object") {
|
|
32
|
-
if (Array.isArray(node)) {
|
|
33
|
-
// Array
|
|
34
|
-
let ret = {
|
|
35
|
-
character: undefined,
|
|
36
|
-
node,
|
|
37
|
-
};
|
|
38
|
-
node = node.map((child) => {
|
|
39
|
-
const r = TildeFinder.findAfterTilde(child);
|
|
40
|
-
if (r.character) {
|
|
41
|
-
// if character is found, modify node instead of returning unmodified child.
|
|
42
|
-
ret = r;
|
|
43
|
-
return r.node;
|
|
44
|
-
}
|
|
45
|
-
return child;
|
|
46
|
-
});
|
|
47
|
-
if (ret.character) {
|
|
48
|
-
return { character: ret.character, node };
|
|
13
|
+
/**
|
|
14
|
+
* Find character following a tilde character within a React.ReactNode.
|
|
15
|
+
* @param node react node to search within for a tilde.
|
|
16
|
+
* @returns character that was found, and the same node with tilde removed, and following character with an underline.
|
|
17
|
+
*/
|
|
18
|
+
static findAfterTilde = (node) => {
|
|
19
|
+
if (typeof node === "string") {
|
|
20
|
+
// String
|
|
21
|
+
const tildeIndex = node.indexOf("~");
|
|
22
|
+
if (tildeIndex !== -1 && tildeIndex <= node.length - 2) {
|
|
23
|
+
const ch = node.charAt(tildeIndex + 1);
|
|
24
|
+
const s1 = node.substring(0, tildeIndex);
|
|
25
|
+
const n = React.createElement("u", { key: "hotkey" }, ch);
|
|
26
|
+
const s2 = node.substring(tildeIndex + 2);
|
|
27
|
+
return { character: ch.toUpperCase(), node: [s1, n, s2] };
|
|
49
28
|
}
|
|
50
29
|
}
|
|
51
|
-
else if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
else if (node && typeof node === "object") {
|
|
31
|
+
if (Array.isArray(node)) {
|
|
32
|
+
// Array
|
|
33
|
+
let ret = {
|
|
34
|
+
character: undefined,
|
|
35
|
+
node,
|
|
36
|
+
};
|
|
37
|
+
node = node.map((child) => {
|
|
59
38
|
const r = TildeFinder.findAfterTilde(child);
|
|
60
39
|
if (r.character) {
|
|
61
40
|
// if character is found, modify node instead of returning unmodified child.
|
|
62
|
-
ret
|
|
41
|
+
ret = r;
|
|
63
42
|
return r.node;
|
|
64
43
|
}
|
|
65
44
|
return child;
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
});
|
|
46
|
+
if (ret.character) {
|
|
47
|
+
return { character: ret.character, node };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (React.isValidElement(node)) {
|
|
51
|
+
// React Node
|
|
52
|
+
const ret = {
|
|
53
|
+
character: undefined,
|
|
54
|
+
node,
|
|
55
|
+
};
|
|
56
|
+
ret.node = React.cloneElement(node, {
|
|
57
|
+
children: React.Children.map(node.props.children, (child) => {
|
|
58
|
+
const r = TildeFinder.findAfterTilde(child);
|
|
59
|
+
if (r.character) {
|
|
60
|
+
// if character is found, modify node instead of returning unmodified child.
|
|
61
|
+
ret.character = r.character;
|
|
62
|
+
return r.node;
|
|
63
|
+
}
|
|
64
|
+
return child;
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
if (ret.character) {
|
|
68
|
+
return ret;
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
72
|
+
return { character: undefined, node };
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
75
|
//# sourceMappingURL=TildeFinder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TildeFinder.js","sourceRoot":"","sources":["../../../src/core-react/contextmenu/TildeFinder.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,OAAO,WAAW
|
|
1
|
+
{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------------------------------------------------------------------------------\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 ContextMenu\n */\n\nimport * as React from \"react\";\n\n/** Finds a tilde character in ContextMenu item label for hot key support\n * @internal\n */\nexport class TildeFinder {\n /**\n * Find character following a tilde character within a React.ReactNode.\n * @param node react node to search within for a tilde.\n * @returns character that was found, and the same node with tilde removed, and following character with an underline.\n */\n public static findAfterTilde = (\n node: React.ReactNode\n ): { character: string | undefined; node: React.ReactNode } => {\n if (typeof node === \"string\") {\n // String\n const tildeIndex = node.indexOf(\"~\");\n if (tildeIndex !== -1 && tildeIndex <= node.length - 2) {\n const ch = node.charAt(tildeIndex + 1);\n const s1 = node.substring(0, tildeIndex);\n const n = <u key=\"hotkey\">{ch}</u>;\n const s2 = node.substring(tildeIndex + 2);\n return { character: ch.toUpperCase(), node: [s1, n, s2] };\n }\n } else if (node && typeof node === \"object\") {\n if (Array.isArray(node)) {\n // Array\n let ret: { character: string | undefined; node: React.ReactNode } = {\n character: undefined,\n node,\n };\n node = node.map((child) => {\n const r = TildeFinder.findAfterTilde(child);\n if (r.character) {\n // if character is found, modify node instead of returning unmodified child.\n ret = r;\n return r.node;\n }\n return child;\n });\n if (ret.character) {\n return { character: ret.character, node };\n }\n } else if (React.isValidElement<React.PropsWithChildren>(node)) {\n // React Node\n const ret: { character: string | undefined; node: React.ReactNode } = {\n character: undefined,\n node,\n };\n ret.node = React.cloneElement(node, {\n children: React.Children.map(\n node.props.children,\n (child: React.ReactNode): React.ReactNode => {\n const r = TildeFinder.findAfterTilde(child);\n if (r.character) {\n // if character is found, modify node instead of returning unmodified child.\n ret.character = r.character;\n return r.node;\n }\n return child;\n }\n ),\n });\n if (ret.character) {\n return ret;\n }\n }\n }\n return { character: undefined, node };\n };\n}\n"]}
|
|
@@ -35,27 +35,21 @@ export var DialogAlignment;
|
|
|
35
35
|
*/
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
37
37
|
export class Dialog extends React.Component {
|
|
38
|
+
_parentDocument = document;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
40
|
+
static defaultProps = {
|
|
41
|
+
maxWidth: "100%",
|
|
42
|
+
width: "50%",
|
|
43
|
+
hideHeader: false,
|
|
44
|
+
resizable: false,
|
|
45
|
+
movable: false,
|
|
46
|
+
modal: true,
|
|
47
|
+
inset: true,
|
|
48
|
+
trapFocus: false,
|
|
49
|
+
};
|
|
38
50
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
39
51
|
constructor(props) {
|
|
40
52
|
super(props);
|
|
41
|
-
this._parentDocument = document;
|
|
42
|
-
this.handleRefSet = (containerDiv) => {
|
|
43
|
-
if (containerDiv)
|
|
44
|
-
this._parentDocument = containerDiv.ownerDocument;
|
|
45
|
-
};
|
|
46
|
-
this._handleKeyUp = (event) => {
|
|
47
|
-
if (event.key === Key.Escape.valueOf() &&
|
|
48
|
-
this.props.opened &&
|
|
49
|
-
this.props.onEscape) {
|
|
50
|
-
this.props.onEscape();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this._handleContainerPointerDown = (event) => {
|
|
54
|
-
if (!this.props.modal) {
|
|
55
|
-
if (this.props.onModelessPointerDown && this.props.modelessId)
|
|
56
|
-
this.props.onModelessPointerDown(event, this.props.modelessId);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
53
|
}
|
|
60
54
|
componentWillUnmount() {
|
|
61
55
|
this._parentDocument.removeEventListener("keyup", this._handleKeyUp, true);
|
|
@@ -63,6 +57,10 @@ export class Dialog extends React.Component {
|
|
|
63
57
|
componentDidMount() {
|
|
64
58
|
this._parentDocument.addEventListener("keyup", this._handleKeyUp, true);
|
|
65
59
|
}
|
|
60
|
+
handleRefSet = (containerDiv) => {
|
|
61
|
+
if (containerDiv)
|
|
62
|
+
this._parentDocument = containerDiv.ownerDocument;
|
|
63
|
+
};
|
|
66
64
|
render() {
|
|
67
65
|
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, as, ...props } = this.props;
|
|
68
66
|
let initialOffset = {};
|
|
@@ -143,18 +141,20 @@ export class Dialog extends React.Component {
|
|
|
143
141
|
});
|
|
144
142
|
return buttons;
|
|
145
143
|
}
|
|
144
|
+
_handleKeyUp = (event) => {
|
|
145
|
+
if (event.key === Key.Escape.valueOf() &&
|
|
146
|
+
this.props.opened &&
|
|
147
|
+
this.props.onEscape) {
|
|
148
|
+
this.props.onEscape();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
_handleContainerPointerDown = (event) => {
|
|
152
|
+
if (!this.props.modal) {
|
|
153
|
+
if (this.props.onModelessPointerDown && this.props.modelessId)
|
|
154
|
+
this.props.onModelessPointerDown(event, this.props.modelessId);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
146
157
|
}
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
148
|
-
Dialog.defaultProps = {
|
|
149
|
-
maxWidth: "100%",
|
|
150
|
-
width: "50%",
|
|
151
|
-
hideHeader: false,
|
|
152
|
-
resizable: false,
|
|
153
|
-
movable: false,
|
|
154
|
-
modal: true,
|
|
155
|
-
inset: true,
|
|
156
|
-
trapFocus: false,
|
|
157
|
-
};
|
|
158
158
|
function DialogButton({ button, primaryStyleType, noCoreButtonClasses, }) {
|
|
159
159
|
const { translate } = useTranslation();
|
|
160
160
|
let buttonText = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CA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WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;IACV,CAAC;IAED,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC;IAExC,OAAO,CACL,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,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,CAAC;AACJ,CAAC","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 classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog as BaseDialog, Button } from \"@itwin/itwinui-react\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick.js\";\nimport type { CommonProps } from \"../utils/Props.js\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.0. Enum used in a deprecated component {@link Dialog}.\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 * @deprecated in 4.12.0. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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/** Dialog React component with optional resizing and dragging functionality\n * @public\n * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public static defaultProps: Partial<DialogProps> = {\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(props: DialogProps) {\n super(props);\n }\n\n public override componentWillUnmount(): void {\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n public override componentDidMount(): void {\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\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 as,\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 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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 isResizable={resizable}\n trapFocus={trapFocus && modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <BaseDialog.Main\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 (buttons && (\n <BaseDialog.ButtonBar style={footerStyle}>\n {buttons}\n </BaseDialog.ButtonBar>\n ))}\n </BaseDialog.Main>\n </DivWithOutsideClick>\n </BaseDialog>\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.0. Use iTwinUI Button instead. */\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 buttons.push(\n <DialogButton\n key={index.toString()}\n button={button}\n primaryStyleType={primaryStyleType}\n noCoreButtonClasses={noCoreButtonClasses}\n />\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === Key.Escape.valueOf() &&\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\nfunction DialogButton({\n button,\n primaryStyleType,\n noCoreButtonClasses,\n}: {\n button: DialogButtonDef;\n primaryStyleType: ButtonProps[\"styleType\"];\n noCoreButtonClasses: boolean;\n}) {\n const { translate } = useTranslation();\n\n let buttonText = \"\";\n\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 = translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n buttonText = button.label || buttonText;\n\n return (\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n}\n"]}
|
|
1
|
+
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AC3B,MAAM;QACR,KAAK,gBAAgB,CAAC,QAAQ;YAC5B,UAAU,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;YAC1C,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;IACV,CAAC;IAED,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC;IAExC,OAAO,CACL,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,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,UAAU,CACJ,CACV,CAAC;AACJ,CAAC","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 classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog as BaseDialog, Button } from \"@itwin/itwinui-react\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick.js\";\nimport type { CommonProps } from \"../utils/Props.js\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.0. Enum used in a deprecated component {@link Dialog}.\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 * @deprecated in 4.12.0. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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/** Dialog React component with optional resizing and dragging functionality\n * @public\n * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public static defaultProps: Partial<DialogProps> = {\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(props: DialogProps) {\n super(props);\n }\n\n public override componentWillUnmount(): void {\n this._parentDocument.removeEventListener(\"keyup\", this._handleKeyUp, true);\n }\n\n public override componentDidMount(): void {\n this._parentDocument.addEventListener(\"keyup\", this._handleKeyUp, true);\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 as,\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 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 // eslint-disable-next-line @typescript-eslint/no-deprecated\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 isResizable={resizable}\n trapFocus={trapFocus && modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <DivWithOutsideClick onOutsideClick={onOutsideClick}>\n <BaseDialog.Main\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 (buttons && (\n <BaseDialog.ButtonBar style={footerStyle}>\n {buttons}\n </BaseDialog.ButtonBar>\n ))}\n </BaseDialog.Main>\n </DivWithOutsideClick>\n </BaseDialog>\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.0. Use iTwinUI Button instead. */\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 buttons.push(\n <DialogButton\n key={index.toString()}\n button={button}\n primaryStyleType={primaryStyleType}\n noCoreButtonClasses={noCoreButtonClasses}\n />\n );\n });\n return buttons;\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (\n event.key === Key.Escape.valueOf() &&\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\nfunction DialogButton({\n button,\n primaryStyleType,\n noCoreButtonClasses,\n}: {\n button: DialogButtonDef;\n primaryStyleType: ButtonProps[\"styleType\"];\n noCoreButtonClasses: boolean;\n}) {\n const { translate } = useTranslation();\n\n let buttonText = \"\";\n\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 = translate(\"dialog.ok\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Retry:\n buttonText = translate(\"dialog.retry\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Yes:\n buttonText = translate(\"dialog.yes\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.No:\n buttonText = translate(\"dialog.no\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Cancel:\n buttonText = translate(\"dialog.cancel\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Close:\n buttonText = translate(\"dialog.close\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n break;\n case DialogButtonType.Next:\n buttonText = translate(\"dialog.next\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n case DialogButtonType.Previous:\n buttonText = translate(\"dialog.previous\");\n buttonClass = classnames(buttonClass, button.buttonStyle);\n usePrimaryStyleType = true;\n break;\n }\n\n buttonText = button.label || buttonText;\n\n return (\n <Button\n className={buttonClass}\n disabled={button.disabled}\n styleType={usePrimaryStyleType ? primaryStyleType : undefined}\n onClick={button.onClick}\n >\n {buttonText}\n </Button>\n );\n}\n"]}
|
|
@@ -13,33 +13,34 @@ import { Dialog } from "./Dialog.js";
|
|
|
13
13
|
* @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.
|
|
14
14
|
*/
|
|
15
15
|
export class GlobalDialog extends React.Component {
|
|
16
|
+
_container;
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
18
|
+
state = {
|
|
19
|
+
parentDocument: null,
|
|
20
|
+
};
|
|
16
21
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
22
|
constructor(props) {
|
|
18
23
|
super(props);
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
20
|
-
this.state = {
|
|
21
|
-
parentDocument: null,
|
|
22
|
-
};
|
|
23
|
-
this._handleRefSet = (popupDiv) => {
|
|
24
|
-
const parentDocument = popupDiv?.ownerDocument ?? null;
|
|
25
|
-
if (parentDocument) {
|
|
26
|
-
this._container = parentDocument.createElement("div");
|
|
27
|
-
this._container.id =
|
|
28
|
-
this.props.identifier !== undefined
|
|
29
|
-
? `dialog-${this.props.identifier}`
|
|
30
|
-
: "core-dialog";
|
|
31
|
-
let rt = parentDocument.getElementById("core-dialog-root");
|
|
32
|
-
if (!rt) {
|
|
33
|
-
rt = parentDocument.createElement("div");
|
|
34
|
-
rt.id = "core-dialog-root";
|
|
35
|
-
parentDocument.body.appendChild(rt);
|
|
36
|
-
}
|
|
37
|
-
rt.appendChild(this._container);
|
|
38
|
-
// used to support component rendering in pop-out window
|
|
39
|
-
this.setState({ parentDocument });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
24
|
}
|
|
25
|
+
_handleRefSet = (popupDiv) => {
|
|
26
|
+
const parentDocument = popupDiv?.ownerDocument ?? null;
|
|
27
|
+
if (parentDocument) {
|
|
28
|
+
this._container = parentDocument.createElement("div");
|
|
29
|
+
this._container.id =
|
|
30
|
+
this.props.identifier !== undefined
|
|
31
|
+
? `dialog-${this.props.identifier}`
|
|
32
|
+
: "core-dialog";
|
|
33
|
+
let rt = parentDocument.getElementById("core-dialog-root");
|
|
34
|
+
if (!rt) {
|
|
35
|
+
rt = parentDocument.createElement("div");
|
|
36
|
+
rt.id = "core-dialog-root";
|
|
37
|
+
parentDocument.body.appendChild(rt);
|
|
38
|
+
}
|
|
39
|
+
rt.appendChild(this._container);
|
|
40
|
+
// used to support component rendering in pop-out window
|
|
41
|
+
this.setState({ parentDocument });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
43
44
|
componentWillUnmount() {
|
|
44
45
|
if (this._container && this._container.parentElement) {
|
|
45
46
|
// cleanup
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalDialog.js","sourceRoot":"","sources":["../../../src/core-react/dialog/GlobalDialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmBrC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAKvC;
|
|
1
|
+
{"version":3,"file":"GlobalDialog.js","sourceRoot":"","sources":["../../../src/core-react/dialog/GlobalDialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmBrC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAKvC;IACS,UAAU,CAAkB;IAEpC,4DAA4D;IACnC,KAAK,GAAsB;QAClD,c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C,KAAK,CAAC;QAC5C,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,IACzB,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY;YACnB,4DAA4D;YAC5D,oBAAC,MAAM,OAAK,KAAK,GAAI,EACrB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAC/B,CACC,CACP,CAAC;IACJ,CAAC;CACF","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 * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { DialogProps } from \"./Dialog.js\";\nimport { Dialog } from \"./Dialog.js\";\n\n/** Properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.0. Props of deprecated component {@link GlobalDialog}.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface GlobalDialogProps extends DialogProps {\n identifier?: string;\n}\n\n/** State properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.0. State of deprecated component {@link GlobalDialog}.\n */\nexport interface GlobalDialogState {\n parentDocument: Document | null;\n}\n\n/** GlobalDialog React component used to display a [[Dialog]] on the top of screen\n * @public\n * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\nexport class GlobalDialog extends React.Component<\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n GlobalDialogProps,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n GlobalDialogState\n> {\n private _container?: HTMLDivElement;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public override readonly state: GlobalDialogState = {\n parentDocument: null,\n };\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(props: GlobalDialogProps) {\n super(props);\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-dialog\";\n let rt = parentDocument.getElementById(\n \"core-dialog-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-dialog-root\";\n parentDocument.body.appendChild(rt);\n }\n rt.appendChild(this._container);\n\n // used to support component rendering in pop-out window\n this.setState({ parentDocument });\n }\n };\n\n public override componentWillUnmount() {\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n public override render(): React.ReactNode {\n const { identifier, ...props } = this.props;\n return (\n <div ref={this._handleRefSet}>\n {this.state.parentDocument &&\n ReactDOM.createPortal(\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Dialog {...props} />,\n this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
|
|
@@ -15,18 +15,23 @@ export class ExpandableList extends React.PureComponent {
|
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
16
16
|
constructor(props) {
|
|
17
17
|
super(props);
|
|
18
|
-
// set active block
|
|
19
|
-
this._handleBlockToggle = (index, onToggle) => {
|
|
20
|
-
let activeBlock = index;
|
|
21
|
-
if (this.props.singleIsCollapsible && index === this.state.activeBlock)
|
|
22
|
-
activeBlock = -1;
|
|
23
|
-
this.setState({ activeBlock });
|
|
24
|
-
if (onToggle) {
|
|
25
|
-
onToggle(activeBlock === index); // fire the ExpandableBlock onToggle
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
18
|
this.state = { activeBlock: this.props.defaultActiveBlock };
|
|
29
19
|
}
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
21
|
+
static defaultProps = {
|
|
22
|
+
singleExpandOnly: false,
|
|
23
|
+
defaultActiveBlock: 0,
|
|
24
|
+
};
|
|
25
|
+
// set active block
|
|
26
|
+
_handleBlockToggle = (index, onToggle) => {
|
|
27
|
+
let activeBlock = index;
|
|
28
|
+
if (this.props.singleIsCollapsible && index === this.state.activeBlock)
|
|
29
|
+
activeBlock = -1;
|
|
30
|
+
this.setState({ activeBlock });
|
|
31
|
+
if (onToggle) {
|
|
32
|
+
onToggle(activeBlock === index); // fire the ExpandableBlock onToggle
|
|
33
|
+
}
|
|
34
|
+
};
|
|
30
35
|
renderBlocks() {
|
|
31
36
|
return React.Children.map(this.props.children, (child, i) => {
|
|
32
37
|
return React.cloneElement(child, {
|
|
@@ -50,9 +55,4 @@ export class ExpandableList extends React.PureComponent {
|
|
|
50
55
|
return (React.createElement("div", { className: classnames("uicore-expandable-blocks-list", this.props.className), style: this.props.style }, this.renderBlocks()));
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
54
|
-
ExpandableList.defaultProps = {
|
|
55
|
-
singleExpandOnly: false,
|
|
56
|
-
defaultActiveBlock: 0,
|
|
57
|
-
};
|
|
58
58
|
//# sourceMappingURL=ExpandableList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandableList.js","sourceRoot":"","sources":["../../../src/core-react/expandable/ExpandableList.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuB/B;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,aAIzC;IACC,4DAA4D;IAC5D,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpandableList.js","sourceRoot":"","sources":["../../../src/core-react/expandable/ExpandableList.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,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AI,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;aACtE,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IAChB,4DAA4D;IAC5C,kBAAkB,CAAC,SAA8B;QAC/D,IACE,IAAI,CAAC,KAAK,CAAC,kBAAkB,KAAK,SAAS,CAAC,kBAAkB;YAC9D,IAAI,CAAC,KAAK,CAAC,kBAAkB,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,EACxD,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,kBAAmB,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CACnB,+BAA+B,EAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,YAAY,EAAE,CAChB,CACP,CAAC;IACJ,CAAC","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 Expandable\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props.js\";\n\n/** Properties for [[ExpandableList]] component\n * @public\n * @deprecated in 4.12.0. Props of deprecated component {@link ExpandableList}.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ExpandableListProps extends CommonProps {\n /** Index of the default active block */\n defaultActiveBlock?: number;\n /** Indicates whether to allow only one expanded block */\n singleExpandOnly?: boolean;\n /** Indicates whether the single expanded block is collapsible */\n singleIsCollapsible?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\ninterface ExpandableListState {\n activeBlock: number;\n}\n\n/** ExpandableList React component is a container for ExpandableBlock components.\n * @public\n * @deprecated in 4.12.0. Use a custom container and manage {@link https://itwinui.bentley.com/docs/expandableblock expandable block} state manually.\n */\nexport class ExpandableList extends React.PureComponent<\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ExpandableListProps,\n ExpandableListState\n> {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n constructor(props: ExpandableListProps) {\n super(props);\n\n this.state = { activeBlock: this.props.defaultActiveBlock! };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public static defaultProps: Partial<ExpandableListProps> = {\n singleExpandOnly: false,\n defaultActiveBlock: 0,\n };\n\n // set active block\n private _handleBlockToggle = (\n index: number,\n onToggle: (isExpanding: boolean) => any\n ) => {\n let activeBlock = index;\n\n if (this.props.singleIsCollapsible && index === this.state.activeBlock)\n activeBlock = -1;\n\n this.setState({ activeBlock });\n\n if (onToggle) {\n onToggle(activeBlock === index); // fire the ExpandableBlock onToggle\n }\n };\n\n private renderBlocks() {\n return React.Children.map(this.props.children, (child: any, i) => {\n return React.cloneElement(child, {\n key: i,\n isExpanded: this.props.singleExpandOnly\n ? i === this.state.activeBlock\n : child.props.isExpanded,\n onToggle: this._handleBlockToggle.bind(this, i, child.props.onToggle),\n });\n });\n }\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public override componentDidUpdate(prevProps: ExpandableListProps) {\n if (\n this.props.defaultActiveBlock !== prevProps.defaultActiveBlock &&\n this.props.defaultActiveBlock !== this.state.activeBlock\n ) {\n this.setState((_, props) => ({ activeBlock: props.defaultActiveBlock! }));\n }\n }\n\n public override render(): React.ReactElement {\n return (\n <div\n className={classnames(\n \"uicore-expandable-blocks-list\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.renderBlocks()}\n </div>\n );\n }\n}\n"]}
|
|
@@ -11,12 +11,16 @@ import { Orientation } from "../enums/Orientation.js";
|
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
export class ItemKeyboardNavigator {
|
|
14
|
+
onFocusItem;
|
|
15
|
+
onActivateItem;
|
|
16
|
+
_direction;
|
|
17
|
+
_itemCount = 0;
|
|
18
|
+
_orientation = Orientation.Horizontal;
|
|
19
|
+
_allowWrap = true;
|
|
20
|
+
_crossAxisArrowKeyHandler;
|
|
14
21
|
constructor(onFocusItem, onActivateItem) {
|
|
15
22
|
this.onFocusItem = onFocusItem;
|
|
16
23
|
this.onActivateItem = onActivateItem;
|
|
17
|
-
this._itemCount = 0;
|
|
18
|
-
this._orientation = Orientation.Horizontal;
|
|
19
|
-
this._allowWrap = true;
|
|
20
24
|
this._direction = new Map([
|
|
21
25
|
[Key.ArrowLeft, -1],
|
|
22
26
|
[Key.ArrowUp, -1],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAStD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,WAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YACnB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,C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AC,UAAU,EAAE,CAAC;gBAChD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IACE,OAAO,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;wBACnC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EACjC,CAAC;wBACD,IAAI,CAAC,aAAa,EAAE,CAAC;oBACvB,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAa;QAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,CACL,UAAU,CAAC,GAAG,CAAC;QACf,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACzB,GAAG,KAAK,GAAG;QACX,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;QAC/B,GAAG,KAAK,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE;QAChC,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAChC,CAAC;AACJ,CAAC","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 Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAStD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAQvB;IACA;IARD,UAAU,CAAsB;IAChC,UAAU,GAAG,CAAC,CAAC;IACf,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC;IACtC,UAAU,GAAG,IAAI,CAAC;IAClB,yBAAyB,CAAyB;IAE1D,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAE9C,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YACnB,CAAC,GAAG,CAAC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AAQ,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IACE,OAAO,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;wBACnC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EACjC,CAAC;wBACD,IAAI,CAAC,aAAa,EAAE,CAAC;oBACvB,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAa;QAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,CACL,UAAU,CAAC,GAAG,CAAC;QACf,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACzB,GAAG,KAAK,GAAG;QACX,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;QAC/B,GAAG,KAAK,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE;QAChC,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAChC,CAAC;AACJ,CAAC","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 Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
|