@itwin/core-react 4.13.1 → 4.13.3

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/core-react/UiCore.js +1 -1
  3. package/lib/cjs/core-react/UiCore.js.map +1 -1
  4. package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
  5. package/lib/cjs/core-react/button/UnderlinedButton.js.map +1 -1
  6. package/lib/cjs/core-react/contextmenu/ContextMenu.js +1 -1
  7. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  8. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js +1 -1
  9. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js.map +1 -1
  10. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +1 -1
  11. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  12. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +1 -1
  13. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  14. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  15. package/lib/cjs/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  16. package/lib/cjs/core-react/contextmenu/TildeFinder.js +1 -1
  17. package/lib/cjs/core-react/contextmenu/TildeFinder.js.map +1 -1
  18. package/lib/cjs/core-react/dialog/Dialog.js +2 -2
  19. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  20. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  21. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  22. package/lib/cjs/core-react/enums/Alignment.js +2 -2
  23. package/lib/cjs/core-react/enums/Alignment.js.map +1 -1
  24. package/lib/cjs/core-react/enums/CheckBoxState.js +1 -1
  25. package/lib/cjs/core-react/enums/CheckBoxState.js.map +1 -1
  26. package/lib/cjs/core-react/enums/Orientation.js +1 -1
  27. package/lib/cjs/core-react/enums/Orientation.js.map +1 -1
  28. package/lib/cjs/core-react/enums/SortDirection.js +1 -1
  29. package/lib/cjs/core-react/enums/SortDirection.js.map +1 -1
  30. package/lib/cjs/core-react/enums/TimeFormat.js +1 -1
  31. package/lib/cjs/core-react/enums/TimeFormat.js.map +1 -1
  32. package/lib/cjs/core-react/expandable/ExpandableList.js +1 -1
  33. package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
  34. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  35. package/lib/cjs/core-react/focustrap/FocusTrap.js.map +1 -1
  36. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  37. package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
  38. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  39. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  40. package/lib/cjs/core-react/inputs/Input.js.map +1 -1
  41. package/lib/cjs/core-react/inputs/InputStatus.js +1 -1
  42. package/lib/cjs/core-react/inputs/InputStatus.js.map +1 -1
  43. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  44. package/lib/cjs/core-react/l10n/usePackageTranslation.js.map +1 -1
  45. package/lib/cjs/core-react/l10n/useTranslation.js.map +1 -1
  46. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  47. package/lib/cjs/core-react/loading/LoadingBar.js +1 -1
  48. package/lib/cjs/core-react/loading/LoadingBar.js.map +1 -1
  49. package/lib/cjs/core-react/loading/LoadingPrompt.js +1 -1
  50. package/lib/cjs/core-react/loading/LoadingPrompt.js.map +1 -1
  51. package/lib/cjs/core-react/loading/LoadingSpinner.js +1 -1
  52. package/lib/cjs/core-react/loading/LoadingSpinner.js.map +1 -1
  53. package/lib/cjs/core-react/loading/LoadingStatus.js +1 -1
  54. package/lib/cjs/core-react/loading/LoadingStatus.js.map +1 -1
  55. package/lib/cjs/core-react/messagebox/MessageBox.js +1 -1
  56. package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
  57. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  58. package/lib/cjs/core-react/popup/Popup.js +1 -1
  59. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  60. package/lib/cjs/core-react/radialmenu/RadialMenu.js +2 -2
  61. package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
  62. package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
  63. package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
  64. package/lib/cjs/core-react/settings/SettingsManager.js.map +1 -1
  65. package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
  66. package/lib/cjs/core-react/text/FilteredText.js.map +1 -1
  67. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  68. package/lib/cjs/core-react/tree/Tree.js.map +1 -1
  69. package/lib/cjs/core-react/uistate/UiStateEntry.js.map +1 -1
  70. package/lib/cjs/core-react/uistate/UiStateStorage.js +1 -1
  71. package/lib/cjs/core-react/uistate/UiStateStorage.js.map +1 -1
  72. package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
  73. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  74. package/lib/cjs/core-react/utils/Rectangle.js +1 -1
  75. package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
  76. package/lib/cjs/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  77. package/lib/cjs/core-react/utils/flattenChildren.js.map +1 -1
  78. package/lib/cjs/core-react/utils/getUserColor.js.map +1 -1
  79. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  80. package/lib/cjs/core-react/utils/hooks/useDisposable.js.map +1 -1
  81. package/lib/cjs/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
  82. package/lib/cjs/core-react/utils/hooks/useEventListener.js.map +1 -1
  83. package/lib/cjs/core-react/utils/hooks/useInterval.js.map +1 -1
  84. package/lib/cjs/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
  85. package/lib/cjs/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
  86. package/lib/cjs/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  87. package/lib/cjs/core-react/utils/hooks/useRefs.js.map +1 -1
  88. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  89. package/lib/cjs/core-react/utils/reuseOrCreatePromise.js.map +1 -1
  90. package/lib/cjs/core-react/utils/shallowDiffers.js.map +1 -1
  91. package/lib/esm/core-react/UiCore.js +1 -2
  92. package/lib/esm/core-react/UiCore.js.map +1 -1
  93. package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
  94. package/lib/esm/core-react/button/UnderlinedButton.js.map +1 -1
  95. package/lib/esm/core-react/contextmenu/ContextMenu.js +1 -2
  96. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  97. package/lib/esm/core-react/contextmenu/ContextMenuItem.js +1 -2
  98. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  99. package/lib/esm/core-react/contextmenu/ContextSubMenu.js +1 -2
  100. package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  101. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  102. package/lib/esm/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  103. package/lib/esm/core-react/contextmenu/TildeFinder.js +1 -2
  104. package/lib/esm/core-react/contextmenu/TildeFinder.js.map +1 -1
  105. package/lib/esm/core-react/dialog/Dialog.js +1 -2
  106. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  107. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  108. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  109. package/lib/esm/core-react/expandable/ExpandableList.js +1 -2
  110. package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
  111. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  112. package/lib/esm/core-react/focustrap/FocusTrap.js.map +1 -1
  113. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  114. package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
  115. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  116. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  117. package/lib/esm/core-react/inputs/Input.js.map +1 -1
  118. package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  119. package/lib/esm/core-react/l10n/usePackageTranslation.js.map +1 -1
  120. package/lib/esm/core-react/l10n/useTranslation.js.map +1 -1
  121. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  122. package/lib/esm/core-react/loading/LoadingBar.js +1 -2
  123. package/lib/esm/core-react/loading/LoadingBar.js.map +1 -1
  124. package/lib/esm/core-react/loading/LoadingPrompt.js +1 -2
  125. package/lib/esm/core-react/loading/LoadingPrompt.js.map +1 -1
  126. package/lib/esm/core-react/loading/LoadingSpinner.js +1 -2
  127. package/lib/esm/core-react/loading/LoadingSpinner.js.map +1 -1
  128. package/lib/esm/core-react/loading/LoadingStatus.js +1 -2
  129. package/lib/esm/core-react/loading/LoadingStatus.js.map +1 -1
  130. package/lib/esm/core-react/messagebox/MessageBox.js +1 -2
  131. package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
  132. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  133. package/lib/esm/core-react/popup/Popup.js +1 -2
  134. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  135. package/lib/esm/core-react/radialmenu/RadialMenu.js +2 -3
  136. package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
  137. package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
  138. package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
  139. package/lib/esm/core-react/settings/SettingsManager.js.map +1 -1
  140. package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
  141. package/lib/esm/core-react/text/FilteredText.js.map +1 -1
  142. package/lib/esm/core-react/tree/Node.js.map +1 -1
  143. package/lib/esm/core-react/tree/Tree.js.map +1 -1
  144. package/lib/esm/core-react/uistate/UiStateEntry.js.map +1 -1
  145. package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
  146. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  147. package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
  148. package/lib/esm/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  149. package/lib/esm/core-react/utils/flattenChildren.js.map +1 -1
  150. package/lib/esm/core-react/utils/getUserColor.js.map +1 -1
  151. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  152. package/lib/esm/core-react/utils/hooks/useDisposable.js.map +1 -1
  153. package/lib/esm/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
  154. package/lib/esm/core-react/utils/hooks/useEventListener.js.map +1 -1
  155. package/lib/esm/core-react/utils/hooks/useInterval.js.map +1 -1
  156. package/lib/esm/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
  157. package/lib/esm/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
  158. package/lib/esm/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  159. package/lib/esm/core-react/utils/hooks/useRefs.js.map +1 -1
  160. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  161. package/lib/esm/core-react/utils/reuseOrCreatePromise.js.map +1 -1
  162. package/lib/esm/core-react/utils/shallowDiffers.js.map +1 -1
  163. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CA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ACrC,MAAM;QACR,KAAK,oBAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,oBAAoB,CAAC,KAAK;YAC7B,SAAS,GAAG,yBAAyB,CAAC;YACtC,MAAM;QACR,KAAK,oBAAoB,CAAC,UAAU;YAClC,SAAS,GAAG,iDAAiD,CAAC;YAC9D,MAAM;QACR,KAAK,oBAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,oBAAoB,CAAC,WAAW;YACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;KACT;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC;SA9NS,WAAW","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 { Key } from \"ts-key-enum\";\nimport { ConditionalBooleanValue } 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 {/* eslint-disable-next-line deprecation/deprecation */}\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 === Key.ArrowLeft.valueOf()) {\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 === Key.Escape.valueOf()) {\n // istanbul ignore else\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (\n (event.key === Key.Enter.valueOf() ||\n event.key === Key.ArrowRight.valueOf()) &&\n this._selectedElement\n ) {\n event.stopPropagation();\n\n // istanbul ignore else\n if (\n event.key === Key.Enter.valueOf() ||\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 === Key.ArrowUp.valueOf() ||\n event.key === Key.ArrowDown.valueOf()\n ) {\n event.stopPropagation();\n if (selectedIndex === -1) {\n selectedIndex = 0;\n } else {\n if (event.key === Key.ArrowUp.valueOf()) {\n if (this.state.selectedIndex === 0) selectedIndex = this._length - 1;\n else selectedIndex--;\n }\n if (event.key === Key.ArrowDown.valueOf()) {\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,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2ClD;;;;GAIG;AACH,MAAM,OAAO,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,oBAAoB,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;YAC9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ACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;IACV,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC","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 { Key } from \"ts-key-enum\";\nimport { ConditionalBooleanValue } 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 {/* eslint-disable-next-line deprecation/deprecation */}\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 === Key.ArrowLeft.valueOf()) {\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 === Key.Escape.valueOf()) {\n // istanbul ignore else\n if (this.props.onEsc) this.props.onEsc(event);\n }\n\n if (\n (event.key === Key.Enter.valueOf() ||\n event.key === Key.ArrowRight.valueOf()) &&\n this._selectedElement\n ) {\n event.stopPropagation();\n\n // istanbul ignore else\n if (\n event.key === Key.Enter.valueOf() ||\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 === Key.ArrowUp.valueOf() ||\n event.key === Key.ArrowDown.valueOf()\n ) {\n event.stopPropagation();\n if (selectedIndex === -1) {\n selectedIndex = 0;\n } else {\n if (event.key === Key.ArrowUp.valueOf()) {\n if (this.state.selectedIndex === 0) selectedIndex = this._length - 1;\n else selectedIndex--;\n }\n if (event.key === Key.ArrowDown.valueOf()) {\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"]}
@@ -16,7 +16,7 @@ import { Badge } from "../badge/Badge";
16
16
  * Menu Item class for use within a [[ContextMenu]] component.
17
17
  * @public
18
18
  */
19
- class ContextMenuItem extends React.PureComponent {
19
+ export class ContextMenuItem extends React.PureComponent {
20
20
  constructor(props) {
21
21
  super(props);
22
22
  this._root = null;
@@ -107,5 +107,4 @@ ContextMenuItem.defaultProps = {
107
107
  hidden: false,
108
108
  isSelected: false,
109
109
  };
110
- export { ContextMenuItem };
111
110
  //# sourceMappingURL=ContextMenuItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenuItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAIhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAoCvC;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAG1C;IAUC,YAAY,KAA2B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAVP,UAAK,GAAuB,IAAI,CAAC;QAYzC,gBAAgB;QACS,UAAK,GAAmC,EAAE,CAAC;QA2F5D,kBAAa,GAAG,CAAC,IAAqB,EAAE,EAAE;YAChD,IAAI,MAA0B,CAAC;YAC/B,MAAM,UAAU,GAAG,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACrE,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ;gBAC1B,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;;gBACjD,MAAM,GAAG,SAAS,CAAC;Y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C9C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzC;IACH,CAAC;;AAnGD,gBAAgB;AACF,4BAAY,GAAkC;IAC1D,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;CAClB,AAJyB,CAIxB;SAZS,eAAe","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 { Key } from \"ts-key-enum\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { ContextMenu } from \"./ContextMenu\";\nimport type { BadgeType } from \"../badge/BadgeType\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Badge } from \"../badge/Badge\";\n\n/** Properties for the [[ContextMenuItem]] component\n * @public\n */\nexport interface ContextMenuItemProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"disabled\" | \"hidden\">,\n CommonProps {\n onSelect?: (event: any) => any;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n /** Icon to display in the left margin. */\n icon?: IconSpec;\n /** Disables any onSelect calls, hover/keyboard highlighting, and grays item. */\n disabled?: boolean | ConditionalBooleanValue;\n /** Indicates whether the item is visible or hidden. The default is for the item to be visible. */\n hidden?: boolean | ConditionalBooleanValue;\n /** Badge to be overlaid on the item. */\n badgeType?: BadgeType;\n /** Icon to display in the right margin. */\n iconRight?: IconSpec;\n /** Hide the icon container. This can be used to eliminate space used to display an icon at the left of the menu item. */\n hideIconContainer?: boolean;\n /** @internal */\n onHover?: () => any;\n /* @internal */\n isSelected?: boolean;\n /** @internal */\n parentMenu?: ContextMenu;\n}\n\n/** @internal */\ninterface ContextMenuItemState {\n hotKey?: string;\n}\n\n/**\n * Menu Item class for use within a [[ContextMenu]] component.\n * @public\n */\nexport class ContextMenuItem extends React.PureComponent<\n ContextMenuItemProps,\n ContextMenuItemState\n> {\n private _root: HTMLElement | null = null;\n private _lastChildren: React.ReactNode;\n private _parsedChildren: React.ReactNode;\n /** @internal */\n public static defaultProps: Partial<ContextMenuItemProps> = {\n disabled: false,\n hidden: false,\n isSelected: false,\n };\n constructor(props: ContextMenuItemProps) {\n super(props);\n }\n /** @internal */\n public override readonly state: Readonly<ContextMenuItemState> = {};\n public override render(): React.ReactElement {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n onClick,\n className,\n style,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n parentMenu,\n onHotKeyParsed,\n badgeType,\n iconRight,\n hideIconContainer,\n ...props\n } = this.props;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastChildren !== this.props.children) {\n this._parsedChildren = TildeFinder.findAfterTilde(\n this.props.children\n ).node;\n this._lastChildren = this.props.children;\n }\n\n return (\n <div\n {...props}\n ref={(el) => {\n this._root = el;\n }}\n onClick={this._handleClick}\n style={style}\n onFocus={this._handleFocus}\n onKeyUp={this._handleKeyUp}\n onMouseOver={this._handleMouseOver}\n data-testid={\"core-context-menu-item\"}\n className={classnames(\n \"core-context-menu-item\",\n className,\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n >\n {!hideIconContainer && (\n <div className=\"core-context-menu-icon\">\n {icon !== undefined && <Icon iconSpec={icon} />}\n </div>\n )}\n <div className={\"core-context-menu-content\"}>\n {this._parsedChildren}\n </div>\n {iconRight && (\n <div\n className={classnames(\n \"core-context-menu-icon\",\n \"core-context-menu-icon-right\"\n )}\n >\n <Icon iconSpec={iconRight} />\n </div>\n )}\n {badgeType && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeType} />\n </div>\n )}\n </div>\n );\n }\n\n public override componentDidMount() {\n this._updateHotkey(this.props.children);\n }\n\n public override componentDidUpdate(prevProps: ContextMenuItemProps) {\n if (this.props.children !== prevProps.children) {\n this._updateHotkey(this.props.children);\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 private _handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n event.stopPropagation();\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n // istanbul ignore else\n if (\n this._root &&\n this._root.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n public select = () => {\n // istanbul ignore else\n if (this._root) {\n this._root.click();\n if (this.props.parentMenu && this.props.parentMenu.props.parentSubmenu)\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n if (isDisabled) return;\n\n if (this.props.onClick) this.props.onClick(event);\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n if (\n event.key === Key.Enter.valueOf() &&\n this.props.onSelect !== undefined &&\n !isDisabled\n ) {\n this.props.onSel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AC;QAC1C,CAAC;IACH,CAAC;;AAnGD,gBAAgB;AACF,4BAAY,GAAkC;IAC1D,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;CAClB,AAJyB,CAIxB","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 { Key } from \"ts-key-enum\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { ContextMenu } from \"./ContextMenu\";\nimport type { BadgeType } from \"../badge/BadgeType\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Badge } from \"../badge/Badge\";\n\n/** Properties for the [[ContextMenuItem]] component\n * @public\n */\nexport interface ContextMenuItemProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"disabled\" | \"hidden\">,\n CommonProps {\n onSelect?: (event: any) => any;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n /** Icon to display in the left margin. */\n icon?: IconSpec;\n /** Disables any onSelect calls, hover/keyboard highlighting, and grays item. */\n disabled?: boolean | ConditionalBooleanValue;\n /** Indicates whether the item is visible or hidden. The default is for the item to be visible. */\n hidden?: boolean | ConditionalBooleanValue;\n /** Badge to be overlaid on the item. */\n badgeType?: BadgeType;\n /** Icon to display in the right margin. */\n iconRight?: IconSpec;\n /** Hide the icon container. This can be used to eliminate space used to display an icon at the left of the menu item. */\n hideIconContainer?: boolean;\n /** @internal */\n onHover?: () => any;\n /* @internal */\n isSelected?: boolean;\n /** @internal */\n parentMenu?: ContextMenu;\n}\n\n/** @internal */\ninterface ContextMenuItemState {\n hotKey?: string;\n}\n\n/**\n * Menu Item class for use within a [[ContextMenu]] component.\n * @public\n */\nexport class ContextMenuItem extends React.PureComponent<\n ContextMenuItemProps,\n ContextMenuItemState\n> {\n private _root: HTMLElement | null = null;\n private _lastChildren: React.ReactNode;\n private _parsedChildren: React.ReactNode;\n /** @internal */\n public static defaultProps: Partial<ContextMenuItemProps> = {\n disabled: false,\n hidden: false,\n isSelected: false,\n };\n constructor(props: ContextMenuItemProps) {\n super(props);\n }\n /** @internal */\n public override readonly state: Readonly<ContextMenuItemState> = {};\n public override render(): React.ReactElement {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const {\n onClick,\n className,\n style,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n parentMenu,\n onHotKeyParsed,\n badgeType,\n iconRight,\n hideIconContainer,\n ...props\n } = this.props;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastChildren !== this.props.children) {\n this._parsedChildren = TildeFinder.findAfterTilde(\n this.props.children\n ).node;\n this._lastChildren = this.props.children;\n }\n\n return (\n <div\n {...props}\n ref={(el) => {\n this._root = el;\n }}\n onClick={this._handleClick}\n style={style}\n onFocus={this._handleFocus}\n onKeyUp={this._handleKeyUp}\n onMouseOver={this._handleMouseOver}\n data-testid={\"core-context-menu-item\"}\n className={classnames(\n \"core-context-menu-item\",\n className,\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n >\n {!hideIconContainer && (\n <div className=\"core-context-menu-icon\">\n {icon !== undefined && <Icon iconSpec={icon} />}\n </div>\n )}\n <div className={\"core-context-menu-content\"}>\n {this._parsedChildren}\n </div>\n {iconRight && (\n <div\n className={classnames(\n \"core-context-menu-icon\",\n \"core-context-menu-icon-right\"\n )}\n >\n <Icon iconSpec={iconRight} />\n </div>\n )}\n {badgeType && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeType} />\n </div>\n )}\n </div>\n );\n }\n\n public override componentDidMount() {\n this._updateHotkey(this.props.children);\n }\n\n public override componentDidUpdate(prevProps: ContextMenuItemProps) {\n if (this.props.children !== prevProps.children) {\n this._updateHotkey(this.props.children);\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 private _handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n event.stopPropagation();\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n // istanbul ignore else\n if (\n this._root &&\n this._root.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n public select = () => {\n // istanbul ignore else\n if (this._root) {\n this._root.click();\n if (this.props.parentMenu && this.props.parentMenu.props.parentSubmenu)\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n if (isDisabled) return;\n\n if (this.props.onClick) this.props.onClick(event);\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n if (\n event.key === Key.Enter.valueOf() &&\n this.props.onSelect !== undefined &&\n !isDisabled\n ) {\n this.props.onSelect(event);\n }\n };\n}\n"]}
@@ -18,7 +18,7 @@ import { Badge } from "../badge/Badge";
18
18
  * Submenu wrapper class for use within a [[ContextMenu]] component.
19
19
  * @public
20
20
  */
21
- class ContextSubMenu extends React.Component {
21
+ export class ContextSubMenu extends React.Component {
22
22
  constructor(props) {
23
23
  super(props);
24
24
  this._menuElement = null;
@@ -178,5 +178,4 @@ ContextSubMenu.defaultProps = {
178
178
  isSelected: false,
179
179
  selectedIndex: 0,
180
180
  };
181
- export { ContextSubMenu };
182
181
  //# sourceMappingURL=ContextSubMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAsBvC;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,SAGzC;IAmBC,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAnBP,iBAAY,GAAuB,IAAI,CAAC;QACxC,oBAAe,GAAuB,IAAI,CAAC;QAC3C,uBAAkB,GAAuB,IAAI,CAAC;QA2L9C,kBAAa,GAAG,CAAC,IAAqB,EAAE,EAAE;YAChD,IAAI,MAA0B,CAAC;YAC/B,MAAM,UAAU,GAAG,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ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;QACvB,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE;YACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,WAAW,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;;AApLa,2BAAY,GAAiC;IACzD,SAAS,EAAE,oBAAoB,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;SAlBS,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 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 { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRightSmall } from \"@itwin/itwinui-icons-react\";\nimport { Badge } from \"../badge/Badge\";\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 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 <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\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 {badgeType && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeType} />\n </div>\n )}\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,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAsBvC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,SAGzC;IAmBC,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAnBP,iBAAY,GAAuB,IAAI,CAAC;QACxC,oBAAe,GAAuB,IAAI,CAAC;QAC3C,uBAAkB,GAAuB,IAAI,CAAC;QA2L9C,kBAAa,GAAG,CAAC,IAAqB,EAAE,EAAE;YAChD,IAAI,MAA0B,CAAC;YAC/B,MAAM,UAAU,GAAG,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC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ACvB,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,WAAW,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;QAClD,CAAC;IACH,CAAC;;AApLa,2BAAY,GAAiC;IACzD,SAAS,EAAE,oBAAoB,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","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 { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRightSmall } from \"@itwin/itwinui-icons-react\";\nimport { Badge } from \"../badge/Badge\";\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 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 <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\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 {badgeType && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeType} />\n </div>\n )}\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 +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,eAAe,CAAC;AAqB5C;;GAEG;AACH,MAAM,OAAO,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;YACvD,MAAM,cAAc,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;YACvD,IAAI,cAAc,EAAE;gBAClB,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,CAAC,UAAU,CAAC,EAAE;oBAChB,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;wBACjC,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;wBACnC,CAAC,CAAC,0BAA0B,CAAC;gBACjC,IAAI,EAAE,GAAG,cAAc,CAAC,cAAc,CACpC,+BAA+B,CACd,CAAC;gBACpB,IAAI,CAAC,EAAE,EAAE;oBACP,EAAE,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACzC,EAAE,CAAC,EAAE,GA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C,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\";\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=\"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 // istanbul ignore next\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"]}
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,eAAe,CAAC;AAqB5C;;GAEG;AACH,MAAM,OAAO,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;YACvD,MAAM,cAAc,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;YACvD,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,CAAC,UAA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G,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,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\";\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=\"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 // istanbul ignore next\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/PopupContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EA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AI;YACxB,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC;YAC1C,MAAM;QACR,KAAK,gBAAgB,CAAC,KAAK;YACzB,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC3C,MAAM;QACR,KAAK,gBAAgB,CAAC,MAAM;YAC1B,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;YAC5C,MAAM;QACR,KAAK,gBAAgB,CAAC,UAAU;YAC9B,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC;YACjD,MAAM;QACR,KAAK,gBAAgB,CAAC,WAAW;YAC/B,aAAa,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAChD,MAAM;KACT;IACD,OAAO,aAAa,CAAC;AACvB,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 ContextMenu\n */\n\nimport * as React from \"react\";\nimport { Popup } from \"../popup/Popup\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\n\n/** Properties for [[PopupContextMenu]] component\n * @public\n */\nexport interface PopupContextMenuProps extends CommonProps {\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position?: RelativePosition;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Top position (absolute positioning - defaults to 0) */\n top?: number;\n /** Left position (absolute positioning - defaults to 0) */\n left?: number;\n /** Offset from the parent (defaults to 4) */\n offset?: number;\n /** accessibility label */\n ariaLabel?: string;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n\n /** When list item or submenu is selected */\n onSelect?: (event: React.MouseEvent | undefined) => void;\n /** when Escape button is pressed */\n onEsc?: (event: React.KeyboardEvent) => void;\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\n /** ContextMenu items */\n children?: React.ReactNode;\n}\n\n/** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.\n * @public\n */\nexport function PopupContextMenu(props: PopupContextMenuProps) {\n const {\n style,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n children,\n ...popupProps\n } = props;\n const menuDirection = getContextMenuDirectionFromRelativePosition(\n popupProps.position\n );\n return (\n <Popup\n {...popupProps}\n closeOnNestedPopupOutsideClick\n showShadow={false}\n showArrow={false}\n moveFocus={true}\n style={{ ...style, border: \"none\" }}\n >\n <ContextMenu\n opened={true}\n onSelect={onSelect}\n onEsc={onEsc}\n autoflip={autoflip}\n edgeLimit={edgeLimit}\n hotkeySelect={hotkeySelect}\n selectedIndex={selectedIndex}\n direction={menuDirection}\n >\n {children}\n </ContextMenu>\n </Popup>\n );\n}\n\nfunction getContextMenuDirectionFromRelativePosition(\n relativePosition?: RelativePosition\n): ContextMenuDirection {\n let menuDirection = ContextMenuDirection.Bottom;\n switch (relativePosition) {\n case RelativePosition.Top:\n menuDirection = ContextMenuDirection.Top;\n break;\n case RelativePosition.TopLeft:\n menuDirection = ContextMenuDirection.TopRight;\n break;\n case RelativePosition.TopRight:\n menuDirection = ContextMenuDirection.TopLeft;\n break;\n case RelativePosition.Left:\n menuDirection = ContextMenuDirection.Left;\n break;\n case RelativePosition.Right:\n menuDirection = ContextMenuDirection.Right;\n break;\n case RelativePosition.Bottom:\n menuDirection = ContextMenuDirection.Bottom;\n break;\n case RelativePosition.BottomLeft:\n menuDirection = ContextMenuDirection.BottomRight;\n break;\n case RelativePosition.BottomRight:\n menuDirection = ContextMenuDirection.BottomLeft;\n break;\n }\n return menuDirection;\n}\n"]}
1
+ {"version":3,"file":"PopupContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/PopupContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAgD9D;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,GAAG,UAAU,EACd,GAAG,KAAK,CAAC;IACV,MAAM,aAAa,GAAG,2CAA2C,CAC/D,UAAU,CAAC,QAAQ,CACpB,CAAC;IACF,OAAO,CACL,oBAAC,KAAK,OACA,UAAU,EACd,8BAA8B,QAC9B,UAAU,EAAE,KAAK,EACjB,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEnC,oBAAC,WAAW,IACV,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,aAAa,IAEvB,QAAQ,CACG,CACR,CACT,CAAC;AACJ,CAAC;AAED,SAAS,2CAA2C,CAClD,gBAAmC;IAEnC,IAAI,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAChD,QAAQ,gBAAgB,EAAE,CAAC;QACzB,KAAK,gBAAgB,CAAC,GAAG;YACvB,aAAa,GAAG,oBAAoB,CAAC,GAAG,CAAC;YACzC,MAAM;QACR,KAAK,gBAAgB,CAAC,OAAO;YAC3B,aAAa,GAAG,oBAAoB,CAAC,QAAQ,CAAC;YAC9C,MAAM;QACR,KAAK,gBAAgB,CAAC,QAAQ;YAC5B,aAAa,GAAG,oBAAoB,CAAC,OAAO,CAAC;YAC7C,MAAM;QACR,KAAK,gBAAgB,CAAC,IAAI;YACxB,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC;YAC1C,MAAM;QACR,KAAK,gBAAgB,CAAC,KAAK;YACzB,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC3C,MAAM;QACR,KAAK,gBAAgB,CAAC,MAAM;YAC1B,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;YAC5C,MAAM;QACR,KAAK,gBAAgB,CAAC,UAAU;YAC9B,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC;YACjD,MAAM;QACR,KAAK,gBAAgB,CAAC,WAAW;YAC/B,aAAa,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAChD,MAAM;IACV,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,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 ContextMenu\n */\n\nimport * as React from \"react\";\nimport { Popup } from \"../popup/Popup\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\n\n/** Properties for [[PopupContextMenu]] component\n * @public\n */\nexport interface PopupContextMenuProps extends CommonProps {\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position?: RelativePosition;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Top position (absolute positioning - defaults to 0) */\n top?: number;\n /** Left position (absolute positioning - defaults to 0) */\n left?: number;\n /** Offset from the parent (defaults to 4) */\n offset?: number;\n /** accessibility label */\n ariaLabel?: string;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n\n /** When list item or submenu is selected */\n onSelect?: (event: React.MouseEvent | undefined) => void;\n /** when Escape button is pressed */\n onEsc?: (event: React.KeyboardEvent) => void;\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\n /** ContextMenu items */\n children?: React.ReactNode;\n}\n\n/** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.\n * @public\n */\nexport function PopupContextMenu(props: PopupContextMenuProps) {\n const {\n style,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n children,\n ...popupProps\n } = props;\n const menuDirection = getContextMenuDirectionFromRelativePosition(\n popupProps.position\n );\n return (\n <Popup\n {...popupProps}\n closeOnNestedPopupOutsideClick\n showShadow={false}\n showArrow={false}\n moveFocus={true}\n style={{ ...style, border: \"none\" }}\n >\n <ContextMenu\n opened={true}\n onSelect={onSelect}\n onEsc={onEsc}\n autoflip={autoflip}\n edgeLimit={edgeLimit}\n hotkeySelect={hotkeySelect}\n selectedIndex={selectedIndex}\n direction={menuDirection}\n >\n {children}\n </ContextMenu>\n </Popup>\n );\n}\n\nfunction getContextMenuDirectionFromRelativePosition(\n relativePosition?: RelativePosition\n): ContextMenuDirection {\n let menuDirection = ContextMenuDirection.Bottom;\n switch (relativePosition) {\n case RelativePosition.Top:\n menuDirection = ContextMenuDirection.Top;\n break;\n case RelativePosition.TopLeft:\n menuDirection = ContextMenuDirection.TopRight;\n break;\n case RelativePosition.TopRight:\n menuDirection = ContextMenuDirection.TopLeft;\n break;\n case RelativePosition.Left:\n menuDirection = ContextMenuDirection.Left;\n break;\n case RelativePosition.Right:\n menuDirection = ContextMenuDirection.Right;\n break;\n case RelativePosition.Bottom:\n menuDirection = ContextMenuDirection.Bottom;\n break;\n case RelativePosition.BottomLeft:\n menuDirection = ContextMenuDirection.BottomRight;\n break;\n case RelativePosition.BottomRight:\n menuDirection = ContextMenuDirection.BottomLeft;\n break;\n }\n return menuDirection;\n}\n"]}
@@ -9,7 +9,7 @@ import * as React from "react";
9
9
  /** Finds a tilde character in ContextMenu item label for hot key support
10
10
  * @internal
11
11
  */
12
- class TildeFinder {
12
+ export class TildeFinder {
13
13
  }
14
14
  /**
15
15
  * Find character following a tilde character within a React.ReactNode.
@@ -72,5 +72,4 @@ TildeFinder.findAfterTilde = (node) => {
72
72
  }
73
73
  return { character: undefined, node };
74
74
  };
75
- export { TildeFinder };
76
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,MAAa,WAAW;;AACtB;;;;GAIG;AACW,0BAAc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E;gBACjB,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;aAC3C;SACF;aAAM,IAAI,OAAO,IAAI,IAAI,EAAE;YAC1B,aAAa;YACb,MAAM,GAAG,GAA6D;gBACpE,SAAS,EAAE,SAAS;gBACpB,IAAI;aACL,CAAC;YACF,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;gBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAC1B,IAAI,CAAC,KAAK,CAAC,QAA2B,EACtC,CAAC,KAAsB,EAAE,EAAE;oBACzB,MAAM,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;oBAC5C,IAAI,CAAC,CAAC,SAAS,EAAE;wBACf,4EAA4E;wBAC5E,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;wBAC5B,OAAO,CAAC,CAAC,IAAI,CAAC;qBACf;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CACF;aACF,CAAC,CAAC;YACH,IAAI,GAAG,CAAC,SAAS,EAAE;gBACjB,OAAO,GAAG,CAAC;aACZ;SACF;KACF;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACxC,CAAC,CAAC;SAhES,WAAW","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\";\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 (\"props\" in 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 as React.ReactNode,\n (child: 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"]}
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;;AACtB;;;;GAIG;AACW,0BAAc,GAAG,CAC7B,IAAqB,EACqC,EAAE;IAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,SAAS;QACT,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,UAAU,IAAI,IAAI,CA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AG,GAA6D;gBACpE,SAAS,EAAE,SAAS;gBACpB,IAAI;aACL,CAAC;YACF,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;gBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAC1B,IAAI,CAAC,KAAK,CAAC,QAA2B,EACtC,CAAC,KAAsB,EAAE,EAAE;oBACzB,MAAM,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;oBAC5C,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;wBAChB,4EAA4E;wBAC5E,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;wBAC5B,OAAO,CAAC,CAAC,IAAI,CAAC;oBAChB,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CACF;aACF,CAAC,CAAC;YACH,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;gBAClB,OAAO,GAAG,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACxC,CAAC,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 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 (\"props\" in 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 as React.ReactNode,\n (child: 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"]}
@@ -34,7 +34,7 @@ export var DialogAlignment;
34
34
  * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.
35
35
  */
36
36
  // eslint-disable-next-line deprecation/deprecation
37
- class Dialog extends React.Component {
37
+ export class Dialog extends React.Component {
38
38
  // eslint-disable-next-line deprecation/deprecation
39
39
  constructor(props) {
40
40
  super(props);
@@ -157,7 +157,6 @@ Dialog.defaultProps = {
157
157
  inset: true,
158
158
  trapFocus: false,
159
159
  };
160
- export { Dialog };
161
160
  function DialogButton({ button, primaryStyleType, noCoreButtonClasses, }) {
162
161
  const { translate } = useTranslation();
163
162
  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,CAAC;AACp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,CAAC,CAAC;YAC1D,mBAAmB,GAAG,IAAI,CAAC;YAC3B,MAAM;KACT;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\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.x. 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.x. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. */\n // eslint-disable-next-line deprecation/deprecation\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.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line deprecation/deprecation\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 deprecation/deprecation\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 // istanbul ignore next\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n 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 deprecation/deprecation\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 && /* istanbul ignore next */ modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line deprecation/deprecation */}\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 deprecation/deprecation\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.x. 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 // istanbul ignore next\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
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/core-react/dialog/Dialog.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MA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C,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\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport \"./Dialog.scss\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\ntype ButtonProps = React.ComponentPropsWithoutRef<typeof Button>;\n\n/** Enum for dialog alignment\n * @public\n * @deprecated in 4.12.x. 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.x. Props of deprecated component {@link Dialog}.\n */\nexport interface DialogProps\n extends Omit<React.AllHTMLAttributes<HTMLDivElement>, \"title\">,\n CommonProps {\n /** Indicates whether to show dialog or not */\n opened: boolean;\n\n /** Indicates whether the user can resize dialog with cursor. Default: false */\n resizable?: boolean;\n /** Indicates whether the user can move dialog with cursor. Default: false */\n movable?: boolean;\n /** Indicates whether the content should be inset. Default: true */\n inset?: boolean;\n /** Indicates whether the focus should be trapped within the dialog. Default: false */\n trapFocus?: boolean;\n\n /** Whether the hide the header. Default: false */\n hideHeader?: boolean;\n /** Override for the header */\n header?: React.ReactNode;\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** Footer to show at bottom of dialog. Note: will override buttonCluster */\n footer?: string | React.ReactElement;\n /** List of DialogButtonDef objects specifying buttons and associated onClick events */\n buttonCluster?: DialogButtonDef[];\n\n /** Default alignment of dialog. */\n // eslint-disable-next-line deprecation/deprecation\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.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class Dialog extends React.Component<DialogProps> {\n private _parentDocument = document;\n // eslint-disable-next-line deprecation/deprecation\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 deprecation/deprecation\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 // istanbul ignore next\n public handleRefSet = (containerDiv: HTMLDivElement | null) => {\n if (containerDiv) this._parentDocument = containerDiv.ownerDocument;\n };\n\n public override render(): React.ReactElement {\n const {\n opened,\n title,\n footer,\n buttonCluster,\n onClose,\n onEscape,\n onOutsideClick,\n minWidth,\n minHeight,\n x,\n y,\n width,\n height,\n maxHeight,\n maxWidth,\n backgroundStyle,\n titleStyle,\n footerStyle,\n style,\n contentStyle,\n contentClassName,\n modal,\n resizable,\n movable,\n className,\n alignment,\n inset,\n trapFocus,\n modelessId,\n onModelessPointerDown,\n hideHeader,\n header,\n 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 deprecation/deprecation\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 && /* istanbul ignore next */ modal}\n preventDocumentScroll={true}\n data-testid=\"core-dialog-root\"\n {...props}\n >\n {modal && <BaseDialog.Backdrop style={backgroundStyle} />}\n {/* eslint-disable-next-line deprecation/deprecation */}\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 deprecation/deprecation\n private getCSSClassNameFromAlignment(alignment: DialogAlignment): string {\n switch (alignment) {\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopLeft:\n return \"core-align-top-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Top:\n return \"core-align-top\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.TopRight:\n return \"core-align-top-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Left:\n return \"core-align-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Center:\n return \"core-align-center\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Right:\n return \"core-align-right\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomLeft:\n return \"core-align-bottom-left\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.Bottom:\n return \"core-align-bottom\";\n // eslint-disable-next-line deprecation/deprecation\n case DialogAlignment.BottomRight:\n return \"core-align-bottom-right\";\n }\n }\n\n /** @deprecated in 4.12.x. 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 // istanbul ignore next\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 +1 @@
1
- {"version":3,"file":"GlobalDialog.js","sourceRoot":"","sources":["../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CAAC;IAvBF,CAAC;IAyBe,oBAAoB;QAClC,uBAAuB;QACvB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE;YACpD,UAAU;YACV,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC5D;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,IACzB,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY;YACnB,mDAAmD;YACnD,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\";\nimport { Dialog } from \"./Dialog\";\n\n/** Properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link GlobalDialog}.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface GlobalDialogProps extends DialogProps {\n identifier?: string;\n}\n\n/** State properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. 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.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\nexport class GlobalDialog extends React.Component<\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogProps,\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogState\n> {\n private _container?: HTMLDivElement;\n\n // eslint-disable-next-line deprecation/deprecation\n public override readonly state: GlobalDialogState = {\n parentDocument: null,\n };\n\n // eslint-disable-next-line deprecation/deprecation\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 // istanbul ignore else\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 deprecation/deprecation\n <Dialog {...props} />,\n this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
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,UAAU,CAAC;AAmBlC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAKvC;IAQC,mDAAmD;IACnD,YAAY,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AU,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,IACzB,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY;YACnB,mDAAmD;YACnD,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\";\nimport { Dialog } from \"./Dialog\";\n\n/** Properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link GlobalDialog}.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface GlobalDialogProps extends DialogProps {\n identifier?: string;\n}\n\n/** State properties for the [[GlobalDialog]] component\n * @public\n * @deprecated in 4.12.x. 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.x. Use {@link https://itwinui.bentley.com/docs/dialog iTwinUI dialog} instead.\n */\nexport class GlobalDialog extends React.Component<\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogProps,\n // eslint-disable-next-line deprecation/deprecation\n GlobalDialogState\n> {\n private _container?: HTMLDivElement;\n\n // eslint-disable-next-line deprecation/deprecation\n public override readonly state: GlobalDialogState = {\n parentDocument: null,\n };\n\n // eslint-disable-next-line deprecation/deprecation\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 // istanbul ignore else\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 deprecation/deprecation\n <Dialog {...props} />,\n this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}