@itwin/core-react 4.9.0 → 4.10.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 (178) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  3. package/lib/cjs/core-react/autosuggest/AutoSuggest.js +11 -6
  4. package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
  5. package/lib/cjs/core-react/autosuggest/AutoSuggest.scss +1 -1
  6. package/lib/cjs/core-react/base/Gap.js +1 -1
  7. package/lib/cjs/core-react/base/Gap.js.map +1 -1
  8. package/lib/cjs/core-react/button/UnderlinedButton.js +1 -1
  9. package/lib/cjs/core-react/button/UnderlinedButton.js.map +1 -1
  10. package/lib/cjs/core-react/checklistbox/CheckListBox.d.ts.map +1 -1
  11. package/lib/cjs/core-react/checklistbox/CheckListBox.js +4 -1
  12. package/lib/cjs/core-react/checklistbox/CheckListBox.js.map +1 -1
  13. package/lib/cjs/core-react/classes.scss +0 -1
  14. package/lib/cjs/core-react/colorvariables.scss +1 -1
  15. package/lib/cjs/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  16. package/lib/cjs/core-react/contextmenu/ContextMenu.js +10 -9
  17. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  18. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +1 -1
  19. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  20. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +3 -5
  21. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  22. package/lib/cjs/core-react/dialog/Dialog.d.ts +4 -13
  23. package/lib/cjs/core-react/dialog/Dialog.d.ts.map +1 -1
  24. package/lib/cjs/core-react/dialog/Dialog.js +9 -7
  25. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  26. package/lib/cjs/core-react/dialog/GlobalDialog.js +1 -2
  27. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  28. package/lib/cjs/core-react/elementseparator/ElementSeparator.js +2 -2
  29. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  30. package/lib/cjs/core-react/expandable/ExpandableList.d.ts +0 -1
  31. package/lib/cjs/core-react/expandable/ExpandableList.d.ts.map +1 -1
  32. package/lib/cjs/core-react/expandable/ExpandableList.js +0 -1
  33. package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
  34. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.d.ts +0 -1
  35. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  36. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js +22 -21
  37. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  38. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +1 -2
  39. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  40. package/lib/cjs/core-react/icons/IconComponent.js +1 -1
  41. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  42. package/lib/cjs/core-react/index.scss +0 -1
  43. package/lib/cjs/core-react/inputs/iconinput/IconInput.d.ts.map +1 -1
  44. package/lib/cjs/core-react/inputs/iconinput/IconInput.js +2 -2
  45. package/lib/cjs/core-react/inputs/iconinput/IconInput.js.map +1 -1
  46. package/lib/cjs/core-react/inputs/iconinput/IconInput.scss +1 -1
  47. package/lib/cjs/core-react/inputs/input.scss +1 -5
  48. package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts +3 -1
  49. package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  50. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js +6 -6
  51. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  52. package/lib/cjs/core-react/inputs/numberinput/NumberInput.scss +1 -1
  53. package/lib/cjs/core-react/listbox/Listbox.js +6 -7
  54. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  55. package/lib/cjs/core-react/loading/LoadingSpinner.d.ts +3 -1
  56. package/lib/cjs/core-react/loading/LoadingSpinner.d.ts.map +1 -1
  57. package/lib/cjs/core-react/loading/LoadingSpinner.js.map +1 -1
  58. package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
  59. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  60. package/lib/cjs/core-react/popup/Popup.d.ts.map +1 -1
  61. package/lib/cjs/core-react/popup/Popup.js +7 -10
  62. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  63. package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  64. package/lib/cjs/core-react/radialmenu/RadialMenu.js +1 -1
  65. package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
  66. package/lib/cjs/core-react/searchbox/SearchBox.js +2 -2
  67. package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
  68. package/lib/cjs/core-react/settings/SettingsManager.d.ts +0 -1
  69. package/lib/cjs/core-react/settings/SettingsManager.d.ts.map +1 -1
  70. package/lib/cjs/core-react/tree/Node.d.ts +3 -1
  71. package/lib/cjs/core-react/tree/Node.d.ts.map +1 -1
  72. package/lib/cjs/core-react/tree/Node.js +2 -3
  73. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  74. package/lib/cjs/core-react/tree/Node.scss +1 -1
  75. package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
  76. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  77. package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
  78. package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
  79. package/lib/cjs/core-react/utils/getObjectClassName.js +2 -3
  80. package/lib/cjs/core-react/utils/getObjectClassName.js.map +1 -1
  81. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +1 -2
  82. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  83. package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  84. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +18 -22
  85. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  86. package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  87. package/lib/esm/core-react/autosuggest/AutoSuggest.js +11 -6
  88. package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
  89. package/lib/esm/core-react/autosuggest/AutoSuggest.scss +1 -1
  90. package/lib/esm/core-react/base/Gap.js +1 -1
  91. package/lib/esm/core-react/base/Gap.js.map +1 -1
  92. package/lib/esm/core-react/button/UnderlinedButton.js +1 -1
  93. package/lib/esm/core-react/button/UnderlinedButton.js.map +1 -1
  94. package/lib/esm/core-react/checklistbox/CheckListBox.d.ts.map +1 -1
  95. package/lib/esm/core-react/checklistbox/CheckListBox.js +4 -1
  96. package/lib/esm/core-react/checklistbox/CheckListBox.js.map +1 -1
  97. package/lib/esm/core-react/classes.scss +0 -1
  98. package/lib/esm/core-react/colorvariables.scss +1 -1
  99. package/lib/esm/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  100. package/lib/esm/core-react/contextmenu/ContextMenu.js +10 -9
  101. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  102. package/lib/esm/core-react/contextmenu/ContextMenuItem.js +1 -1
  103. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  104. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +3 -5
  105. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  106. package/lib/esm/core-react/dialog/Dialog.d.ts +4 -13
  107. package/lib/esm/core-react/dialog/Dialog.d.ts.map +1 -1
  108. package/lib/esm/core-react/dialog/Dialog.js +9 -7
  109. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  110. package/lib/esm/core-react/dialog/GlobalDialog.js +1 -2
  111. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  112. package/lib/esm/core-react/elementseparator/ElementSeparator.js +2 -2
  113. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  114. package/lib/esm/core-react/expandable/ExpandableList.d.ts +0 -1
  115. package/lib/esm/core-react/expandable/ExpandableList.d.ts.map +1 -1
  116. package/lib/esm/core-react/expandable/ExpandableList.js +0 -1
  117. package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
  118. package/lib/esm/core-react/focus/ItemKeyboardNavigator.d.ts +0 -1
  119. package/lib/esm/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  120. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js +22 -21
  121. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  122. package/lib/esm/core-react/hocs/withOnOutsideClick.js +1 -2
  123. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  124. package/lib/esm/core-react/icons/IconComponent.js +1 -1
  125. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  126. package/lib/esm/core-react/index.scss +0 -1
  127. package/lib/esm/core-react/inputs/iconinput/IconInput.d.ts.map +1 -1
  128. package/lib/esm/core-react/inputs/iconinput/IconInput.js +2 -2
  129. package/lib/esm/core-react/inputs/iconinput/IconInput.js.map +1 -1
  130. package/lib/esm/core-react/inputs/iconinput/IconInput.scss +1 -1
  131. package/lib/esm/core-react/inputs/input.scss +1 -5
  132. package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts +3 -1
  133. package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  134. package/lib/esm/core-react/inputs/numberinput/NumberInput.js +6 -6
  135. package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  136. package/lib/esm/core-react/inputs/numberinput/NumberInput.scss +1 -1
  137. package/lib/esm/core-react/listbox/Listbox.js +6 -7
  138. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  139. package/lib/esm/core-react/loading/LoadingSpinner.d.ts +3 -1
  140. package/lib/esm/core-react/loading/LoadingSpinner.d.ts.map +1 -1
  141. package/lib/esm/core-react/loading/LoadingSpinner.js.map +1 -1
  142. package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
  143. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  144. package/lib/esm/core-react/popup/Popup.d.ts.map +1 -1
  145. package/lib/esm/core-react/popup/Popup.js +7 -10
  146. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  147. package/lib/esm/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  148. package/lib/esm/core-react/radialmenu/RadialMenu.js +1 -1
  149. package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
  150. package/lib/esm/core-react/searchbox/SearchBox.js +2 -2
  151. package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
  152. package/lib/esm/core-react/settings/SettingsManager.d.ts +0 -1
  153. package/lib/esm/core-react/settings/SettingsManager.d.ts.map +1 -1
  154. package/lib/esm/core-react/tree/Node.d.ts +3 -1
  155. package/lib/esm/core-react/tree/Node.d.ts.map +1 -1
  156. package/lib/esm/core-react/tree/Node.js +2 -3
  157. package/lib/esm/core-react/tree/Node.js.map +1 -1
  158. package/lib/esm/core-react/tree/Node.scss +1 -1
  159. package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
  160. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  161. package/lib/esm/core-react/utils/getCssVariable.js +1 -1
  162. package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
  163. package/lib/esm/core-react/utils/getObjectClassName.js +2 -3
  164. package/lib/esm/core-react/utils/getObjectClassName.js.map +1 -1
  165. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +1 -2
  166. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  167. package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  168. package/lib/esm/core-react/utils/hooks/useResizeObserver.js +18 -22
  169. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  170. package/package.json +13 -13
  171. package/lib/cjs/core-react/expandable/ExpandableList.scss +0 -9
  172. package/lib/cjs/core-react/expandable/classes.scss +0 -9
  173. package/lib/cjs/core-react/expandable/index.scss +0 -5
  174. package/lib/cjs/core-react/expandable/list.scss +0 -35
  175. package/lib/esm/core-react/expandable/ExpandableList.scss +0 -9
  176. package/lib/esm/core-react/expandable/classes.scss +0 -9
  177. package/lib/esm/core-react/expandable/index.scss +0 -5
  178. package/lib/esm/core-react/expandable/list.scss +0 -35
@@ -10,10 +10,9 @@
10
10
  * @internal
11
11
  */
12
12
  export const getObjectClassName = (obj) => {
13
- var _a;
14
- return (obj === null || obj === void 0 ? void 0 : obj.name)
13
+ return obj?.name
15
14
  ? obj.name
16
- : ((_a = obj === null || obj === void 0 ? void 0 : obj.constructor) === null || _a === void 0 ? void 0 : _a.name)
15
+ : obj?.constructor?.name
17
16
  ? obj.constructor.name
18
17
  : "";
19
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getObjectClassName.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getObjectClassName.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAU,EAAE;;IACrD,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI;QACd,CAAC,CAAC,GAAG,CAAC,IAAI;QACV,CAAC,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,0CAAE,IAAI;YACxB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI;YACtB,CAAC,CAAC,EAAE,CAAC;AACT,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 Utilities\n */\n\n/**\n * Returns the name of a class from a static or instance object.\n * @internal\n */\nexport const getObjectClassName = (obj: any): string => {\n return obj?.name\n ? obj.name\n : obj?.constructor?.name\n ? obj.constructor.name\n : \"\";\n};\n"]}
1
+ {"version":3,"file":"getObjectClassName.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getObjectClassName.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAU,EAAE;IACrD,OAAO,GAAG,EAAE,IAAI;QACd,CAAC,CAAC,GAAG,CAAC,IAAI;QACV,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI;YACxB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI;YACtB,CAAC,CAAC,EAAE,CAAC;AACT,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 Utilities\n */\n\n/**\n * Returns the name of a class from a static or instance object.\n * @internal\n */\nexport const getObjectClassName = (obj: any): string => {\n return obj?.name\n ? obj.name\n : obj?.constructor?.name\n ? obj.constructor.name\n : \"\";\n};\n"]}
@@ -48,8 +48,7 @@ export function useCrossOriginPopup(visible, url, title, width, height, onClose)
48
48
  }
49
49
  }, [handleClosedPopup]);
50
50
  const checkPopupClosed = React.useCallback(() => {
51
- var _a;
52
- if ((_a = popupWindow.current) === null || _a === void 0 ? void 0 : _a.closed) {
51
+ if (popupWindow.current?.closed) {
53
52
  // Popup has been closed by end-user, inform our host and cleanup
54
53
  handleClosedPopup();
55
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCrossOriginPopup.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useCrossOriginPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;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,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,GAAG,EAAE;YACV,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,oDAAoD;IACpD,WAAW,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IAEpD,yBAAyB;IACzB,oEAAoE;IACpE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,6EAA6E;QAC7E,IAAI,OAAO,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE;YAChD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,QAAQ,CAAC,OAAO,EAChB,UAAU,CAAC,OAAO,EAClB,SAAS,UAAU,CAAC,OAAO,WAAW,WAAW,CAAC,OAAO,EAAE,CAC5D,CAAC;YACF,IAAI,KAAK,EAAE;gBACT,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;gBAE5B,iEAAiE;gBACjE,uBAAuB,CAAC,IAAI,CAAC,CAAC;aAC/B;SACF;QAED,sEAAsE;QACtE,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS,EAAE;YACjD,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAE5B,iBAAiB,EAAE,CAAC;SACrB;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnC,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 Utilities\n */\n\nimport * as React from \"react\";\nimport { useInterval } from \"./useInterval\";\n\n/** Hook that will show a popup window\n * @beta\n */\nexport function useCrossOriginPopup(\n visible: boolean,\n url: string | undefined,\n title: string,\n width: number,\n height: number,\n onClose: () => void\n) {\n const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState<\n number | undefined\n >();\n\n // ONLY re-render the popup when visibility changes, any other changes get deferred until next visibility change\n // hence the massive use of 'useRef'\n const popupWindow = React.useRef<Window>();\n const savedUrl = React.useRef(url);\n const savedTitle = React.useRef(title);\n const savedWidth = React.useRef(width);\n const savedHeight = React.useRef(height);\n const savedOnClose = React.useRef(onClose);\n\n React.useEffect(() => {\n savedUrl.current = url;\n }, [url]);\n React.useEffect(() => {\n savedTitle.current = title;\n }, [title]);\n React.useEffect(() => {\n savedWidth.current = width;\n }, [width]);\n React.useEffect(() => {\n savedHeight.current = height;\n }, [height]);\n React.useEffect(() => {\n savedOnClose.current = onClose;\n }, [onClose]);\n\n // Cleanup method after a popup closure. Also calls the OnClose callback.\n const handleClosedPopup = React.useCallback(() => {\n savedOnClose.current();\n setCheckPopupAliveDelay(undefined);\n popupWindow.current = undefined;\n }, []);\n\n const closePopup = React.useCallback(() => {\n if (popupWindow.current !== undefined) {\n popupWindow.current.close(); // Manually close the popup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n const checkPopupClosed = React.useCallback(() => {\n if (popupWindow.current?.closed) {\n // Popup has been closed by end-user, inform our host and cleanup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n // Close popup when parent window get closed\n React.useEffect(() => {\n window.onbeforeunload = (_event) => {\n closePopup();\n };\n return () => {\n window.onbeforeunload = null;\n };\n }, [closePopup]);\n\n // Whenever the hook is unloaded, make sure the underlying popup get closed.\n // Note: An interval is used to check if popup was closed by user: because we access\n // a cross domain resource inside the popup, we don't have access to popup window events.\n // As a workaround, we periodically check if popup is still alive.\n // Reference: https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128\n React.useEffect(() => {\n return () => {\n closePopup();\n };\n }, [closePopup]);\n\n // Timer that checks if popup was closed by end-user\n useInterval(checkPopupClosed, checkPopupAliveDelay);\n\n // ==> Main render effect\n // Monitors visibility changes and open/close the popup accordingly.\n React.useEffect(() => {\n // If visible and a popup window is not already open, open a new popup window\n if (visible && popupWindow.current === undefined) {\n const popup = window.open(\n savedUrl.current,\n savedTitle.current,\n `width=${savedWidth.current},height=${savedHeight.current}`\n );\n if (popup) {\n popup.focus();\n popupWindow.current = popup;\n\n // Start and interval that will check if popup got closed by user\n setCheckPopupAliveDelay(1000);\n }\n }\n\n // If not visible but a previous popup window is still open, close it.\n if (!visible && popupWindow.current !== undefined) {\n popupWindow.current.close();\n\n handleClosedPopup();\n }\n }, [handleClosedPopup, visible]);\n}\n"]}
1
+ {"version":3,"file":"useCrossOriginPopup.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useCrossOriginPopup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,GAAuB,EACvB,KAAa,EACb,KAAa,EACb,MAAc,EACd,OAAmB;IAEnB,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,KAAK,CAAC,QAAQ,EAEnE,CAAC;IAEJ,gHAAgH;IAChH,oCAAoC;IACpC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAU,CAAC;IAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE3C,KAAK,CAAC,SAAS,CAAC,GAAG,E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YACjD,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAE5B,iBAAiB,EAAE,CAAC;SACrB;IACH,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;AACnC,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 Utilities\n */\n\nimport * as React from \"react\";\nimport { useInterval } from \"./useInterval\";\n\n/** Hook that will show a popup window\n * @beta\n */\nexport function useCrossOriginPopup(\n visible: boolean,\n url: string | undefined,\n title: string,\n width: number,\n height: number,\n onClose: () => void\n) {\n const [checkPopupAliveDelay, setCheckPopupAliveDelay] = React.useState<\n number | undefined\n >();\n\n // ONLY re-render the popup when visibility changes, any other changes get deferred until next visibility change\n // hence the massive use of 'useRef'\n const popupWindow = React.useRef<Window>();\n const savedUrl = React.useRef(url);\n const savedTitle = React.useRef(title);\n const savedWidth = React.useRef(width);\n const savedHeight = React.useRef(height);\n const savedOnClose = React.useRef(onClose);\n\n React.useEffect(() => {\n savedUrl.current = url;\n }, [url]);\n React.useEffect(() => {\n savedTitle.current = title;\n }, [title]);\n React.useEffect(() => {\n savedWidth.current = width;\n }, [width]);\n React.useEffect(() => {\n savedHeight.current = height;\n }, [height]);\n React.useEffect(() => {\n savedOnClose.current = onClose;\n }, [onClose]);\n\n // Cleanup method after a popup closure. Also calls the OnClose callback.\n const handleClosedPopup = React.useCallback(() => {\n savedOnClose.current();\n setCheckPopupAliveDelay(undefined);\n popupWindow.current = undefined;\n }, []);\n\n const closePopup = React.useCallback(() => {\n if (popupWindow.current !== undefined) {\n popupWindow.current.close(); // Manually close the popup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n const checkPopupClosed = React.useCallback(() => {\n if (popupWindow.current?.closed) {\n // Popup has been closed by end-user, inform our host and cleanup\n handleClosedPopup();\n }\n }, [handleClosedPopup]);\n\n // Close popup when parent window get closed\n React.useEffect(() => {\n window.onbeforeunload = (_event) => {\n closePopup();\n };\n return () => {\n window.onbeforeunload = null;\n };\n }, [closePopup]);\n\n // Whenever the hook is unloaded, make sure the underlying popup get closed.\n // Note: An interval is used to check if popup was closed by user: because we access\n // a cross domain resource inside the popup, we don't have access to popup window events.\n // As a workaround, we periodically check if popup is still alive.\n // Reference: https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128\n React.useEffect(() => {\n return () => {\n closePopup();\n };\n }, [closePopup]);\n\n // Timer that checks if popup was closed by end-user\n useInterval(checkPopupClosed, checkPopupAliveDelay);\n\n // ==> Main render effect\n // Monitors visibility changes and open/close the popup accordingly.\n React.useEffect(() => {\n // If visible and a popup window is not already open, open a new popup window\n if (visible && popupWindow.current === undefined) {\n const popup = window.open(\n savedUrl.current,\n savedTitle.current,\n `width=${savedWidth.current},height=${savedHeight.current}`\n );\n if (popup) {\n popup.focus();\n popupWindow.current = popup;\n\n // Start and interval that will check if popup got closed by user\n setCheckPopupAliveDelay(1000);\n }\n }\n\n // If not visible but a previous popup window is still open, close it.\n if (!visible && popupWindow.current !== undefined) {\n popupWindow.current.close();\n\n handleClosedPopup();\n }\n }, [handleClosedPopup, visible]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAuHnD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BA+GrD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC;CACxD,sEAGA;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,qBA2CA"}
1
+ {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAyHnD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BA+GrD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC;CACxD,sEAGA;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,qBA2CA"}
@@ -13,38 +13,37 @@ import { useRefs } from "./useRefs";
13
13
  * @internal
14
14
  */
15
15
  export function useResizeObserver(onResize) {
16
- const [bounds, setBounds] = React.useState({ width: 0, height: 0 });
16
+ const bounds = React.useRef({ width: 0, height: 0 });
17
17
  const resizeObserver = React.useRef(null);
18
18
  const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active
19
19
  const isMountedRef = React.useRef(false);
20
20
  const owningWindowRef = React.useRef(null);
21
21
  // istanbul ignore next
22
22
  const resizeObserverCleanup = () => {
23
- var _a;
24
23
  if (rafRef.current)
25
24
  owningWindowRef.current.cancelAnimationFrame(rafRef.current);
26
- (_a = resizeObserver.current) === null || _a === void 0 ? void 0 : _a.disconnect();
25
+ resizeObserver.current?.disconnect();
27
26
  resizeObserver.current = null;
28
27
  };
29
28
  React.useEffect(() => {
30
29
  isMountedRef.current = true;
31
30
  return () => {
32
- var _a;
33
31
  isMountedRef.current = false;
34
32
  if (rafRef.current)
35
33
  owningWindowRef.current.cancelAnimationFrame(rafRef.current);
36
- (_a = owningWindowRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("beforeunload", resizeObserverCleanup);
34
+ owningWindowRef.current?.removeEventListener("beforeunload", resizeObserverCleanup);
37
35
  };
38
36
  }, []);
39
37
  const processResize = React.useCallback((target) => {
40
38
  const newBounds = target.getBoundingClientRect();
41
39
  // istanbul ignore else
42
40
  if (isMountedRef.current &&
43
- (bounds.width !== newBounds.width || bounds.height !== newBounds.height)) {
44
- setBounds(newBounds);
41
+ (bounds.current.width !== newBounds.width ||
42
+ bounds.current.height !== newBounds.height)) {
43
+ bounds.current = newBounds;
45
44
  onResize && onResize(newBounds.width, newBounds.height);
46
45
  }
47
- }, [onResize, bounds.height, bounds.width]);
46
+ }, [onResize]);
48
47
  const handleResize = React.useCallback((entries) => {
49
48
  // istanbul ignore if
50
49
  if (!isMountedRef.current ||
@@ -71,13 +70,11 @@ export function useResizeObserver(onResize) {
71
70
  resizeObserver.current.observe(instance);
72
71
  const newBounds = instance.getBoundingClientRect();
73
72
  onResize && onResize(newBounds.width, newBounds.height);
74
- setBounds(newBounds);
73
+ bounds.current = newBounds;
75
74
  }
76
75
  return () => {
77
- var _a;
78
76
  instance &&
79
- (
80
- /* istanbul ignore next */ (_a = resizeObserver.current) === null || _a === void 0 ? void 0 : _a.unobserve(instance));
77
+ /* istanbul ignore next */ resizeObserver.current?.unobserve(instance);
81
78
  resizeObserver.current = null;
82
79
  };
83
80
  }, [handleResize, onResize]);
@@ -85,11 +82,12 @@ export function useResizeObserver(onResize) {
85
82
  const newBounds = instance && instance.getBoundingClientRect();
86
83
  // istanbul ignore if
87
84
  if (newBounds &&
88
- (bounds.width !== newBounds.width || bounds.height !== newBounds.height)) {
89
- setBounds(newBounds);
85
+ (bounds.current.width !== newBounds.width ||
86
+ bounds.current.height !== newBounds.height)) {
87
+ bounds.current = newBounds;
90
88
  onResize && onResize(newBounds.width, newBounds.height);
91
89
  }
92
- }, [bounds.height, bounds.width, onResize]);
90
+ }, [onResize]);
93
91
  const ref = useRefs(handleRef, observerRef);
94
92
  return ref;
95
93
  }
@@ -99,8 +97,8 @@ export function useResizeObserver(onResize) {
99
97
  * @internal
100
98
  */
101
99
  export function useLayoutResizeObserver(inElement, onResize) {
102
- const inBoundingRect = inElement === null || inElement === void 0 ? void 0 : inElement.getBoundingClientRect();
103
- const [bounds, setBounds] = React.useState({ width: inBoundingRect === null || inBoundingRect === void 0 ? void 0 : inBoundingRect.width, height: inBoundingRect === null || inBoundingRect === void 0 ? void 0 : inBoundingRect.height });
100
+ const inBoundingRect = inElement?.getBoundingClientRect();
101
+ const [bounds, setBounds] = React.useState({ width: inBoundingRect?.width, height: inBoundingRect?.height });
104
102
  const [watchedElement, setWatchedElement] = React.useState(inElement);
105
103
  const resizeObserver = React.useRef(null);
106
104
  const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active
@@ -108,10 +106,9 @@ export function useLayoutResizeObserver(inElement, onResize) {
108
106
  const owningWindowRef = React.useRef(null);
109
107
  // istanbul ignore next
110
108
  const resizeObserverCleanup = () => {
111
- var _a;
112
109
  if (rafRef.current)
113
110
  owningWindowRef.current.cancelAnimationFrame(rafRef.current);
114
- (_a = resizeObserver.current) === null || _a === void 0 ? void 0 : _a.disconnect();
111
+ resizeObserver.current?.disconnect();
115
112
  resizeObserver.current = null;
116
113
  };
117
114
  React.useEffect(() => {
@@ -168,9 +165,8 @@ export function useLayoutResizeObserver(inElement, onResize) {
168
165
  resizeObserver.current = new ResizeObserver(handleResize);
169
166
  resizeObserver.current.observe(watchedElement);
170
167
  return () => {
171
- var _a;
172
168
  // istanbul ignore next
173
- (_a = resizeObserver.current) === null || _a === void 0 ? void 0 : _a.disconnect();
169
+ resizeObserver.current?.disconnect();
174
170
  resizeObserver.current = null;
175
171
  };
176
172
  }, [handleResize, watchedElement]);
@@ -208,7 +204,7 @@ export function ResizableContainerObserver({ onResize, children, }) {
208
204
  }, [hasChildren]);
209
205
  const processResize = React.useCallback((width, height) => {
210
206
  // istanbul ignore next
211
- onResize(width !== null && width !== void 0 ? width : 0, height !== null && height !== void 0 ? height : 0);
207
+ onResize(width ?? 0, height ?? 0);
212
208
  }, [onResize]);
213
209
  useLayoutResizeObserver(containerElement, processResize);
214
210
  const style = hasChildren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AO;gBACtB,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CACvC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE;QAClC,uBAAuB;QACvB,QAAQ,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,CAAC,CAAC;IACpC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,KAAK,GAAwB,WAAW;QAC5C,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,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 Utilities\n */\nimport * as React from \"react\";\nimport { ResizeObserver } from \"./ResizeObserverPolyfill\";\nimport { useRefEffect } from \"./useRefEffect\";\nimport { useRefs } from \"./useRefs\";\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const [bounds, setBounds] = React.useState({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore else\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n setBounds(newBounds);\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize, bounds.height, bounds.width]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore if\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n resizeObserver.current = new ResizeObserver(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n instance &&\n /* istanbul ignore next */ resizeObserver.current?.unobserve(\n instance\n );\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n // istanbul ignore if\n if (\n newBounds &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n setBounds(newBounds);\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n // istanbul ignore next\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore next\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore next\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n resizeObserver.current = new ResizeObserver(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n // istanbul ignore next\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n // istanbul ignore next\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n // istanbul ignore next\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,iB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CAAC;IAExB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAC,4BAA4B,EACtC,KAAK,EAAE,KAAK,IAEX,WAAW,IAAI,QAAQ,CACpB,CACP,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 Utilities\n */\nimport * as React from \"react\";\nimport { ResizeObserver } from \"./ResizeObserverPolyfill\";\nimport { useRefEffect } from \"./useRefEffect\";\nimport { useRefs } from \"./useRefs\";\n\n/** Uses ResizeObserver API to notify about element bound changes.\n * @internal\n */\nexport function useResizeObserver<T extends Element>(\n onResize?: (width: number, height: number) => void\n) {\n const bounds = React.useRef({ width: 0, height: 0 });\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current?.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, []);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore else\n if (\n isMountedRef.current &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore if\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n const observerRef = useRefEffect(\n (instance: T | null) => {\n resizeObserver.current = new ResizeObserver(handleResize);\n if (instance) {\n resizeObserver.current.observe(instance);\n const newBounds = instance.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n bounds.current = newBounds;\n }\n\n return () => {\n instance &&\n /* istanbul ignore next */ resizeObserver.current?.unobserve(\n instance\n );\n resizeObserver.current = null;\n };\n },\n [handleResize, onResize]\n );\n\n const handleRef = React.useCallback(\n (instance: Element | null) => {\n const newBounds = instance && instance.getBoundingClientRect();\n // istanbul ignore if\n if (\n newBounds &&\n (bounds.current.width !== newBounds.width ||\n bounds.current.height !== newBounds.height)\n ) {\n bounds.current = newBounds;\n onResize && onResize(newBounds.width, newBounds.height);\n }\n },\n [onResize]\n );\n\n const ref = useRefs(handleRef, observerRef);\n return ref;\n}\n\n/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector\n * width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly\n * handles observing element in pop-out/child windows.\n * @internal\n */\nexport function useLayoutResizeObserver(\n inElement: HTMLElement | null,\n onResize?: (width?: number, height?: number) => void\n) {\n const inBoundingRect = inElement?.getBoundingClientRect();\n const [bounds, setBounds] = React.useState<{\n width?: number;\n height?: number;\n }>({ width: inBoundingRect?.width, height: inBoundingRect?.height });\n const [watchedElement, setWatchedElement] = React.useState(inElement);\n const resizeObserver = React.useRef<ResizeObserver | null>(null);\n const rafRef = React.useRef(0); // set to non-zero when requestAnimationFrame processing is active\n const isMountedRef = React.useRef(false);\n const owningWindowRef = React.useRef<any>(null);\n\n // istanbul ignore next\n const resizeObserverCleanup = () => {\n if (rafRef.current)\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n\n React.useEffect(() => {\n isMountedRef.current = true;\n setWatchedElement(inElement);\n\n // istanbul ignore next\n if (inElement) {\n const newBounds = inElement.getBoundingClientRect();\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n\n return () => {\n isMountedRef.current = false;\n rafRef.current &&\n owningWindowRef.current &&\n owningWindowRef.current.cancelAnimationFrame(rafRef.current);\n owningWindowRef.current &&\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n };\n }, [onResize, inElement]);\n\n const processResize = React.useCallback(\n (target: HTMLElement) => {\n const newBounds = target.getBoundingClientRect();\n // istanbul ignore next\n if (\n isMountedRef.current &&\n (bounds.width !== newBounds.width || bounds.height !== newBounds.height)\n ) {\n onResize && onResize(newBounds.width, newBounds.height);\n setBounds(newBounds);\n }\n },\n [bounds.height, bounds.width, onResize]\n );\n\n const handleResize = React.useCallback(\n (entries: any[]) => {\n // istanbul ignore next\n if (\n !isMountedRef.current ||\n !Array.isArray(entries) ||\n 0 === entries.length\n ) {\n return;\n }\n const target = entries[0].target as HTMLElement;\n // istanbul ignore next\n if (owningWindowRef.current)\n owningWindowRef.current.removeEventListener(\n \"beforeunload\",\n resizeObserverCleanup\n );\n\n owningWindowRef.current = target.ownerDocument.defaultView;\n // istanbul ignore else\n if (owningWindowRef.current) {\n owningWindowRef.current.addEventListener(\n \"unload\",\n resizeObserverCleanup\n );\n\n // using requestAnimationFrame to stop the \"ResizeObserver loop completed with undelivered notifications.\" and\n // \"ResizeObserver loop limit exceeded\" messages reported to window.onError\n rafRef.current = owningWindowRef.current.requestAnimationFrame(() =>\n processResize(target)\n );\n }\n },\n [processResize]\n );\n\n React.useLayoutEffect(() => {\n if (!watchedElement) {\n return;\n }\n resizeObserver.current = new ResizeObserver(handleResize);\n resizeObserver.current.observe(watchedElement);\n return () => {\n // istanbul ignore next\n resizeObserver.current?.disconnect();\n resizeObserver.current = null;\n };\n }, [handleResize, watchedElement]);\n\n return [bounds.width, bounds.height];\n}\n\n/** Prop the ElementResizeObserver sends to the render function.\n * @public\n */\nexport interface RenderPropsArgs {\n width?: number;\n height?: number;\n}\n\n/** ElementResizeObserver provides functionality similar to ReactResizeDetector when a render function is specified. This implementation properly handles\n * observing element in pop-out/child windows.\n * @public\n */\nexport function ElementResizeObserver({\n watchedElement,\n render,\n}: {\n watchedElement: HTMLElement | null;\n render: (props: RenderPropsArgs) => React.ReactElement;\n}) {\n const [width, height] = useLayoutResizeObserver(watchedElement);\n return render({ width, height });\n}\n\n/** ResizableContainerObserver is a component that provides the functionality similar to the ReactResizeDetector option that call a function when\n * the observed element is resized. This implementation properly handles observing element in pop-out/child windows. If children nodes are defined then\n * the div added by the component is considered the container whose size will be observed. If no children are provided then the component will report\n * size changes from its parent container.\n * @public\n */\nexport function ResizableContainerObserver({\n onResize,\n children,\n}: {\n onResize: (width: number, height: number) => void;\n children?: React.ReactNode;\n}) {\n const containerRef = React.useRef<HTMLDivElement>(null); // set to non-zero when requestAnimationFrame processing is active\n const [containerElement, setContainerElement] =\n React.useState<HTMLElement | null>(null);\n const isMountedRef = React.useRef(false);\n const hasChildren = React.Children.count(children) !== 0;\n\n // if no children are specified then monitor size of parent element.\n React.useEffect(() => {\n // istanbul ignore next\n if (!isMountedRef.current && containerRef.current) {\n isMountedRef.current = true;\n const hasParent = !!containerRef.current.parentElement;\n setContainerElement(\n hasChildren && hasParent\n ? containerRef.current\n : containerRef.current.parentElement\n );\n }\n }, [hasChildren]);\n\n const processResize = React.useCallback(\n (width?: number, height?: number) => {\n // istanbul ignore next\n onResize(width ?? 0, height ?? 0);\n },\n [onResize]\n );\n\n useLayoutResizeObserver(containerElement, processResize);\n const style: React.CSSProperties = hasChildren\n ? { width: \"100%\", height: \"100%\" }\n : { display: \"none\" };\n\n return (\n <div\n ref={containerRef}\n className=\"uicore-resizable-container\"\n style={style}\n >\n {hasChildren && children}\n </div>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-react",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "iTwin.js UI core components",
5
5
  "main": "lib/cjs/core-react.js",
6
6
  "module": "lib/esm/core-react.js",
@@ -34,12 +34,12 @@
34
34
  "NOTE: All tools used by scripts in this package must be listed as devDependencies"
35
35
  ],
36
36
  "devDependencies": {
37
- "@itwin/appui-abstract": "^3.7.0",
38
- "@itwin/build-tools": "^3.7.0",
39
- "@itwin/core-bentley": "^3.7.0",
40
- "@itwin/core-common": "^3.7.0",
41
- "@itwin/core-i18n": "^3.7.0",
42
- "@itwin/eslint-plugin": "^4.0.0-dev.45",
37
+ "@itwin/appui-abstract": "^3.7.0 || ^4.0.0",
38
+ "@itwin/build-tools": "^3.7.0 || ^4.0.0",
39
+ "@itwin/core-bentley": "^3.7.0 || ^4.0.0",
40
+ "@itwin/core-common": "^3.7.0 || ^4.0.0",
41
+ "@itwin/core-i18n": "^3.7.0 || ^4.0.0",
42
+ "@itwin/eslint-plugin": "^4.0.0-dev.52",
43
43
  "@testing-library/dom": "^8.11.2",
44
44
  "@testing-library/react": "^12.0.0",
45
45
  "@testing-library/react-hooks": "^7.0.2",
@@ -59,6 +59,7 @@
59
59
  "chai-as-promised": "^7",
60
60
  "cpx2": "^3.0.0",
61
61
  "eslint": "^8.44.0",
62
+ "eslint-config-prettier": "~8.8.0",
62
63
  "ignore-styles": "^5.0.1",
63
64
  "jsdom": "^19.0.0",
64
65
  "jsdom-global": "3.0.2",
@@ -68,14 +69,13 @@
68
69
  "raf": "^3.4.0",
69
70
  "react": "^17.0.0",
70
71
  "react-dom": "^17.0.0",
71
- "react-test-renderer": "^17.0.0",
72
72
  "rimraf": "^3.0.2",
73
73
  "sinon": "^17.0.1",
74
74
  "sinon-chai": "^3.2.0",
75
75
  "ts-node": "^10.8.2",
76
76
  "typemoq": "^2.1.0",
77
77
  "typescript": "~5.0.2",
78
- "eslint-config-prettier": "~8.8.0"
78
+ "upath": "^2.0.1"
79
79
  },
80
80
  "//dependencies": [
81
81
  "NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
@@ -83,9 +83,9 @@
83
83
  ],
84
84
  "dependencies": {
85
85
  "@bentley/icons-generic": "^1.0.34",
86
- "@itwin/itwinui-react": "^2.11.11",
87
- "@itwin/itwinui-variables": "^2.0.0",
88
- "@itwin/itwinui-icons-react": "^2.1.0",
86
+ "@itwin/itwinui-react": "^3.2.4",
87
+ "@itwin/itwinui-variables": "^3.0.0",
88
+ "@itwin/itwinui-icons-react": "^2.8.0",
89
89
  "classnames": "2.3.1",
90
90
  "dompurify": "^2.0.12",
91
91
  "lodash": "^4.17.10",
@@ -103,7 +103,7 @@
103
103
  ],
104
104
  "check-coverage": true,
105
105
  "statements": 100,
106
- "branches": 100,
106
+ "branches": 99,
107
107
  "functions": 100,
108
108
  "lines": 100
109
109
  },
@@ -1,9 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./list.scss";
6
-
7
- .uicore-expandable-blocks-list {
8
- @include uicore-expandable-blocks-list;
9
- }
@@ -1,9 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./index";
6
-
7
- .uicore-expandable-blocks-list {
8
- @include uicore-expandable-blocks-list;
9
- }
@@ -1,5 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./list";
@@ -1,35 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "../style/index";
6
-
7
- @mixin uicore-expandable-blocks-list {
8
- > div {
9
- transition: margin var(--iui-duration-1) ease-in-out;
10
-
11
- > .iui-header {
12
- border-color: var(--iui-color-border);
13
- }
14
-
15
- &:first-child {
16
- > .iui-header {
17
- border-top-color: var(--iui-color-border);
18
- }
19
- }
20
- }
21
-
22
- > .iui-expanded + div {
23
- > .iui-header {
24
- border-top-color: var(--iui-color-border);
25
- }
26
-
27
- &.iui-expanded > .iui-header {
28
- border-top-color: var(--iui-color-border-accent);
29
- }
30
- }
31
-
32
- > .iui-expanded + .iui-expanded {
33
- margin-top: 0;
34
- }
35
- }
@@ -1,9 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./list.scss";
6
-
7
- .uicore-expandable-blocks-list {
8
- @include uicore-expandable-blocks-list;
9
- }
@@ -1,9 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./index";
6
-
7
- .uicore-expandable-blocks-list {
8
- @include uicore-expandable-blocks-list;
9
- }
@@ -1,5 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "./list";
@@ -1,35 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "../style/index";
6
-
7
- @mixin uicore-expandable-blocks-list {
8
- > div {
9
- transition: margin var(--iui-duration-1) ease-in-out;
10
-
11
- > .iui-header {
12
- border-color: var(--iui-color-border);
13
- }
14
-
15
- &:first-child {
16
- > .iui-header {
17
- border-top-color: var(--iui-color-border);
18
- }
19
- }
20
- }
21
-
22
- > .iui-expanded + div {
23
- > .iui-header {
24
- border-top-color: var(--iui-color-border);
25
- }
26
-
27
- &.iui-expanded > .iui-header {
28
- border-top-color: var(--iui-color-border-accent);
29
- }
30
- }
31
-
32
- > .iui-expanded + .iui-expanded {
33
- margin-top: 0;
34
- }
35
- }