@itwin/core-react 4.3.1 → 4.5.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 +14 -4
- package/lib/cjs/core-react/base/Gap.js +1 -1
- package/lib/cjs/core-react/base/Gap.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.js +1 -2
- package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/ContextMenu.scss +3 -8
- package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +1 -1
- package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +3 -5
- package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.d.ts +0 -9
- package/lib/cjs/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.js +6 -98
- package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
- package/lib/cjs/core-react/dialog/Dialog.scss +1 -31
- package/lib/cjs/core-react/dialog/GlobalDialog.js +1 -2
- package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js +2 -2
- package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js +1 -2
- package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/cjs/core-react/icons/ConditionalIconItem.d.ts +1 -1
- package/lib/cjs/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
- package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/listbox/Listbox.js +2 -3
- package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/cjs/core-react/popup/Popup.js +4 -8
- package/lib/cjs/core-react/popup/Popup.js.map +1 -1
- package/lib/cjs/core-react/tree/Node.d.ts.map +1 -1
- package/lib/cjs/core-react/tree/Node.js +2 -3
- package/lib/cjs/core-react/tree/Node.js.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.js +1 -1
- package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
- package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +1 -2
- package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +8 -14
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/lib/esm/core-react/base/Gap.js +1 -1
- package/lib/esm/core-react/base/Gap.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.js +1 -2
- package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/ContextMenu.scss +3 -8
- package/lib/esm/core-react/contextmenu/ContextSubMenu.js +2 -2
- package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +3 -5
- package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.d.ts +0 -9
- package/lib/esm/core-react/dialog/Dialog.d.ts.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.js +6 -98
- package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
- package/lib/esm/core-react/dialog/Dialog.scss +1 -31
- package/lib/esm/core-react/dialog/GlobalDialog.js +1 -2
- package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/esm/core-react/elementseparator/ElementSeparator.js +2 -2
- package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
- package/lib/esm/core-react/hocs/withOnOutsideClick.js +1 -2
- package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/esm/core-react/icons/ConditionalIconItem.d.ts +1 -1
- package/lib/esm/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
- package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js +1 -1
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/listbox/Listbox.js +2 -3
- package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/esm/core-react/popup/Popup.js +4 -8
- package/lib/esm/core-react/popup/Popup.js.map +1 -1
- package/lib/esm/core-react/tree/Node.d.ts.map +1 -1
- package/lib/esm/core-react/tree/Node.js +2 -3
- package/lib/esm/core-react/tree/Node.js.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.d.ts.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.js +1 -1
- package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js +1 -1
- package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +1 -2
- package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js +8 -14
- package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# Change Log - @itwin/core-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 06 Sep 2023 17:29:22 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
|
-
## 4.
|
|
6
|
-
|
|
5
|
+
## 4.5.0
|
|
6
|
+
Wed, 06 Sep 2023 17:29:22 GMT
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Added ControlledTree to component providers example. Fixed spacing issue with ControlledTree
|
|
11
|
+
|
|
12
|
+
## 4.4.0
|
|
13
|
+
Tue, 15 Aug 2023 18:02:09 GMT
|
|
14
|
+
|
|
15
|
+
### Updates
|
|
16
|
+
|
|
17
|
+
- Decrease size of arrows in ContextSubMenu
|
|
18
|
+
- `ConditionalIconItem.isConditionalIconItem` is now a _type predicate_.
|
|
9
19
|
|
|
10
20
|
## 4.3.0
|
|
11
21
|
Mon, 17 Jul 2023 10:16:20 GMT
|
|
@@ -14,7 +14,7 @@ const React = require("react");
|
|
|
14
14
|
*/
|
|
15
15
|
function Gap(props) {
|
|
16
16
|
const { size, style, ...rest } = props;
|
|
17
|
-
const paddingLeft = size
|
|
17
|
+
const paddingLeft = size ?? "10px";
|
|
18
18
|
return React.createElement("span", { style: { ...style, paddingLeft }, ...rest });
|
|
19
19
|
}
|
|
20
20
|
exports.Gap = Gap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gap.js","sourceRoot":"","sources":["../../../../src/core-react/base/Gap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAU/B;;GAEG;AACH,SAAgB,GAAG,CAAC,KAAe;IACjC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"Gap.js","sourceRoot":"","sources":["../../../../src/core-react/base/Gap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAU/B;;GAEG;AACH,SAAgB,GAAG,CAAC,KAAe;IACjC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,IAAI,MAAM,CAAC;IAEnC,OAAO,8BAAM,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,KAAM,IAAI,GAAI,CAAC;AAC9D,CAAC;AALD,kBAKC","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 Base\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for the [[Gap]] component.\n * @public\n */\nexport interface GapProps extends CommonProps {\n size?: string;\n}\n\n/** Horizontal gap or space React component. Defaults to 10px.\n * @public\n */\nexport function Gap(props: GapProps) {\n const { size, style, ...rest } = props;\n const paddingLeft = size ?? \"10px\";\n\n return <span style={{ ...style, paddingLeft }} {...rest} />;\n}\n"]}
|
|
@@ -222,13 +222,12 @@ class ContextMenu extends React.PureComponent {
|
|
|
222
222
|
React.createElement("div", { ref: this._menuRef, role: "menu", tabIndex: 0, "data-testid": "core-context-menu-container", className: (0, classnames_1.default)("core-context-menu-container", opened && "core-context-menu-opened", floating && "core-context-menu-floating", ContextMenu.getCSSClassNameFromDirection(renderDirection)) }, this._injectedChildren))));
|
|
223
223
|
}
|
|
224
224
|
getWindow() {
|
|
225
|
-
var _a;
|
|
226
225
|
const el = this._rootElement
|
|
227
226
|
? this._rootElement
|
|
228
227
|
: /* istanbul ignore next */ this._menuElement;
|
|
229
228
|
const parentDocument = el.ownerDocument;
|
|
230
229
|
// istanbul ignore next
|
|
231
|
-
return
|
|
230
|
+
return parentDocument.defaultView ?? window;
|
|
232
231
|
}
|
|
233
232
|
/** @internal */
|
|
234
233
|
componentDidMount() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,8BAA4B;AAC5B,2CAAoC;AACpC,+BAA+B;AAC/B,0DAA4E;AAE5E,qEAAkE;AAClE,iEAA8D;AAE9D,uDAAoD;AAEpD,qDAAkD;AA2ClD;;;;GAIG;AACH,MAAa,WAAY,SAAQ,KAAK,CAAC,aAGtC;IA0BC,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QA1BP,iBAAY,GAAuB,IAAI,CAAC;QACxC,iBAAY,GAAuB,IAAI,CAAC;QACxC,qBAAgB,GAA4C,IAAI,CAAC;QACjE,YAAO,GAAW,CAAC,CAAC;QACpB,eAAU,GAAwB,IAAI,GAAG,EAAE,CAAC;QAG5C,mBAAc,GACpB,2CAAoB,CAAC,WAAW,CAAC;QAC3B,uBAAkB,GAAW,CAAC,CAAC;QAE/B,wBAAmB,GAAW,CAAC,CAAC;QAChC,uBAAkB,GAAW,CAAC,CAAC;QAoF/B,wBAAmB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE;YAC9D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,uBAAuB;QACf,0BAAqB,GAAG,CAAC,KAAiB,EAAQ,EAAE;YAC1D,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc;gBAChD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC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,IAAI;YAC5B,SAAS,GAAG,wBAAwB,CAAC;YACrC,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,KAAK;YAC7B,SAAS,GAAG,yBAAyB,CAAC;YACtC,MAAM;QACR,KAAK,2CAAoB,CAAC,UAAU;YAClC,SAAS,GAAG,iDAAiD,CAAC;YAC9D,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,WAAW;YACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;KACT;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC;AA7NS,kCAAW","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 \"./ContextMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ConditionalBooleanValue, SpecialKey } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport { ContextMenuItem } from \"./ContextMenuItem\";\nimport type { ContextSubMenuProps } from \"./ContextSubMenu\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\n\n/** Properties for the [[ContextMenu]] component\n * @public\n */\nexport interface ContextMenuProps extends CommonProps {\n /** Whether ContextMenu is currently opened. */\n opened: boolean;\n /** Which direction the menu opens. Default: ContextMenuDirection.BottomRight */\n direction?: ContextMenuDirection;\n /** When click is registered outside of ContextMenu. */\n onOutsideClick?: (event: MouseEvent) => any;\n /** When list item or submenu is selected */\n onSelect?: (event: any) => any;\n /** when Escape button is pressed */\n onEsc?: (data: any) => any;\n /** Whether menu flips directions based on screen edge. Default: true */\n autoflip?: boolean;\n /** Whether menu hugs screen edge when autoflip is off. Default: true */\n edgeLimit?: boolean;\n /** Whether Hotkey press selects item, or just highlights item. Default: true */\n hotkeySelect?: boolean;\n /** starting menu item selected index Default: -1 */\n selectedIndex?: number;\n /** whether menu floats on the viewport, or the page. When false, container elements can clip menu with overflow: hidden; Default: true */\n floating?: boolean;\n /** @internal */\n parentMenu?: ContextMenu;\n /** @internal */\n parentSubmenu?: ContextSubMenu;\n /** @internal */\n ignoreNextKeyUp?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface ContextMenuState {\n selectedIndex: number;\n direction: ContextMenuDirection;\n ignoreNextKeyUp: boolean;\n}\n\n/**\n * A context menu populated with [[ContextMenuItem]] components.\n * Can be nested using [[ContextSubMenu]] component.\n * @public\n */\nexport class ContextMenu extends React.PureComponent<\n ContextMenuProps,\n ContextMenuState\n> {\n private _rootElement: HTMLElement | null = null;\n private _menuElement: HTMLElement | null = null;\n private _selectedElement: ContextMenuItem | ContextSubMenu | null = null;\n private _length: number = 0;\n private _hotKeyMap: Map<number, string> = new Map();\n\n private _lastChildren: React.ReactNode;\n private _lastDirection: ContextMenuDirection | undefined =\n ContextMenuDirection.BottomRight;\n private _lastSelectedIndex: number = 0;\n private _injectedChildren: React.ReactNode;\n private _parentWindowHeight: number = 0;\n private _parentWindowWidth: number = 0;\n\n public static defaultProps: Partial<ContextMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n autoflip: true,\n edgeLimit: true,\n hotkeySelect: true,\n selectedIndex: -1,\n floating: true,\n };\n\n /** @internal */\n public override readonly state: Readonly<ContextMenuState>;\n constructor(props: ContextMenuProps) {\n super(props);\n this.state = {\n selectedIndex: this.props.selectedIndex!,\n direction: props.direction!,\n ignoreNextKeyUp: props.ignoreNextKeyUp!,\n };\n }\n\n /** @internal */\n public static autoFlip = (\n dir: ContextMenuDirection,\n rect: DOMRectReadOnly,\n windowWidth: number,\n windowHeight: number\n ): ContextMenuDirection => {\n if (rect.right > windowWidth) {\n switch (dir) {\n case ContextMenuDirection.TopRight:\n dir = ContextMenuDirection.TopLeft;\n break;\n case ContextMenuDirection.Right:\n dir = ContextMenuDirection.Left;\n break;\n case ContextMenuDirection.BottomRight:\n dir = ContextMenuDirection.BottomLeft;\n break;\n }\n }\n if (rect.left < 0) {\n switch (dir) {\n case ContextMenuDirection.TopLeft:\n dir = ContextMenuDirection.TopRight;\n break;\n case ContextMenuDirection.Left:\n dir = ContextMenuDirection.Right;\n break;\n case ContextMenuDirection.BottomLeft:\n dir = ContextMenuDirection.BottomRight;\n break;\n }\n }\n if (rect.bottom > windowHeight) {\n switch (dir) {\n case ContextMenuDirection.BottomLeft:\n dir = ContextMenuDirection.TopLeft;\n break;\n case ContextMenuDirection.Bottom:\n dir = ContextMenuDirection.Top;\n break;\n case ContextMenuDirection.BottomRight:\n dir = ContextMenuDirection.TopRight;\n break;\n }\n }\n if (rect.top < 0) {\n switch (dir) {\n case ContextMenuDirection.TopLeft:\n dir = ContextMenuDirection.BottomLeft;\n break;\n case ContextMenuDirection.Top:\n dir = ContextMenuDirection.Bottom;\n break;\n case ContextMenuDirection.TopRight:\n dir = ContextMenuDirection.BottomRight;\n break;\n }\n }\n return dir;\n };\n\n private _handleHotKeyParsed = (index: number, hotKey: string) => {\n this._hotKeyMap.set(index, hotKey);\n };\n\n // istanbul ignore next\n private _handleOnOutsideClick = (event: MouseEvent): void => {\n if (this.props.opened && this.props.onOutsideClick)\n this.props.onOutsideClick(event);\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n direction,\n onOutsideClick,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n children,\n className,\n ignoreNextKeyUp,\n ...props\n } = this.props;\n const renderDirection =\n parentMenu === undefined ? this.state.direction : direction;\n\n if (\n this._lastChildren !== children ||\n this._lastDirection !== renderDirection ||\n this._lastSelectedIndex !== this.state.selectedIndex\n ) {\n this._injectedChildren = this._injectMenuItemProps(\n children,\n renderDirection,\n this.state.selectedIndex\n );\n this._lastChildren = children;\n this._lastDirection = renderDirection;\n this._lastSelectedIndex = this.state.selectedIndex;\n }\n\n const classNames = classnames(\"core-context-menu\", className);\n\n return (\n <div\n role=\"presentation\"\n className={classNames}\n onKeyUp={this._handleKeyUp}\n onClick={this._handleClick}\n data-testid=\"core-context-menu-root\"\n {...props}\n ref={this._rootRef}\n >\n <DivWithOutsideClick onOutsideClick={this._handleOnOutsideClick}>\n <div\n ref={this._menuRef}\n role=\"menu\"\n tabIndex={0}\n data-testid=\"core-context-menu-container\"\n className={classnames(\n \"core-context-menu-container\",\n opened && \"core-context-menu-opened\",\n floating && \"core-context-menu-floating\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection)\n )}\n >\n {this._injectedChildren}\n </div>\n </DivWithOutsideClick>\n </div>\n );\n }\n\n /** @internal */\n public static getCSSClassNameFromDirection = (\n direction?: ContextMenuDirection\n ): string => {\n let className = \"\";\n\n // istanbul ignore next\n if (direction === undefined) direction = ContextMenuDirection.BottomRight;\n\n if (direction === ContextMenuDirection.None) return \"\";\n\n switch (direction) {\n case ContextMenuDirection.TopLeft:\n className = \"core-context-menu-top core-context-menu-left\";\n break;\n case ContextMenuDirection.Top:\n className = \"core-context-menu-top\";\n break;\n case ContextMenuDirection.TopRight:\n className = \"core-context-menu-top core-context-menu-right\";\n break;\n case ContextMenuDirection.Left:\n className = \"core-context-menu-left\";\n break;\n case ContextMenuDirection.Center:\n className = \"core-context-menu-center\";\n break;\n case ContextMenuDirection.Right:\n className = \"core-context-menu-right\";\n break;\n case ContextMenuDirection.BottomLeft:\n className = \"core-context-menu-bottom core-context-menu-left\";\n break;\n case ContextMenuDirection.Bottom:\n className = \"core-context-menu-bottom\";\n break;\n case ContextMenuDirection.BottomRight:\n className = \"core-context-menu-bottom core-context-menu-right\";\n break;\n }\n\n return className;\n };\n\n private _injectMenuItemProps = (\n children: React.ReactNode,\n direction: ContextMenuDirection | undefined,\n selectedIndex: number\n ) => {\n let index = 0;\n // add inheritance data to submenu children\n const ch = React.Children.map(children, (child: React.ReactNode) => {\n // Capture only ContextSubMenus and ContextMenuItems.\n if (\n child &&\n typeof child === \"object\" &&\n \"props\" in child &&\n (child.type === ContextSubMenu || child.type === ContextMenuItem) &&\n !ConditionalBooleanValue.getValue(child.props.disabled) &&\n !ConditionalBooleanValue.getValue(child.props.hidden)\n ) {\n const id = index; // get separate id variable so value stays the same when onHover is called later.\n const onHover = () => {\n this.setState({ selectedIndex: id });\n this.focus();\n };\n const ref = (el: ContextSubMenu | ContextMenuItem | null) => {\n if (selectedIndex === id)\n // only save to this._selectedElement if previously captured bool is true\n this._selectedElement = el;\n };\n const boundHandleHotKeyParse = this._handleHotKeyParsed.bind(this, id); // bind local callback for specific index\n const childProps: Partial<\n ContextSubMenuProps & ContextMenuItemProps & { ref: typeof ref }\n > = {\n parentMenu: this,\n ref,\n onHover,\n isSelected: selectedIndex === id,\n onHotKeyParsed: boundHandleHotKeyParse,\n };\n if (child.type === ContextSubMenu) {\n // add direction only to sub-menus\n childProps.direction =\n child.props.direction || /* istanbul ignore next */ direction;\n }\n index++;\n return React.cloneElement(child, childProps);\n } else return child; // Else, pass through unmodified\n });\n this._length = index;\n return ch;\n };\n\n private _rootRef = (el: HTMLDivElement | null) => {\n this._rootElement = el;\n };\n\n private _menuRef = (el: HTMLDivElement | null) => {\n this._menuElement = el;\n };\n\n private getWindow() {\n const el = this._rootElement\n ? this._rootElement\n : /* istanbul ignore next */ this._menuElement;\n const parentDocument = el!.ownerDocument;\n // istanbul ignore next\n return parentDocument.defaultView ?? window;\n }\n\n /** @internal */\n public override componentDidMount() {\n const parentWindow = this.getWindow();\n parentWindow.addEventListener(\"focus\", this._handleFocusChange);\n parentWindow.addEventListener(\"mouseup\", this._handleFocusChange);\n\n this.checkRenderDirection();\n\n if (this.props.opened) this.focus();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n const parentWindow = this.getWindow();\n parentWindow.removeEventListener(\"focus\", this._handleFocusChange);\n parentWindow.removeEventListener(\"mouseup\", this._handleFocusChange);\n }\n\n private checkRenderDirection() {\n const { direction, autoflip, parentMenu } = this.props;\n const parentWindow = this.getWindow();\n\n let renderDirection =\n parentMenu === undefined ? this.state.direction : direction;\n\n if (\n parentWindow.innerHeight === this._parentWindowHeight &&\n parentWindow.innerWidth === this._parentWindowWidth\n )\n return;\n this._parentWindowHeight = parentWindow.innerHeight;\n this._parentWindowWidth = parentWindow.innerWidth;\n\n // check if menu should flip\n if (parentWindow && autoflip && parentMenu === undefined) {\n const menuRect = this.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection!,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n // istanbul ignore next\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n public focus = () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.focus();\n };\n\n public blur = () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.blur();\n };\n\n public getRect = (): DOMRect => {\n let clientRect = DOMRect.fromRect({ x: 0, y: 0, width: 0, height: 0 });\n\n // istanbul ignore else\n if (this._menuElement) {\n clientRect = this._menuElement.getBoundingClientRect();\n }\n return clientRect;\n };\n\n private _handleFocusChange = (event: any): void => {\n // istanbul ignore else\n if (\n this._rootElement &&\n this.props.opened &&\n event.target instanceof Node &&\n this.props.onOutsideClick &&\n !this._rootElement.contains(event.target)\n )\n this.props.onOutsideClick(event);\n };\n\n private _handleClick = (event: React.MouseEvent<HTMLDivElement>): void => {\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (this.state.ignoreNextKeyUp) {\n this.setState({ ignoreNextKeyUp: false });\n return;\n }\n\n // istanbul ignore else\n if (event.key) {\n for (const [key, value] of this._hotKeyMap) {\n if (!this.props.hotkeySelect! && key > this.state.selectedIndex) {\n // Start search at current index.\n if (event.key.toUpperCase() === value) {\n this.setState({ selectedIndex: key });\n return;\n }\n }\n }\n for (const [key, value] of this._hotKeyMap) {\n if (event.key.toUpperCase() === value) {\n this.setState({ selectedIndex: key }, () => {\n if (this.props.hotkeySelect && this._selectedElement) {\n this._selectedElement.select();\n }\n });\n event.stopPropagation();\n return;\n }\n }\n }\n\n if (event.key === SpecialKey.ArrowLeft) {\n event.stopPropagation();\n if (this.props.parentMenu && this.props.parentSubmenu) {\n this.props.parentSubmenu.close();\n this.props.parentMenu.focus();\n }\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (event.key === SpecialKey.Escape) {\n // istanbul ignore else\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (\n (event.key === SpecialKey.Enter || event.key === SpecialKey.ArrowRight) &&\n this._selectedElement\n ) {\n event.stopPropagation();\n\n // istanbul ignore else\n if (\n event.key === SpecialKey.Enter ||\n /* istanbul ignore next */ this._selectedElement instanceof\n ContextSubMenu\n ) {\n // istanbul ignore else\n if (this._selectedElement.select) this._selectedElement.select();\n }\n }\n\n let { selectedIndex } = this.state;\n if (\n event.key === SpecialKey.ArrowUp ||\n event.key === SpecialKey.ArrowDown\n ) {\n event.stopPropagation();\n if (selectedIndex === -1) {\n selectedIndex = 0;\n } else {\n if (event.key === SpecialKey.ArrowUp) {\n if (this.state.selectedIndex === 0) selectedIndex = this._length - 1;\n else selectedIndex--;\n }\n if (event.key === SpecialKey.ArrowDown) {\n if (this.state.selectedIndex === this._length - 1) selectedIndex = 0;\n else selectedIndex++;\n }\n }\n }\n this.setState({ selectedIndex });\n };\n\n public override componentDidUpdate(prevProps: ContextMenuProps) {\n if (prevProps.selectedIndex !== this.props.selectedIndex) {\n this.setState((_, props) => ({ selectedIndex: props.selectedIndex! }));\n }\n if (!prevProps.opened && this.props.opened) {\n this.setState((_, props) => ({ selectedIndex: props.selectedIndex! }));\n }\n if (!this.props.parentMenu) {\n // const direction = this.props.direction!;\n // if ((!this.props.opened && prevProps.opened && direction !== this.state.direction) || prevProps.direction !== direction)\n this.checkRenderDirection();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,8BAA4B;AAC5B,2CAAoC;AACpC,+BAA+B;AAC/B,0DAA4E;AAE5E,qEAAkE;AAClE,iEAA8D;AAE9D,uDAAoD;AAEpD,qDAAkD;AA2ClD;;;;GAIG;AACH,MAAa,WAAY,SAAQ,KAAK,CAAC,aAGtC;IA0BC,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QA1BP,iBAAY,GAAuB,IAAI,CAAC;QACxC,iBAAY,GAAuB,IAAI,CAAC;QACxC,qBAAgB,GAA4C,IAAI,CAAC;QACjE,YAAO,GAAW,CAAC,CAAC;QACpB,eAAU,GAAwB,IAAI,GAAG,EAAE,CAAC;QAG5C,mBAAc,GACpB,2CAAoB,CAAC,WAAW,CAAC;QAC3B,uBAAkB,GAAW,CAAC,CAAC;QAE/B,wBAAmB,GAAW,CAAC,CAAC;QAChC,uBAAkB,GAAW,CAAC,CAAC;QAoF/B,wBAAmB,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE;YAC9D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,uBAAuB;QACf,0BAAqB,GAAG,CAAC,KAAiB,EAAQ,EAAE;YAC1D,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc;gBAChD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC,CAAC;QAmHM,yBAAoB,G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B,CAAC;YACrC,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,KAAK;YAC7B,SAAS,GAAG,yBAAyB,CAAC;YACtC,MAAM;QACR,KAAK,2CAAoB,CAAC,UAAU;YAClC,SAAS,GAAG,iDAAiD,CAAC;YAC9D,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,WAAW;YACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;KACT;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC;AA7NS,kCAAW","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 \"./ContextMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ConditionalBooleanValue, SpecialKey } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { DivWithOutsideClick } from \"../base/DivWithOutsideClick\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport { ContextMenuItem } from \"./ContextMenuItem\";\nimport type { ContextSubMenuProps } from \"./ContextSubMenu\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\n\n/** Properties for the [[ContextMenu]] component\n * @public\n */\nexport interface ContextMenuProps extends CommonProps {\n /** Whether ContextMenu is currently opened. */\n opened: boolean;\n /** Which direction the menu opens. Default: ContextMenuDirection.BottomRight */\n direction?: ContextMenuDirection;\n /** When click is registered outside of ContextMenu. */\n onOutsideClick?: (event: MouseEvent) => any;\n /** When list item or submenu is selected */\n onSelect?: (event: any) => any;\n /** when Escape button is pressed */\n onEsc?: (data: any) => any;\n /** Whether menu flips directions based on screen edge. Default: true */\n autoflip?: boolean;\n /** Whether menu hugs screen edge when autoflip is off. Default: true */\n edgeLimit?: boolean;\n /** Whether Hotkey press selects item, or just highlights item. Default: true */\n hotkeySelect?: boolean;\n /** starting menu item selected index Default: -1 */\n selectedIndex?: number;\n /** whether menu floats on the viewport, or the page. When false, container elements can clip menu with overflow: hidden; Default: true */\n floating?: boolean;\n /** @internal */\n parentMenu?: ContextMenu;\n /** @internal */\n parentSubmenu?: ContextSubMenu;\n /** @internal */\n ignoreNextKeyUp?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface ContextMenuState {\n selectedIndex: number;\n direction: ContextMenuDirection;\n ignoreNextKeyUp: boolean;\n}\n\n/**\n * A context menu populated with [[ContextMenuItem]] components.\n * Can be nested using [[ContextSubMenu]] component.\n * @public\n */\nexport class ContextMenu extends React.PureComponent<\n ContextMenuProps,\n ContextMenuState\n> {\n private _rootElement: HTMLElement | null = null;\n private _menuElement: HTMLElement | null = null;\n private _selectedElement: ContextMenuItem | ContextSubMenu | null = null;\n private _length: number = 0;\n private _hotKeyMap: Map<number, string> = new Map();\n\n private _lastChildren: React.ReactNode;\n private _lastDirection: ContextMenuDirection | undefined =\n ContextMenuDirection.BottomRight;\n private _lastSelectedIndex: number = 0;\n private _injectedChildren: React.ReactNode;\n private _parentWindowHeight: number = 0;\n private _parentWindowWidth: number = 0;\n\n public static defaultProps: Partial<ContextMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n autoflip: true,\n edgeLimit: true,\n hotkeySelect: true,\n selectedIndex: -1,\n floating: true,\n };\n\n /** @internal */\n public override readonly state: Readonly<ContextMenuState>;\n constructor(props: ContextMenuProps) {\n super(props);\n this.state = {\n selectedIndex: this.props.selectedIndex!,\n direction: props.direction!,\n ignoreNextKeyUp: props.ignoreNextKeyUp!,\n };\n }\n\n /** @internal */\n public static autoFlip = (\n dir: ContextMenuDirection,\n rect: DOMRectReadOnly,\n windowWidth: number,\n windowHeight: number\n ): ContextMenuDirection => {\n if (rect.right > windowWidth) {\n switch (dir) {\n case ContextMenuDirection.TopRight:\n dir = ContextMenuDirection.TopLeft;\n break;\n case ContextMenuDirection.Right:\n dir = ContextMenuDirection.Left;\n break;\n case ContextMenuDirection.BottomRight:\n dir = ContextMenuDirection.BottomLeft;\n break;\n }\n }\n if (rect.left < 0) {\n switch (dir) {\n case ContextMenuDirection.TopLeft:\n dir = ContextMenuDirection.TopRight;\n break;\n case ContextMenuDirection.Left:\n dir = ContextMenuDirection.Right;\n break;\n case ContextMenuDirection.BottomLeft:\n dir = ContextMenuDirection.BottomRight;\n break;\n }\n }\n if (rect.bottom > windowHeight) {\n switch (dir) {\n case ContextMenuDirection.BottomLeft:\n dir = ContextMenuDirection.TopLeft;\n break;\n case ContextMenuDirection.Bottom:\n dir = ContextMenuDirection.Top;\n break;\n case ContextMenuDirection.BottomRight:\n dir = ContextMenuDirection.TopRight;\n break;\n }\n }\n if (rect.top < 0) {\n switch (dir) {\n case ContextMenuDirection.TopLeft:\n dir = ContextMenuDirection.BottomLeft;\n break;\n case ContextMenuDirection.Top:\n dir = ContextMenuDirection.Bottom;\n break;\n case ContextMenuDirection.TopRight:\n dir = ContextMenuDirection.BottomRight;\n break;\n }\n }\n return dir;\n };\n\n private _handleHotKeyParsed = (index: number, hotKey: string) => {\n this._hotKeyMap.set(index, hotKey);\n };\n\n // istanbul ignore next\n private _handleOnOutsideClick = (event: MouseEvent): void => {\n if (this.props.opened && this.props.onOutsideClick)\n this.props.onOutsideClick(event);\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n direction,\n onOutsideClick,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n children,\n className,\n ignoreNextKeyUp,\n ...props\n } = this.props;\n const renderDirection =\n parentMenu === undefined ? this.state.direction : direction;\n\n if (\n this._lastChildren !== children ||\n this._lastDirection !== renderDirection ||\n this._lastSelectedIndex !== this.state.selectedIndex\n ) {\n this._injectedChildren = this._injectMenuItemProps(\n children,\n renderDirection,\n this.state.selectedIndex\n );\n this._lastChildren = children;\n this._lastDirection = renderDirection;\n this._lastSelectedIndex = this.state.selectedIndex;\n }\n\n const classNames = classnames(\"core-context-menu\", className);\n\n return (\n <div\n role=\"presentation\"\n className={classNames}\n onKeyUp={this._handleKeyUp}\n onClick={this._handleClick}\n data-testid=\"core-context-menu-root\"\n {...props}\n ref={this._rootRef}\n >\n <DivWithOutsideClick onOutsideClick={this._handleOnOutsideClick}>\n <div\n ref={this._menuRef}\n role=\"menu\"\n tabIndex={0}\n data-testid=\"core-context-menu-container\"\n className={classnames(\n \"core-context-menu-container\",\n opened && \"core-context-menu-opened\",\n floating && \"core-context-menu-floating\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection)\n )}\n >\n {this._injectedChildren}\n </div>\n </DivWithOutsideClick>\n </div>\n );\n }\n\n /** @internal */\n public static getCSSClassNameFromDirection = (\n direction?: ContextMenuDirection\n ): string => {\n let className = \"\";\n\n // istanbul ignore next\n if (direction === undefined) direction = ContextMenuDirection.BottomRight;\n\n if (direction === ContextMenuDirection.None) return \"\";\n\n switch (direction) {\n case ContextMenuDirection.TopLeft:\n className = \"core-context-menu-top core-context-menu-left\";\n break;\n case ContextMenuDirection.Top:\n className = \"core-context-menu-top\";\n break;\n case ContextMenuDirection.TopRight:\n className = \"core-context-menu-top core-context-menu-right\";\n break;\n case ContextMenuDirection.Left:\n className = \"core-context-menu-left\";\n break;\n case ContextMenuDirection.Center:\n className = \"core-context-menu-center\";\n break;\n case ContextMenuDirection.Right:\n className = \"core-context-menu-right\";\n break;\n case ContextMenuDirection.BottomLeft:\n className = \"core-context-menu-bottom core-context-menu-left\";\n break;\n case ContextMenuDirection.Bottom:\n className = \"core-context-menu-bottom\";\n break;\n case ContextMenuDirection.BottomRight:\n className = \"core-context-menu-bottom core-context-menu-right\";\n break;\n }\n\n return className;\n };\n\n private _injectMenuItemProps = (\n children: React.ReactNode,\n direction: ContextMenuDirection | undefined,\n selectedIndex: number\n ) => {\n let index = 0;\n // add inheritance data to submenu children\n const ch = React.Children.map(children, (child: React.ReactNode) => {\n // Capture only ContextSubMenus and ContextMenuItems.\n if (\n child &&\n typeof child === \"object\" &&\n \"props\" in child &&\n (child.type === ContextSubMenu || child.type === ContextMenuItem) &&\n !ConditionalBooleanValue.getValue(child.props.disabled) &&\n !ConditionalBooleanValue.getValue(child.props.hidden)\n ) {\n const id = index; // get separate id variable so value stays the same when onHover is called later.\n const onHover = () => {\n this.setState({ selectedIndex: id });\n this.focus();\n };\n const ref = (el: ContextSubMenu | ContextMenuItem | null) => {\n if (selectedIndex === id)\n // only save to this._selectedElement if previously captured bool is true\n this._selectedElement = el;\n };\n const boundHandleHotKeyParse = this._handleHotKeyParsed.bind(this, id); // bind local callback for specific index\n const childProps: Partial<\n ContextSubMenuProps & ContextMenuItemProps & { ref: typeof ref }\n > = {\n parentMenu: this,\n ref,\n onHover,\n isSelected: selectedIndex === id,\n onHotKeyParsed: boundHandleHotKeyParse,\n };\n if (child.type === ContextSubMenu) {\n // add direction only to sub-menus\n childProps.direction =\n child.props.direction || /* istanbul ignore next */ direction;\n }\n index++;\n return React.cloneElement(child, childProps);\n } else return child; // Else, pass through unmodified\n });\n this._length = index;\n return ch;\n };\n\n private _rootRef = (el: HTMLDivElement | null) => {\n this._rootElement = el;\n };\n\n private _menuRef = (el: HTMLDivElement | null) => {\n this._menuElement = el;\n };\n\n private getWindow() {\n const el = this._rootElement\n ? this._rootElement\n : /* istanbul ignore next */ this._menuElement;\n const parentDocument = el!.ownerDocument;\n // istanbul ignore next\n return parentDocument.defaultView ?? window;\n }\n\n /** @internal */\n public override componentDidMount() {\n const parentWindow = this.getWindow();\n parentWindow.addEventListener(\"focus\", this._handleFocusChange);\n parentWindow.addEventListener(\"mouseup\", this._handleFocusChange);\n\n this.checkRenderDirection();\n\n if (this.props.opened) this.focus();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n const parentWindow = this.getWindow();\n parentWindow.removeEventListener(\"focus\", this._handleFocusChange);\n parentWindow.removeEventListener(\"mouseup\", this._handleFocusChange);\n }\n\n private checkRenderDirection() {\n const { direction, autoflip, parentMenu } = this.props;\n const parentWindow = this.getWindow();\n\n let renderDirection =\n parentMenu === undefined ? this.state.direction : direction;\n\n if (\n parentWindow.innerHeight === this._parentWindowHeight &&\n parentWindow.innerWidth === this._parentWindowWidth\n )\n return;\n this._parentWindowHeight = parentWindow.innerHeight;\n this._parentWindowWidth = parentWindow.innerWidth;\n\n // check if menu should flip\n if (parentWindow && autoflip && parentMenu === undefined) {\n const menuRect = this.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection!,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n // istanbul ignore next\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n public focus = () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.focus();\n };\n\n public blur = () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.blur();\n };\n\n public getRect = (): DOMRect => {\n let clientRect = DOMRect.fromRect({ x: 0, y: 0, width: 0, height: 0 });\n\n // istanbul ignore else\n if (this._menuElement) {\n clientRect = this._menuElement.getBoundingClientRect();\n }\n return clientRect;\n };\n\n private _handleFocusChange = (event: any): void => {\n // istanbul ignore else\n if (\n this._rootElement &&\n this.props.opened &&\n event.target instanceof Node &&\n this.props.onOutsideClick &&\n !this._rootElement.contains(event.target)\n )\n this.props.onOutsideClick(event);\n };\n\n private _handleClick = (event: React.MouseEvent<HTMLDivElement>): void => {\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>): void => {\n if (this.state.ignoreNextKeyUp) {\n this.setState({ ignoreNextKeyUp: false });\n return;\n }\n\n // istanbul ignore else\n if (event.key) {\n for (const [key, value] of this._hotKeyMap) {\n if (!this.props.hotkeySelect! && key > this.state.selectedIndex) {\n // Start search at current index.\n if (event.key.toUpperCase() === value) {\n this.setState({ selectedIndex: key });\n return;\n }\n }\n }\n for (const [key, value] of this._hotKeyMap) {\n if (event.key.toUpperCase() === value) {\n this.setState({ selectedIndex: key }, () => {\n if (this.props.hotkeySelect && this._selectedElement) {\n this._selectedElement.select();\n }\n });\n event.stopPropagation();\n return;\n }\n }\n }\n\n if (event.key === SpecialKey.ArrowLeft) {\n event.stopPropagation();\n if (this.props.parentMenu && this.props.parentSubmenu) {\n this.props.parentSubmenu.close();\n this.props.parentMenu.focus();\n }\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (event.key === SpecialKey.Escape) {\n // istanbul ignore else\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (\n (event.key === SpecialKey.Enter || event.key === SpecialKey.ArrowRight) &&\n this._selectedElement\n ) {\n event.stopPropagation();\n\n // istanbul ignore else\n if (\n event.key === SpecialKey.Enter ||\n /* istanbul ignore next */ this._selectedElement instanceof\n ContextSubMenu\n ) {\n // istanbul ignore else\n if (this._selectedElement.select) this._selectedElement.select();\n }\n }\n\n let { selectedIndex } = this.state;\n if (\n event.key === SpecialKey.ArrowUp ||\n event.key === SpecialKey.ArrowDown\n ) {\n event.stopPropagation();\n if (selectedIndex === -1) {\n selectedIndex = 0;\n } else {\n if (event.key === SpecialKey.ArrowUp) {\n if (this.state.selectedIndex === 0) selectedIndex = this._length - 1;\n else selectedIndex--;\n }\n if (event.key === SpecialKey.ArrowDown) {\n if (this.state.selectedIndex === this._length - 1) selectedIndex = 0;\n else selectedIndex++;\n }\n }\n }\n this.setState({ selectedIndex });\n };\n\n public override componentDidUpdate(prevProps: ContextMenuProps) {\n if (prevProps.selectedIndex !== this.props.selectedIndex) {\n this.setState((_, props) => ({ selectedIndex: props.selectedIndex! }));\n }\n if (!prevProps.opened && this.props.opened) {\n this.setState((_, props) => ({ selectedIndex: props.selectedIndex! }));\n }\n if (!this.props.parentMenu) {\n // const direction = this.props.direction!;\n // if ((!this.props.opened && prevProps.opened && direction !== this.state.direction) || prevProps.direction !== direction)\n this.checkRenderDirection();\n }\n }\n}\n"]}
|
|
@@ -213,14 +213,9 @@ $uicore-menu-top-bottom-padding: calc(#{$uicore-menu-padding} * 0.6667);
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
.core-context-submenu-container .core-context-submenu-arrow {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
margin-
|
|
219
|
-
width: $uicore-icons-small;
|
|
220
|
-
height: var(--iui-size-l);
|
|
221
|
-
font-size: calc(var(--iui-font-size-2) * 0.5);
|
|
222
|
-
line-height: var(--iui-size-l);
|
|
223
|
-
text-align: center;
|
|
216
|
+
margin-left: var(--iui-size-s);
|
|
217
|
+
margin-top: var(--iui-size-3xs);
|
|
218
|
+
margin-bottom: calc(var(--iui-size-3xs) * -1);
|
|
224
219
|
}
|
|
225
220
|
}
|
|
226
221
|
}
|
|
@@ -130,7 +130,7 @@ class ContextSubMenu extends React.Component {
|
|
|
130
130
|
React.createElement("div", { className: (0, classnames_1.default)("core-context-menu-icon", "icon", icon) }),
|
|
131
131
|
React.createElement("div", { className: "core-context-menu-content" }, this._parsedLabel),
|
|
132
132
|
React.createElement("div", { className: (0, classnames_1.default)("core-context-submenu-arrow", "icon") },
|
|
133
|
-
React.createElement(IconComponent_1.Icon, { iconSpec: React.createElement(itwinui_icons_react_1.
|
|
133
|
+
React.createElement(IconComponent_1.Icon, { iconSpec: React.createElement(itwinui_icons_react_1.SvgCaretRightSmall, null) })),
|
|
134
134
|
badge && React.createElement("div", { className: "core-context-menu-badge" }, badge)),
|
|
135
135
|
React.createElement(ContextMenu_1.ContextMenu, { ref: (el) => {
|
|
136
136
|
this._menuElement = el;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":";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esContent":["/*---------------------------------------------------------------------------------------------\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 classnames from \"classnames\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRight } from \"@itwin/itwinui-icons-react\";\n\n/** Properties for the [[ContextSubMenu]] component\n * @public\n */\nexport interface ContextSubMenuProps\n extends Omit<ContextMenuItemProps, \"label\">,\n Omit<ContextMenuProps, \"label\">,\n CommonProps {\n /** Text/jsx to display in the list item */\n label: string | React.ReactElement;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n}\n\n/** @internal */\ninterface ContextSubMenuState {\n opened: boolean;\n direction: ContextMenuDirection;\n hotKey?: string;\n}\n\n/**\n * Submenu wrapper class for use within a [[ContextMenu]] component.\n * @public\n */\nexport class ContextSubMenu extends React.Component<\n ContextSubMenuProps,\n ContextSubMenuState\n> {\n private _menuElement: ContextMenu | null = null;\n private _subMenuElement: HTMLElement | null = null;\n private _menuButtonElement: HTMLElement | null = null;\n\n private _lastLabel: React.ReactNode;\n private _parsedLabel: React.ReactNode;\n\n public static defaultProps: Partial<ContextSubMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n disabled: false,\n hidden: false,\n autoflip: true,\n isSelected: false,\n selectedIndex: 0,\n };\n\n /** @internal */\n public override readonly state: Readonly<ContextSubMenuState>;\n constructor(props: ContextSubMenuProps) {\n super(props);\n this.state = {\n opened: false,\n direction: props.direction!,\n };\n }\n\n public override render(): React.ReactElement {\n const {\n label,\n opened,\n direction,\n onOutsideClick,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n onHotKeyParsed,\n children,\n onClick,\n className,\n badgeType,\n ...props\n } = this.props;\n\n const onOutsideClickWrapper = (event: MouseEvent) => {\n this.close();\n onOutsideClick && onOutsideClick(event);\n };\n const contextMenuProps = {\n onOutsideClick: onOutsideClickWrapper,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n };\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\n const renderDirection = this.state.direction;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastLabel !== label) {\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\n this._lastLabel = label;\n }\n return (\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n onMouseOver={this._handleMouseOver}\n ref={(el) => {\n this._subMenuElement = el;\n }}\n data-testid=\"core-context-submenu\"\n {...props}\n >\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\n <div\n onClick={this._handleClick}\n ref={(el) => {\n this._menuButtonElement = el;\n }}\n className={classnames(\n \"core-context-menu-item\",\n \"core-context-submenu-container\",\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n data-testid=\"core-context-submenu-container\"\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n aria-haspopup={true}\n >\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon)} />\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\")}>\n <Icon iconSpec={<SvgCaretRight />} />\n </div>\n {badge && <div className=\"core-context-menu-badge\">{badge}</div>}\n </div>\n <ContextMenu\n ref={(el) => {\n this._menuElement = el;\n }}\n className=\"core-context-submenu-popup\"\n opened={this.state.opened}\n direction={renderDirection}\n parentSubmenu={this}\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n </div>\n );\n }\n\n public override componentDidMount() {\n document.addEventListener(\"click\", this._handleClickGlobal);\n this._updateHotkey(this.props.label);\n\n this.checkRenderDirection();\n }\n\n public override componentWillUnmount() {\n document.removeEventListener(\"click\", this._handleClickGlobal);\n }\n\n public override componentDidUpdate(\n prevProps: ContextSubMenuProps,\n prevState: ContextSubMenuState\n ) {\n const direction = this.props.direction!;\n if (\n (this.state.opened !== prevState.opened &&\n direction !== this.state.direction) ||\n prevProps.direction !== direction\n )\n this.checkRenderDirection();\n if (this.props.label !== prevProps.label) {\n this._updateHotkey(this.props.label);\n }\n }\n\n private getWindow() {\n const el = this._subMenuElement;\n const parentDocument = el!.ownerDocument;\n return parentDocument.defaultView;\n }\n\n private checkRenderDirection() {\n const { autoflip } = this.props;\n const parentWindow = this.getWindow();\n let renderDirection = this.state.direction;\n // istanbul ignore else\n if (parentWindow && autoflip && this._menuElement) {\n const menuRect = this._menuElement.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n // istanbul ignore next\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n private _updateHotkey = (node: React.ReactNode) => {\n let hotKey: string | undefined;\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\n if (!isDisabled && !isHidden)\n hotKey = TildeFinder.findAfterTilde(node).character;\n else hotKey = undefined;\n if (hotKey && hotKey !== this.state.hotKey) {\n this.setState({ hotKey });\n if (this.props.onHotKeyParsed) this.props.onHotKeyParsed(hotKey);\n }\n };\n\n public select = () => {\n this.setState({ opened: true }, () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.focus();\n if (this.props.onSelect !== undefined) this.props.onSelect(undefined);\n });\n };\n\n public close = (propagate?: boolean) => {\n this.setState({ opened: false }, () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.blur();\n });\n // istanbul ignore next\n if (\n propagate &&\n this.props.parentMenu &&\n this.props.parentMenu.props.parentSubmenu\n ) {\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n // istanbul ignore else\n if (\n this._menuButtonElement &&\n this._menuButtonElement.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n private _handleClick = (event: any) => {\n event.stopPropagation();\n\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n\n // istanbul ignore else\n if (!isDisabled) {\n // istanbul ignore else\n if (this.props.onClick !== undefined) this.props.onClick(event);\n // istanbul ignore next\n if (this.props.opened) this.close();\n else this.select();\n }\n };\n\n private _handleClickGlobal = (event: any) => {\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\n this.setState((_prevState) => ({ opened: false }));\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,2CAAoC;AACpC,0DAAgE;AAGhE,+CAA4C;AAE5C,iEAA8D;AAC9D,+CAA4C;AAC5C,4DAAyD;AACzD,0DAA8C;AAC9C,oEAAgE;AAsBhE;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,SAGzC;IAmBC,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAnBP,iBAAY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AChC,MAAM,cAAc,GAAG,EAAG,CAAC,aAAa,CAAC;QACzC,OAAO,cAAc,CAAC,WAAW,CAAC;IACpC,CAAC;IAEO,oBAAoB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC3C,uBAAuB;QACvB,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE;YACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,yBAAW,CAAC,QAAQ,CACpC,eAAe,EACf,QAAQ,EACR,YAAY,CAAC,UAAU,EACvB,YAAY,CAAC,WAAW,CACzB,CAAC;YACF,uBAAuB;YACvB,IAAI,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;SACjD;IACH,CAAC;;AAjLa,2BAAY,GAAiC;IACzD,SAAS,EAAE,2CAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,AAPyB,CAOxB;AAlBS,wCAAc","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 classnames from \"classnames\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRightSmall } from \"@itwin/itwinui-icons-react\";\n\n/** Properties for the [[ContextSubMenu]] component\n * @public\n */\nexport interface ContextSubMenuProps\n extends Omit<ContextMenuItemProps, \"label\">,\n Omit<ContextMenuProps, \"label\">,\n CommonProps {\n /** Text/jsx to display in the list item */\n label: string | React.ReactElement;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n}\n\n/** @internal */\ninterface ContextSubMenuState {\n opened: boolean;\n direction: ContextMenuDirection;\n hotKey?: string;\n}\n\n/**\n * Submenu wrapper class for use within a [[ContextMenu]] component.\n * @public\n */\nexport class ContextSubMenu extends React.Component<\n ContextSubMenuProps,\n ContextSubMenuState\n> {\n private _menuElement: ContextMenu | null = null;\n private _subMenuElement: HTMLElement | null = null;\n private _menuButtonElement: HTMLElement | null = null;\n\n private _lastLabel: React.ReactNode;\n private _parsedLabel: React.ReactNode;\n\n public static defaultProps: Partial<ContextSubMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n disabled: false,\n hidden: false,\n autoflip: true,\n isSelected: false,\n selectedIndex: 0,\n };\n\n /** @internal */\n public override readonly state: Readonly<ContextSubMenuState>;\n constructor(props: ContextSubMenuProps) {\n super(props);\n this.state = {\n opened: false,\n direction: props.direction!,\n };\n }\n\n public override render(): React.ReactElement {\n const {\n label,\n opened,\n direction,\n onOutsideClick,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n onHotKeyParsed,\n children,\n onClick,\n className,\n badgeType,\n ...props\n } = this.props;\n\n const onOutsideClickWrapper = (event: MouseEvent) => {\n this.close();\n onOutsideClick && onOutsideClick(event);\n };\n const contextMenuProps = {\n onOutsideClick: onOutsideClickWrapper,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n };\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\n const renderDirection = this.state.direction;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastLabel !== label) {\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\n this._lastLabel = label;\n }\n return (\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n onMouseOver={this._handleMouseOver}\n ref={(el) => {\n this._subMenuElement = el;\n }}\n data-testid=\"core-context-submenu\"\n {...props}\n >\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\n <div\n onClick={this._handleClick}\n ref={(el) => {\n this._menuButtonElement = el;\n }}\n className={classnames(\n \"core-context-menu-item\",\n \"core-context-submenu-container\",\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n data-testid=\"core-context-submenu-container\"\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n aria-haspopup={true}\n >\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon)} />\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\")}>\n <Icon iconSpec={<SvgCaretRightSmall />} />\n </div>\n {badge && <div className=\"core-context-menu-badge\">{badge}</div>}\n </div>\n <ContextMenu\n ref={(el) => {\n this._menuElement = el;\n }}\n className=\"core-context-submenu-popup\"\n opened={this.state.opened}\n direction={renderDirection}\n parentSubmenu={this}\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n </div>\n );\n }\n\n public override componentDidMount() {\n document.addEventListener(\"click\", this._handleClickGlobal);\n this._updateHotkey(this.props.label);\n\n this.checkRenderDirection();\n }\n\n public override componentWillUnmount() {\n document.removeEventListener(\"click\", this._handleClickGlobal);\n }\n\n public override componentDidUpdate(\n prevProps: ContextSubMenuProps,\n prevState: ContextSubMenuState\n ) {\n const direction = this.props.direction!;\n if (\n (this.state.opened !== prevState.opened &&\n direction !== this.state.direction) ||\n prevProps.direction !== direction\n )\n this.checkRenderDirection();\n if (this.props.label !== prevProps.label) {\n this._updateHotkey(this.props.label);\n }\n }\n\n private getWindow() {\n const el = this._subMenuElement;\n const parentDocument = el!.ownerDocument;\n return parentDocument.defaultView;\n }\n\n private checkRenderDirection() {\n const { autoflip } = this.props;\n const parentWindow = this.getWindow();\n let renderDirection = this.state.direction;\n // istanbul ignore else\n if (parentWindow && autoflip && this._menuElement) {\n const menuRect = this._menuElement.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n // istanbul ignore next\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n private _updateHotkey = (node: React.ReactNode) => {\n let hotKey: string | undefined;\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\n if (!isDisabled && !isHidden)\n hotKey = TildeFinder.findAfterTilde(node).character;\n else hotKey = undefined;\n if (hotKey && hotKey !== this.state.hotKey) {\n this.setState({ hotKey });\n if (this.props.onHotKeyParsed) this.props.onHotKeyParsed(hotKey);\n }\n };\n\n public select = () => {\n this.setState({ opened: true }, () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.focus();\n if (this.props.onSelect !== undefined) this.props.onSelect(undefined);\n });\n };\n\n public close = (propagate?: boolean) => {\n this.setState({ opened: false }, () => {\n // istanbul ignore else\n if (this._menuElement) this._menuElement.blur();\n });\n // istanbul ignore next\n if (\n propagate &&\n this.props.parentMenu &&\n this.props.parentMenu.props.parentSubmenu\n ) {\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n // istanbul ignore else\n if (\n this._menuButtonElement &&\n this._menuButtonElement.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n private _handleClick = (event: any) => {\n event.stopPropagation();\n\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n\n // istanbul ignore else\n if (!isDisabled) {\n // istanbul ignore else\n if (this.props.onClick !== undefined) this.props.onClick(event);\n // istanbul ignore next\n if (this.props.opened) this.close();\n else this.select();\n }\n };\n\n private _handleClickGlobal = (event: any) => {\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\n this.setState((_prevState) => ({ opened: false }));\n };\n}\n"]}
|
|
@@ -21,8 +21,7 @@ class GlobalContextMenu extends React.PureComponent {
|
|
|
21
21
|
parentDocument: null,
|
|
22
22
|
};
|
|
23
23
|
this._handleRefSet = (popupDiv) => {
|
|
24
|
-
|
|
25
|
-
const parentDocument = (_a = popupDiv === null || popupDiv === void 0 ? void 0 : popupDiv.ownerDocument) !== null && _a !== void 0 ? _a : null;
|
|
24
|
+
const parentDocument = popupDiv?.ownerDocument ?? null;
|
|
26
25
|
if (parentDocument) {
|
|
27
26
|
this._container = parentDocument.createElement("div");
|
|
28
27
|
this._container.id =
|
|
@@ -34,7 +33,7 @@ class GlobalContextMenu extends React.PureComponent {
|
|
|
34
33
|
rt = parentDocument.createElement("div");
|
|
35
34
|
rt.id = "core-global-context-menu-root";
|
|
36
35
|
// istanbul ignore next
|
|
37
|
-
(
|
|
36
|
+
(parentDocument.body.querySelector('[data-root-container="iui-root-id"]') ?? parentDocument.body).appendChild(rt);
|
|
38
37
|
}
|
|
39
38
|
rt.appendChild(this._container);
|
|
40
39
|
// used to support component rendering in pop-out window
|
|
@@ -50,7 +49,6 @@ class GlobalContextMenu extends React.PureComponent {
|
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
render() {
|
|
53
|
-
var _a;
|
|
54
52
|
const { x, y, identifier, contextMenuComponent, ...props } = this.props;
|
|
55
53
|
const positioningStyle = {
|
|
56
54
|
left: x,
|
|
@@ -61,7 +59,7 @@ class GlobalContextMenu extends React.PureComponent {
|
|
|
61
59
|
ReactDOM.createPortal(React.createElement("div", { className: "core-context-menu-global", style: positioningStyle },
|
|
62
60
|
React.createElement(CtxMenu, { ...props })),
|
|
63
61
|
// istanbul ignore next
|
|
64
|
-
|
|
62
|
+
this.state.parentDocument.body.querySelector('[data-root-container="iui-root-id"]') ?? this.state.parentDocument.body)));
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
exports.GlobalContextMenu = GlobalContextMenu;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sCAAsC;AAEtC,+CAA4C;AAqB5C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IAOC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QALU,UAAK,GAA2B;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC;QAcM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sCAAsC;AAEtC,+CAA4C;AAqB5C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IAOC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QALU,UAAK,GAA2B;YAC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,oBAAoB,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxE,MAAM,gBAAgB,GAAwB;YAC5C,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,CAAC;SACP,CAAC;QAEF,MAAM,OAAO,GAAG,oBAAoB,IAAI,yBAAW,CAAC;QAEpD,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,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;YACN,uBAAuB;YACvB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,qCAAqC,CACtC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF;AA1ED,8CA0EC","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\";\nimport { ContextMenu } from \"./ContextMenu\";\n\n/** Properties for the [[GlobalContextMenu]] component\n * @public\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\n/** @internal */\ninterface GlobalContextMenuState {\n parentDocument: Document | null;\n}\n\n/** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor\n * @public\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 // istanbul ignore else\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 // istanbul ignore next\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"iui-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 // istanbul ignore next\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"iui-root-id\"]'\n ) ?? this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
|
|
@@ -103,12 +103,8 @@ interface DialogState {
|
|
|
103
103
|
*/
|
|
104
104
|
export declare class Dialog extends React.Component<DialogProps, DialogState> {
|
|
105
105
|
private _parentDocument;
|
|
106
|
-
private _containerRef;
|
|
107
106
|
static defaultProps: Partial<DialogProps>;
|
|
108
|
-
/** @internal */
|
|
109
|
-
readonly state: Readonly<DialogState>;
|
|
110
107
|
constructor(props: DialogProps);
|
|
111
|
-
private getParentWindow;
|
|
112
108
|
componentWillUnmount(): void;
|
|
113
109
|
componentDidMount(): void;
|
|
114
110
|
handleRefSet: (containerDiv: HTMLDivElement | null) => void;
|
|
@@ -117,11 +113,6 @@ export declare class Dialog extends React.Component<DialogProps, DialogState> {
|
|
|
117
113
|
protected getFooterButtons(buttonCluster: DialogButtonDef[] | undefined, primaryStyleType?: ButtonProps["styleType"], noCoreButtonClasses?: boolean): React.ReactNode[] | undefined;
|
|
118
114
|
private _handleKeyUp;
|
|
119
115
|
protected _handleContainerPointerDown: (event: React.PointerEvent) => void;
|
|
120
|
-
private _handleStartResizeRight;
|
|
121
|
-
private _handleStartResizeDown;
|
|
122
|
-
private _handleStartResizeDownRight;
|
|
123
|
-
private _handlePointerMove;
|
|
124
|
-
private _handlePointerUp;
|
|
125
116
|
}
|
|
126
117
|
export {};
|
|
127
118
|
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;GAEG;AACH,oB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ClC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAClC,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACpC;AAED,gBAAgB;AAChB,UAAU,WAAW;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC;IACnE,OAAO,CAAC,eAAe,CAAY;IACnC,OAAc,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,CAS9C;gBAEU,KAAK,EAAE,WAAW;IAId,oBAAoB,IAAI,IAAI;IAI5B,iBAAiB,IAAI,IAAI;IAKlC,YAAY,iBAAkB,cAAc,GAAG,IAAI,UAExD;IAEc,MAAM,IAAI,KAAK,CAAC,YAAY;IAyH5C,OAAO,CAAC,4BAA4B;IAuBpC,SAAS,CAAC,gBAAgB,CACxB,aAAa,EAAE,eAAe,EAAE,GAAG,SAAS,EACjB,gBAAgB,GAAE,WAAW,CAAC,WAAW,CAAS,EAClD,mBAAmB,GAAE,OAAe,GAC9D,KAAK,CAAC,SAAS,EAAE,GAAG,SAAS;IAuEhC,OAAO,CAAC,YAAY,CAQlB;IAEF,SAAS,CAAC,2BAA2B,UAAW,kBAAkB,KAAG,IAAI,CAMvE;CACH"}
|
|
@@ -40,7 +40,6 @@ class Dialog extends React.Component {
|
|
|
40
40
|
constructor(props) {
|
|
41
41
|
super(props);
|
|
42
42
|
this._parentDocument = document;
|
|
43
|
-
this._containerRef = React.createRef();
|
|
44
43
|
// istanbul ignore next
|
|
45
44
|
this.handleRefSet = (containerDiv) => {
|
|
46
45
|
if (containerDiv)
|
|
@@ -54,96 +53,17 @@ class Dialog extends React.Component {
|
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
this._handleContainerPointerDown = (event) => {
|
|
56
|
+
// istanbul ignore next
|
|
57
57
|
if (!this.props.modal) {
|
|
58
58
|
if (this.props.onModelessPointerDown && this.props.modelessId)
|
|
59
59
|
this.props.onModelessPointerDown(event, this.props.modelessId);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
this._handleStartResizeRight = (event) => {
|
|
63
|
-
event.preventDefault();
|
|
64
|
-
this.setState({ rightResizing: true });
|
|
65
|
-
const parentWindow = this.getParentWindow();
|
|
66
|
-
parentWindow.addEventListener("pointermove", this._handlePointerMove, true);
|
|
67
|
-
};
|
|
68
|
-
this._handleStartResizeDown = (event) => {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
this.setState({ downResizing: true });
|
|
71
|
-
const parentWindow = this.getParentWindow();
|
|
72
|
-
parentWindow.addEventListener("pointermove", this._handlePointerMove, true);
|
|
73
|
-
};
|
|
74
|
-
this._handleStartResizeDownRight = (event) => {
|
|
75
|
-
event.preventDefault();
|
|
76
|
-
this.setState({ downResizing: true, rightResizing: true });
|
|
77
|
-
const parentWindow = this.getParentWindow();
|
|
78
|
-
parentWindow.addEventListener("pointermove", this._handlePointerMove, true);
|
|
79
|
-
};
|
|
80
|
-
this._handlePointerMove = (event) => {
|
|
81
|
-
// istanbul ignore next
|
|
82
|
-
if (!this.props.resizable || !this._containerRef.current)
|
|
83
|
-
return;
|
|
84
|
-
const { minWidth, maxWidth, minHeight, maxHeight } = this.props;
|
|
85
|
-
let { x, y, width, height } = this.state;
|
|
86
|
-
// istanbul ignore else
|
|
87
|
-
if (x === undefined) {
|
|
88
|
-
// if x is undefined, so is y, width, and height
|
|
89
|
-
const rect = this._containerRef.current.getBoundingClientRect();
|
|
90
|
-
(width = rect.width),
|
|
91
|
-
(height = rect.height),
|
|
92
|
-
(x = rect.left),
|
|
93
|
-
(y = rect.top);
|
|
94
|
-
}
|
|
95
|
-
if (this.state.rightResizing) {
|
|
96
|
-
const pointerX = event.clientX;
|
|
97
|
-
width = pointerX - x;
|
|
98
|
-
// istanbul ignore else
|
|
99
|
-
if (typeof minWidth === "number")
|
|
100
|
-
width = Math.max(width, minWidth);
|
|
101
|
-
if (maxWidth !== undefined && typeof maxWidth === "number")
|
|
102
|
-
width = Math.min(width, maxWidth);
|
|
103
|
-
}
|
|
104
|
-
if (this.state.downResizing) {
|
|
105
|
-
const pointerY = event.clientY;
|
|
106
|
-
height = pointerY - y;
|
|
107
|
-
// istanbul ignore else
|
|
108
|
-
if (typeof minHeight === "number")
|
|
109
|
-
height = Math.max(height, minHeight);
|
|
110
|
-
if (maxHeight !== undefined && typeof maxHeight === "number")
|
|
111
|
-
height = Math.min(height, maxHeight);
|
|
112
|
-
}
|
|
113
|
-
this.setState({ width, height });
|
|
114
|
-
};
|
|
115
|
-
this._handlePointerUp = (_event) => {
|
|
116
|
-
if (!this.props.resizable)
|
|
117
|
-
return;
|
|
118
|
-
// istanbul ignore else
|
|
119
|
-
if (this._containerRef.current) {
|
|
120
|
-
this.setState({
|
|
121
|
-
rightResizing: false,
|
|
122
|
-
downResizing: false,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
const parentWindow = this.getParentWindow();
|
|
126
|
-
parentWindow.removeEventListener("pointermove", this._handlePointerMove, true);
|
|
127
|
-
};
|
|
128
|
-
this.state = {
|
|
129
|
-
rightResizing: false,
|
|
130
|
-
downResizing: false,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
getParentWindow() {
|
|
134
|
-
var _a;
|
|
135
|
-
// istanbul ignore next
|
|
136
|
-
return (_a = this._parentDocument.defaultView) !== null && _a !== void 0 ? _a : window;
|
|
137
62
|
}
|
|
138
63
|
componentWillUnmount() {
|
|
139
|
-
const parentWindow = this.getParentWindow();
|
|
140
|
-
parentWindow.removeEventListener("pointerup", this._handlePointerUp, true);
|
|
141
|
-
parentWindow.removeEventListener("pointermove", this._handlePointerMove, true);
|
|
142
64
|
this._parentDocument.removeEventListener("keyup", this._handleKeyUp, true);
|
|
143
65
|
}
|
|
144
66
|
componentDidMount() {
|
|
145
|
-
const parentWindow = this.getParentWindow();
|
|
146
|
-
parentWindow.addEventListener("pointerup", this._handlePointerUp, true);
|
|
147
67
|
this._parentDocument.addEventListener("keyup", this._handleKeyUp, true);
|
|
148
68
|
}
|
|
149
69
|
render() {
|
|
@@ -151,8 +71,8 @@ class Dialog extends React.Component {
|
|
|
151
71
|
let initialOffset = {};
|
|
152
72
|
if (x || y) {
|
|
153
73
|
initialOffset = {
|
|
154
|
-
left: x
|
|
155
|
-
top: y
|
|
74
|
+
left: x ?? 0,
|
|
75
|
+
top: y ?? 0,
|
|
156
76
|
transform: "none",
|
|
157
77
|
};
|
|
158
78
|
}
|
|
@@ -162,12 +82,6 @@ class Dialog extends React.Component {
|
|
|
162
82
|
width,
|
|
163
83
|
height,
|
|
164
84
|
};
|
|
165
|
-
// istanbul ignore else
|
|
166
|
-
if (this.state.width !== undefined)
|
|
167
|
-
containerStyle.width = this.state.width;
|
|
168
|
-
// istanbul ignore else
|
|
169
|
-
if (this.state.height !== undefined)
|
|
170
|
-
containerStyle.height = this.state.height;
|
|
171
85
|
const minMaxStyle = {
|
|
172
86
|
minWidth,
|
|
173
87
|
minHeight,
|
|
@@ -179,18 +93,14 @@ class Dialog extends React.Component {
|
|
|
179
93
|
...minMaxStyle,
|
|
180
94
|
};
|
|
181
95
|
const buttons = this.getFooterButtons(buttonCluster, "high-visibility", true);
|
|
182
|
-
return (React.createElement(itwinui_react_1.Dialog, { isOpen: opened, onClose: onClose, closeOnExternalClick: false, closeOnEsc: false, style: style, className: (0, classnames_1.default)("core-dialog", className), isDraggable: movable, trapFocus: trapFocus && /* istanbul ignore next */ modal, preventDocumentScroll: true, "data-testid": "core-dialog-root", ...props },
|
|
96
|
+
return (React.createElement(itwinui_react_1.Dialog, { isOpen: opened, onClose: onClose, closeOnExternalClick: false, closeOnEsc: false, style: style, className: (0, classnames_1.default)("core-dialog", className), isDraggable: movable, isResizable: resizable, trapFocus: trapFocus && /* istanbul ignore next */ modal, preventDocumentScroll: true, "data-testid": "core-dialog-root", ...props },
|
|
183
97
|
modal && React.createElement(itwinui_react_1.Dialog.Backdrop, { style: backgroundStyle }),
|
|
184
98
|
React.createElement(DivWithOutsideClick_1.DivWithOutsideClick, { onOutsideClick: onOutsideClick },
|
|
185
|
-
React.createElement(itwinui_react_1.Dialog.Main, {
|
|
99
|
+
React.createElement(itwinui_react_1.Dialog.Main, { className: (0, classnames_1.default)("core-dialog-main", alignment && this.getCSSClassNameFromAlignment(alignment)), "data-testid": "core-dialog-container", style: dialogBaseContainerStyle, onPointerDown: this._handleContainerPointerDown },
|
|
186
100
|
!hideHeader &&
|
|
187
101
|
(header || (React.createElement(itwinui_react_1.Dialog.TitleBar, { titleText: title, style: titleStyle, "data-testid": "core-dialog-head" }))),
|
|
188
102
|
React.createElement(itwinui_react_1.Dialog.Content, { className: contentClassName, style: { padding: inset ? undefined : 0, ...contentStyle } }, this.props.children),
|
|
189
|
-
footer || (React.createElement(itwinui_react_1.Dialog.ButtonBar, { style: footerStyle }, buttons))
|
|
190
|
-
resizable && (React.createElement(React.Fragment, null,
|
|
191
|
-
React.createElement("div", { className: (0, classnames_1.default)("core-dialog-resize-bar", "core-drag-right"), onPointerDown: this._handleStartResizeRight, "data-testid": "core-dialog-drag-right" }),
|
|
192
|
-
React.createElement("div", { className: (0, classnames_1.default)("core-dialog-resize-bar", "core-drag-bottom-right"), onPointerDown: this._handleStartResizeDownRight, "data-testid": "core-dialog-drag-bottom-right" }),
|
|
193
|
-
React.createElement("div", { className: (0, classnames_1.default)("core-dialog-resize-bar", "core-drag-bottom"), onPointerDown: this._handleStartResizeDown, "data-testid": "core-dialog-drag-bottom" })))))));
|
|
103
|
+
footer || (React.createElement(itwinui_react_1.Dialog.ButtonBar, { style: footerStyle }, buttons))))));
|
|
194
104
|
}
|
|
195
105
|
getCSSClassNameFromAlignment(alignment) {
|
|
196
106
|
switch (alignment) {
|
|
@@ -272,8 +182,6 @@ class Dialog extends React.Component {
|
|
|
272
182
|
}
|
|
273
183
|
}
|
|
274
184
|
Dialog.defaultProps = {
|
|
275
|
-
minWidth: 300,
|
|
276
|
-
minHeight: 135,
|
|
277
185
|
maxWidth: "100%",
|
|
278
186
|
width: "50%",
|
|
279
187
|
hideHeader: false,
|