@itwin/core-react 4.10.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/core-react/UiCore.d.ts +1 -1
  3. package/lib/cjs/core-react/UiCore.js +2 -4
  4. package/lib/cjs/core-react/UiCore.js.map +1 -1
  5. package/lib/cjs/core-react/badge/BadgeUtilities.d.ts +10 -2
  6. package/lib/cjs/core-react/badge/BadgeUtilities.d.ts.map +1 -1
  7. package/lib/cjs/core-react/badge/BadgeUtilities.js +9 -5
  8. package/lib/cjs/core-react/badge/BadgeUtilities.js.map +1 -1
  9. package/lib/cjs/core-react/base/Gap.js +1 -1
  10. package/lib/cjs/core-react/base/Gap.js.map +1 -1
  11. package/lib/cjs/core-react/contextmenu/ContextMenu.js +2 -1
  12. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  13. package/lib/cjs/core-react/contextmenu/ContextMenu.scss +0 -1
  14. package/lib/cjs/core-react/contextmenu/ContextMenuItem.d.ts +1 -1
  15. package/lib/cjs/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  16. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  17. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +5 -3
  18. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  19. package/lib/cjs/core-react/dialog/Dialog.js +2 -2
  20. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  21. package/lib/cjs/core-react/dialog/GlobalDialog.js +2 -1
  22. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  23. package/lib/cjs/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  24. package/lib/cjs/core-react/elementseparator/ElementSeparator.js +5 -5
  25. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  26. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +2 -1
  27. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  28. package/lib/cjs/core-react/icons/IconComponent.js +1 -1
  29. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  30. package/lib/cjs/core-react/inputs/input-label.scss +1 -2
  31. package/lib/cjs/core-react/inputs/variables.scss +0 -2
  32. package/lib/cjs/core-react/listbox/Listbox.js +3 -2
  33. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  34. package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
  35. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  36. package/lib/cjs/core-react/popup/Popup.js +8 -4
  37. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  38. package/lib/cjs/core-react/tabs/tabs.scss +1 -1
  39. package/lib/cjs/core-react/tree/Node.js +2 -1
  40. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  41. package/lib/cjs/core-react/useTranslation.d.ts +10 -0
  42. package/lib/cjs/core-react/useTranslation.d.ts.map +1 -0
  43. package/lib/cjs/core-react/useTranslation.js +20 -0
  44. package/lib/cjs/core-react/useTranslation.js.map +1 -0
  45. package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
  46. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  47. package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
  48. package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
  49. package/lib/cjs/core-react/utils/getObjectClassName.js +3 -2
  50. package/lib/cjs/core-react/utils/getObjectClassName.js.map +1 -1
  51. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
  52. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  53. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +14 -8
  54. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  55. package/lib/esm/core-react/UiCore.d.ts +1 -1
  56. package/lib/esm/core-react/UiCore.js +2 -4
  57. package/lib/esm/core-react/UiCore.js.map +1 -1
  58. package/lib/esm/core-react/badge/BadgeUtilities.d.ts +10 -2
  59. package/lib/esm/core-react/badge/BadgeUtilities.d.ts.map +1 -1
  60. package/lib/esm/core-react/badge/BadgeUtilities.js +6 -2
  61. package/lib/esm/core-react/badge/BadgeUtilities.js.map +1 -1
  62. package/lib/esm/core-react/base/Gap.js +1 -1
  63. package/lib/esm/core-react/base/Gap.js.map +1 -1
  64. package/lib/esm/core-react/contextmenu/ContextMenu.js +2 -1
  65. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  66. package/lib/esm/core-react/contextmenu/ContextMenu.scss +0 -1
  67. package/lib/esm/core-react/contextmenu/ContextMenuItem.d.ts +1 -1
  68. package/lib/esm/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  69. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  70. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +5 -3
  71. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  72. package/lib/esm/core-react/dialog/Dialog.js +2 -2
  73. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  74. package/lib/esm/core-react/dialog/GlobalDialog.js +2 -1
  75. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  76. package/lib/esm/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  77. package/lib/esm/core-react/elementseparator/ElementSeparator.js +5 -5
  78. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  79. package/lib/esm/core-react/hocs/withOnOutsideClick.js +2 -1
  80. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  81. package/lib/esm/core-react/icons/IconComponent.js +1 -1
  82. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  83. package/lib/esm/core-react/inputs/input-label.scss +1 -2
  84. package/lib/esm/core-react/inputs/variables.scss +0 -2
  85. package/lib/esm/core-react/listbox/Listbox.js +3 -2
  86. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  87. package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
  88. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  89. package/lib/esm/core-react/popup/Popup.js +8 -4
  90. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  91. package/lib/esm/core-react/tabs/tabs.scss +1 -1
  92. package/lib/esm/core-react/tree/Node.js +2 -1
  93. package/lib/esm/core-react/tree/Node.js.map +1 -1
  94. package/lib/esm/core-react/useTranslation.d.ts +10 -0
  95. package/lib/esm/core-react/useTranslation.d.ts.map +1 -0
  96. package/lib/esm/core-react/useTranslation.js +16 -0
  97. package/lib/esm/core-react/useTranslation.js.map +1 -0
  98. package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
  99. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  100. package/lib/esm/core-react/utils/getCssVariable.js +1 -1
  101. package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
  102. package/lib/esm/core-react/utils/getObjectClassName.js +3 -2
  103. package/lib/esm/core-react/utils/getObjectClassName.js.map +1 -1
  104. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
  105. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  106. package/lib/esm/core-react/utils/hooks/useResizeObserver.js +14 -8
  107. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  108. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log - @itwin/core-react
2
2
 
3
- This log was last generated on Mon, 26 Feb 2024 15:50:45 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 21 Mar 2024 16:38:04 GMT and should not be manually modified.
4
+
5
+ ## 4.11.0
6
+ Thu, 21 Mar 2024 16:38:04 GMT
7
+
8
+ ### Updates
9
+
10
+ - Add BadgeType
11
+ - Removed memoization for translated strings in components.
4
12
 
5
13
  ## 4.10.0
6
14
  Mon, 26 Feb 2024 15:50:45 GMT
@@ -29,7 +29,7 @@ export declare class UiCore {
29
29
  static get localization(): Localization;
30
30
  /** The internationalization service namespace. */
31
31
  static get localizationNamespace(): string;
32
- /** Calls localization.getLocalizedStringWithNamespace with the "UiCore" namespace. Do NOT include the namespace in the key.
32
+ /** Calls localization.getLocalizedString with the "UiCore" namespace. Do NOT include the namespace in the key.
33
33
  * @internal
34
34
  */
35
35
  static translate(key: string | string[]): string;
@@ -64,7 +64,7 @@ class UiCore {
64
64
  static get localizationNamespace() {
65
65
  return "UiCore";
66
66
  }
67
- /** Calls localization.getLocalizedStringWithNamespace with the "UiCore" namespace. Do NOT include the namespace in the key.
67
+ /** Calls localization.getLocalizedString with the "UiCore" namespace. Do NOT include the namespace in the key.
68
68
  * @internal
69
69
  */
70
70
  static translate(key) {
@@ -72,9 +72,7 @@ class UiCore {
72
72
  core_bentley_1.Logger.logError(UiCore.loggerCategory(this), `translate: UiCore must be initialize with a localization provider. Returning blank string.`);
73
73
  return "";
74
74
  }
75
- return UiCore._localization.getLocalizedString(key, {
76
- ns: UiCore.localizationNamespace,
77
- });
75
+ return UiCore._localization.getLocalizedString(`${UiCore.localizationNamespace}:${key}`);
78
76
  }
79
77
  /** @internal */
80
78
  static get packageName() {
@@ -1 +1 @@
1
- {"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,4EAA4E;AAC5E,8BAA4B;AAC5B,iCAA+B;AAC/B,mCAAiC;AACjC,0BAAwB;AAExB,sDAA6C;AAE7C,0DAAgD;AAChD,+DAA4D;AAC5D,mEAAgE;AAChE,2CAA2C;AAE3C;;;GAGG;AACH,MAAa,MAAM;IAIjB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,MAAM,CAAC,YAAY,EAAE;YACvB,qBAAM,CAAC,OAAO,CACZ,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,E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,OAAO,EAAE,CAAC;SACX;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE;YAClD,EAAE,EAAE,MAAM,CAAC,qBAAqB;SACjC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,uCAAkB,EAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AApFc,mBAAY,GAAG,KAAK,CAAC;AADzB,wBAAM","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 Utilities\n */\n\n/** Import color variables, layout variables and Sass classes barrel file */\nimport \"./colorthemes.scss\";\nimport \"./colorvariables.scss\";\nimport \"./layout-variables.scss\";\nimport \"./classes.scss\";\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { UiError } from \"@itwin/appui-abstract\";\nimport { IconWebComponent } from \"./utils/IconWebComponent\";\nimport { getObjectClassName } from \"./utils/getObjectClassName\";\n// cSpell:ignore colorthemes colorvariables\n\n/**\n * Manages the Localization service for the core-react package.\n * @public\n */\nexport class UiCore {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the Localization service namespace for UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiCore._initialized) {\n Logger.logInfo(\n UiCore.loggerCategory(UiCore),\n `UiCore.initialize already called`\n );\n return;\n }\n\n UiCore._localization = localization;\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\n if (window.customElements.get(\"svg-loader\") === undefined)\n window.customElements.define(\"svg-loader\", IconWebComponent);\n\n UiCore._initialized = true;\n }\n\n /** Unregisters the UiCore localization namespace */\n public static terminate() {\n if (UiCore._localization)\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\n UiCore._localization = undefined;\n\n UiCore._initialized = false;\n }\n\n /** Determines if UiCore has been initialized */\n public static get initialized(): boolean {\n return UiCore._initialized;\n }\n\n /** The internationalization service created by the host application.\n * @internal\n */\n public static get localization(): Localization {\n // istanbul ignore else\n if (!UiCore._localization)\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiCore.loggerCategory(this),\n \"localization: UiCore.initialize has not been called. Unable to return Localization object.\"\n );\n // istanbul ignore next\n return UiCore._localization;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiCore\";\n }\n\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiCore\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiCore._localization) {\n Logger.logError(\n UiCore.loggerCategory(this),\n `translate: UiCore must be initialize with a localization provider. Returning blank string.`\n );\n return \"\";\n }\n return UiCore._localization.getLocalizedString(key, {\n ns: UiCore.localizationNamespace,\n });\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"core-react\";\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category = UiCore.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
1
+ {"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,4EAA4E;AAC5E,8BAA4B;AAC5B,iCAA+B;AAC/B,mCAAiC;AACjC,0BAAwB;AAExB,sDAA6C;AAE7C,0DAAgD;AAChD,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K,qBAAqB;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;YACzB,qBAAM,CAAC,QAAQ,CACb,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAC3B,4FAA4F,CAC7F,CAAC;YACF,OAAO,EAAE,CAAC;SACX;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAC5C,GAAG,MAAM,CAAC,qBAAqB,IAAI,GAAG,EAAE,CACzC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,uCAAkB,EAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AApFc,mBAAY,GAAG,KAAK,CAAC;AADzB,wBAAM","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 Utilities\n */\n\n/** Import color variables, layout variables and Sass classes barrel file */\nimport \"./colorthemes.scss\";\nimport \"./colorvariables.scss\";\nimport \"./layout-variables.scss\";\nimport \"./classes.scss\";\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { UiError } from \"@itwin/appui-abstract\";\nimport { IconWebComponent } from \"./utils/IconWebComponent\";\nimport { getObjectClassName } from \"./utils/getObjectClassName\";\n// cSpell:ignore colorthemes colorvariables\n\n/**\n * Manages the Localization service for the core-react package.\n * @public\n */\nexport class UiCore {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the Localization service namespace for UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiCore._initialized) {\n Logger.logInfo(\n UiCore.loggerCategory(UiCore),\n `UiCore.initialize already called`\n );\n return;\n }\n\n UiCore._localization = localization;\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\n if (window.customElements.get(\"svg-loader\") === undefined)\n window.customElements.define(\"svg-loader\", IconWebComponent);\n\n UiCore._initialized = true;\n }\n\n /** Unregisters the UiCore localization namespace */\n public static terminate() {\n if (UiCore._localization)\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\n UiCore._localization = undefined;\n\n UiCore._initialized = false;\n }\n\n /** Determines if UiCore has been initialized */\n public static get initialized(): boolean {\n return UiCore._initialized;\n }\n\n /** The internationalization service created by the host application.\n * @internal\n */\n public static get localization(): Localization {\n // istanbul ignore else\n if (!UiCore._localization)\n // eslint-disable-next-line deprecation/deprecation\n throw new UiError(\n UiCore.loggerCategory(this),\n \"localization: UiCore.initialize has not been called. Unable to return Localization object.\"\n );\n // istanbul ignore next\n return UiCore._localization;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiCore\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiCore\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiCore._localization) {\n Logger.logError(\n UiCore.loggerCategory(this),\n `translate: UiCore must be initialize with a localization provider. Returning blank string.`\n );\n return \"\";\n }\n return UiCore._localization.getLocalizedString(\n `${UiCore.localizationNamespace}:${key}`\n );\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"core-react\";\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category = UiCore.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
@@ -2,8 +2,16 @@
2
2
  * @module Utilities
3
3
  */
4
4
  import * as React from "react";
5
- import { BadgeType } from "@itwin/appui-abstract";
6
- /** Converts BetaType to Badge React component
5
+ import { BadgeType as _BadgeType } from "@itwin/appui-abstract";
6
+ /** Specifies type of badge, if any, that should be overlaid on UI component.
7
+ * @public
8
+ */
9
+ export type BadgeType = _BadgeType;
10
+ /** Specifies type of badge, if any, that should be overlaid on UI component.
11
+ * @public
12
+ */
13
+ export declare const BadgeType: typeof _BadgeType;
14
+ /** Converts BadgeType to Badge React component
7
15
  * @internal
8
16
  */
9
17
  export declare class BadgeUtilities {
@@ -1 +1 @@
1
- {"version":3,"file":"BadgeUtilities.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/BadgeUtilities.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD;;GAEG;AACH,qBAAa,cAAc;IACzB,iDAAiD;WACnC,wBAAwB,CACpC,SAAS,CAAC,EAAE,SAAS,GACpB,KAAK,CAAC,SAAS;CAmBnB"}
1
+ {"version":3,"file":"BadgeUtilities.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/BadgeUtilities.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,SAAS,mBAAa,CAAC;AAEpC;;GAEG;AACH,qBAAa,cAAc;IACzB,iDAAiD;WACnC,wBAAwB,CACpC,SAAS,CAAC,EAAE,SAAS,GACpB,KAAK,CAAC,SAAS;CAmBnB"}
@@ -7,12 +7,16 @@
7
7
  * @module Utilities
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.BadgeUtilities = void 0;
10
+ exports.BadgeUtilities = exports.BadgeType = void 0;
11
11
  const React = require("react");
12
12
  const appui_abstract_1 = require("@itwin/appui-abstract");
13
13
  const BetaBadge_1 = require("./BetaBadge");
14
14
  const NewBadge_1 = require("./NewBadge");
15
- /** Converts BetaType to Badge React component
15
+ /** Specifies type of badge, if any, that should be overlaid on UI component.
16
+ * @public
17
+ */
18
+ exports.BadgeType = appui_abstract_1.BadgeType; // eslint-disable-line @typescript-eslint/no-redeclare, deprecation/deprecation
19
+ /** Converts BadgeType to Badge React component
16
20
  * @internal
17
21
  */
18
22
  class BadgeUtilities {
@@ -22,13 +26,13 @@ class BadgeUtilities {
22
26
  return undefined;
23
27
  let component;
24
28
  switch (badgeType) {
25
- case appui_abstract_1.BadgeType.TechnicalPreview:
29
+ case exports.BadgeType.TechnicalPreview:
26
30
  component = React.createElement(BetaBadge_1.BetaBadge, null);
27
31
  break;
28
- case appui_abstract_1.BadgeType.New:
32
+ case exports.BadgeType.New:
29
33
  component = React.createElement(NewBadge_1.NewBadge, null);
30
34
  break;
31
- case appui_abstract_1.BadgeType.None:
35
+ case exports.BadgeType.None:
32
36
  component = undefined;
33
37
  break;
34
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BadgeUtilities.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BadgeUtilities.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,0DAAkD;AAClD,2CAAwC;AACxC,yCAAsC;AAEtC;;GAEG;AACH,MAAa,cAAc;IACzB,iDAAiD;IAC1C,MAAM,CAAC,wBAAwB,CACpC,SAAqB;QAErB,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAE9C,IAAI,SAA0B,CAAC;QAE/B,QAAQ,SAAS,EAAE;YACjB,KAAK,0BAAS,CAAC,gBAAgB;gBAC7B,SAAS,GAAG,oBAAC,qBAAS,OAAG,CAAC;gBAC1B,MAAM;YACR,KAAK,0BAAS,CAAC,GAAG;gBAChB,SAAS,GAAG,oBAAC,mBAAQ,OAAG,CAAC;gBACzB,MAAM;YACR,KAAK,0BAAS,CAAC,IAAI;gBACjB,SAAS,GAAG,SAAS,CAAC;gBACtB,MAAM;SACT;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAvBD,wCAuBC","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 Utilities\n */\n\nimport * as React from \"react\";\nimport { BadgeType } from \"@itwin/appui-abstract\";\nimport { BetaBadge } from \"./BetaBadge\";\nimport { NewBadge } from \"./NewBadge\";\n\n/** Converts BetaType to Badge React component\n * @internal\n */\nexport class BadgeUtilities {\n /** Converts BetaType to Badge React component */\n public static getComponentForBadgeType(\n badgeType?: BadgeType\n ): React.ReactNode {\n if (badgeType === undefined) return undefined;\n\n let component: React.ReactNode;\n\n switch (badgeType) {\n case BadgeType.TechnicalPreview:\n component = <BetaBadge />;\n break;\n case BadgeType.New:\n component = <NewBadge />;\n break;\n case BadgeType.None:\n component = undefined;\n break;\n }\n\n return component;\n }\n}\n"]}
1
+ {"version":3,"file":"BadgeUtilities.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BadgeUtilities.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,0DAAgE;AAChE,2CAAwC;AACxC,yCAAsC;AAOtC;;GAEG;AACU,QAAA,SAAS,GAAG,0BAAU,CAAC,CAAC,+EAA+E;AAEpH;;GAEG;AACH,MAAa,cAAc;IACzB,iDAAiD;IAC1C,MAAM,CAAC,wBAAwB,CACpC,SAAqB;QAErB,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAE9C,IAAI,SAA0B,CAAC;QAE/B,QAAQ,SAAS,EAAE;YACjB,KAAK,iBAAS,CAAC,gBAAgB;gBAC7B,SAAS,GAAG,oBAAC,qBAAS,OAAG,CAAC;gBAC1B,MAAM;YACR,KAAK,iBAAS,CAAC,GAAG;gBAChB,SAAS,GAAG,oBAAC,mBAAQ,OAAG,CAAC;gBACzB,MAAM;YACR,KAAK,iBAAS,CAAC,IAAI;gBACjB,SAAS,GAAG,SAAS,CAAC;gBACtB,MAAM;SACT;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAvBD,wCAuBC","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 Utilities\n */\n\nimport * as React from \"react\";\nimport { BadgeType as _BadgeType } from \"@itwin/appui-abstract\";\nimport { BetaBadge } from \"./BetaBadge\";\nimport { NewBadge } from \"./NewBadge\";\n\n/** Specifies type of badge, if any, that should be overlaid on UI component.\n * @public\n */\nexport type BadgeType = _BadgeType; // eslint-disable-line deprecation/deprecation\n\n/** Specifies type of badge, if any, that should be overlaid on UI component.\n * @public\n */\nexport const BadgeType = _BadgeType; // eslint-disable-line @typescript-eslint/no-redeclare, deprecation/deprecation\n\n/** Converts BadgeType to Badge React component\n * @internal\n */\nexport class BadgeUtilities {\n /** Converts BetaType to Badge React component */\n public static getComponentForBadgeType(\n badgeType?: BadgeType\n ): React.ReactNode {\n if (badgeType === undefined) return undefined;\n\n let component: React.ReactNode;\n\n switch (badgeType) {\n case BadgeType.TechnicalPreview:\n component = <BetaBadge />;\n break;\n case BadgeType.New:\n component = <NewBadge />;\n break;\n case BadgeType.None:\n component = undefined;\n break;\n }\n\n return component;\n }\n}\n"]}
@@ -14,7 +14,7 @@ const React = require("react");
14
14
  */
15
15
  function Gap(props) {
16
16
  const { size, style, ...rest } = props;
17
- const paddingLeft = size ?? "10px";
17
+ const paddingLeft = size !== null && size !== void 0 ? size : "10px";
18
18
  return React.createElement("span", { style: { ...style, paddingLeft }, ...rest });
19
19
  }
20
20
  exports.Gap = Gap;
@@ -1 +1 @@
1
- {"version":3,"file":"Gap.js","sourceRoot":"","sources":["../../../../src/core-react/base/Gap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAU/B;;GAEG;AACH,SAAgB,GAAG,CAAC,KAAe;IACjC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,IAAI,MAAM,CAAC;IAEnC,OAAO,8BAAM,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,KAAM,IAAI,GAAI,CAAC;AAC9D,CAAC;AALD,kBAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Base\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for the [[Gap]] component.\n * @public\n */\nexport interface GapProps extends CommonProps {\n size?: string;\n}\n\n/** Horizontal gap or space React component. Defaults to 10px.\n * @public\n */\nexport function Gap(props: GapProps) {\n const { size, style, ...rest } = props;\n const paddingLeft = size ?? \"10px\";\n\n return <span style={{ ...style, paddingLeft }} {...rest} />;\n}\n"]}
1
+ {"version":3,"file":"Gap.js","sourceRoot":"","sources":["../../../../src/core-react/base/Gap.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAU/B;;GAEG;AACH,SAAgB,GAAG,CAAC,KAAe;IACjC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,MAAM,CAAC;IAEnC,OAAO,8BAAM,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,KAAM,IAAI,GAAI,CAAC;AAC9D,CAAC;AALD,kBAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Base\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for the [[Gap]] component.\n * @public\n */\nexport interface GapProps extends CommonProps {\n size?: string;\n}\n\n/** Horizontal gap or space React component. Defaults to 10px.\n * @public\n */\nexport function Gap(props: GapProps) {\n const { size, style, ...rest } = props;\n const paddingLeft = size ?? \"10px\";\n\n return <span style={{ ...style, paddingLeft }} {...rest} />;\n}\n"]}
@@ -224,12 +224,13 @@ class ContextMenu extends React.PureComponent {
224
224
  React.createElement("div", { ref: this._menuRef, role: "menu", tabIndex: 0, "data-testid": "core-context-menu-container", className: (0, classnames_1.default)("core-context-menu-container", opened && "core-context-menu-opened", floating && "core-context-menu-floating", ContextMenu.getCSSClassNameFromDirection(renderDirection)) }, this._injectedChildren))));
225
225
  }
226
226
  getWindow() {
227
+ var _a;
227
228
  const el = this._rootElement
228
229
  ? this._rootElement
229
230
  : /* istanbul ignore next */ this._menuElement;
230
231
  const parentDocument = el.ownerDocument;
231
232
  // istanbul ignore next
232
- return parentDocument.defaultView ?? window;
233
+ return (_a = parentDocument.defaultView) !== null && _a !== void 0 ? _a : window;
233
234
  }
234
235
  /** @internal */
235
236
  componentDidMount() {
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,8BAA4B;AAC5B,2CAAoC;AACpC,+BAA+B;AA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AC;YACtC,MAAM;QACR,KAAK,2CAAoB,CAAC,UAAU;YAClC,SAAS,GAAG,iDAAiD,CAAC;YAC9D,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,WAAW;YACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;KACT;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC;AA7NS,kCAAW","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport \"./ContextMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { 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 <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}\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YAC5B,SAAS,GAAG,wBAAwB,CAAC;YACrC,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,KAAK;YAC7B,SAAS,GAAG,yBAAyB,CAAC;YACtC,MAAM;QACR,KAAK,2CAAoB,CAAC,UAAU;YAClC,SAAS,GAAG,iDAAiD,CAAC;YAC9D,MAAM;QACR,KAAK,2CAAoB,CAAC,MAAM;YAC9B,SAAS,GAAG,0BAA0B,CAAC;YACvC,MAAM;QACR,KAAK,2CAAoB,CAAC,WAAW;YACnC,SAAS,GAAG,kDAAkD,CAAC;YAC/D,MAAM;KACT;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,AAzCyC,CAyCxC;AA7NS,kCAAW","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport \"./ContextMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { 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 <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"]}
@@ -3,7 +3,6 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  @import "../icons/variables";
6
- @import "../inputs/variables";
7
6
  @import "../style/baseline";
8
7
  @import "../style/colors";
9
8
  @import "../style/opacity";
@@ -2,10 +2,10 @@
2
2
  * @module ContextMenu
3
3
  */
4
4
  import * as React from "react";
5
- import type { BadgeType } from "@itwin/appui-abstract";
6
5
  import { ConditionalBooleanValue } from "@itwin/appui-abstract";
7
6
  import type { CommonProps } from "../utils/Props";
8
7
  import type { ContextMenu } from "./ContextMenu";
8
+ import type { BadgeType } from "../badge/BadgeUtilities";
9
9
  import type { IconSpec } from "../icons/IconComponent";
10
10
  /** Properties for the [[ContextMenuItem]] component
11
11
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.d.ts","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenuItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,oBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,UAAU,G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AAgB;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC;IAEpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB;IAChB,UAAU,CAAC,EAAE,WAAW,CAAC;CAC1B;AAED,gBAAgB;AAChB,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK,CAAC,aAAa,CACtD,oBAAoB,EACpB,oBAAoB,CACrB;IACC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,eAAe,CAAkB;IACzC,gBAAgB;IAChB,OAAc,YAAY,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAIvD;gBACU,KAAK,EAAE,oBAAoB;IAGvC,gBAAgB;IAChB,SAAyB,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAM;IACpD,MAAM,IAAI,KAAK,CAAC,YAAY;IA6E5B,iBAAiB;IAIjB,kBAAkB,CAAC,SAAS,EAAE,oBAAoB;IAMlE,OAAO,CAAC,aAAa,CAWnB;IAEF,OAAO,CAAC,YAAY,CAElB;IAEF,OAAO,CAAC,gBAAgB,CAStB;IAEK,MAAM,aAOX;IAEF,OAAO,CAAC,YAAY,CAMlB;IAEF,OAAO,CAAC,YAAY,CASlB;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenuItem.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,2CAAoC;AACpC,6CAAkC;AAElC,0DAAgE;AAGhE,4DAAyD;AACzD,+CAA4C;AAE5C,0DAA8C;AAoC9C;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAG1C;IAUC,YAAY,KAA2B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAVP,UAAK,GA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,CACP;YACD,6BAAK,SAAS,EAAE,2BAA2B,IACxC,IAAI,CAAC,eAAe,CACjB;YACL,SAAS,IAAI,CACZ,6BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,wBAAwB,EACxB,8BAA8B,CAC/B;gBAED,oBAAC,oBAAI,IAAC,QAAQ,EAAE,SAAS,GAAI,CACzB,CACP;YACA,KAAK,IAAI,6BAAK,SAAS,EAAC,yBAAyB,IAAE,KAAK,CAAO,CAC5D,CACP,CAAC;IACJ,CAAC;IAEe,iBAAiB;QAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEe,kBAAkB,CAAC,SAA+B;QAChE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE;YAC9C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzC;IACH,CAAC;;AAhGD,gBAAgB;AACF,4BAAY,GAAkC;IAC1D,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;CAClB,AAJyB,CAIxB;AAZS,0CAAe","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 type { BadgeType } from \"@itwin/appui-abstract\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { ContextMenu } from \"./ContextMenu\";\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\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 badge = BadgeUtilities.getComponentForBadgeType(badgeType);\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 {badge && <div className=\"core-context-menu-badge\">{badge}</div>}\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"]}
1
+ {"version":3,"file":"ContextMenuItem.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextMenuItem.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,2CAAoC;AACpC,6CAAkC;AAClC,0DAAgE;AAIhE,4DAAyD;AACzD,+CAA4C;AAE5C,0DAA8C;AAoC9C;;;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;QAwF5D,kBAAa,GAAG,CAAC,IAAqB,EAAE,EAAE;YAChD,IAAI,MAA0B,CAAC;YAC/B,MAAM,UAAU,GAAG,wCAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,wCAAuB,CAAC,QAAQ,CAAC,IAAI,CAAC,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CAAC;IACJ,CAAC;IAEe,iBAAiB;QAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEe,kBAAkB,CAAC,SAA+B;QAChE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE;YAC9C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACzC;IACH,CAAC;;AAhGD,gBAAgB;AACF,4BAAY,GAAkC;IAC1D,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,KAAK;CAClB,AAJyB,CAIxB;AAZS,0CAAe","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/BadgeUtilities\";\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\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 badge = BadgeUtilities.getComponentForBadgeType(badgeType);\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 {badge && <div className=\"core-context-menu-badge\">{badge}</div>}\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"]}
@@ -21,7 +21,8 @@ class GlobalContextMenu extends React.PureComponent {
21
21
  parentDocument: null,
22
22
  };
23
23
  this._handleRefSet = (popupDiv) => {
24
- const parentDocument = popupDiv?.ownerDocument ?? null;
24
+ var _a, _b;
25
+ const parentDocument = (_a = popupDiv === null || popupDiv === void 0 ? void 0 : popupDiv.ownerDocument) !== null && _a !== void 0 ? _a : null;
25
26
  if (parentDocument) {
26
27
  this._container = parentDocument.createElement("div");
27
28
  this._container.id =
@@ -33,7 +34,7 @@ class GlobalContextMenu extends React.PureComponent {
33
34
  rt = parentDocument.createElement("div");
34
35
  rt.id = "core-global-context-menu-root";
35
36
  // istanbul ignore next
36
- (parentDocument.body.querySelector('[data-root-container="appui-root-id"]') ?? parentDocument.body).appendChild(rt);
37
+ ((_b = parentDocument.body.querySelector('[data-root-container="appui-root-id"]')) !== null && _b !== void 0 ? _b : parentDocument.body).appendChild(rt);
37
38
  }
38
39
  rt.appendChild(this._container);
39
40
  // used to support component rendering in pop-out window
@@ -49,6 +50,7 @@ class GlobalContextMenu extends React.PureComponent {
49
50
  }
50
51
  }
51
52
  render() {
53
+ var _a;
52
54
  const { x, y, identifier, contextMenuComponent, ...props } = this.props;
53
55
  const positioningStyle = {
54
56
  left: x,
@@ -59,7 +61,7 @@ class GlobalContextMenu extends React.PureComponent {
59
61
  ReactDOM.createPortal(React.createElement("div", { className: "core-context-menu-global", style: positioningStyle },
60
62
  React.createElement(CtxMenu, { ...props })),
61
63
  // istanbul ignore next
62
- this.state.parentDocument.body.querySelector('[data-root-container="appui-root-id"]') ?? this.state.parentDocument.body)));
64
+ (_a = this.state.parentDocument.body.querySelector('[data-root-container="appui-root-id"]')) !== null && _a !== void 0 ? _a : this.state.parentDocument.body)));
63
65
  }
64
66
  }
65
67
  exports.GlobalContextMenu = GlobalContextMenu;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,sCAAsC;AAEtC,+CAA4C;AAqB5C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IAOC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QALU,UAAK,GAA2B;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC;QAcM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE;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,GAAG,+BAA+B,CAAC;oBACxC,uBAAuB;oBACvB,CACE,cAAc,CAAC,IAAI,CAAC,aAAa,CAC/B,uCAAuC,CACxC,IAAI,cAAc,CAAC,IAAI,CACzB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;iBACnB;gBACD,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAEhC,wDAAwD;gBACxD,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;aACnC;QACH,CAAC,CAAC;IApCF,CAAC;IAEe,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;IA8Be,MAAM;QACpB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxE,MAAM,gBAAgB,GAAwB;YAC5C,IAAI,EAAE,CAAC;YACP,GAAG,EAAE,CAAC;SACP,CAAC;QAEF,MAAM,OAAO,GAAG,oBAAoB,IAAI,yBAAW,CAAC;QAEpD,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IACrD,IAAI,CAAC,KAAK,CAAC,cAAc;YACxB,QAAQ,CAAC,YAAY,CACnB,6BAAK,SAAS,EAAC,0BAA0B,EAAC,KAAK,EAAE,gBAAgB;gBAC/D,oBAAC,OAAO,OAAK,KAAK,GAAI,CAClB;YACN,uBAAuB;YACvB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,uCAAuC,CACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF;AA1ED,8CA0EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\n\n/** Properties for the [[GlobalContextMenu]] component\n * @public\n */\nexport interface GlobalContextMenuProps extends ContextMenuProps {\n /** Unique identifier, to distinguish from other GlobalContextMenu components. Needed only if multiple GlobalContextMenus are used simultaneously. */\n identifier?: string;\n /** Specifies the x/horizontal position on the viewport. */\n x: number | string;\n /** Specifies the y/vertical position on the viewport. */\n y: number | string;\n /** Context menu element. Default: ContextMenu */\n contextMenuComponent?: React.ComponentType<ContextMenuProps>;\n}\n\n/** @internal */\ninterface GlobalContextMenuState {\n parentDocument: Document | null;\n}\n\n/** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor\n * @public\n */\nexport class GlobalContextMenu extends React.PureComponent<\n GlobalContextMenuProps,\n GlobalContextMenuState\n> {\n private _container?: HTMLDivElement;\n\n public override readonly state: GlobalContextMenuState = {\n parentDocument: null,\n };\n\n constructor(props: GlobalContextMenuProps) {\n super(props);\n }\n\n public override componentWillUnmount() {\n // istanbul ignore else\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-global-context-menu\";\n let rt = parentDocument.getElementById(\n \"core-global-context-menu-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-global-context-menu-root\";\n // istanbul ignore next\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"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,+BAA+B;AAC/B,sCAAsC;AAEtC,+CAA4C;AAqB5C;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IAOC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QALU,UAAK,GAA2B;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC;QAcM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE;;YACvD,MAAM,cAAc,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,mCAAI,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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BAC/D,oBAAC,OAAO,OAAK,KAAK,GAAI,CAClB;YACN,uBAAuB;YACvB,MAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,uCAAuC,CACxC,mCAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF;AA1ED,8CA0EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\n\n/** Properties for the [[GlobalContextMenu]] component\n * @public\n */\nexport interface GlobalContextMenuProps extends ContextMenuProps {\n /** Unique identifier, to distinguish from other GlobalContextMenu components. Needed only if multiple GlobalContextMenus are used simultaneously. */\n identifier?: string;\n /** Specifies the x/horizontal position on the viewport. */\n x: number | string;\n /** Specifies the y/vertical position on the viewport. */\n y: number | string;\n /** Context menu element. Default: ContextMenu */\n contextMenuComponent?: React.ComponentType<ContextMenuProps>;\n}\n\n/** @internal */\ninterface GlobalContextMenuState {\n parentDocument: Document | null;\n}\n\n/** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor\n * @public\n */\nexport class GlobalContextMenu extends React.PureComponent<\n GlobalContextMenuProps,\n GlobalContextMenuState\n> {\n private _container?: HTMLDivElement;\n\n public override readonly state: GlobalContextMenuState = {\n parentDocument: null,\n };\n\n constructor(props: GlobalContextMenuProps) {\n super(props);\n }\n\n public override componentWillUnmount() {\n // istanbul ignore else\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-global-context-menu\";\n let rt = parentDocument.getElementById(\n \"core-global-context-menu-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-global-context-menu-root\";\n // istanbul ignore next\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"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"]}
@@ -70,8 +70,8 @@ class Dialog extends React.Component {
70
70
  let initialOffset = {};
71
71
  if (x || y) {
72
72
  initialOffset = {
73
- left: x ?? 0,
74
- top: y ?? 0,
73
+ left: x !== null && x !== void 0 ? x : 0,
74
+ top: y !== null && y !== void 0 ? y : 0,
75
75
  transform: "none",
76
76
  };
77
77
  }