@itwin/core-react 4.15.4 → 4.16.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 (350) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/lib/cjs/core-react/UiCore.d.ts +1 -0
  3. package/lib/cjs/core-react/UiCore.d.ts.map +1 -1
  4. package/lib/cjs/core-react/UiCore.js +2 -0
  5. package/lib/cjs/core-react/UiCore.js.map +1 -1
  6. package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts +5 -3
  7. package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  8. package/lib/cjs/core-react/autosuggest/AutoSuggest.js +1 -2
  9. package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
  10. package/lib/cjs/core-react/badge/Badge.d.ts +3 -2
  11. package/lib/cjs/core-react/badge/Badge.d.ts.map +1 -1
  12. package/lib/cjs/core-react/badge/Badge.js +5 -2
  13. package/lib/cjs/core-react/badge/Badge.js.map +1 -1
  14. package/lib/cjs/core-react/badge/BadgeType.d.ts +6 -0
  15. package/lib/cjs/core-react/badge/BadgeType.d.ts.map +1 -1
  16. package/lib/cjs/core-react/badge/BadgeType.js +2 -1
  17. package/lib/cjs/core-react/badge/BadgeType.js.map +1 -1
  18. package/lib/cjs/core-react/badge/DeprecatedBadge.d.ts +10 -0
  19. package/lib/cjs/core-react/badge/DeprecatedBadge.d.ts.map +1 -0
  20. package/lib/cjs/core-react/badge/DeprecatedBadge.js +29 -0
  21. package/lib/cjs/core-react/badge/DeprecatedBadge.js.map +1 -0
  22. package/lib/cjs/core-react/badge/DeprecatedBadge.scss +11 -0
  23. package/lib/cjs/core-react/badge/NewBadge.scss +4 -0
  24. package/lib/cjs/core-react/badge/TechnicalPreviewBadge.js +2 -2
  25. package/lib/cjs/core-react/badge/TechnicalPreviewBadge.js.map +1 -1
  26. package/lib/cjs/core-react/badge/TechnicalPreviewBadge.scss +4 -0
  27. package/lib/cjs/core-react/colorthemes.scss +0 -8
  28. package/lib/cjs/core-react/contextmenu/ContextMenu.d.ts +3 -6
  29. package/lib/cjs/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  30. package/lib/cjs/core-react/contextmenu/ContextMenu.js +2 -4
  31. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  32. package/lib/cjs/core-react/contextmenu/ContextMenu.scss +5 -6
  33. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.d.ts +1 -3
  34. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.d.ts.map +1 -1
  35. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js +1 -7
  36. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js.map +1 -1
  37. package/lib/cjs/core-react/contextmenu/ContextMenuDivider.d.ts +2 -2
  38. package/lib/cjs/core-react/contextmenu/ContextMenuDivider.d.ts.map +1 -1
  39. package/lib/cjs/core-react/contextmenu/ContextMenuDivider.js +3 -3
  40. package/lib/cjs/core-react/contextmenu/ContextMenuDivider.js.map +1 -1
  41. package/lib/cjs/core-react/contextmenu/ContextMenuItem.d.ts +8 -6
  42. package/lib/cjs/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  43. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +6 -7
  44. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  45. package/lib/cjs/core-react/contextmenu/ContextSubMenu.d.ts +3 -4
  46. package/lib/cjs/core-react/contextmenu/ContextSubMenu.d.ts.map +1 -1
  47. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +6 -5
  48. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  49. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.d.ts +2 -1
  50. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.d.ts.map +1 -1
  51. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +1 -0
  52. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  53. package/lib/cjs/core-react/contextmenu/PopupContextMenu.d.ts +2 -0
  54. package/lib/cjs/core-react/contextmenu/PopupContextMenu.d.ts.map +1 -1
  55. package/lib/cjs/core-react/contextmenu/PopupContextMenu.js +2 -3
  56. package/lib/cjs/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  57. package/lib/cjs/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  58. package/lib/cjs/core-react/elementseparator/ElementSeparator.js +0 -1
  59. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  60. package/lib/cjs/core-react/enums/CheckBoxState.d.ts +1 -0
  61. package/lib/cjs/core-react/enums/CheckBoxState.d.ts.map +1 -1
  62. package/lib/cjs/core-react/enums/CheckBoxState.js +1 -0
  63. package/lib/cjs/core-react/enums/CheckBoxState.js.map +1 -1
  64. package/lib/cjs/core-react/enums/Orientation.d.ts +1 -0
  65. package/lib/cjs/core-react/enums/Orientation.d.ts.map +1 -1
  66. package/lib/cjs/core-react/enums/Orientation.js +1 -0
  67. package/lib/cjs/core-react/enums/Orientation.js.map +1 -1
  68. package/lib/cjs/core-react/enums/TimeFormat.d.ts +1 -0
  69. package/lib/cjs/core-react/enums/TimeFormat.d.ts.map +1 -1
  70. package/lib/cjs/core-react/enums/TimeFormat.js +1 -0
  71. package/lib/cjs/core-react/enums/TimeFormat.js.map +1 -1
  72. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  73. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  74. package/lib/cjs/core-react/focustrap/FocusTrap.js +1 -1
  75. package/lib/cjs/core-react/focustrap/FocusTrap.js.map +1 -1
  76. package/lib/cjs/core-react/hocs/withOnOutsideClick.d.ts +0 -2
  77. package/lib/cjs/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  78. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +0 -1
  79. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  80. package/lib/cjs/core-react/icons/ConditionalIconItem.d.ts +1 -0
  81. package/lib/cjs/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
  82. package/lib/cjs/core-react/icons/ConditionalIconItem.js +2 -0
  83. package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
  84. package/lib/cjs/core-react/icons/IconComponent.d.ts +3 -0
  85. package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
  86. package/lib/cjs/core-react/icons/IconComponent.js +1 -0
  87. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  88. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.d.ts +0 -1
  89. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
  90. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js +0 -2
  91. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  92. package/lib/cjs/core-react/inputs/InputLabel.d.ts.map +1 -1
  93. package/lib/cjs/core-react/inputs/InputLabel.js +1 -8
  94. package/lib/cjs/core-react/inputs/InputLabel.js.map +1 -1
  95. package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  96. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  97. package/lib/cjs/core-react/l10n/LocalizationProvider.d.ts +1 -0
  98. package/lib/cjs/core-react/l10n/LocalizationProvider.d.ts.map +1 -1
  99. package/lib/cjs/core-react/l10n/LocalizationProvider.js +1 -0
  100. package/lib/cjs/core-react/l10n/LocalizationProvider.js.map +1 -1
  101. package/lib/cjs/core-react/l10n/useTranslation.d.ts.map +1 -1
  102. package/lib/cjs/core-react/l10n/useTranslation.js +1 -1
  103. package/lib/cjs/core-react/l10n/useTranslation.js.map +1 -1
  104. package/lib/cjs/core-react/listbox/Listbox.d.ts +10 -7
  105. package/lib/cjs/core-react/listbox/Listbox.d.ts.map +1 -1
  106. package/lib/cjs/core-react/listbox/Listbox.js +6 -3
  107. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  108. package/lib/cjs/core-react/messagebox/MessageBox.d.ts.map +1 -1
  109. package/lib/cjs/core-react/messagebox/MessageBox.js +2 -9
  110. package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
  111. package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts +0 -2
  112. package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  113. package/lib/cjs/core-react/radialmenu/RadialMenu.js +0 -2
  114. package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
  115. package/lib/cjs/core-react/radialmenu/RadialMenu.scss +3 -3
  116. package/lib/cjs/core-react/searchbox/SearchBox.d.ts +0 -2
  117. package/lib/cjs/core-react/searchbox/SearchBox.d.ts.map +1 -1
  118. package/lib/cjs/core-react/searchbox/SearchBox.js +0 -2
  119. package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
  120. package/lib/cjs/core-react/settings/SettingsContainer.d.ts +7 -3
  121. package/lib/cjs/core-react/settings/SettingsContainer.d.ts.map +1 -1
  122. package/lib/cjs/core-react/settings/SettingsContainer.js +14 -19
  123. package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
  124. package/lib/cjs/core-react/settings/SettingsManager.d.ts +3 -1
  125. package/lib/cjs/core-react/settings/SettingsManager.d.ts.map +1 -1
  126. package/lib/cjs/core-react/settings/SettingsManager.js +6 -10
  127. package/lib/cjs/core-react/settings/SettingsManager.js.map +1 -1
  128. package/lib/cjs/core-react/tabs/Tabs.d.ts +0 -3
  129. package/lib/cjs/core-react/tabs/Tabs.d.ts.map +1 -1
  130. package/lib/cjs/core-react/tabs/Tabs.js +0 -4
  131. package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
  132. package/lib/cjs/core-react/tree/ExpansionToggle.d.ts.map +1 -1
  133. package/lib/cjs/core-react/tree/ExpansionToggle.js +0 -1
  134. package/lib/cjs/core-react/tree/ExpansionToggle.js.map +1 -1
  135. package/lib/cjs/core-react/tree/Node.d.ts +2 -0
  136. package/lib/cjs/core-react/tree/Node.d.ts.map +1 -1
  137. package/lib/cjs/core-react/tree/Node.js +1 -5
  138. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  139. package/lib/cjs/core-react/uistate/LocalStateStorage.d.ts +2 -2
  140. package/lib/cjs/core-react/uistate/LocalStateStorage.d.ts.map +1 -1
  141. package/lib/cjs/core-react/uistate/LocalStateStorage.js +3 -4
  142. package/lib/cjs/core-react/uistate/LocalStateStorage.js.map +1 -1
  143. package/lib/cjs/core-react/uistate/UiStateEntry.d.ts +1 -0
  144. package/lib/cjs/core-react/uistate/UiStateEntry.d.ts.map +1 -1
  145. package/lib/cjs/core-react/uistate/UiStateEntry.js +2 -0
  146. package/lib/cjs/core-react/uistate/UiStateEntry.js.map +1 -1
  147. package/lib/cjs/core-react/uistate/UiStateStorage.d.ts +3 -0
  148. package/lib/cjs/core-react/uistate/UiStateStorage.d.ts.map +1 -1
  149. package/lib/cjs/core-react/uistate/UiStateStorage.js +1 -0
  150. package/lib/cjs/core-react/uistate/UiStateStorage.js.map +1 -1
  151. package/lib/cjs/core-react/utils/IconWebComponent.d.ts.map +1 -1
  152. package/lib/cjs/core-react/utils/IconWebComponent.js +1 -3
  153. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  154. package/lib/cjs/core-react/utils/ListenerType.d.ts +15 -0
  155. package/lib/cjs/core-react/utils/ListenerType.d.ts.map +1 -0
  156. package/lib/cjs/core-react/utils/ListenerType.js +3 -0
  157. package/lib/cjs/core-react/utils/ListenerType.js.map +1 -0
  158. package/lib/cjs/core-react/utils/Rectangle.d.ts +1 -0
  159. package/lib/cjs/core-react/utils/Rectangle.d.ts.map +1 -1
  160. package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
  161. package/lib/cjs/core-react/utils/Size.d.ts +1 -0
  162. package/lib/cjs/core-react/utils/Size.d.ts.map +1 -1
  163. package/lib/cjs/core-react/utils/Size.js.map +1 -1
  164. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.d.ts +1 -0
  165. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.d.ts.map +1 -1
  166. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +1 -0
  167. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  168. package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts +3 -2
  169. package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  170. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +2 -1
  171. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  172. package/lib/cjs/core-react.d.ts +5 -0
  173. package/lib/cjs/core-react.d.ts.map +1 -1
  174. package/lib/cjs/core-react.js +10 -6
  175. package/lib/cjs/core-react.js.map +1 -1
  176. package/lib/esm/core-react/UiCore.d.ts +1 -0
  177. package/lib/esm/core-react/UiCore.d.ts.map +1 -1
  178. package/lib/esm/core-react/UiCore.js +2 -0
  179. package/lib/esm/core-react/UiCore.js.map +1 -1
  180. package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts +5 -3
  181. package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  182. package/lib/esm/core-react/autosuggest/AutoSuggest.js +1 -2
  183. package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
  184. package/lib/esm/core-react/badge/Badge.d.ts +3 -2
  185. package/lib/esm/core-react/badge/Badge.d.ts.map +1 -1
  186. package/lib/esm/core-react/badge/Badge.js +5 -2
  187. package/lib/esm/core-react/badge/Badge.js.map +1 -1
  188. package/lib/esm/core-react/badge/BadgeType.d.ts +6 -0
  189. package/lib/esm/core-react/badge/BadgeType.d.ts.map +1 -1
  190. package/lib/esm/core-react/badge/BadgeType.js +2 -1
  191. package/lib/esm/core-react/badge/BadgeType.js.map +1 -1
  192. package/lib/esm/core-react/badge/DeprecatedBadge.d.ts +10 -0
  193. package/lib/esm/core-react/badge/DeprecatedBadge.d.ts.map +1 -0
  194. package/lib/esm/core-react/badge/DeprecatedBadge.js +25 -0
  195. package/lib/esm/core-react/badge/DeprecatedBadge.js.map +1 -0
  196. package/lib/esm/core-react/badge/DeprecatedBadge.scss +11 -0
  197. package/lib/esm/core-react/badge/NewBadge.scss +4 -0
  198. package/lib/esm/core-react/badge/TechnicalPreviewBadge.js +2 -2
  199. package/lib/esm/core-react/badge/TechnicalPreviewBadge.js.map +1 -1
  200. package/lib/esm/core-react/badge/TechnicalPreviewBadge.scss +4 -0
  201. package/lib/esm/core-react/colorthemes.scss +0 -8
  202. package/lib/esm/core-react/contextmenu/ContextMenu.d.ts +3 -6
  203. package/lib/esm/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  204. package/lib/esm/core-react/contextmenu/ContextMenu.js +2 -4
  205. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  206. package/lib/esm/core-react/contextmenu/ContextMenu.scss +5 -6
  207. package/lib/esm/core-react/contextmenu/ContextMenuDirection.d.ts +1 -3
  208. package/lib/esm/core-react/contextmenu/ContextMenuDirection.d.ts.map +1 -1
  209. package/lib/esm/core-react/contextmenu/ContextMenuDirection.js +1 -7
  210. package/lib/esm/core-react/contextmenu/ContextMenuDirection.js.map +1 -1
  211. package/lib/esm/core-react/contextmenu/ContextMenuDivider.d.ts +2 -2
  212. package/lib/esm/core-react/contextmenu/ContextMenuDivider.d.ts.map +1 -1
  213. package/lib/esm/core-react/contextmenu/ContextMenuDivider.js +3 -3
  214. package/lib/esm/core-react/contextmenu/ContextMenuDivider.js.map +1 -1
  215. package/lib/esm/core-react/contextmenu/ContextMenuItem.d.ts +8 -6
  216. package/lib/esm/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  217. package/lib/esm/core-react/contextmenu/ContextMenuItem.js +6 -7
  218. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  219. package/lib/esm/core-react/contextmenu/ContextSubMenu.d.ts +3 -4
  220. package/lib/esm/core-react/contextmenu/ContextSubMenu.d.ts.map +1 -1
  221. package/lib/esm/core-react/contextmenu/ContextSubMenu.js +6 -5
  222. package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  223. package/lib/esm/core-react/contextmenu/GlobalContextMenu.d.ts +2 -1
  224. package/lib/esm/core-react/contextmenu/GlobalContextMenu.d.ts.map +1 -1
  225. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +1 -0
  226. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  227. package/lib/esm/core-react/contextmenu/PopupContextMenu.d.ts +2 -0
  228. package/lib/esm/core-react/contextmenu/PopupContextMenu.d.ts.map +1 -1
  229. package/lib/esm/core-react/contextmenu/PopupContextMenu.js +2 -3
  230. package/lib/esm/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  231. package/lib/esm/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  232. package/lib/esm/core-react/elementseparator/ElementSeparator.js +0 -1
  233. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  234. package/lib/esm/core-react/enums/CheckBoxState.d.ts +1 -0
  235. package/lib/esm/core-react/enums/CheckBoxState.d.ts.map +1 -1
  236. package/lib/esm/core-react/enums/CheckBoxState.js +1 -0
  237. package/lib/esm/core-react/enums/CheckBoxState.js.map +1 -1
  238. package/lib/esm/core-react/enums/Orientation.d.ts +1 -0
  239. package/lib/esm/core-react/enums/Orientation.d.ts.map +1 -1
  240. package/lib/esm/core-react/enums/Orientation.js +1 -0
  241. package/lib/esm/core-react/enums/Orientation.js.map +1 -1
  242. package/lib/esm/core-react/enums/TimeFormat.d.ts +1 -0
  243. package/lib/esm/core-react/enums/TimeFormat.d.ts.map +1 -1
  244. package/lib/esm/core-react/enums/TimeFormat.js +1 -0
  245. package/lib/esm/core-react/enums/TimeFormat.js.map +1 -1
  246. package/lib/esm/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  247. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  248. package/lib/esm/core-react/focustrap/FocusTrap.js +1 -1
  249. package/lib/esm/core-react/focustrap/FocusTrap.js.map +1 -1
  250. package/lib/esm/core-react/hocs/withOnOutsideClick.d.ts +0 -2
  251. package/lib/esm/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  252. package/lib/esm/core-react/hocs/withOnOutsideClick.js +0 -1
  253. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  254. package/lib/esm/core-react/icons/ConditionalIconItem.d.ts +1 -0
  255. package/lib/esm/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
  256. package/lib/esm/core-react/icons/ConditionalIconItem.js +2 -0
  257. package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
  258. package/lib/esm/core-react/icons/IconComponent.d.ts +3 -0
  259. package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
  260. package/lib/esm/core-react/icons/IconComponent.js +1 -0
  261. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  262. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.d.ts +0 -1
  263. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
  264. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js +0 -2
  265. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  266. package/lib/esm/core-react/inputs/InputLabel.d.ts.map +1 -1
  267. package/lib/esm/core-react/inputs/InputLabel.js +1 -8
  268. package/lib/esm/core-react/inputs/InputLabel.js.map +1 -1
  269. package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  270. package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  271. package/lib/esm/core-react/l10n/LocalizationProvider.d.ts +1 -0
  272. package/lib/esm/core-react/l10n/LocalizationProvider.d.ts.map +1 -1
  273. package/lib/esm/core-react/l10n/LocalizationProvider.js +1 -0
  274. package/lib/esm/core-react/l10n/LocalizationProvider.js.map +1 -1
  275. package/lib/esm/core-react/l10n/useTranslation.d.ts.map +1 -1
  276. package/lib/esm/core-react/l10n/useTranslation.js +1 -1
  277. package/lib/esm/core-react/l10n/useTranslation.js.map +1 -1
  278. package/lib/esm/core-react/listbox/Listbox.d.ts +10 -7
  279. package/lib/esm/core-react/listbox/Listbox.d.ts.map +1 -1
  280. package/lib/esm/core-react/listbox/Listbox.js +6 -3
  281. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  282. package/lib/esm/core-react/messagebox/MessageBox.d.ts.map +1 -1
  283. package/lib/esm/core-react/messagebox/MessageBox.js +2 -9
  284. package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
  285. package/lib/esm/core-react/radialmenu/RadialMenu.d.ts +0 -2
  286. package/lib/esm/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  287. package/lib/esm/core-react/radialmenu/RadialMenu.js +0 -2
  288. package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
  289. package/lib/esm/core-react/radialmenu/RadialMenu.scss +3 -3
  290. package/lib/esm/core-react/searchbox/SearchBox.d.ts +0 -2
  291. package/lib/esm/core-react/searchbox/SearchBox.d.ts.map +1 -1
  292. package/lib/esm/core-react/searchbox/SearchBox.js +0 -2
  293. package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
  294. package/lib/esm/core-react/settings/SettingsContainer.d.ts +7 -3
  295. package/lib/esm/core-react/settings/SettingsContainer.d.ts.map +1 -1
  296. package/lib/esm/core-react/settings/SettingsContainer.js +14 -19
  297. package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
  298. package/lib/esm/core-react/settings/SettingsManager.d.ts +3 -1
  299. package/lib/esm/core-react/settings/SettingsManager.d.ts.map +1 -1
  300. package/lib/esm/core-react/settings/SettingsManager.js +6 -10
  301. package/lib/esm/core-react/settings/SettingsManager.js.map +1 -1
  302. package/lib/esm/core-react/tabs/Tabs.d.ts +0 -3
  303. package/lib/esm/core-react/tabs/Tabs.d.ts.map +1 -1
  304. package/lib/esm/core-react/tabs/Tabs.js +0 -4
  305. package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
  306. package/lib/esm/core-react/tree/ExpansionToggle.d.ts.map +1 -1
  307. package/lib/esm/core-react/tree/ExpansionToggle.js +0 -1
  308. package/lib/esm/core-react/tree/ExpansionToggle.js.map +1 -1
  309. package/lib/esm/core-react/tree/Node.d.ts +2 -0
  310. package/lib/esm/core-react/tree/Node.d.ts.map +1 -1
  311. package/lib/esm/core-react/tree/Node.js +1 -5
  312. package/lib/esm/core-react/tree/Node.js.map +1 -1
  313. package/lib/esm/core-react/uistate/LocalStateStorage.d.ts +2 -2
  314. package/lib/esm/core-react/uistate/LocalStateStorage.d.ts.map +1 -1
  315. package/lib/esm/core-react/uistate/LocalStateStorage.js +3 -4
  316. package/lib/esm/core-react/uistate/LocalStateStorage.js.map +1 -1
  317. package/lib/esm/core-react/uistate/UiStateEntry.d.ts +1 -0
  318. package/lib/esm/core-react/uistate/UiStateEntry.d.ts.map +1 -1
  319. package/lib/esm/core-react/uistate/UiStateEntry.js +2 -0
  320. package/lib/esm/core-react/uistate/UiStateEntry.js.map +1 -1
  321. package/lib/esm/core-react/uistate/UiStateStorage.d.ts +3 -0
  322. package/lib/esm/core-react/uistate/UiStateStorage.d.ts.map +1 -1
  323. package/lib/esm/core-react/uistate/UiStateStorage.js +1 -0
  324. package/lib/esm/core-react/uistate/UiStateStorage.js.map +1 -1
  325. package/lib/esm/core-react/utils/IconWebComponent.d.ts.map +1 -1
  326. package/lib/esm/core-react/utils/IconWebComponent.js +1 -3
  327. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  328. package/lib/esm/core-react/utils/ListenerType.d.ts +15 -0
  329. package/lib/esm/core-react/utils/ListenerType.d.ts.map +1 -0
  330. package/lib/esm/core-react/utils/ListenerType.js +2 -0
  331. package/lib/esm/core-react/utils/ListenerType.js.map +1 -0
  332. package/lib/esm/core-react/utils/Rectangle.d.ts +1 -0
  333. package/lib/esm/core-react/utils/Rectangle.d.ts.map +1 -1
  334. package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
  335. package/lib/esm/core-react/utils/Size.d.ts +1 -0
  336. package/lib/esm/core-react/utils/Size.d.ts.map +1 -1
  337. package/lib/esm/core-react/utils/Size.js.map +1 -1
  338. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.d.ts +1 -0
  339. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.d.ts.map +1 -1
  340. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +1 -0
  341. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  342. package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts +3 -2
  343. package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  344. package/lib/esm/core-react/utils/hooks/useResizeObserver.js +2 -1
  345. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  346. package/lib/esm/core-react.d.ts +5 -0
  347. package/lib/esm/core-react.d.ts.map +1 -1
  348. package/lib/esm/core-react.js +6 -2
  349. package/lib/esm/core-react.js.map +1 -1
  350. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACh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AK,EAAE,CAAC;YACzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAEO,SAAS;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAChC,MAAM,cAAc,GAAG,EAAG,CAAC,aAAa,CAAC;QACzC,OAAO,cAAc,CAAC,WAAW,CAAC;IACpC,CAAC;IAEO,oBAAoB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC3C,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,WAAW,CAAC,QAAQ,CACpC,eAAe,EACf,QAAQ,EACR,YAAY,CAAC,UAAU,EACvB,YAAY,CAAC,WAAW,CACzB,CAAC;YACF,IAAI,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;;AAvLa,2BAAY,GAAiC;IACzD,SAAS,EAAE,oBAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,AAPyB,CAOxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRightSmall } from \"@itwin/itwinui-icons-react\";\nimport { Badge } from \"../badge/Badge\";\n\n/** Properties for the [[ContextSubMenu]] component\n * @public\n */\nexport interface ContextSubMenuProps\n extends Omit<ContextMenuItemProps, \"label\">,\n Omit<ContextMenuProps, \"label\">,\n // eslint-disable-next-line deprecation/deprecation\n CommonProps {\n /** Text/jsx to display in the list item */\n label: string | React.ReactElement;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n}\n\n/** @internal */\ninterface ContextSubMenuState {\n opened: boolean;\n direction: ContextMenuDirection;\n hotKey?: string;\n}\n\n/**\n * Submenu wrapper class for use within a [[ContextMenu]] component.\n * @public\n */\nexport class ContextSubMenu extends React.Component<\n ContextSubMenuProps,\n ContextSubMenuState\n> {\n private _menuElement: ContextMenu | null = null;\n private _subMenuElement: HTMLElement | null = null;\n private _menuButtonElement: HTMLElement | null = null;\n\n private _lastLabel: React.ReactNode;\n private _parsedLabel: React.ReactNode;\n\n public static defaultProps: Partial<ContextSubMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n disabled: false,\n hidden: false,\n autoflip: true,\n isSelected: false,\n selectedIndex: 0,\n };\n\n /** @internal */\n public override readonly state: Readonly<ContextSubMenuState>;\n constructor(props: ContextSubMenuProps) {\n super(props);\n this.state = {\n opened: false,\n direction: props.direction!,\n };\n }\n\n public override render(): React.ReactElement {\n const {\n label,\n opened,\n direction,\n onOutsideClick,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n onHotKeyParsed,\n children,\n onClick,\n className,\n badgeType,\n hideIconContainer,\n ...props\n } = this.props;\n\n const onOutsideClickWrapper = (event: MouseEvent) => {\n this.close();\n onOutsideClick && onOutsideClick(event);\n };\n const contextMenuProps = {\n onOutsideClick: onOutsideClickWrapper,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n };\n const renderDirection = this.state.direction;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastLabel !== label) {\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\n this._lastLabel = label;\n }\n return (\n <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={this._handleMouseOver}\n ref={(el) => {\n this._subMenuElement = el;\n }}\n data-testid=\"core-context-submenu\"\n {...props}\n >\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\n <div\n onClick={this._handleClick}\n ref={(el) => {\n this._menuButtonElement = el;\n }}\n className={classnames(\n \"core-context-menu-item\",\n \"core-context-submenu-container\",\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n data-testid=\"core-context-submenu-container\"\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n aria-haspopup={true}\n >\n {!hideIconContainer && (\n <div className=\"core-context-menu-icon\">\n {icon !== undefined && <Icon iconSpec={icon} />}\n </div>\n )}\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\")}>\n <Icon iconSpec={<SvgCaretRightSmall />} />\n </div>\n {badgeType && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeType} />\n </div>\n )}\n </div>\n <ContextMenu\n ref={(el) => {\n this._menuElement = el;\n }}\n className=\"core-context-submenu-popup\"\n opened={this.state.opened}\n direction={renderDirection}\n parentSubmenu={this}\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n </div>\n );\n }\n\n public override componentDidMount() {\n document.addEventListener(\"click\", this._handleClickGlobal);\n this._updateHotkey(this.props.label);\n\n this.checkRenderDirection();\n }\n\n public override componentWillUnmount() {\n document.removeEventListener(\"click\", this._handleClickGlobal);\n }\n\n public override componentDidUpdate(\n prevProps: ContextSubMenuProps,\n prevState: ContextSubMenuState\n ) {\n const direction = this.props.direction!;\n if (\n (this.state.opened !== prevState.opened &&\n direction !== this.state.direction) ||\n prevProps.direction !== direction\n )\n this.checkRenderDirection();\n if (this.props.label !== prevProps.label) {\n this._updateHotkey(this.props.label);\n }\n }\n\n private getWindow() {\n const el = this._subMenuElement;\n const parentDocument = el!.ownerDocument;\n return parentDocument.defaultView;\n }\n\n private checkRenderDirection() {\n const { autoflip } = this.props;\n const parentWindow = this.getWindow();\n let renderDirection = this.state.direction;\n if (parentWindow && autoflip && this._menuElement) {\n const menuRect = this._menuElement.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n private _updateHotkey = (node: React.ReactNode) => {\n let hotKey: string | undefined;\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\n if (!isDisabled && !isHidden)\n hotKey = TildeFinder.findAfterTilde(node).character;\n else hotKey = undefined;\n if (hotKey && hotKey !== this.state.hotKey) {\n this.setState({ hotKey });\n if (this.props.onHotKeyParsed) this.props.onHotKeyParsed(hotKey);\n }\n };\n\n public select = () => {\n this.setState({ opened: true }, () => {\n if (this._menuElement) this._menuElement.focus();\n if (this.props.onSelect !== undefined) this.props.onSelect(undefined);\n });\n };\n\n public close = (propagate?: boolean) => {\n this.setState({ opened: false }, () => {\n if (this._menuElement) this._menuElement.blur();\n });\n if (\n propagate &&\n this.props.parentMenu &&\n this.props.parentMenu.props.parentSubmenu\n ) {\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n if (\n this._menuButtonElement &&\n this._menuButtonElement.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n private _handleClick = (event: any) => {\n event.stopPropagation();\n\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n\n if (!isDisabled) {\n if (this.props.onClick !== undefined) this.props.onClick(event);\n if (this.props.opened) this.close();\n else this.select();\n }\n };\n\n private _handleClickGlobal = (event: any) => {\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\n this.setState((_prevState) => ({ opened: false }));\n };\n}\n"]}
1
+ {"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAwBvC;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,C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a,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAEO,SAAS;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAChC,MAAM,cAAc,GAAG,EAAG,CAAC,aAAa,CAAC;QACzC,OAAO,cAAc,CAAC,WAAW,CAAC;IACpC,CAAC;IAEO,oBAAoB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC3C,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,WAAW,CAAC,QAAQ,CACpC,eAAe,EACf,QAAQ,EACR,YAAY,CAAC,UAAU,EACvB,YAAY,CAAC,WAAW,CACzB,CAAC;YACF,IAAI,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;;AAvLa,2BAAY,GAAiC;IACzD,SAAS,EAAE,oBAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,AAPyB,CAOxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport type { ContextMenuItemProps } from \"./ContextMenuItem\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\nimport { TildeFinder } from \"./TildeFinder\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgCaretRightSmall } from \"@itwin/itwinui-icons-react\";\nimport { Badge } from \"../badge/Badge\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for the [[ContextSubMenu]] component\n * @public\n * @deprecated in 4.16.0. Props of deprecated {@link ContextSubMenu} component.\n */\nexport interface ContextSubMenuProps\n extends Omit<ContextMenuItemProps, \"label\">,\n Omit<ContextMenuProps, \"label\">,\n CommonProps {\n /** Text/jsx to display in the list item */\n label: string | React.ReactElement;\n /** @internal */\n onHotKeyParsed?: (hotKey: string) => void;\n}\n\ninterface ContextSubMenuState {\n opened: boolean;\n direction: ContextMenuDirection;\n hotKey?: string;\n}\n\n/** Submenu wrapper class for use within a [[ContextMenu]] component.\n * @public\n * @deprecated in 4.16.0. Use `subMenuItems` property {@link https://itwinui.bentley.com/docs/dropdownmenu#submenu iTwinUI MenuItem} component instead.\n */\nexport class ContextSubMenu extends React.Component<\n ContextSubMenuProps,\n ContextSubMenuState\n> {\n private _menuElement: ContextMenu | null = null;\n private _subMenuElement: HTMLElement | null = null;\n private _menuButtonElement: HTMLElement | null = null;\n\n private _lastLabel: React.ReactNode;\n private _parsedLabel: React.ReactNode;\n\n public static defaultProps: Partial<ContextSubMenuProps> = {\n direction: ContextMenuDirection.BottomRight,\n disabled: false,\n hidden: false,\n autoflip: true,\n isSelected: false,\n selectedIndex: 0,\n };\n\n public override readonly state: Readonly<ContextSubMenuState>;\n constructor(props: ContextSubMenuProps) {\n super(props);\n this.state = {\n opened: false,\n direction: props.direction!,\n };\n }\n\n public override render(): React.ReactElement {\n const {\n label,\n opened,\n direction,\n onOutsideClick,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n parentSubmenu,\n onSelect,\n icon,\n disabled,\n hidden,\n onHover,\n isSelected,\n onHotKeyParsed,\n children,\n onClick,\n className,\n badgeType, // eslint-disable-line deprecation/deprecation\n badgeKind,\n hideIconContainer,\n ...props\n } = this.props;\n\n const onOutsideClickWrapper = (event: MouseEvent) => {\n this.close();\n onOutsideClick && onOutsideClick(event);\n };\n const contextMenuProps = {\n onOutsideClick: onOutsideClickWrapper,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n selectedIndex,\n floating,\n parentMenu,\n };\n const renderDirection = this.state.direction;\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\n const isHidden = ConditionalBooleanValue.getValue(hidden);\n\n if (this._lastLabel !== label) {\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\n this._lastLabel = label;\n }\n return (\n <div\n className={classnames(\n \"core-context-submenu\",\n ContextMenu.getCSSClassNameFromDirection(renderDirection),\n className\n )}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={this._handleMouseOver}\n ref={(el) => {\n this._subMenuElement = el;\n }}\n data-testid=\"core-context-submenu\"\n {...props}\n >\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\n <div\n onClick={this._handleClick}\n ref={(el) => {\n this._menuButtonElement = el;\n }}\n className={classnames(\n \"core-context-menu-item\",\n \"core-context-submenu-container\",\n isDisabled && \"core-context-menu-disabled\",\n isHidden && \"core-context-menu-hidden\",\n isSelected && \"core-context-menu-is-selected\"\n )}\n data-testid=\"core-context-submenu-container\"\n role=\"menuitem\"\n tabIndex={isSelected ? 0 : -1}\n aria-disabled={isDisabled}\n aria-hidden={isHidden}\n aria-haspopup={true}\n >\n {!hideIconContainer && (\n <div className=\"core-context-menu-icon\">\n {icon !== undefined && <Icon iconSpec={icon} />}\n </div>\n )}\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\")}>\n <Icon iconSpec={<SvgCaretRightSmall />} />\n </div>\n {(badgeKind || badgeType) && (\n <div className=\"core-context-menu-badge\">\n <Badge type={badgeKind || badgeType} />\n </div>\n )}\n </div>\n <ContextMenu\n ref={(el) => {\n this._menuElement = el;\n }}\n className=\"core-context-submenu-popup\"\n opened={this.state.opened}\n direction={renderDirection}\n parentSubmenu={this}\n {...contextMenuProps}\n >\n {children}\n </ContextMenu>\n </div>\n );\n }\n\n public override componentDidMount() {\n document.addEventListener(\"click\", this._handleClickGlobal);\n this._updateHotkey(this.props.label);\n\n this.checkRenderDirection();\n }\n\n public override componentWillUnmount() {\n document.removeEventListener(\"click\", this._handleClickGlobal);\n }\n\n public override componentDidUpdate(\n prevProps: ContextSubMenuProps,\n prevState: ContextSubMenuState\n ) {\n const direction = this.props.direction!;\n if (\n (this.state.opened !== prevState.opened &&\n direction !== this.state.direction) ||\n prevProps.direction !== direction\n )\n this.checkRenderDirection();\n if (this.props.label !== prevProps.label) {\n this._updateHotkey(this.props.label);\n }\n }\n\n private getWindow() {\n const el = this._subMenuElement;\n const parentDocument = el!.ownerDocument;\n return parentDocument.defaultView;\n }\n\n private checkRenderDirection() {\n const { autoflip } = this.props;\n const parentWindow = this.getWindow();\n let renderDirection = this.state.direction;\n if (parentWindow && autoflip && this._menuElement) {\n const menuRect = this._menuElement.getRect();\n renderDirection = ContextMenu.autoFlip(\n renderDirection,\n menuRect,\n parentWindow.innerWidth,\n parentWindow.innerHeight\n );\n if (renderDirection !== this.state.direction)\n this.setState({ direction: renderDirection });\n }\n }\n\n private _updateHotkey = (node: React.ReactNode) => {\n let hotKey: string | undefined;\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\n if (!isDisabled && !isHidden)\n hotKey = TildeFinder.findAfterTilde(node).character;\n else hotKey = undefined;\n if (hotKey && hotKey !== this.state.hotKey) {\n this.setState({ hotKey });\n if (this.props.onHotKeyParsed) this.props.onHotKeyParsed(hotKey);\n }\n };\n\n public select = () => {\n this.setState({ opened: true }, () => {\n if (this._menuElement) this._menuElement.focus();\n if (this.props.onSelect !== undefined) this.props.onSelect(undefined);\n });\n };\n\n public close = (propagate?: boolean) => {\n this.setState({ opened: false }, () => {\n if (this._menuElement) this._menuElement.blur();\n });\n if (\n propagate &&\n this.props.parentMenu &&\n this.props.parentMenu.props.parentSubmenu\n ) {\n this.props.parentMenu.props.parentSubmenu.close(true);\n }\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\n if (\n this._menuButtonElement &&\n this._menuButtonElement.style.visibility !== \"hidden\" &&\n this.props.onHover\n ) {\n this.props.onHover();\n }\n };\n\n private _handleClick = (event: any) => {\n event.stopPropagation();\n\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\n\n if (!isDisabled) {\n if (this.props.onClick !== undefined) this.props.onClick(event);\n if (this.props.opened) this.close();\n else this.select();\n }\n };\n\n private _handleClickGlobal = (event: any) => {\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\n this.setState((_prevState) => ({ opened: false }));\n };\n}\n"]}
@@ -5,6 +5,7 @@ import * as React from "react";
5
5
  import type { ContextMenuProps } from "./ContextMenu";
6
6
  /** Properties for the [[GlobalContextMenu]] component
7
7
  * @public
8
+ * @deprecated in 4.16.0. Props of deprecated {@link GlobalContextMenu} component.
8
9
  */
9
10
  export interface GlobalContextMenuProps extends ContextMenuProps {
10
11
  /** Unique identifier, to distinguish from other GlobalContextMenu components. Needed only if multiple GlobalContextMenus are used simultaneously. */
@@ -16,12 +17,12 @@ export interface GlobalContextMenuProps extends ContextMenuProps {
16
17
  /** Context menu element. Default: ContextMenu */
17
18
  contextMenuComponent?: React.ComponentType<ContextMenuProps>;
18
19
  }
19
- /** @internal */
20
20
  interface GlobalContextMenuState {
21
21
  parentDocument: Document | null;
22
22
  }
23
23
  /** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor
24
24
  * @public
25
+ * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.
25
26
  */
26
27
  export declare class GlobalContextMenu extends React.PureComponent<GlobalContextMenuProps, GlobalContextMenuState> {
27
28
  private _container?;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextMenu.d.ts","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,qJAAqJ;IACrJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,yDAAyD;IACzD,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,iDAAiD;IACjD,oBAAoB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC9D;AAED,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,cAAc,EAAE,QAAQ,GAAG,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,aAAa,CACxD,sBAAsB,EACtB,sBAAsB,CACvB;IACC,OAAO,CAAC,UAAU,CAAC,CAAiB;IAEpC,SAAyB,KAAK,EAAE,sBAAsB,CAEpD;gBAEU,KAAK,EAAE,sBAAsB;IAIzB,oBAAoB;IAOpC,OAAO,CAAC,aAAa,CAyBnB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAuB1C"}
1
+ {"version":3,"file":"GlobalContextMenu.d.ts","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKtD;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,qJAAqJ;IACrJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,yDAAyD;IACzD,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,iDAAiD;IACjD,oBAAoB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC9D;AAED,UAAU,sBAAsB;IAC9B,cAAc,EAAE,QAAQ,GAAG,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,aAAa,CACxD,sBAAsB,EACtB,sBAAsB,CACvB;IACC,OAAO,CAAC,UAAU,CAAC,CAAiB;IAEpC,SAAyB,KAAK,EAAE,sBAAsB,CAEpD;gBAEU,KAAK,EAAE,sBAAsB;IAIzB,oBAAoB;IAOpC,OAAO,CAAC,aAAa,CAyBnB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAuB1C"}
@@ -10,6 +10,7 @@ import * as ReactDOM from "react-dom";
10
10
  import { ContextMenu } from "./ContextMenu";
11
11
  /** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor
12
12
  * @public
13
+ * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.
13
14
  */
14
15
  export class GlobalContextMenu extends React.PureComponent {
15
16
  constructor(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,K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I,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACrD,UAAU;YACV,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IA6Be,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,WAAW,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,EACN,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,uCAAuC,CACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\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 if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-global-context-menu\";\n let rt = parentDocument.getElementById(\n \"core-global-context-menu-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-global-context-menu-root\";\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? parentDocument.body\n ).appendChild(rt);\n }\n rt.appendChild(this._container);\n\n // used to support component rendering in pop-out window\n this.setState({ parentDocument });\n }\n };\n\n public override render(): React.ReactNode {\n const { x, y, identifier, contextMenuComponent, ...props } = this.props;\n const positioningStyle: React.CSSProperties = {\n left: x,\n top: y,\n };\n\n const CtxMenu = contextMenuComponent || ContextMenu;\n\n return (\n <div ref={this._handleRefSet} style={{ display: \"none\" }}>\n {this.state.parentDocument &&\n ReactDOM.createPortal(\n <div className=\"core-context-menu-global\" style={positioningStyle}>\n <CtxMenu {...props} />\n </div>,\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"GlobalContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/GlobalContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAuB5C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,aAG5C;IAOC,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QALU,UAAK,GAA2B;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC;QAaM,kBAAa,GAAG,CAAC,QAA4B,EAAE,EAAE;YACvD,MAAM,cAAc,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;YACvD,IAAI,cAAc,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,CAAC,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,CAAC;oBACR,EAAE,GAAG,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;oBACzC,EAAE,CAAC,EAAE,GAAG,+BAA+B,CAAC;oBACxC,CACE,cAAc,CAAC,IAAI,CAAC,aAAa,CAC/B,uCAAuC,CACxC,IAAI,cAAc,CAAC,IAAI,CACzB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC;gBACD,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAEhC,wDAAwD;gBACxD,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;IAlCF,CAAC;IAEe,oBAAoB;QAClC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YACrD,UAAU;YACV,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IA6Be,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,WAAW,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,EACN,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,uCAAuC,CACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CACC,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport type { ContextMenuProps } from \"./ContextMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for the [[GlobalContextMenu]] component\n * @public\n * @deprecated in 4.16.0. Props of deprecated {@link GlobalContextMenu} component.\n */\nexport interface GlobalContextMenuProps extends ContextMenuProps {\n /** Unique identifier, to distinguish from other GlobalContextMenu components. Needed only if multiple GlobalContextMenus are used simultaneously. */\n identifier?: string;\n /** Specifies the x/horizontal position on the viewport. */\n x: number | string;\n /** Specifies the y/vertical position on the viewport. */\n y: number | string;\n /** Context menu element. Default: ContextMenu */\n contextMenuComponent?: React.ComponentType<ContextMenuProps>;\n}\n\ninterface GlobalContextMenuState {\n parentDocument: Document | null;\n}\n\n/** GlobalContextMenu React component used to display a [[ContextMenu]] at the cursor\n * @public\n * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.\n */\nexport class GlobalContextMenu extends React.PureComponent<\n GlobalContextMenuProps,\n GlobalContextMenuState\n> {\n private _container?: HTMLDivElement;\n\n public override readonly state: GlobalContextMenuState = {\n parentDocument: null,\n };\n\n constructor(props: GlobalContextMenuProps) {\n super(props);\n }\n\n public override componentWillUnmount() {\n if (this._container && this._container.parentElement) {\n // cleanup\n this._container.parentElement.removeChild(this._container);\n }\n }\n\n private _handleRefSet = (popupDiv: HTMLElement | null) => {\n const parentDocument = popupDiv?.ownerDocument ?? null;\n if (parentDocument) {\n this._container = parentDocument.createElement(\"div\");\n this._container.id =\n this.props.identifier !== undefined\n ? `dialog-${this.props.identifier}`\n : \"core-global-context-menu\";\n let rt = parentDocument.getElementById(\n \"core-global-context-menu-root\"\n ) as HTMLDivElement;\n if (!rt) {\n rt = parentDocument.createElement(\"div\");\n rt.id = \"core-global-context-menu-root\";\n (\n parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? parentDocument.body\n ).appendChild(rt);\n }\n rt.appendChild(this._container);\n\n // used to support component rendering in pop-out window\n this.setState({ parentDocument });\n }\n };\n\n public override render(): React.ReactNode {\n const { x, y, identifier, contextMenuComponent, ...props } = this.props;\n const positioningStyle: React.CSSProperties = {\n left: x,\n top: y,\n };\n\n const CtxMenu = contextMenuComponent || ContextMenu;\n\n return (\n <div ref={this._handleRefSet} style={{ display: \"none\" }}>\n {this.state.parentDocument &&\n ReactDOM.createPortal(\n <div className=\"core-context-menu-global\" style={positioningStyle}>\n <CtxMenu {...props} />\n </div>,\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"appui-root-id\"]'\n ) ?? this.state.parentDocument.body\n )}\n </div>\n );\n }\n}\n"]}
@@ -7,6 +7,7 @@ import { RelativePosition } from "@itwin/appui-abstract";
7
7
  import type { CommonProps } from "../utils/Props";
8
8
  /** Properties for [[PopupContextMenu]] component
9
9
  * @public
10
+ * @deprecated in 4.16.0. Props of deprecated {@link PopupContextMenu} component.
10
11
  */
11
12
  export interface PopupContextMenuProps extends CommonProps {
12
13
  /** Indicates whether the popup is shown or not (defaults to false) */
@@ -50,6 +51,7 @@ export interface PopupContextMenuProps extends CommonProps {
50
51
  }
51
52
  /** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.
52
53
  * @public
54
+ * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.
53
55
  */
54
56
  export declare function PopupContextMenu(props: PopupContextMenuProps): React.JSX.Element;
55
57
  //# sourceMappingURL=PopupContextMenu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContextMenu.d.ts","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/PopupContextMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO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AQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,SAAS,KAAK,IAAI,CAAC;IACzD,oCAAoC;IACpC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAC7C,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAuC5D"}
@@ -13,13 +13,12 @@ import { RelativePosition } from "@itwin/appui-abstract";
13
13
  import { ContextMenuDirection } from "./ContextMenuDirection";
14
14
  /** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.
15
15
  * @public
16
+ * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.
16
17
  */
17
18
  export function PopupContextMenu(props) {
18
19
  const { style, onSelect, onEsc, autoflip, edgeLimit, hotkeySelect, selectedIndex, children, ...popupProps } = props;
19
20
  const menuDirection = getContextMenuDirectionFromRelativePosition(popupProps.position);
20
- return (
21
- // eslint-disable-next-line deprecation/deprecation
22
- React.createElement(Popup, { ...popupProps, closeOnNestedPopupOutsideClick: true, showShadow: false, showArrow: false, moveFocus: true, style: { ...style, border: "none" } },
21
+ return (React.createElement(Popup, { ...popupProps, closeOnNestedPopupOutsideClick: true, showShadow: false, showArrow: false, moveFocus: true, style: { ...style, border: "none" } },
23
22
  React.createElement(ContextMenu, { className: "core-contextMenu-popupContextMenu_menu", opened: true, onSelect: onSelect, onEsc: onEsc, autoflip: autoflip, edgeLimit: edgeLimit, hotkeySelect: hotkeySelect, selectedIndex: selectedIndex, direction: menuDirection }, children)));
24
23
  }
25
24
  function getContextMenuDirectionFromRelativePosition(relativePosition) {
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/PopupContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAiD9D;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,GAAG,UAAU,EACd,GAAG,KAAK,CAAC;IACV,MAAM,aAAa,GAAG,2CAA2C,CAC/D,UAAU,CAAC,QAAQ,CACpB,CAAC;IACF,OAAO;IACL,mDAAmD;IACnD,oBAAC,KAAK,OACA,UAAU,EACd,8BAA8B,QAC9B,UAAU,EAAE,KAAK,EACjB,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAEnC,oBAAC,WAAW,IACV,SAAS,EAAC,wCAAwC,EAClD,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,aAAa,IAEvB,QAAQ,CACG,CACR,CACT,CAAC;AACJ,CAAC;AAED,SAAS,2CAA2C,CAClD,gBAAmC;IAEnC,IAAI,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;IAChD,QAAQ,gBAAgB,EAAE,CAAC;QACzB,KAAK,gBAAgB,CAAC,GAAG;YACvB,aAAa,GAAG,oBAAoB,CAAC,GAAG,CAAC;YACzC,MAAM;QACR,KAAK,gBAAgB,CAAC,OAAO;YAC3B,aAAa,GAAG,oBAAoB,CAAC,QAAQ,CAAC;YAC9C,MAAM;QACR,KAAK,gBAAgB,CAAC,QAAQ;YAC5B,aAAa,GAAG,oBAAoB,CAAC,OAAO,CAAC;YAC7C,MAAM;QACR,KAAK,gBAAgB,CAAC,IAAI;YACxB,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC;YAC1C,MAAM;QACR,KAAK,gBAAgB,CAAC,KAAK;YACzB,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC3C,MAAM;QACR,KAAK,gBAAgB,CAAC,MAAM;YAC1B,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;YAC5C,MAAM;QACR,KAAK,gBAAgB,CAAC,UAAU;YAC9B,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC;YACjD,MAAM;QACR,KAAK,gBAAgB,CAAC,WAAW;YAC/B,aAAa,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAChD,MAAM;IACV,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport \"./PopupContextMenu.scss\";\nimport * as React from \"react\";\nimport { Popup } from \"../popup/Popup\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\n\n/** Properties for [[PopupContextMenu]] component\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface PopupContextMenuProps extends CommonProps {\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position?: RelativePosition;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Top position (absolute positioning - defaults to 0) */\n top?: number;\n /** Left position (absolute positioning - defaults to 0) */\n left?: number;\n /** Offset from the parent (defaults to 4) */\n offset?: number;\n /** accessibility label */\n ariaLabel?: string;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n\n /** When list item or submenu is selected */\n onSelect?: (event: React.MouseEvent | undefined) => void;\n /** when Escape button is pressed */\n onEsc?: (event: React.KeyboardEvent) => void;\n /** Whether menu flips directions based on screen edge. Default: true */\n autoflip?: boolean;\n /** Whether menu hugs screen edge when autoflip is off. Default: true */\n edgeLimit?: boolean;\n /** Whether Hotkey press selects item, or just highlights item. Default: true */\n hotkeySelect?: boolean;\n /** starting menu item selected index Default: -1 */\n selectedIndex?: number;\n\n /** ContextMenu items */\n children?: React.ReactNode;\n}\n\n/** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.\n * @public\n */\nexport function PopupContextMenu(props: PopupContextMenuProps) {\n const {\n style,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n children,\n ...popupProps\n } = props;\n const menuDirection = getContextMenuDirectionFromRelativePosition(\n popupProps.position\n );\n return (\n // eslint-disable-next-line deprecation/deprecation\n <Popup\n {...popupProps}\n closeOnNestedPopupOutsideClick\n showShadow={false}\n showArrow={false}\n moveFocus={true}\n style={{ ...style, border: \"none\" }}\n >\n <ContextMenu\n className=\"core-contextMenu-popupContextMenu_menu\"\n opened={true}\n onSelect={onSelect}\n onEsc={onEsc}\n autoflip={autoflip}\n edgeLimit={edgeLimit}\n hotkeySelect={hotkeySelect}\n selectedIndex={selectedIndex}\n direction={menuDirection}\n >\n {children}\n </ContextMenu>\n </Popup>\n );\n}\n\nfunction getContextMenuDirectionFromRelativePosition(\n relativePosition?: RelativePosition\n): ContextMenuDirection {\n let menuDirection = ContextMenuDirection.Bottom;\n switch (relativePosition) {\n case RelativePosition.Top:\n menuDirection = ContextMenuDirection.Top;\n break;\n case RelativePosition.TopLeft:\n menuDirection = ContextMenuDirection.TopRight;\n break;\n case RelativePosition.TopRight:\n menuDirection = ContextMenuDirection.TopLeft;\n break;\n case RelativePosition.Left:\n menuDirection = ContextMenuDirection.Left;\n break;\n case RelativePosition.Right:\n menuDirection = ContextMenuDirection.Right;\n break;\n case RelativePosition.Bottom:\n menuDirection = ContextMenuDirection.Bottom;\n break;\n case RelativePosition.BottomLeft:\n menuDirection = ContextMenuDirection.BottomRight;\n break;\n case RelativePosition.BottomRight:\n menuDirection = ContextMenuDirection.BottomLeft;\n break;\n }\n return menuDirection;\n}\n"]}
1
+ {"version":3,"file":"PopupContextMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/PopupContextMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmD9D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CA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,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC3C,MAAM;QACR,KAAK,gBAAgB,CAAC,MAAM;YAC1B,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC;YAC5C,MAAM;QACR,KAAK,gBAAgB,CAAC,UAAU;YAC9B,aAAa,GAAG,oBAAoB,CAAC,WAAW,CAAC;YACjD,MAAM;QACR,KAAK,gBAAgB,CAAC,WAAW;YAC/B,aAAa,GAAG,oBAAoB,CAAC,UAAU,CAAC;YAChD,MAAM;IACV,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ContextMenu\n */\n\nimport \"./PopupContextMenu.scss\";\nimport * as React from \"react\";\nimport { Popup } from \"../popup/Popup\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for [[PopupContextMenu]] component\n * @public\n * @deprecated in 4.16.0. Props of deprecated {@link PopupContextMenu} component.\n */\nexport interface PopupContextMenuProps extends CommonProps {\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position?: RelativePosition;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Top position (absolute positioning - defaults to 0) */\n top?: number;\n /** Left position (absolute positioning - defaults to 0) */\n left?: number;\n /** Offset from the parent (defaults to 4) */\n offset?: number;\n /** accessibility label */\n ariaLabel?: string;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n\n /** When list item or submenu is selected */\n onSelect?: (event: React.MouseEvent | undefined) => void;\n /** when Escape button is pressed */\n onEsc?: (event: React.KeyboardEvent) => void;\n /** Whether menu flips directions based on screen edge. Default: true */\n autoflip?: boolean;\n /** Whether menu hugs screen edge when autoflip is off. Default: true */\n edgeLimit?: boolean;\n /** Whether Hotkey press selects item, or just highlights item. Default: true */\n hotkeySelect?: boolean;\n /** starting menu item selected index Default: -1 */\n selectedIndex?: number;\n\n /** ContextMenu items */\n children?: React.ReactNode;\n}\n\n/** Component that displays a ContextMenu within a Popup component, allowing the target element to be specified.\n * @public\n * @deprecated in 4.16.0. Use {@link https://itwinui.bentley.com/docs/dropdownmenu iTwinUI DropdownMenu} component instead.\n */\nexport function PopupContextMenu(props: PopupContextMenuProps) {\n const {\n style,\n onSelect,\n onEsc,\n autoflip,\n edgeLimit,\n hotkeySelect,\n selectedIndex,\n children,\n ...popupProps\n } = props;\n const menuDirection = getContextMenuDirectionFromRelativePosition(\n popupProps.position\n );\n return (\n <Popup\n {...popupProps}\n closeOnNestedPopupOutsideClick\n showShadow={false}\n showArrow={false}\n moveFocus={true}\n style={{ ...style, border: \"none\" }}\n >\n <ContextMenu\n className=\"core-contextMenu-popupContextMenu_menu\"\n opened={true}\n onSelect={onSelect}\n onEsc={onEsc}\n autoflip={autoflip}\n edgeLimit={edgeLimit}\n hotkeySelect={hotkeySelect}\n selectedIndex={selectedIndex}\n direction={menuDirection}\n >\n {children}\n </ContextMenu>\n </Popup>\n );\n}\n\nfunction getContextMenuDirectionFromRelativePosition(\n relativePosition?: RelativePosition\n): ContextMenuDirection {\n let menuDirection = ContextMenuDirection.Bottom;\n switch (relativePosition) {\n case RelativePosition.Top:\n menuDirection = ContextMenuDirection.Top;\n break;\n case RelativePosition.TopLeft:\n menuDirection = ContextMenuDirection.TopRight;\n break;\n case RelativePosition.TopRight:\n menuDirection = ContextMenuDirection.TopLeft;\n break;\n case RelativePosition.Left:\n menuDirection = ContextMenuDirection.Left;\n break;\n case RelativePosition.Right:\n menuDirection = ContextMenuDirection.Right;\n break;\n case RelativePosition.Bottom:\n menuDirection = ContextMenuDirection.Bottom;\n break;\n case RelativePosition.BottomLeft:\n menuDirection = ContextMenuDirection.BottomRight;\n break;\n case RelativePosition.BottomRight:\n menuDirection = ContextMenuDirection.BottomLeft;\n break;\n }\n return menuDirection;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ElementSeparator.d.ts","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AAEH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,4BAA4B;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IAEtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,iBAAiB,CAAC;IAC7D,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,oCAAoC;IACpC,yBAAyB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D;AA8KD;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,sBA8C5D,CAAC"}
1
+ {"version":3,"file":"ElementSeparator.d.ts","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,4BAA4B;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,iBAAiB,CAAC;IAC7D,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,oCAAoC;IACpC,yBAAyB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D;AA6KD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,sBA8C5D,CAAC"}
@@ -137,7 +137,6 @@ function getStyle(orientation, separatorSize) {
137
137
  * @public
138
138
  * @deprecated in 4.12.0. Basic components that need to be user-resized support this out of the box. Use {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent pointer events} API to implement a custom resizer.
139
139
  */
140
- // eslint-disable-next-line deprecation/deprecation
141
140
  export const ElementSeparator = (props) => {
142
141
  const { translate } = useTranslation();
143
142
  const [hasHoverHappened, setHasHoverHappened] = useState(false);
@@ -1 +1 @@
1
- {"version":3,"file":"ElementSeparator.js","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAqCxD,SAAS,wBAAwB,CAC/B,WAAwB,EACxB,CAAoC;IAEpC,OAAO,WAAW,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,qBAAqB,GAAG,CAAC,SAAkB,EAAE,OAAmB,EAAE,EAAE;IACxE,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnC,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;IACjC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACb,OA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AAI,CAAC,gBAAgB,IAAI,aAAa;QAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAE3E,iEAAiE;IACjE,MAAM,YAAY,GAAG,gBAAgB;QACnC,CAAC,CAAC,wCAAwC;QAC1C,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,UAAU,GAAG,UAAU,CAC3B,wBAAwB,EACxB,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU;QAC1C,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,kCAAkC,EACtC,KAAK,CAAC,SAAS,EACf,aAAa,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,YAAY,CACtE,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,EAC1C,CAAC,WAAW,EAAE,aAAa,CAAC,CAC7B,CAAC;IACF,MAAM,MAAM,GAAwB;QAClC,GAAG,KAAK;QACR,GAAG,KAAK,CAAC,KAAK;KACf,CAAC;IAEF,OAAO,CACL,gCACE,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,gBACd,SAAS,CAAC,wBAAwB,CAAC,EAC/C,QAAQ,EAAE,CAAC,CAAC,GACZ,CACH,CAAC;AACJ,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 ElementSeparator\n */\n\nimport \"./ElementSeparator.scss\";\nimport * as React from \"react\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classnames from \"classnames\";\nimport { Orientation } from \"../enums/Orientation\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { useThrottledFn } from \"../utils/hooks/useThrottledFn\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/** Results returned by onRatioChanged callback for determining new ratio and whether the ratio was updated.\n * @public\n * @deprecated in 4.12.0. Interface used in a deprecated component {@link ElementSeparator}.\n */\nexport interface RatioChangeResult {\n ratio: number;\n}\n\n/** Properties of [[ElementSeparator]] React component\n * @public\n * @deprecated in 4.12.0. Props of deprecated component {@link ElementSeparator}.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface ElementSeparatorProps extends CommonProps {\n /** Separator orientation */\n orientation: Orientation;\n /** Ratio between left cell and right cell */\n ratio: number;\n /** Area width or height (depending on orientation) in pixels */\n movableArea?: number;\n /** Separator width or height in pixels. 30 by default */\n separatorSize?: number;\n /** Callback to ratio changed event */\n // eslint-disable-next-line deprecation/deprecation\n onRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n}\n\nfunction getCurrentGlobalPosition(\n orientation: Orientation,\n e: PointerEvent | React.PointerEvent\n) {\n return orientation === Orientation.Horizontal ? e.clientX : e.clientY;\n}\n\nconst useConditionalCleanup = (condition: boolean, cleanup: () => void) => {\n const conditionRef = useRef(condition);\n const cleanupRef = useRef(cleanup);\n\n conditionRef.current = condition;\n cleanupRef.current = cleanup;\n\n useEffect(() => {\n return () => {\n if (conditionRef.current) cleanupRef.current();\n };\n }, []);\n};\n\nconst useElementSeparatorPointerHandler = ({\n onResizeHandleDragChanged,\n onResizeHandleHoverChanged,\n isResizeHandleBeingDragged,\n isResizeHandleHovered,\n movableArea,\n ratio,\n orientation,\n onRatioChanged,\n}: // eslint-disable-next-line deprecation/deprecation\nElementSeparatorProps) => {\n const globalPosition = useRef(0);\n const pointerOutOfBounds = useRef(false);\n\n const [isElementDragged, setIsDragged] = useState(false);\n const [isElementHovered, setIsHovered] = useState(false);\n const isGroupDragged = isResizeHandleBeingDragged ?? isElementDragged;\n const isGroupHovered = isResizeHandleHovered ?? isElementHovered;\n\n useConditionalCleanup(isElementDragged && !!onResizeHandleDragChanged, () =>\n onResizeHandleDragChanged!(false)\n );\n useConditionalCleanup(isElementHovered && !!onResizeHandleHoverChanged, () =>\n onResizeHandleHoverChanged!(false)\n );\n\n if (isGroupHovered && pointerOutOfBounds.current)\n pointerOutOfBounds.current = false;\n\n const stopDrag = useCallback(() => {\n if (isGroupDragged) {\n setIsDragged(false);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(false);\n }\n }, [isGroupDragged, onResizeHandleDragChanged]);\n\n const startDrag = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n globalPosition.current = getCurrentGlobalPosition(orientation, e);\n\n if (!isGroupDragged) {\n setIsDragged(true);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(true);\n }\n },\n [isGroupDragged, orientation, onResizeHandleDragChanged]\n );\n\n const onPointerUp = useCallback(() => {\n stopDrag();\n }, [stopDrag]);\n\n const onThrottledPointerMove = useThrottledFn(\n (e: PointerEvent | React.PointerEvent) => {\n if (!movableArea) {\n stopDrag();\n return;\n }\n\n const currentPosition = getCurrentGlobalPosition(orientation, e);\n const positionChange = currentPosition - globalPosition.current;\n\n // Should not need to recalculate if position on our movement axis does not change\n if (Math.abs(positionChange) < 1) return;\n\n const currentLocalPosition = movableArea * ratio + positionChange;\n const newRatio = currentLocalPosition / movableArea;\n\n globalPosition.current = currentPosition;\n if (pointerOutOfBounds.current || !onRatioChanged) return;\n\n const result = onRatioChanged(newRatio);\n if (\n result &&\n result.ratio === ratio &&\n !isGroupHovered &&\n !pointerOutOfBounds.current\n )\n pointerOutOfBounds.current = true;\n },\n 16,\n [stopDrag, isGroupHovered, ratio, movableArea, onRatioChanged, orientation]\n );\n\n useEffect(() => {\n return () => onThrottledPointerMove.cancel();\n }, [onThrottledPointerMove]);\n\n useLayoutEffect(() => {\n if (isElementDragged) {\n document.addEventListener(\"pointerup\", onPointerUp);\n document.addEventListener(\"pointermove\", onThrottledPointerMove);\n }\n\n return () => {\n document.removeEventListener(\"pointerup\", onPointerUp);\n document.removeEventListener(\"pointermove\", onThrottledPointerMove);\n };\n }, [isElementDragged, onPointerUp, onThrottledPointerMove]);\n\n const onPointerDown = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n if (!isGroupDragged) {\n startDrag(e);\n } else {\n stopDrag();\n }\n },\n [isGroupDragged, startDrag, stopDrag]\n );\n\n const onPointerOver = useCallback(() => {\n if (isGroupHovered) return;\n\n setIsHovered(true);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(true);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n const onPointerOut = useCallback(() => {\n if (!isGroupHovered) return;\n\n setIsHovered(false);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(false);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n return {\n isHovered: isGroupHovered,\n isDragged: isGroupDragged,\n onPointerDown,\n onPointerOver,\n onPointerOut,\n };\n};\n\nfunction getStyle(\n orientation: Orientation,\n separatorSize?: number\n): React.CSSProperties {\n separatorSize = separatorSize || 30;\n\n if (orientation === Orientation.Horizontal)\n return {\n width: separatorSize,\n margin: `0px ${-Math.floor(separatorSize / 2)}px`,\n };\n return {\n height: separatorSize,\n margin: `${-Math.floor(separatorSize / 2)}px 1px`,\n };\n}\n\n/** A movable button, which allows to change the ratio between left element and right element\n * @public\n * @deprecated in 4.12.0. Basic components that need to be user-resized support this out of the box. Use {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent pointer events} API to implement a custom resizer.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport const ElementSeparator = (props: ElementSeparatorProps) => {\n const { translate } = useTranslation();\n\n const [hasHoverHappened, setHasHoverHappened] = useState(false);\n const { isDragged, isHovered, onPointerDown, onPointerOver, onPointerOut } =\n useElementSeparatorPointerHandler(props);\n\n const isHoverNeeded = isHovered || isDragged;\n if (!hasHoverHappened && isHoverNeeded) setHasHoverHappened(isHoverNeeded);\n\n // This is done to avoid fade-out animation when first rendering.\n const unhoverClass = hasHoverHappened\n ? \"core-element-separator-group-unhovered\"\n : \"\";\n\n const classNames = classnames(\n \"core-element-separator\",\n props.orientation === Orientation.Horizontal\n ? \"core-element-separator--horizontal\"\n : \"core-element-separator--vertical\",\n props.className,\n isHoverNeeded ? \"core-element-separator-group-hovered\" : unhoverClass\n );\n\n const orientation = props.orientation;\n const separatorSize = props.separatorSize;\n const style = useMemo(\n () => getStyle(orientation, separatorSize),\n [orientation, separatorSize]\n );\n const styles: React.CSSProperties = {\n ...style,\n ...props.style,\n };\n\n return (\n <button\n style={styles}\n className={classNames}\n onPointerDown={onPointerDown}\n onPointerOver={onPointerOver}\n onPointerOut={onPointerOut}\n aria-label={translate(\"elementSeparator.label\")}\n tabIndex={-1}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"ElementSeparator.js","sourceRoot":"","sources":["../../../../src/core-react/elementseparator/ElementSeparator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAqCxD,SAAS,wBA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EACb,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,gBACd,SAAS,CAAC,wBAAwB,CAAC,EAC/C,QAAQ,EAAE,CAAC,CAAC,GACZ,CACH,CAAC;AACJ,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 ElementSeparator\n */\n\nimport \"./ElementSeparator.scss\";\nimport * as React from \"react\";\nimport {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classnames from \"classnames\";\nimport { Orientation } from \"../enums/Orientation\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { useThrottledFn } from \"../utils/hooks/useThrottledFn\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Results returned by onRatioChanged callback for determining new ratio and whether the ratio was updated.\n * @public\n * @deprecated in 4.12.0. Interface used in a deprecated component {@link ElementSeparator}.\n */\nexport interface RatioChangeResult {\n ratio: number;\n}\n\n/** Properties of [[ElementSeparator]] React component\n * @public\n * @deprecated in 4.12.0. Props of deprecated component {@link ElementSeparator}.\n */\nexport interface ElementSeparatorProps extends CommonProps {\n /** Separator orientation */\n orientation: Orientation;\n /** Ratio between left cell and right cell */\n ratio: number;\n /** Area width or height (depending on orientation) in pixels */\n movableArea?: number;\n /** Separator width or height in pixels. 30 by default */\n separatorSize?: number;\n /** Callback to ratio changed event */\n onRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n}\n\nfunction getCurrentGlobalPosition(\n orientation: Orientation,\n e: PointerEvent | React.PointerEvent\n) {\n return orientation === Orientation.Horizontal ? e.clientX : e.clientY;\n}\n\nconst useConditionalCleanup = (condition: boolean, cleanup: () => void) => {\n const conditionRef = useRef(condition);\n const cleanupRef = useRef(cleanup);\n\n conditionRef.current = condition;\n cleanupRef.current = cleanup;\n\n useEffect(() => {\n return () => {\n if (conditionRef.current) cleanupRef.current();\n };\n }, []);\n};\n\nconst useElementSeparatorPointerHandler = ({\n onResizeHandleDragChanged,\n onResizeHandleHoverChanged,\n isResizeHandleBeingDragged,\n isResizeHandleHovered,\n movableArea,\n ratio,\n orientation,\n onRatioChanged,\n}: ElementSeparatorProps) => {\n const globalPosition = useRef(0);\n const pointerOutOfBounds = useRef(false);\n\n const [isElementDragged, setIsDragged] = useState(false);\n const [isElementHovered, setIsHovered] = useState(false);\n const isGroupDragged = isResizeHandleBeingDragged ?? isElementDragged;\n const isGroupHovered = isResizeHandleHovered ?? isElementHovered;\n\n useConditionalCleanup(isElementDragged && !!onResizeHandleDragChanged, () =>\n onResizeHandleDragChanged!(false)\n );\n useConditionalCleanup(isElementHovered && !!onResizeHandleHoverChanged, () =>\n onResizeHandleHoverChanged!(false)\n );\n\n if (isGroupHovered && pointerOutOfBounds.current)\n pointerOutOfBounds.current = false;\n\n const stopDrag = useCallback(() => {\n if (isGroupDragged) {\n setIsDragged(false);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(false);\n }\n }, [isGroupDragged, onResizeHandleDragChanged]);\n\n const startDrag = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n globalPosition.current = getCurrentGlobalPosition(orientation, e);\n\n if (!isGroupDragged) {\n setIsDragged(true);\n if (onResizeHandleDragChanged) onResizeHandleDragChanged(true);\n }\n },\n [isGroupDragged, orientation, onResizeHandleDragChanged]\n );\n\n const onPointerUp = useCallback(() => {\n stopDrag();\n }, [stopDrag]);\n\n const onThrottledPointerMove = useThrottledFn(\n (e: PointerEvent | React.PointerEvent) => {\n if (!movableArea) {\n stopDrag();\n return;\n }\n\n const currentPosition = getCurrentGlobalPosition(orientation, e);\n const positionChange = currentPosition - globalPosition.current;\n\n // Should not need to recalculate if position on our movement axis does not change\n if (Math.abs(positionChange) < 1) return;\n\n const currentLocalPosition = movableArea * ratio + positionChange;\n const newRatio = currentLocalPosition / movableArea;\n\n globalPosition.current = currentPosition;\n if (pointerOutOfBounds.current || !onRatioChanged) return;\n\n const result = onRatioChanged(newRatio);\n if (\n result &&\n result.ratio === ratio &&\n !isGroupHovered &&\n !pointerOutOfBounds.current\n )\n pointerOutOfBounds.current = true;\n },\n 16,\n [stopDrag, isGroupHovered, ratio, movableArea, onRatioChanged, orientation]\n );\n\n useEffect(() => {\n return () => onThrottledPointerMove.cancel();\n }, [onThrottledPointerMove]);\n\n useLayoutEffect(() => {\n if (isElementDragged) {\n document.addEventListener(\"pointerup\", onPointerUp);\n document.addEventListener(\"pointermove\", onThrottledPointerMove);\n }\n\n return () => {\n document.removeEventListener(\"pointerup\", onPointerUp);\n document.removeEventListener(\"pointermove\", onThrottledPointerMove);\n };\n }, [isElementDragged, onPointerUp, onThrottledPointerMove]);\n\n const onPointerDown = useCallback(\n (e: PointerEvent | React.PointerEvent) => {\n if (!isGroupDragged) {\n startDrag(e);\n } else {\n stopDrag();\n }\n },\n [isGroupDragged, startDrag, stopDrag]\n );\n\n const onPointerOver = useCallback(() => {\n if (isGroupHovered) return;\n\n setIsHovered(true);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(true);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n const onPointerOut = useCallback(() => {\n if (!isGroupHovered) return;\n\n setIsHovered(false);\n if (onResizeHandleHoverChanged) onResizeHandleHoverChanged(false);\n }, [isGroupHovered, onResizeHandleHoverChanged]);\n\n return {\n isHovered: isGroupHovered,\n isDragged: isGroupDragged,\n onPointerDown,\n onPointerOver,\n onPointerOut,\n };\n};\n\nfunction getStyle(\n orientation: Orientation,\n separatorSize?: number\n): React.CSSProperties {\n separatorSize = separatorSize || 30;\n\n if (orientation === Orientation.Horizontal)\n return {\n width: separatorSize,\n margin: `0px ${-Math.floor(separatorSize / 2)}px`,\n };\n return {\n height: separatorSize,\n margin: `${-Math.floor(separatorSize / 2)}px 1px`,\n };\n}\n\n/** A movable button, which allows to change the ratio between left element and right element\n * @public\n * @deprecated in 4.12.0. Basic components that need to be user-resized support this out of the box. Use {@link https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent pointer events} API to implement a custom resizer.\n */\nexport const ElementSeparator = (props: ElementSeparatorProps) => {\n const { translate } = useTranslation();\n\n const [hasHoverHappened, setHasHoverHappened] = useState(false);\n const { isDragged, isHovered, onPointerDown, onPointerOver, onPointerOut } =\n useElementSeparatorPointerHandler(props);\n\n const isHoverNeeded = isHovered || isDragged;\n if (!hasHoverHappened && isHoverNeeded) setHasHoverHappened(isHoverNeeded);\n\n // This is done to avoid fade-out animation when first rendering.\n const unhoverClass = hasHoverHappened\n ? \"core-element-separator-group-unhovered\"\n : \"\";\n\n const classNames = classnames(\n \"core-element-separator\",\n props.orientation === Orientation.Horizontal\n ? \"core-element-separator--horizontal\"\n : \"core-element-separator--vertical\",\n props.className,\n isHoverNeeded ? \"core-element-separator-group-hovered\" : unhoverClass\n );\n\n const orientation = props.orientation;\n const separatorSize = props.separatorSize;\n const style = useMemo(\n () => getStyle(orientation, separatorSize),\n [orientation, separatorSize]\n );\n const styles: React.CSSProperties = {\n ...style,\n ...props.style,\n };\n\n return (\n <button\n style={styles}\n className={classNames}\n onPointerDown={onPointerDown}\n onPointerOver={onPointerOver}\n onPointerOut={onPointerOut}\n aria-label={translate(\"elementSeparator.label\")}\n tabIndex={-1}\n />\n );\n};\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  /** State of a checkbox
5
5
  * @public
6
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#CheckBoxState} instead.
6
7
  */
7
8
  export declare enum CheckBoxState {
8
9
  Off = 0,
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBoxState.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,oBAAY,aAAa;IACvB,GAAG,IAAA;IACH,EAAE,IAAA;IACF,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
1
+ {"version":3,"file":"CheckBoxState.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,oBAAY,aAAa;IACvB,GAAG,IAAA;IACH,EAAE,IAAA;IACF,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /** State of a checkbox
9
9
  * @public
10
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#CheckBoxState} instead.
10
11
  */
11
12
  export var CheckBoxState;
12
13
  (function (CheckBoxState) {
@@ -1 +1 @@
1
- {"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+CAAG,CAAA;IACH,6CAAE,CAAA;IACF,uDAAO,CAAA;AACT,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","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 Common\n */\n\n/** State of a checkbox\n * @public\n */\nexport enum CheckBoxState {\n Off,\n On,\n Partial,\n}\n\n/** A data type that holds all the checkbox display attributes\n * @public\n * @deprecated in 4.15.0. Not used by AppUI.\n */\nexport interface CheckBoxInfo {\n isVisible?: boolean;\n isDisabled?: boolean;\n state?: CheckBoxState;\n tooltip?: string;\n}\n"]}
1
+ {"version":3,"file":"CheckBoxState.js","sourceRoot":"","sources":["../../../../src/core-react/enums/CheckBoxState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+CAAG,CAAA;IACH,6CAAE,CAAA;IACF,uDAAO,CAAA;AACT,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","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 Common\n */\n\n/** State of a checkbox\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/components-react#CheckBoxState} instead.\n */\nexport enum CheckBoxState {\n Off,\n On,\n Partial,\n}\n\n/** A data type that holds all the checkbox display attributes\n * @public\n * @deprecated in 4.15.0. Not used by AppUI.\n */\nexport interface CheckBoxInfo {\n isVisible?: boolean;\n isDisabled?: boolean;\n // eslint-disable-next-line deprecation/deprecation\n state?: CheckBoxState;\n tooltip?: string;\n}\n"]}
@@ -4,6 +4,7 @@
4
4
  /**
5
5
  * Enumeration of orientation.
6
6
  * @public
7
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#Orientation} instead.
7
8
  */
8
9
  export declare enum Orientation {
9
10
  Horizontal = 0,
@@ -1 +1 @@
1
- {"version":3,"file":"Orientation.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,oBAAY,WAAW;IACrB,UAAU,IAAA;IACV,QAAQ,IAAA;CACT"}
1
+ {"version":3,"file":"Orientation.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,WAAW;IACrB,UAAU,IAAA;IACV,QAAQ,IAAA;CACT"}
@@ -8,6 +8,7 @@
8
8
  /**
9
9
  * Enumeration of orientation.
10
10
  * @public
11
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#Orientation} instead.
11
12
  */
12
13
  export var Orientation;
13
14
  (function (Orientation) {
@@ -1 +1 @@
1
- {"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,yDAAU,CAAA;IACV,qDAAQ,CAAA;AACV,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","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 Common\n */\n\n/**\n * Enumeration of orientation.\n * @public\n */\nexport enum Orientation {\n Horizontal,\n Vertical,\n}\n"]}
1
+ {"version":3,"file":"Orientation.js","sourceRoot":"","sources":["../../../../src/core-react/enums/Orientation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,yDAAU,CAAA;IACV,qDAAQ,CAAA;AACV,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","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 Common\n */\n\n/**\n * Enumeration of orientation.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/components-react#Orientation} instead.\n */\nexport enum Orientation {\n Horizontal,\n Vertical,\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  /** Enumeration of time formats.
5
5
  * @public
6
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#TimeFormat} instead.
6
7
  */
7
8
  export declare enum TimeFormat {
8
9
  /** Show Date and time using toISOString */
@@ -1 +1 @@
1
- {"version":3,"file":"TimeFormat.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,oBAAY,UAAU;IACpB,2CAA2C;IAC3C,IAAI,IAAI;IACR,yCAAyC;IACzC,KAAK,IAAA;IACL,0CAA0C;IAC1C,IAAI,IAAA;CACL"}
1
+ {"version":3,"file":"TimeFormat.d.ts","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,oBAAY,UAAU;IACpB,2CAA2C;IAC3C,IAAI,IAAI;IACR,yCAAyC;IACzC,KAAK,IAAA;IACL,0CAA0C;IAC1C,IAAI,IAAA;CACL"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /** Enumeration of time formats.
9
9
  * @public
10
+ * @deprecated in 4.16.0. Use {@link @itwin/components-react#TimeFormat} instead.
10
11
  */
11
12
  export var TimeFormat;
12
13
  (function (TimeFormat) {
@@ -1 +1 @@
1
- {"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,2CAA2C;IAC3C,2CAAQ,CAAA;IACR,yCAAyC;IACzC,6CAAK,CAAA;IACL,0CAA0C;IAC1C,2CAAI,CAAA;AACN,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB","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 Common\n */\n\n/** Enumeration of time formats.\n * @public\n */\nexport enum TimeFormat {\n /** Show Date and time using toISOString */\n None = 0,\n /** Show Date using toLocaleDateString */\n Short,\n /** Show Date Time using toLocaleString */\n Long,\n}\n"]}
1
+ {"version":3,"file":"TimeFormat.js","sourceRoot":"","sources":["../../../../src/core-react/enums/TimeFormat.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH;;;GAGG;AACH,MAAM,CAAN,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,2CAA2C;IAC3C,2CAAQ,CAAA;IACR,yCAAyC;IACzC,6CAAK,CAAA;IACL,0CAA0C;IAC1C,2CAAI,CAAA;AACN,CAAC,EAPW,UAAU,KAAV,UAAU,QAOrB","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 Common\n */\n\n/** Enumeration of time formats.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/components-react#TimeFormat} instead.\n */\nexport enum TimeFormat {\n /** Show Date and time using toISOString */\n None = 0,\n /** Show Date using toLocaleDateString */\n Short,\n /** Show Date Time using toLocaleString */\n Long,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,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CAE9B;IACD,IAAW,SAAS,CAAC,CAAC,EAAE,OAAO,EAE9B;IAED,+FAA+F;IAC/F,IAAW,wBAAwB,IAAI,qBAAqB,GAAG,SAAS,CAEvE;IACD,IAAW,wBAAwB,CAAC,CAAC,EAAE,qBAAqB,GAAG,SAAS,EAEvE;IAED,8BAA8B;IACvB,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IA6B1E,4BAA4B;IACrB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAWxE,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAKrB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAkC5B;OACG;IACH,OAAO,CAAC,sBAAsB;IA4B9B,OAAO,CAAC,YAAY;CAGrB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOnD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,WAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,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ourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation\";\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
1
+ {"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASnD;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,WAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,GAAG,CAAC,UAAU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C;YAEzC,IAAI,CAAC,IAAI,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IACE,OAAO,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;wBACnC,OAAO,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EACjC,CAAC;wBACD,IAAI,CAAC,aAAa,EAAE,CAAC;oBACvB,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,cAAc,EAAE,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAa;QAChC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,CACL,UAAU,CAAC,GAAG,CAAC;QACf,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACzB,GAAG,KAAK,GAAG;QACX,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE;QAC/B,GAAG,KAAK,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE;QAChC,GAAG,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,CAChC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Focus\n */\n\nimport { Key } from \"ts-key-enum\";\nimport { Orientation } from \"../enums/Orientation\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Cross-Axis Arrow Key Callback\n * @internal\n */\nexport type CrossAxisArrowKeyFunc = (forward: boolean) => void;\n\n/** Keyboard Navigator for parent components\n * @internal\n */\nexport class ItemKeyboardNavigator {\n private _direction: Map<string, number>;\n private _itemCount = 0;\n private _orientation = Orientation.Horizontal;\n private _allowWrap = true;\n private _crossAxisArrowKeyHandler?: CrossAxisArrowKeyFunc;\n\n constructor(\n public onFocusItem: (index: number) => void,\n public onActivateItem: (index: number) => void\n ) {\n this._direction = new Map<string, number>([\n [Key.ArrowLeft, -1],\n [Key.ArrowUp, -1],\n [Key.ArrowRight, 1],\n [Key.ArrowDown, 1],\n ]);\n }\n\n /** The item count */\n public get itemCount(): number {\n return this._itemCount;\n }\n public set itemCount(count: number) {\n this._itemCount = count;\n }\n\n /** The primary orientation */\n public get orientation(): Orientation {\n return this._orientation;\n }\n public set orientation(orientation: Orientation) {\n this._orientation = orientation;\n }\n\n /** The allow wrap property controls whether the movement will stop at the first and last items or wrap */\n public get allowWrap(): boolean {\n return this._allowWrap;\n }\n public set allowWrap(v: boolean) {\n this._allowWrap = v;\n }\n\n /** Called when the arrow keys that run perpendicular to the primary orientation are pressed */\n public get crossAxisArrowKeyHandler(): CrossAxisArrowKeyFunc | undefined {\n return this._crossAxisArrowKeyHandler;\n }\n public set crossAxisArrowKeyHandler(v: CrossAxisArrowKeyFunc | undefined) {\n this._crossAxisArrowKeyHandler = v;\n }\n\n /** Handle KeyDown on items */\n public handleKeyDownEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.Home.valueOf():\n event.preventDefault();\n // Activate first item\n this.focusFirstItem();\n break;\n case Key.End.valueOf():\n event.preventDefault();\n // Activate last item\n this.focusLastItem();\n break;\n\n // Up and down are in keydown\n // because we need to prevent page scroll >:)\n case Key.ArrowUp.valueOf():\n case Key.ArrowDown.valueOf():\n this.determineOrientation(event, index);\n break;\n\n case Key.Enter.valueOf():\n case \" \":\n this.activateItem(index);\n break;\n }\n }\n\n /** Handle KeyUp on items */\n public handleKeyUpEvent(event: React.KeyboardEvent, index: number): void {\n const key = event.key;\n\n switch (key) {\n case Key.ArrowLeft.valueOf():\n case Key.ArrowRight.valueOf():\n this.determineOrientation(event, index);\n break;\n }\n }\n\n private focusFirstItem(): void {\n this.onFocusItem(0);\n }\n\n private focusLastItem(): void {\n const index = this._itemCount - 1;\n this.onFocusItem(index);\n }\n\n /** When an item list's orientation is set to vertical,\n * only up and down arrow should function.\n * In all other cases only left and right arrow function.\n */\n private determineOrientation(\n event: React.KeyboardEvent,\n index: number\n ): void {\n const key = event.key;\n const vertical = this._orientation === Orientation.Vertical;\n let proceed = false;\n\n if (vertical) {\n if (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf()) {\n event.preventDefault();\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowRight.valueOf());\n }\n } else {\n if (key === Key.ArrowLeft.valueOf() || key === Key.ArrowRight.valueOf()) {\n proceed = true;\n } else if (\n this.crossAxisArrowKeyHandler &&\n (key === Key.ArrowUp.valueOf() || key === Key.ArrowDown.valueOf())\n ) {\n this.crossAxisArrowKeyHandler(key === Key.ArrowDown.valueOf());\n }\n }\n\n if (proceed) {\n this.switchItemOnArrowPress(event, index);\n }\n }\n\n /** Either focus the next, previous, first, or last item depending on key pressed\n */\n private switchItemOnArrowPress(\n event: React.KeyboardEvent,\n index: number\n ): void {\n // Add or subtract depending on key pressed\n const pressed = event.key;\n const targetDirection = this._direction.get(pressed);\n\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n if (this._allowWrap) {\n if (\n pressed === Key.ArrowLeft.valueOf() ||\n pressed === Key.ArrowUp.valueOf()\n ) {\n this.focusLastItem();\n } else {\n this.focusFirstItem();\n }\n }\n }\n }\n }\n\n private activateItem(index: number): void {\n this.onActivateItem(index);\n }\n}\n\n/** Determines if a KeyboardEvent.key is an Item Navigation key\n * @internal\n */\nexport function isNavigationKey(key: string): boolean {\n return (\n isArrowKey(key) ||\n key === Key.Home.valueOf() ||\n key === Key.End.valueOf() ||\n key === \" \" ||\n key === Key.Enter.valueOf()\n );\n}\n\nfunction isArrowKey(key: string): boolean {\n return (\n key === Key.ArrowLeft.valueOf() ||\n key === Key.ArrowRight.valueOf() ||\n key === Key.ArrowUp.valueOf() ||\n key === Key.ArrowDown.valueOf()\n );\n}\n"]}
@@ -8,7 +8,7 @@
8
8
  import * as React from "react";
9
9
  import { Logger } from "@itwin/core-bentley";
10
10
  import { UiCore } from "../UiCore";
11
- // cSpell:ignore focusable
11
+ /* eslint-disable deprecation/deprecation */
12
12
  function isFocusable(element) {
13
13
  if (!element || element.tabIndex < 0)
14
14
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"FocusTrap.js","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,0BAA0B;AAE1B,SAAS,WAAW,CAAC,OAAoB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,IACE,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAE5D,OA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GACX,CACD,CACJ,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 Popup\n */\n\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiCore } from \"../UiCore\";\n\n// cSpell:ignore focusable\n\nfunction isFocusable(element: HTMLElement): boolean {\n if (!element || element.tabIndex < 0) return false;\n\n if (\n element.classList &&\n element.classList.contains(\"core-focus-trap-ignore-initial\")\n )\n return false;\n\n if (\n element.getAttribute &&\n typeof element.getAttribute === \"function\" &&\n element.getAttribute(\"disabled\") !== null\n )\n return false;\n\n if (\n element.tabIndex > 0 ||\n (element.tabIndex === 0 && element.getAttribute(\"tabIndex\") !== null)\n )\n return true;\n\n switch (element.nodeName) {\n case \"A\":\n const anchorElement = element as HTMLAnchorElement;\n return !!anchorElement.href && anchorElement.rel !== \"ignore\";\n case \"INPUT\":\n const inputElement = element as HTMLInputElement;\n return inputElement.type !== \"hidden\" && inputElement.type !== \"file\";\n case \"BUTTON\":\n case \"SELECT\":\n case \"TEXTAREA\":\n return true;\n default:\n return false;\n }\n}\n\nfunction processFindFocusableDescendant(\n element: HTMLElement | null\n): HTMLElement | null {\n if (!element) return null;\n\n for (const child of element.childNodes) {\n if (isFocusable(child as HTMLElement)) return child as HTMLElement;\n\n const focusable = processFindFocusableDescendant(child as HTMLElement);\n if (focusable) return focusable;\n }\n return null;\n}\n\nfunction findFirstFocusableDescendant(\n focusContainer: HTMLDivElement | null\n): HTMLElement | null {\n return processFindFocusableDescendant(focusContainer);\n}\n\nfunction processFindLastFocusableDescendant(\n element: HTMLElement\n): HTMLElement | null {\n for (let i = element.childNodes.length - 1; i >= 0; i--) {\n const child = element.childNodes[i] as HTMLElement;\n\n const focusable = processFindLastFocusableDescendant(child);\n if (focusable) return focusable;\n\n if (isFocusable(child)) return child;\n }\n return null;\n}\n\nfunction findLastFocusableDescendant(\n focusContainer: HTMLDivElement\n): HTMLElement | null {\n return processFindLastFocusableDescendant(focusContainer);\n}\n\nfunction getInitialFocusElement(\n focusContainer: HTMLDivElement | null,\n initialFocusSpec: React.RefObject<HTMLElement> | string | undefined\n): HTMLElement | null {\n if (!focusContainer) return null;\n\n if (initialFocusSpec) {\n if (typeof initialFocusSpec === \"string\") {\n const node = focusContainer.querySelector(initialFocusSpec);\n if (node) {\n return node as HTMLElement;\n } else {\n Logger.logError(\n `${UiCore.packageName}.FocusTrap`,\n `Unable to locate element via selector ${initialFocusSpec}`\n );\n }\n } else {\n return initialFocusSpec.current;\n }\n }\n return findFirstFocusableDescendant(focusContainer);\n}\n\nfunction attemptFocus(element: HTMLElement, preventScroll: boolean): boolean {\n if (!isFocusable(element)) return false;\n\n try {\n if (document.activeElement !== element)\n element.focus({\n preventScroll: preventScroll ? true : false,\n });\n } catch (e) {\n return false;\n }\n return document.activeElement === element;\n} // end attemptFocus\n\n/** Focus into first focusable element of a container.\n * @internal\n */\nexport function focusIntoContainer(\n focusContainer: HTMLDivElement,\n initialFocusElement?: React.RefObject<HTMLElement> | string\n): boolean {\n let result = false;\n const focusElement = getInitialFocusElement(\n focusContainer,\n initialFocusElement\n );\n if (focusElement) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n setTimeout(() => {\n attemptFocus(focusElement, true);\n }, 60);\n result = true;\n }\n return result;\n}\n\n/** Properties supported by [[FocusTrap]] component.\n * @internal\n */\nexport interface FocusTrapProps extends React.AllHTMLAttributes<any> {\n /** child components */\n children: React.ReactNode;\n /** if active is not true then no trapping of focus is attempted. */\n active?: boolean;\n /** restore focus to element that had focus before trap was activated */\n returnFocusOnDeactivate: boolean;\n /** Optional reference to element to receive focus when trap is activated. Optionally a CSS Selector\n * string can be supplied to locate an element in the FocusTrap container. If no specification is defined\n * the first focusable element is used.\n */\n initialFocusElement?: React.RefObject<HTMLElement> | string;\n}\n\n/** Trap Focus in container while trap is active.\n * @internal\n */\nexport function FocusTrap(props: FocusTrapProps) {\n const restoreFocusElement = React.useRef<Element | null>(null);\n const initialFocusElement = React.useRef<Element | null>(null);\n const focusContainer = React.useRef<HTMLDivElement | null>(null);\n const isInitialMount = React.useRef(true);\n const timeoutRef = React.useRef<number | undefined>();\n\n // Run on initial mount and when dependencies change. which could happen often.\n React.useEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n if (props.active) {\n if (props.returnFocusOnDeactivate) {\n restoreFocusElement.current = document.activeElement;\n }\n\n initialFocusElement.current = getInitialFocusElement(\n focusContainer.current,\n props.initialFocusElement\n );\n if (initialFocusElement.current) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n timeoutRef.current = window.setTimeout(() => {\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }, 60);\n }\n }\n }\n }, [\n props.children,\n props.initialFocusElement,\n props.active,\n props.returnFocusOnDeactivate,\n ]);\n\n // Return function to run only when FocusTrap is unmounted to restore focus\n React.useEffect(() => {\n return () => {\n window.clearTimeout(timeoutRef.current);\n if (restoreFocusElement.current)\n (restoreFocusElement.current as HTMLElement).focus({\n preventScroll: true,\n });\n };\n }, []);\n\n // this is hit if Shift tab is used.\n const cycleFocusToEnd = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (!props.active) return;\n\n if (focusContainer.current && event.target === focusContainer.current) {\n event.stopPropagation();\n event.preventDefault();\n const focusable = findLastFocusableDescendant(focusContainer.current);\n\n if (focusable) {\n focusable.focus();\n } else {\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }\n }\n },\n [props.active]\n );\n\n // this is hit if tab is used on last focusable item in child container.\n const cycleFocusToStart = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (!props.active) return;\n\n event.stopPropagation();\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n (initialFocusElement.current as HTMLElement).focus();\n },\n [props.active]\n );\n\n if (!props.children) return null;\n return (\n <>\n <div\n data-testid=\"focus-trap-div\"\n onFocus={cycleFocusToEnd}\n ref={focusContainer}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n style={{ outline: \"none\", WebkitTapHighlightColor: \"rgba(0,0,0,0)\" }}\n >\n {props.children}\n </div>\n <div\n data-testid=\"focus-trap-limit-div\"\n onFocus={cycleFocusToStart}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FocusTrap.js","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,4CAA4C;AAE5C,SAAS,WAAW,CAAC,OAAoB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,IACE,OAAO,CAAC,SAAS;QACjB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAE5D,OAAO,KAAK,CAAC;IAEf,IACE,OAAO,CAAC,YAAY;QACpB,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU;QAC1C,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI;QAEzC,OAAO,KAAK,CAAC;IAEf,IACE,OAAO,CAAC,QAAQ,GAAG,CAAC;QACpB,CAAC,OAAO,CAAC,QAAQ,KAAK,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;QAErE,OAAO,IAAI,CAAC;IAEd,QAAQ,O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,CAAC,mBAAmB,CAAC,OAAsB,EAAE,IAAI,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,wEAAwE;IACxE,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,CAAC,KAAuC,EAAE,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO;QAE1B,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,IACE,mBAAmB,CAAC,OAAO;YAC3B,mBAAmB,CAAC,OAAO,KAAK,QAAQ,CAAC,aAAa;YAErD,mBAAmB,CAAC,OAAuB,CAAC,KAAK,EAAE,CAAC;IACzD,CAAC,EACD,CAAC,KAAK,CAAC,MAAM,CAAC,CACf,CAAC;IAEF,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,CACL;QACE,4CACc,gBAAgB,EAC5B,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,cAAc;YACnB,kEAAkE;YAClE,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,IAEnE,KAAK,CAAC,QAAQ,CACX;QACN,4CACc,sBAAsB,EAClC,OAAO,EAAE,iBAAiB;YAC1B,kEAAkE;YAClE,QAAQ,EAAE,CAAC,GACX,CACD,CACJ,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 Popup\n */\n\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiCore } from \"../UiCore\";\n\n/* eslint-disable deprecation/deprecation */\n\nfunction isFocusable(element: HTMLElement): boolean {\n if (!element || element.tabIndex < 0) return false;\n\n if (\n element.classList &&\n element.classList.contains(\"core-focus-trap-ignore-initial\")\n )\n return false;\n\n if (\n element.getAttribute &&\n typeof element.getAttribute === \"function\" &&\n element.getAttribute(\"disabled\") !== null\n )\n return false;\n\n if (\n element.tabIndex > 0 ||\n (element.tabIndex === 0 && element.getAttribute(\"tabIndex\") !== null)\n )\n return true;\n\n switch (element.nodeName) {\n case \"A\":\n const anchorElement = element as HTMLAnchorElement;\n return !!anchorElement.href && anchorElement.rel !== \"ignore\";\n case \"INPUT\":\n const inputElement = element as HTMLInputElement;\n return inputElement.type !== \"hidden\" && inputElement.type !== \"file\";\n case \"BUTTON\":\n case \"SELECT\":\n case \"TEXTAREA\":\n return true;\n default:\n return false;\n }\n}\n\nfunction processFindFocusableDescendant(\n element: HTMLElement | null\n): HTMLElement | null {\n if (!element) return null;\n\n for (const child of element.childNodes) {\n if (isFocusable(child as HTMLElement)) return child as HTMLElement;\n\n const focusable = processFindFocusableDescendant(child as HTMLElement);\n if (focusable) return focusable;\n }\n return null;\n}\n\nfunction findFirstFocusableDescendant(\n focusContainer: HTMLDivElement | null\n): HTMLElement | null {\n return processFindFocusableDescendant(focusContainer);\n}\n\nfunction processFindLastFocusableDescendant(\n element: HTMLElement\n): HTMLElement | null {\n for (let i = element.childNodes.length - 1; i >= 0; i--) {\n const child = element.childNodes[i] as HTMLElement;\n\n const focusable = processFindLastFocusableDescendant(child);\n if (focusable) return focusable;\n\n if (isFocusable(child)) return child;\n }\n return null;\n}\n\nfunction findLastFocusableDescendant(\n focusContainer: HTMLDivElement\n): HTMLElement | null {\n return processFindLastFocusableDescendant(focusContainer);\n}\n\nfunction getInitialFocusElement(\n focusContainer: HTMLDivElement | null,\n initialFocusSpec: React.RefObject<HTMLElement> | string | undefined\n): HTMLElement | null {\n if (!focusContainer) return null;\n\n if (initialFocusSpec) {\n if (typeof initialFocusSpec === \"string\") {\n const node = focusContainer.querySelector(initialFocusSpec);\n if (node) {\n return node as HTMLElement;\n } else {\n Logger.logError(\n `${UiCore.packageName}.FocusTrap`,\n `Unable to locate element via selector ${initialFocusSpec}`\n );\n }\n } else {\n return initialFocusSpec.current;\n }\n }\n return findFirstFocusableDescendant(focusContainer);\n}\n\nfunction attemptFocus(element: HTMLElement, preventScroll: boolean): boolean {\n if (!isFocusable(element)) return false;\n\n try {\n if (document.activeElement !== element)\n element.focus({\n preventScroll: preventScroll ? true : false,\n });\n } catch (e) {\n return false;\n }\n return document.activeElement === element;\n} // end attemptFocus\n\n/** Focus into first focusable element of a container.\n * @internal\n */\nexport function focusIntoContainer(\n focusContainer: HTMLDivElement,\n initialFocusElement?: React.RefObject<HTMLElement> | string\n): boolean {\n let result = false;\n const focusElement = getInitialFocusElement(\n focusContainer,\n initialFocusElement\n );\n if (focusElement) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n setTimeout(() => {\n attemptFocus(focusElement, true);\n }, 60);\n result = true;\n }\n return result;\n}\n\n/** Properties supported by [[FocusTrap]] component.\n * @internal\n */\nexport interface FocusTrapProps extends React.AllHTMLAttributes<any> {\n /** child components */\n children: React.ReactNode;\n /** if active is not true then no trapping of focus is attempted. */\n active?: boolean;\n /** restore focus to element that had focus before trap was activated */\n returnFocusOnDeactivate: boolean;\n /** Optional reference to element to receive focus when trap is activated. Optionally a CSS Selector\n * string can be supplied to locate an element in the FocusTrap container. If no specification is defined\n * the first focusable element is used.\n */\n initialFocusElement?: React.RefObject<HTMLElement> | string;\n}\n\n/** Trap Focus in container while trap is active.\n * @internal\n */\nexport function FocusTrap(props: FocusTrapProps) {\n const restoreFocusElement = React.useRef<Element | null>(null);\n const initialFocusElement = React.useRef<Element | null>(null);\n const focusContainer = React.useRef<HTMLDivElement | null>(null);\n const isInitialMount = React.useRef(true);\n const timeoutRef = React.useRef<number | undefined>();\n\n // Run on initial mount and when dependencies change. which could happen often.\n React.useEffect(() => {\n if (isInitialMount.current) {\n isInitialMount.current = false;\n if (props.active) {\n if (props.returnFocusOnDeactivate) {\n restoreFocusElement.current = document.activeElement;\n }\n\n initialFocusElement.current = getInitialFocusElement(\n focusContainer.current,\n props.initialFocusElement\n );\n if (initialFocusElement.current) {\n // delay setting focus immediately because in some browsers other focus events happen when popup is initially opened.\n timeoutRef.current = window.setTimeout(() => {\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }, 60);\n }\n }\n }\n }, [\n props.children,\n props.initialFocusElement,\n props.active,\n props.returnFocusOnDeactivate,\n ]);\n\n // Return function to run only when FocusTrap is unmounted to restore focus\n React.useEffect(() => {\n return () => {\n window.clearTimeout(timeoutRef.current);\n if (restoreFocusElement.current)\n (restoreFocusElement.current as HTMLElement).focus({\n preventScroll: true,\n });\n };\n }, []);\n\n // this is hit if Shift tab is used.\n const cycleFocusToEnd = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (!props.active) return;\n\n if (focusContainer.current && event.target === focusContainer.current) {\n event.stopPropagation();\n event.preventDefault();\n const focusable = findLastFocusableDescendant(focusContainer.current);\n\n if (focusable) {\n focusable.focus();\n } else {\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n attemptFocus(initialFocusElement.current as HTMLElement, true);\n }\n }\n },\n [props.active]\n );\n\n // this is hit if tab is used on last focusable item in child container.\n const cycleFocusToStart = React.useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (!props.active) return;\n\n event.stopPropagation();\n if (\n initialFocusElement.current &&\n initialFocusElement.current !== document.activeElement\n )\n (initialFocusElement.current as HTMLElement).focus();\n },\n [props.active]\n );\n\n if (!props.children) return null;\n return (\n <>\n <div\n data-testid=\"focus-trap-div\"\n onFocus={cycleFocusToEnd}\n ref={focusContainer}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n style={{ outline: \"none\", WebkitTapHighlightColor: \"rgba(0,0,0,0)\" }}\n >\n {props.children}\n </div>\n <div\n data-testid=\"focus-trap-limit-div\"\n onFocus={cycleFocusToStart}\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n />\n </>\n );\n}\n"]}