@itwin/core-react 4.13.4 → 4.14.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 (228) hide show
  1. package/CHANGELOG.md +5 -8
  2. package/lib/cjs/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  3. package/lib/cjs/core-react/autosuggest/AutoSuggest.js +1 -5
  4. package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
  5. package/lib/cjs/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  6. package/lib/cjs/core-react/contextmenu/ContextMenu.js +4 -21
  7. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  8. package/lib/cjs/core-react/contextmenu/ContextMenu.scss +2 -0
  9. package/lib/cjs/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  10. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +0 -2
  11. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  12. package/lib/cjs/core-react/contextmenu/ContextSubMenu.d.ts.map +1 -1
  13. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +2 -11
  14. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  15. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.d.ts.map +1 -1
  16. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +1 -5
  17. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  18. package/lib/cjs/core-react/dialog/Dialog.d.ts.map +1 -1
  19. package/lib/cjs/core-react/dialog/Dialog.js +1 -3
  20. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  21. package/lib/cjs/core-react/dialog/GlobalDialog.d.ts.map +1 -1
  22. package/lib/cjs/core-react/dialog/GlobalDialog.js +0 -1
  23. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  24. package/lib/cjs/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  25. package/lib/cjs/core-react/elementseparator/ElementSeparator.js +1 -5
  26. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  27. package/lib/cjs/core-react/elementseparator/ElementSeparator.scss +1 -0
  28. package/lib/cjs/core-react/expandable/ExpandableList.d.ts.map +1 -1
  29. package/lib/cjs/core-react/expandable/ExpandableList.js +0 -1
  30. package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
  31. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  32. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js +0 -2
  33. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  34. package/lib/cjs/core-react/focustrap/FocusTrap.d.ts.map +1 -1
  35. package/lib/cjs/core-react/focustrap/FocusTrap.js +1 -14
  36. package/lib/cjs/core-react/focustrap/FocusTrap.js.map +1 -1
  37. package/lib/cjs/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  38. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +0 -6
  39. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  40. package/lib/cjs/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
  41. package/lib/cjs/core-react/icons/ConditionalIconItem.js +0 -8
  42. package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
  43. package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
  44. package/lib/cjs/core-react/icons/IconComponent.js +0 -1
  45. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  46. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
  47. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js +0 -4
  48. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  49. package/lib/cjs/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  50. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js +0 -1
  51. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  52. package/lib/cjs/core-react/listbox/Listbox.d.ts.map +1 -1
  53. package/lib/cjs/core-react/listbox/Listbox.js +0 -11
  54. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  55. package/lib/cjs/core-react/messagebox/MessageBox.js +0 -2
  56. package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
  57. package/lib/cjs/core-react/notification/MessageRenderer.d.ts.map +1 -1
  58. package/lib/cjs/core-react/notification/MessageRenderer.js +0 -3
  59. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  60. package/lib/cjs/core-react/popup/Popup.d.ts.map +1 -1
  61. package/lib/cjs/core-react/popup/Popup.js +2 -14
  62. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  63. package/lib/cjs/core-react/radialmenu/Annulus.d.ts.map +1 -1
  64. package/lib/cjs/core-react/radialmenu/Annulus.js +1 -1
  65. package/lib/cjs/core-react/radialmenu/Annulus.js.map +1 -1
  66. package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts +6 -5
  67. package/lib/cjs/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  68. package/lib/cjs/core-react/radialmenu/RadialMenu.js +4 -9
  69. package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
  70. package/lib/cjs/core-react/searchbox/SearchBox.d.ts.map +1 -1
  71. package/lib/cjs/core-react/searchbox/SearchBox.js +0 -7
  72. package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
  73. package/lib/cjs/core-react/settings/SettingsContainer.d.ts.map +1 -1
  74. package/lib/cjs/core-react/settings/SettingsContainer.js +0 -1
  75. package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
  76. package/lib/cjs/core-react/tabs/Tabs.d.ts.map +1 -1
  77. package/lib/cjs/core-react/tabs/Tabs.js +0 -4
  78. package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
  79. package/lib/cjs/core-react/text/FilteredText.d.ts.map +1 -1
  80. package/lib/cjs/core-react/text/FilteredText.js +0 -3
  81. package/lib/cjs/core-react/text/FilteredText.js.map +1 -1
  82. package/lib/cjs/core-react/tree/Tree.d.ts.map +1 -1
  83. package/lib/cjs/core-react/tree/Tree.js +0 -3
  84. package/lib/cjs/core-react/tree/Tree.js.map +1 -1
  85. package/lib/cjs/core-react/utils/IconHelper.d.ts.map +1 -1
  86. package/lib/cjs/core-react/utils/IconHelper.js +0 -8
  87. package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
  88. package/lib/cjs/core-react/utils/IconWebComponent.d.ts.map +1 -1
  89. package/lib/cjs/core-react/utils/IconWebComponent.js +0 -1
  90. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  91. package/lib/cjs/core-react/utils/ScrollPositionMaintainer.d.ts.map +1 -1
  92. package/lib/cjs/core-react/utils/ScrollPositionMaintainer.js +0 -2
  93. package/lib/cjs/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  94. package/lib/cjs/core-react/utils/flattenChildren.d.ts.map +1 -1
  95. package/lib/cjs/core-react/utils/flattenChildren.js +0 -1
  96. package/lib/cjs/core-react/utils/flattenChildren.js.map +1 -1
  97. package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.d.ts.map +1 -1
  98. package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.js +0 -1
  99. package/lib/cjs/core-react/utils/hooks/ResizeObserverPolyfill.js.map +1 -1
  100. package/lib/cjs/core-react/utils/hooks/useEventListener.d.ts.map +1 -1
  101. package/lib/cjs/core-react/utils/hooks/useEventListener.js +0 -1
  102. package/lib/cjs/core-react/utils/hooks/useEventListener.js.map +1 -1
  103. package/lib/cjs/core-react/utils/hooks/useProximityToMouse.d.ts.map +1 -1
  104. package/lib/cjs/core-react/utils/hooks/useProximityToMouse.js +0 -1
  105. package/lib/cjs/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  106. package/lib/cjs/core-react/utils/hooks/useRefs.d.ts.map +1 -1
  107. package/lib/cjs/core-react/utils/hooks/useRefs.js +0 -2
  108. package/lib/cjs/core-react/utils/hooks/useRefs.js.map +1 -1
  109. package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  110. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +1 -17
  111. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  112. package/lib/cjs/core-react/utils/hooks/useWidgetOpacityContext.d.ts.map +1 -1
  113. package/lib/cjs/core-react/utils/hooks/useWidgetOpacityContext.js +1 -1
  114. package/lib/cjs/core-react/utils/hooks/useWidgetOpacityContext.js.map +1 -1
  115. package/lib/esm/core-react/autosuggest/AutoSuggest.d.ts.map +1 -1
  116. package/lib/esm/core-react/autosuggest/AutoSuggest.js +1 -5
  117. package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
  118. package/lib/esm/core-react/contextmenu/ContextMenu.d.ts.map +1 -1
  119. package/lib/esm/core-react/contextmenu/ContextMenu.js +4 -21
  120. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  121. package/lib/esm/core-react/contextmenu/ContextMenu.scss +2 -0
  122. package/lib/esm/core-react/contextmenu/ContextMenuItem.d.ts.map +1 -1
  123. package/lib/esm/core-react/contextmenu/ContextMenuItem.js +0 -2
  124. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  125. package/lib/esm/core-react/contextmenu/ContextSubMenu.d.ts.map +1 -1
  126. package/lib/esm/core-react/contextmenu/ContextSubMenu.js +2 -11
  127. package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  128. package/lib/esm/core-react/contextmenu/GlobalContextMenu.d.ts.map +1 -1
  129. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +1 -5
  130. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  131. package/lib/esm/core-react/dialog/Dialog.d.ts.map +1 -1
  132. package/lib/esm/core-react/dialog/Dialog.js +1 -3
  133. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  134. package/lib/esm/core-react/dialog/GlobalDialog.d.ts.map +1 -1
  135. package/lib/esm/core-react/dialog/GlobalDialog.js +0 -1
  136. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  137. package/lib/esm/core-react/elementseparator/ElementSeparator.d.ts.map +1 -1
  138. package/lib/esm/core-react/elementseparator/ElementSeparator.js +1 -5
  139. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  140. package/lib/esm/core-react/elementseparator/ElementSeparator.scss +1 -0
  141. package/lib/esm/core-react/expandable/ExpandableList.d.ts.map +1 -1
  142. package/lib/esm/core-react/expandable/ExpandableList.js +0 -1
  143. package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
  144. package/lib/esm/core-react/focus/ItemKeyboardNavigator.d.ts.map +1 -1
  145. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js +0 -2
  146. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  147. package/lib/esm/core-react/focustrap/FocusTrap.d.ts.map +1 -1
  148. package/lib/esm/core-react/focustrap/FocusTrap.js +1 -14
  149. package/lib/esm/core-react/focustrap/FocusTrap.js.map +1 -1
  150. package/lib/esm/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  151. package/lib/esm/core-react/hocs/withOnOutsideClick.js +0 -6
  152. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  153. package/lib/esm/core-react/icons/ConditionalIconItem.d.ts.map +1 -1
  154. package/lib/esm/core-react/icons/ConditionalIconItem.js +0 -8
  155. package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
  156. package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
  157. package/lib/esm/core-react/icons/IconComponent.js +0 -1
  158. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  159. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.d.ts.map +1 -1
  160. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js +0 -4
  161. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  162. package/lib/esm/core-react/inputs/numberinput/NumberInput.d.ts.map +1 -1
  163. package/lib/esm/core-react/inputs/numberinput/NumberInput.js +0 -1
  164. package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  165. package/lib/esm/core-react/listbox/Listbox.d.ts.map +1 -1
  166. package/lib/esm/core-react/listbox/Listbox.js +0 -11
  167. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  168. package/lib/esm/core-react/messagebox/MessageBox.js +0 -2
  169. package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
  170. package/lib/esm/core-react/notification/MessageRenderer.d.ts.map +1 -1
  171. package/lib/esm/core-react/notification/MessageRenderer.js +0 -3
  172. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  173. package/lib/esm/core-react/popup/Popup.d.ts.map +1 -1
  174. package/lib/esm/core-react/popup/Popup.js +2 -14
  175. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  176. package/lib/esm/core-react/radialmenu/Annulus.d.ts.map +1 -1
  177. package/lib/esm/core-react/radialmenu/Annulus.js +1 -1
  178. package/lib/esm/core-react/radialmenu/Annulus.js.map +1 -1
  179. package/lib/esm/core-react/radialmenu/RadialMenu.d.ts +6 -5
  180. package/lib/esm/core-react/radialmenu/RadialMenu.d.ts.map +1 -1
  181. package/lib/esm/core-react/radialmenu/RadialMenu.js +4 -9
  182. package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
  183. package/lib/esm/core-react/searchbox/SearchBox.d.ts.map +1 -1
  184. package/lib/esm/core-react/searchbox/SearchBox.js +0 -7
  185. package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
  186. package/lib/esm/core-react/settings/SettingsContainer.d.ts.map +1 -1
  187. package/lib/esm/core-react/settings/SettingsContainer.js +0 -1
  188. package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
  189. package/lib/esm/core-react/tabs/Tabs.d.ts.map +1 -1
  190. package/lib/esm/core-react/tabs/Tabs.js +0 -4
  191. package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
  192. package/lib/esm/core-react/text/FilteredText.d.ts.map +1 -1
  193. package/lib/esm/core-react/text/FilteredText.js +0 -3
  194. package/lib/esm/core-react/text/FilteredText.js.map +1 -1
  195. package/lib/esm/core-react/tree/Tree.d.ts.map +1 -1
  196. package/lib/esm/core-react/tree/Tree.js +0 -3
  197. package/lib/esm/core-react/tree/Tree.js.map +1 -1
  198. package/lib/esm/core-react/utils/IconHelper.d.ts.map +1 -1
  199. package/lib/esm/core-react/utils/IconHelper.js +0 -8
  200. package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
  201. package/lib/esm/core-react/utils/IconWebComponent.d.ts.map +1 -1
  202. package/lib/esm/core-react/utils/IconWebComponent.js +0 -1
  203. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  204. package/lib/esm/core-react/utils/ScrollPositionMaintainer.d.ts.map +1 -1
  205. package/lib/esm/core-react/utils/ScrollPositionMaintainer.js +0 -2
  206. package/lib/esm/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  207. package/lib/esm/core-react/utils/flattenChildren.d.ts.map +1 -1
  208. package/lib/esm/core-react/utils/flattenChildren.js +0 -1
  209. package/lib/esm/core-react/utils/flattenChildren.js.map +1 -1
  210. package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.d.ts.map +1 -1
  211. package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.js +0 -1
  212. package/lib/esm/core-react/utils/hooks/ResizeObserverPolyfill.js.map +1 -1
  213. package/lib/esm/core-react/utils/hooks/useEventListener.d.ts.map +1 -1
  214. package/lib/esm/core-react/utils/hooks/useEventListener.js +0 -1
  215. package/lib/esm/core-react/utils/hooks/useEventListener.js.map +1 -1
  216. package/lib/esm/core-react/utils/hooks/useProximityToMouse.d.ts.map +1 -1
  217. package/lib/esm/core-react/utils/hooks/useProximityToMouse.js +0 -1
  218. package/lib/esm/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  219. package/lib/esm/core-react/utils/hooks/useRefs.d.ts.map +1 -1
  220. package/lib/esm/core-react/utils/hooks/useRefs.js +0 -2
  221. package/lib/esm/core-react/utils/hooks/useRefs.js.map +1 -1
  222. package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
  223. package/lib/esm/core-react/utils/hooks/useResizeObserver.js +1 -17
  224. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  225. package/lib/esm/core-react/utils/hooks/useWidgetOpacityContext.d.ts.map +1 -1
  226. package/lib/esm/core-react/utils/hooks/useWidgetOpacityContext.js +1 -1
  227. package/lib/esm/core-react/utils/hooks/useWidgetOpacityContext.js.map +1 -1
  228. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ItemKeyboardNavigator.js","sourceRoot":"","sources":["../../../../src/core-react/focus/ItemKeyboardNavigator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,6CAAkC;AAClC,sDAAmD;AAOnD;;GAEG;AACH,MAAa,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,yBAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,iBAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,iBAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,iBAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YACnB,CAAC,iBAAG,CAAC,SAAS,EAAE,CAAC,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB;IACrB,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,C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CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,uBAAuB;gBACvB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IACE,OAAO,KAAK,iBAAG,CAAC,SAAS,CAAC,OAAO,EAAE;wBACnC,OAAO,KAAK,iBAAG,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;AA/KD,sDA+KC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,CACL,UAAU,CAAC,GAAG,CAAC;QACf,GAAG,KAAK,iBAAG,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,GAAG,KAAK,iBAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACzB,GAAG,KAAK,GAAG;QACX,GAAG,KAAK,iBAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AARD,0CAQC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,GAAG,KAAK,iBAAG,CAAC,SAAS,CAAC,OAAO,EAAE;QAC/B,GAAG,KAAK,iBAAG,CAAC,UAAU,CAAC,OAAO,EAAE;QAChC,GAAG,KAAK,iBAAG,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,KAAK,iBAAG,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/** 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 // istanbul ignore else\n if (targetDirection) {\n const newIndex = index + targetDirection;\n\n if (0 <= newIndex && newIndex < this._itemCount) {\n this.onFocusItem(newIndex);\n } else {\n // istanbul ignore 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,6CAAkC;AAClC,sDAAmD;AAOnD;;GAEG;AACH,MAAa,qBAAqB;IAOhC,YACS,WAAoC,EACpC,cAAuC;QADvC,gBAAW,GAAX,WAAW,CAAyB;QACpC,mBAAc,GAAd,cAAc,CAAyB;QAPxC,eAAU,GAAG,CAAC,CAAC;QACf,iBAAY,GAAG,yBAAW,CAAC,UAAU,CAAC;QACtC,eAAU,GAAG,IAAI,CAAC;QAOxB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAiB;YACxC,CAAC,iBAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YACnB,CAAC,iBAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACjB,CAAC,iBAAG,CAAC,UAAU,EAAE,CAAC,CAAC;YACnB,CAAC,iBAAG,CAAC,SAAS,EAAE,CAAC,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,qBAAqB;IACrB,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,IAA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BACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IACE,OAAO,KAAK,iBAAG,CAAC,SAAS,CAAC,OAAO,EAAE;wBACnC,OAAO,KAAK,iBAAG,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;AA7KD,sDA6KC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,CACL,UAAU,CAAC,GAAG,CAAC;QACf,GAAG,KAAK,iBAAG,CAAC,IAAI,CAAC,OAAO,EAAE;QAC1B,GAAG,KAAK,iBAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACzB,GAAG,KAAK,GAAG;QACX,GAAG,KAAK,iBAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AARD,0CAQC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,CACL,GAAG,KAAK,iBAAG,CAAC,SAAS,CAAC,OAAO,EAAE;QAC/B,GAAG,KAAK,iBAAG,CAAC,UAAU,CAAC,OAAO,EAAE;QAChC,GAAG,KAAK,iBAAG,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7B,GAAG,KAAK,iBAAG,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/** 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 +1 @@
1
- {"version":3,"file":"FocusTrap.d.ts","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkI/B;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,cAAc,EAC9B,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,GAC1D,OAAO,CAcT;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC;IAClE,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,uBAAuB,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC;CAC7D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,4BA+G9C"}
1
+ {"version":3,"file":"FocusTrap.d.ts","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA0H/B;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,cAAc,EAC9B,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,GAC1D,OAAO,CAcT;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC;IAClE,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,uBAAuB,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC;CAC7D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,4BA0G9C"}
@@ -41,11 +41,9 @@ function isFocusable(element) {
41
41
  }
42
42
  }
43
43
  function processFindFocusableDescendant(element) {
44
- // istanbul ignore next
45
44
  if (!element)
46
45
  return null;
47
46
  for (const child of element.childNodes) {
48
- // istanbul ignore else
49
47
  if (isFocusable(child))
50
48
  return child;
51
49
  const focusable = processFindFocusableDescendant(child);
@@ -61,10 +59,8 @@ function processFindLastFocusableDescendant(element) {
61
59
  for (let i = element.childNodes.length - 1; i >= 0; i--) {
62
60
  const child = element.childNodes[i];
63
61
  const focusable = processFindLastFocusableDescendant(child);
64
- // istanbul ignore else
65
62
  if (focusable)
66
63
  return focusable;
67
- // istanbul ignore else
68
64
  if (isFocusable(child))
69
65
  return child;
70
66
  }
@@ -74,7 +70,6 @@ function findLastFocusableDescendant(focusContainer) {
74
70
  return processFindLastFocusableDescendant(focusContainer);
75
71
  }
76
72
  function getInitialFocusElement(focusContainer, initialFocusSpec) {
77
- // istanbul ignore next
78
73
  if (!focusContainer)
79
74
  return null;
80
75
  if (initialFocusSpec) {
@@ -94,18 +89,15 @@ function getInitialFocusElement(focusContainer, initialFocusSpec) {
94
89
  return findFirstFocusableDescendant(focusContainer);
95
90
  }
96
91
  function attemptFocus(element, preventScroll) {
97
- // istanbul ignore next
98
92
  if (!isFocusable(element))
99
93
  return false;
100
94
  try {
101
- // istanbul ignore else
102
95
  if (document.activeElement !== element)
103
96
  element.focus({
104
- preventScroll: preventScroll ? true : /* istanbul ignore next */ false,
97
+ preventScroll: preventScroll ? true : false,
105
98
  });
106
99
  }
107
100
  catch (e) {
108
- // istanbul ignore next
109
101
  return false;
110
102
  }
111
103
  return document.activeElement === element;
@@ -137,7 +129,6 @@ function FocusTrap(props) {
137
129
  const timeoutRef = React.useRef();
138
130
  // Run on initial mount and when dependencies change. which could happen often.
139
131
  React.useEffect(() => {
140
- // istanbul ignore else
141
132
  if (isInitialMount.current) {
142
133
  isInitialMount.current = false;
143
134
  if (props.active) {
@@ -171,14 +162,12 @@ function FocusTrap(props) {
171
162
  }, []);
172
163
  // this is hit if Shift tab is used.
173
164
  const cycleFocusToEnd = React.useCallback((event) => {
174
- // istanbul ignore next
175
165
  if (!props.active)
176
166
  return;
177
167
  if (focusContainer.current && event.target === focusContainer.current) {
178
168
  event.stopPropagation();
179
169
  event.preventDefault();
180
170
  const focusable = findLastFocusableDescendant(focusContainer.current);
181
- // istanbul ignore else
182
171
  if (focusable) {
183
172
  focusable.focus();
184
173
  }
@@ -191,11 +180,9 @@ function FocusTrap(props) {
191
180
  }, [props.active]);
192
181
  // this is hit if tab is used on last focusable item in child container.
193
182
  const cycleFocusToStart = React.useCallback((event) => {
194
- // istanbul ignore next
195
183
  if (!props.active)
196
184
  return;
197
185
  event.stopPropagation();
198
- // istanbul ignore else
199
186
  if (initialFocusElement.current &&
200
187
  initialFocusElement.current !== document.activeElement)
201
188
  initialFocusElement.current.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"FocusTrap.js","sourceRoot":"","sources":["../../../../src/core-react/focustrap/FocusTrap.tsx"],"names":[],"mappings":";AAAA;;;gG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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;AA/GD,8BA+GC","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 // istanbul ignore next\n if (!element) return null;\n\n for (const child of element.childNodes) {\n // istanbul ignore else\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 // istanbul ignore else\n if (focusable) return focusable;\n\n // istanbul ignore else\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 // istanbul ignore next\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 // istanbul ignore next\n if (!isFocusable(element)) return false;\n\n try {\n // istanbul ignore else\n if (document.activeElement !== element)\n element.focus({\n preventScroll: preventScroll ? true : /* istanbul ignore next */ false,\n });\n } catch (e) {\n // istanbul ignore next\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 // istanbul ignore else\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 // istanbul ignore next\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 // istanbul ignore else\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 // istanbul ignore next\n if (!props.active) return;\n\n event.stopPropagation();\n // istanbul ignore else\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,+BAA+B;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O,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;AA1GD,8BA0GC","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 +1 @@
1
- {"version":3,"file":"withOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5C,8HAA8H;IAC9H,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,+GAEG,UAAU,KAAK,GAAG,4BACtC,OAAO,qBACD,OAAO;;QAKvB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAenC,gBAAgB;iCACiB,UAAU;QAW3C,gBAAgB;uCACuB,YAAY;QAWnD,gBAAgB;qCACqB,YAAY;sEAgBrB,cAAc,GAAG,IAAI;;;QA+BjD,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;QA5GhB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAenC,gBAAgB;iCACiB,UAAU;QAW3C,gBAAgB;uCACuB,YAAY;QAWnD,gBAAgB;qCACqB,YAAY;sEAgBrB,cAAc,GAAG,IAAI;;;QA+BjD,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;CAgCnB,CAAC"}
1
+ {"version":3,"file":"withOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5C,8HAA8H;IAC9H,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,+GAEG,UAAU,KAAK,GAAG,4BACtC,OAAO,qBACD,OAAO;;QAKvB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAanD,gBAAgB;0BACS,UAAU;QAanC,gBAAgB;iCACiB,UAAU;QAW3C,gBAAgB;uCACuB,YAAY;QAUnD,gBAAgB;qCACqB,YAAY;sEAerB,cAAc,GAAG,IAAI;;;QA8BjD,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;QAtGhB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAanD,gBAAgB;0BACS,UAAU;QAanC,gBAAgB;iCACiB,UAAU;QAW3C,gBAAgB;uCACuB,YAAY;QAUnD,gBAAgB;qCACqB,YAAY;sEAerB,cAAc,GAAG,IAAI;;;QA8BjD,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;CAgCnB,CAAC"}
@@ -31,7 +31,6 @@ const withOnOutsideClick = (Component, defaultOnOutsideClick, useCapture = true,
31
31
  /** @internal */
32
32
  this.handleDocumentPointerDown = (e) => {
33
33
  this.isDownOutside = true;
34
- // istanbul ignore else
35
34
  if (this.outsideClickContainerDiv) {
36
35
  // typically e.target test for instance of Node, but this is not working from pop out windows
37
36
  this.isDownOutside =
@@ -42,7 +41,6 @@ const withOnOutsideClick = (Component, defaultOnOutsideClick, useCapture = true,
42
41
  /** @internal */
43
42
  this.handleDocumentPointerUp = (e) => {
44
43
  let isUpOutside = true;
45
- // istanbul ignore else
46
44
  if (this.outsideClickContainerDiv) {
47
45
  // typically e.target test for instance of Node, but this is not working from pop out windows
48
46
  isUpOutside =
@@ -66,7 +64,6 @@ const withOnOutsideClick = (Component, defaultOnOutsideClick, useCapture = true,
66
64
  return true;
67
65
  }
68
66
  else {
69
- // istanbul ignore else
70
67
  if (element.parentElement && this.isInCorePopup(element.parentElement))
71
68
  return true;
72
69
  }
@@ -74,9 +71,7 @@ const withOnOutsideClick = (Component, defaultOnOutsideClick, useCapture = true,
74
71
  }
75
72
  /** @internal */
76
73
  onOutsideClick(e) {
77
- // istanbul ignore else
78
74
  if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {
79
- // istanbul ignore else
80
75
  if (!this.props.closeOnNestedPopupOutsideClick &&
81
76
  this.isInCorePopup(e.target))
82
77
  return;
@@ -87,7 +82,6 @@ const withOnOutsideClick = (Component, defaultOnOutsideClick, useCapture = true,
87
82
  return defaultOnOutsideClick(e);
88
83
  }
89
84
  getParentDocument() {
90
- // istanbul ignore next
91
85
  return this.outsideClickContainerDiv?.ownerDocument ?? document;
92
86
  }
93
87
  componentDidMount() {
@@ -1 +1 @@
1
- {"version":3,"file":"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B,EAAE,GAAG,KAAK,EAAE,GAChE,IAAI,CAAC,KAAK,CAAC;YACb,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAM,KAAwB,GAAI,CACxC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AArJW,QAAA,kBAAkB,sBAqJ7B","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\nimport * as React from \"react\";\n\n/** Properties for [[withOnOutsideClick]] React higher-order component\n * @public\n */\nexport interface WithOnOutsideClickProps {\n /** Outside click callback function */\n onOutsideClick?: (event: MouseEvent) => any;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n}\n\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\n * @public\n */\nexport const withOnOutsideClick = <ComponentProps extends {}>(\n Component: React.ComponentType<ComponentProps>,\n defaultOnOutsideClick?: (event: MouseEvent) => any,\n useCapture: boolean = true,\n usePointerEvents: boolean = true\n) => {\n return class WithOnOutsideClick extends React.PureComponent<\n ComponentProps & WithOnOutsideClickProps\n > {\n /** @internal */\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\n /** @internal */\n public isDownOutside = false;\n\n /** @internal */\n public isInCorePopup(element: HTMLElement): boolean {\n if (element.nodeName === \"DIV\") {\n if (element.classList && element.classList.contains(\"core-popup\"))\n return true;\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n } else {\n // istanbul ignore else\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n }\n return false;\n }\n\n /** @internal */\n public onOutsideClick(e: MouseEvent) {\n // istanbul ignore else\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\n // istanbul ignore else\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(e.target as HTMLElement)\n )\n return;\n }\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(e);\n else if (defaultOnOutsideClick) return defaultOnOutsideClick(e);\n }\n\n /** @internal */\n public handleDocumentClick = (e: MouseEvent) => {\n if (\n !this.outsideClickContainerDiv ||\n !(e.target instanceof Node) ||\n this.outsideClickContainerDiv.contains(e.target)\n )\n return;\n\n return this.onOutsideClick(e);\n };\n\n /** @internal */\n public handleDocumentPointerDown = (e: PointerEvent) => {\n this.isDownOutside = true;\n // istanbul ignore else\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n this.isDownOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n };\n\n /** @internal */\n public handleDocumentPointerUp = (e: PointerEvent) => {\n let isUpOutside = true;\n // istanbul ignore else\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n isUpOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n\n const isOutsideClick = isUpOutside && this.isDownOutside;\n this.isDownOutside = false;\n isOutsideClick && this.onOutsideClick(e);\n };\n\n public handleOutsideClickContainerDivSet = (\n outsideClickContainerDiv: HTMLDivElement | null\n ) => {\n this.outsideClickContainerDiv = outsideClickContainerDiv;\n };\n\n public getParentDocument() {\n // istanbul ignore next\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\n }\n\n public override componentDidMount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.addEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.addEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.addEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n /** @internal */\n public override componentWillUnmount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.removeEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.removeEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.removeEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n public override render() {\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } =\n this.props;\n return (\n <div ref={this.handleOutsideClickContainerDivSet}>\n <Component {...(props as ComponentProps)} />\n </div>\n );\n }\n };\n};\n"]}
1
+ {"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAY/B;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAChC,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EAC1B,mBAA4B,IAAI,EAChC,EAAE;IACF,OAAO,MAAM,kBAAmB,SAAQ,KAAK,CAAC,aAE7C;QAFM;;YAGL,gBAAgB;YACT,6BAAwB,GAA2B,IAAI,CAAC;YAC/D,gBAAgB;YACT,kBAAa,GAAG,KAAK,CAAC;YA8B7B,gBAAgB;YACT,wBAAmB,GAAG,CAAC,CAAa,EAAE,EAAE;gBAC7C,IACE,CAAC,IAAI,CAAC,wBAAwB;oBAC9B,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC;oBAC3B,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;oBAEhD,OAAO;gBAET,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAChC,CAAC,CAAC;YAEF,gBAAgB;YACT,8BAAyB,GAAG,CAAC,CAAe,EAAE,EAAE;gBACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;gBAC1B,IAAI,IAAI,CAAC,wBAAwB,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AAC,yBAAyB,EAC9B,UAAU,CACX,CAAC;gBACF,0BAA0B,CAAC,mBAAmB,CAC5C,WAAW,EACX,IAAI,CAAC,uBAAuB,EAC5B,UAAU,CACX,CAAC;YACJ,CAAC;;gBACC,0BAA0B,CAAC,mBAAmB,CAC5C,OAAO,EACP,IAAI,CAAC,mBAAmB,EACxB,UAAU,CACX,CAAC;QACN,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAChE,IAAI,CAAC,KAAK,CAAC;YACb,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAM,KAAwB,GAAI,CACxC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA/IW,QAAA,kBAAkB,sBA+I7B","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\nimport * as React from \"react\";\n\n/** Properties for [[withOnOutsideClick]] React higher-order component\n * @public\n */\nexport interface WithOnOutsideClickProps {\n /** Outside click callback function */\n onOutsideClick?: (event: MouseEvent) => any;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n}\n\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\n * @public\n */\nexport const withOnOutsideClick = <ComponentProps extends {}>(\n Component: React.ComponentType<ComponentProps>,\n defaultOnOutsideClick?: (event: MouseEvent) => any,\n useCapture: boolean = true,\n usePointerEvents: boolean = true\n) => {\n return class WithOnOutsideClick extends React.PureComponent<\n ComponentProps & WithOnOutsideClickProps\n > {\n /** @internal */\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\n /** @internal */\n public isDownOutside = false;\n\n /** @internal */\n public isInCorePopup(element: HTMLElement): boolean {\n if (element.nodeName === \"DIV\") {\n if (element.classList && element.classList.contains(\"core-popup\"))\n return true;\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n } else {\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n }\n return false;\n }\n\n /** @internal */\n public onOutsideClick(e: MouseEvent) {\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(e.target as HTMLElement)\n )\n return;\n }\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(e);\n else if (defaultOnOutsideClick) return defaultOnOutsideClick(e);\n }\n\n /** @internal */\n public handleDocumentClick = (e: MouseEvent) => {\n if (\n !this.outsideClickContainerDiv ||\n !(e.target instanceof Node) ||\n this.outsideClickContainerDiv.contains(e.target)\n )\n return;\n\n return this.onOutsideClick(e);\n };\n\n /** @internal */\n public handleDocumentPointerDown = (e: PointerEvent) => {\n this.isDownOutside = true;\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n this.isDownOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n };\n\n /** @internal */\n public handleDocumentPointerUp = (e: PointerEvent) => {\n let isUpOutside = true;\n if (this.outsideClickContainerDiv) {\n // typically e.target test for instance of Node, but this is not working from pop out windows\n isUpOutside =\n !!e.target &&\n !this.outsideClickContainerDiv.contains(e.target as any);\n }\n\n const isOutsideClick = isUpOutside && this.isDownOutside;\n this.isDownOutside = false;\n isOutsideClick && this.onOutsideClick(e);\n };\n\n public handleOutsideClickContainerDivSet = (\n outsideClickContainerDiv: HTMLDivElement | null\n ) => {\n this.outsideClickContainerDiv = outsideClickContainerDiv;\n };\n\n public getParentDocument() {\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\n }\n\n public override componentDidMount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.addEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.addEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.addEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n /** @internal */\n public override componentWillUnmount() {\n const outsideClickParentDocument = this.getParentDocument();\n if (usePointerEvents) {\n outsideClickParentDocument.removeEventListener(\n \"pointerdown\",\n this.handleDocumentPointerDown,\n useCapture\n );\n outsideClickParentDocument.removeEventListener(\n \"pointerup\",\n this.handleDocumentPointerUp,\n useCapture\n );\n } else\n outsideClickParentDocument.removeEventListener(\n \"click\",\n this.handleDocumentClick,\n useCapture\n );\n }\n\n public override render() {\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } =\n this.props;\n return (\n <div ref={this.handleOutsideClickContainerDivSet}>\n <Component {...(props as ComponentProps)} />\n </div>\n );\n }\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionalIconItem.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/ConditionalIconItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,qBAAa,mBAAmB;aASZ,UAAU,EAAE,MAAM,QAAQ;aAC1B,YAAY,EAAE,MAAM,EAAE;IATxC,OAAO,CAAC,MAAM,CAAC,CAAW;IAE1B;;;;OAIG;gBAEe,UAAU,EAAE,MAAM,QAAQ,EAC1B,YAAY,EAAE,MAAM,EAAE,EACtC,KAAK,CAAC,EAAE,QAAQ;IAKlB;;OAEG;WACW,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,mBAAmB;IAS3E,mDAAmD;IACnD,IAAW,KAAK,IAAI,QAAQ,CAK3B;IAED,2DAA2D;IACpD,OAAO,IAAI,OAAO;IAUzB,gGAAgG;WAClF,YAAY,CACxB,gBAAgB,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,EAC1D,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GACpB,OAAO;IAmBV,0FAA0F;WAC5E,QAAQ,CACpB,gBAAgB,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,GACzD,QAAQ,GAAG,SAAS;CAYxB"}
1
+ {"version":3,"file":"ConditionalIconItem.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/ConditionalIconItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,qBAAa,mBAAmB;aASZ,UAAU,EAAE,MAAM,QAAQ;aAC1B,YAAY,EAAE,MAAM,EAAE;IATxC,OAAO,CAAC,MAAM,CAAC,CAAW;IAE1B;;;;OAIG;gBAEe,UAAU,EAAE,MAAM,QAAQ,EAC1B,YAAY,EAAE,MAAM,EAAE,EACtC,KAAK,CAAC,EAAE,QAAQ;IAKlB;;OAEG;WACW,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,mBAAmB;IAQ3E,mDAAmD;IACnD,IAAW,KAAK,IAAI,QAAQ,CAI3B;IAED,2DAA2D;IACpD,OAAO,IAAI,OAAO;IAUzB,gGAAgG;WAClF,YAAY,CACxB,gBAAgB,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,EAC1D,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GACpB,OAAO;IAkBV,0FAA0F;WAC5E,QAAQ,CACpB,gBAAgB,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,GACzD,QAAQ,GAAG,SAAS;CAUxB"}
@@ -26,18 +26,15 @@ class ConditionalIconItem {
26
26
  * @internal
27
27
  */
28
28
  static isConditionalIconItem(item) {
29
- /* istanbul ignore else */
30
29
  if (!item || typeof item !== "object")
31
30
  return false;
32
31
  const itemPrototype = Object.getPrototypeOf(item);
33
- /* istanbul ignore else */
34
32
  if (itemPrototype.constructor.name !== "ConditionalIconItem")
35
33
  return false;
36
34
  return true;
37
35
  }
38
36
  /** The current IconSpec according to conditions */
39
37
  get value() {
40
- /* istanbul ignore else */
41
38
  if (undefined !== this._value)
42
39
  return this._value;
43
40
  this._value = this.iconGetter();
@@ -46,7 +43,6 @@ class ConditionalIconItem {
46
43
  /** Called to update the value by running the iconGetter */
47
44
  refresh() {
48
45
  const newValue = this.iconGetter();
49
- /* istanbul ignore else */
50
46
  if (newValue !== this._value) {
51
47
  this._value = newValue;
52
48
  return true;
@@ -55,22 +51,18 @@ class ConditionalIconItem {
55
51
  }
56
52
  /** A helper function that updates the IconSpec value when the specified events are triggered */
57
53
  static refreshValue(conditionalValue, eventIds) {
58
- /* istanbul ignore else */
59
54
  if (undefined === conditionalValue ||
60
55
  !ConditionalIconItem.isConditionalIconItem(conditionalValue))
61
56
  return false;
62
57
  const iconItem = conditionalValue;
63
- /* istanbul ignore else */
64
58
  if (iconItem.syncEventIds.some((value) => eventIds.has(value.toLowerCase())))
65
59
  return iconItem.refresh();
66
60
  return false;
67
61
  }
68
62
  /** helper function to get the iconSpec from a ConditionIconItem as IconSpec | undefined*/
69
63
  static getValue(conditionalValue) {
70
- /* istanbul ignore else */
71
64
  if (undefined === conditionalValue)
72
65
  return undefined;
73
- /* istanbul ignore else */
74
66
  if (ConditionalIconItem.isConditionalIconItem(conditionalValue)) {
75
67
  const iconItem = conditionalValue;
76
68
  return iconItem.value;
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionalIconItem.js","sourceRoot":"","sources":["../../../../src/core-react/icons/ConditionalIconItem.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAIH;;GAEG;AACH,MAAa,mBAAmB;IAG9B;;;;OAIG;IACH,YACkB,UAA0B,EAC1B,YAAsB,EACtC,KAAgB;QAFA,eAAU,GAAV,UAAU,CAAgB;QAC1B,iBAAY,GAAZ,YAAY,CAAU;QAGtC,IAAI,CAAC,MAAM,GAAG,KAA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,EAAE,CAAC,CAClC;YAED,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;QAE5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,0FAA0F;IACnF,MAAM,CAAC,QAAQ,CACpB,gBAA0D;QAE1D,0BAA0B;QAC1B,IAAI,SAAS,KAAK,gBAAgB;YAAE,OAAO,SAAS,CAAC;QAErD,0BAA0B;QAC1B,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAChE,MAAM,QAAQ,GAAG,gBAAgB,CAAC;YAClC,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AArFD,kDAqFC","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 Icon\n */\n\nimport type { IconSpec } from \"./IconComponent\";\n\n/** Class used to return an icon. The icon is variable and can be changed in response to subscribed event ids.\n * @public\n */\nexport class ConditionalIconItem {\n private _value?: IconSpec;\n\n /** Constructor for ConditionalIconItem\n * @param iconGetter Function to retrieve the icon that matches the condition. Returns an IconSpec.\n * @param syncEventIds The array of event ids to be monitored. These events are triggered when the condition(s) that control the icon change.\n * @param value The default IconSpec. If this is not specified, the function is run to get the initial value.\n */\n constructor(\n public readonly iconGetter: () => IconSpec,\n public readonly syncEventIds: string[],\n value?: IconSpec\n ) {\n this._value = value;\n }\n\n /** A work-around for instanceOf\n * @internal\n */\n public static isConditionalIconItem(item: any): item is ConditionalIconItem {\n /* istanbul ignore else */\n if (!item || typeof item !== \"object\") return false;\n const itemPrototype = Object.getPrototypeOf(item);\n /* istanbul ignore else */\n if (itemPrototype.constructor.name !== \"ConditionalIconItem\") return false;\n\n return true;\n }\n /** The current IconSpec according to conditions */\n public get value(): IconSpec {\n /* istanbul ignore else */\n if (undefined !== this._value) return this._value;\n this._value = this.iconGetter();\n return this._value;\n }\n\n /** Called to update the value by running the iconGetter */\n public refresh(): boolean {\n const newValue = this.iconGetter();\n /* istanbul ignore else */\n if (newValue !== this._value) {\n this._value = newValue;\n return true;\n }\n return false;\n }\n\n /** A helper function that updates the IconSpec value when the specified events are triggered */\n public static refreshValue(\n conditionalValue: ConditionalIconItem | string | undefined,\n eventIds: Set<string>\n ): boolean {\n /* istanbul ignore else */\n if (\n undefined === conditionalValue ||\n !ConditionalIconItem.isConditionalIconItem(conditionalValue)\n )\n return false;\n\n const iconItem = conditionalValue;\n /* istanbul ignore else */\n if (\n iconItem.syncEventIds.some((value: string): boolean =>\n eventIds.has(value.toLowerCase())\n )\n )\n return iconItem.refresh();\n\n return false;\n }\n /** helper function to get the iconSpec from a ConditionIconItem as IconSpec | undefined*/\n public static getValue(\n conditionalValue: ConditionalIconItem | string | undefined\n ): IconSpec | undefined {\n /* istanbul ignore else */\n if (undefined === conditionalValue) return undefined;\n\n /* istanbul ignore else */\n if (ConditionalIconItem.isConditionalIconItem(conditionalValue)) {\n const iconItem = conditionalValue;\n return iconItem.value;\n }\n\n return conditionalValue;\n }\n}\n"]}
1
+ {"version":3,"file":"ConditionalIconItem.js","sourceRoot":"","sources":["../../../../src/core-react/icons/ConditionalIconItem.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAIH;;GAEG;AACH,MAAa,mBAAmB;IAG9B;;;;OAIG;IACH,YACkB,UAA0B,EAC1B,YAAsB,EACtC,KAAgB;QAFA,eAAU,GAAV,UAAU,CAAgB;QAC1B,iBAAY,GAAZ,YAAY,CAAU;QAGtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,qBAAqB,CAAC,IAAS;QAC3C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACpD,MAAM,aAAa,GAAG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AE,CAAC;YAChE,MAAM,QAAQ,GAAG,gBAAgB,CAAC;YAClC,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAhFD,kDAgFC","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 Icon\n */\n\nimport type { IconSpec } from \"./IconComponent\";\n\n/** Class used to return an icon. The icon is variable and can be changed in response to subscribed event ids.\n * @public\n */\nexport class ConditionalIconItem {\n private _value?: IconSpec;\n\n /** Constructor for ConditionalIconItem\n * @param iconGetter Function to retrieve the icon that matches the condition. Returns an IconSpec.\n * @param syncEventIds The array of event ids to be monitored. These events are triggered when the condition(s) that control the icon change.\n * @param value The default IconSpec. If this is not specified, the function is run to get the initial value.\n */\n constructor(\n public readonly iconGetter: () => IconSpec,\n public readonly syncEventIds: string[],\n value?: IconSpec\n ) {\n this._value = value;\n }\n\n /** A work-around for instanceOf\n * @internal\n */\n public static isConditionalIconItem(item: any): item is ConditionalIconItem {\n if (!item || typeof item !== \"object\") return false;\n const itemPrototype = Object.getPrototypeOf(item);\n\n if (itemPrototype.constructor.name !== \"ConditionalIconItem\") return false;\n\n return true;\n }\n /** The current IconSpec according to conditions */\n public get value(): IconSpec {\n if (undefined !== this._value) return this._value;\n this._value = this.iconGetter();\n return this._value;\n }\n\n /** Called to update the value by running the iconGetter */\n public refresh(): boolean {\n const newValue = this.iconGetter();\n\n if (newValue !== this._value) {\n this._value = newValue;\n return true;\n }\n return false;\n }\n\n /** A helper function that updates the IconSpec value when the specified events are triggered */\n public static refreshValue(\n conditionalValue: ConditionalIconItem | string | undefined,\n eventIds: Set<string>\n ): boolean {\n if (\n undefined === conditionalValue ||\n !ConditionalIconItem.isConditionalIconItem(conditionalValue)\n )\n return false;\n\n const iconItem = conditionalValue;\n\n if (\n iconItem.syncEventIds.some((value: string): boolean =>\n eventIds.has(value.toLowerCase())\n )\n )\n return iconItem.refresh();\n\n return false;\n }\n /** helper function to get the iconSpec from a ConditionIconItem as IconSpec | undefined*/\n public static getValue(\n conditionalValue: ConditionalIconItem | string | undefined\n ): IconSpec | undefined {\n if (undefined === conditionalValue) return undefined;\n\n if (ConditionalIconItem.isConditionalIconItem(conditionalValue)) {\n const iconItem = conditionalValue;\n return iconItem.value;\n }\n\n return conditionalValue;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,sBAAsB,GACtB,KAAK,CAAC,SAAS,GACf,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAWD;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,4BA6DpC"}
1
+ {"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,sBAAsB,GACtB,KAAK,CAAC,SAAS,GACf,mBAAmB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAWD;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,4BA4DpC"}
@@ -41,7 +41,6 @@ function Icon(props) {
41
41
  const svgDiv = `<div>${svgLoader}</div>`;
42
42
  // the esm build of dompurify has a default import but the cjs build does not
43
43
  // if there is a default export, use it (likely esm), otherwise use the namespace
44
- // istanbul ignore next
45
44
  const sanitizer = dompurify_1.default ?? DOMPurifyNS;
46
45
  const sanitizerConfig = {
47
46
  ALLOWED_TAGS: ["svg-loader"],
@@ -1 +1 @@
1
- {"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAA+D;AAE/D,oEAAoD;AACpD,+DAA4D;AA0B5D,qDAAqD;AACrD,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,Q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C,SAAS,CAAC,EAC1D,KAAK,EAAE,KAAK,CAAC,KAAK,GAClB,CACH,CAAC;IACJ,CAAC;IAED,iBAAiB;IACjB,OAAO,CACL,2BACE,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAC/D,KAAK,EAAE,KAAK,CAAC,KAAK,IAEjB,aAAa,CACZ,CACL,CAAC;AACJ,CAAC;AA7DD,oBA6DC;AAED,SAAS,gBAAgB,CACvB,QAAkB;IAElB,IAAI,KAAK,GAAG,QAAQ,CAAC;IACrB,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,yCAAmB,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,KAAK,GAAG,yCAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,IAAI,KAAK,YAAY,uCAAsB,EAAE,CAAC;YAC5C,KAAK,GAAG,uCAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM;QACR,CAAC;QACD,MAAM;IACR,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 Icon\n */\n\nimport \"./IconComponent.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport { ConditionalIconItem } from \"./ConditionalIconItem\";\n\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\n * Strings are expected to be one of the following:\n * - Created by `IconSpecUtilities.createWebComponentIconSpec` in appui-abstract (deprecated).\n * - A URL to a SVG file (must end with \".svg\").\n * - A dataURI with MimeTypes `image/svg+xml` (ensure valid dataURI encoding) or `image/svg+xml;base64`;\n * - Anything else will be treated as a class name and be directly added to the `class` attribute.\n * @public\n */\nexport type IconSpec =\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem;\n\n/** Properties for the [[Icon]] React component\n * @public\n */\nexport interface IconProps extends CommonProps {\n /** CSS class name or SvgPath for icon. This is optional because it is improperly\n * used to extend other interfaces and changing it would break existing API.\n */\n iconSpec?: IconSpec;\n}\n\n/** Get the SVG Source from an svg-loader IconSpec */\nfunction getWebComponentSource(iconSpec: string): string | undefined {\n if (iconSpec.startsWith(\"webSvg:\") && iconSpec.length > 7) {\n return iconSpec.slice(7);\n }\n\n return undefined;\n}\n\n/** Icon Functional component displays an icon based on an [[IconSpec]].\n * @public\n */\nexport function Icon(props: IconProps) {\n if (!props.iconSpec) return null;\n\n const iconSpecValue = getIconSpecValue(props.iconSpec);\n if (typeof iconSpecValue === \"string\") {\n const iconString = iconSpecValue;\n const webComponentString = getWebComponentSource(iconString);\n\n if (\n iconString.startsWith(\"data:\") ||\n iconString.endsWith(\".svg\") ||\n webComponentString\n ) {\n const definitiveIconString = webComponentString\n ? webComponentString\n : iconString;\n const svgLoader = `<svg-loader src=\"${definitiveIconString}\"></svg-loader>`;\n const svgDiv = `<div>${svgLoader}</div>`;\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS;\n\n const sanitizerConfig = {\n ALLOWED_TAGS: [\"svg-loader\"],\n ADD_URI_SAFE_ATTR: definitiveIconString.startsWith(\"data:\")\n ? [\"src\"]\n : [],\n };\n\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\n const webComponentNode = (\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n <div dangerouslySetInnerHTML={{ __html: sanitizedIconString }}></div>\n );\n return (\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)}>\n {webComponentNode}\n </i>\n );\n }\n\n // CSS icon\n return (\n <i\n className={classnames(\"icon\", iconString, props.className)}\n style={props.style}\n />\n );\n }\n\n // ReactNode icon\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {iconSpecValue}\n </i>\n );\n}\n\nfunction getIconSpecValue(\n iconSpec: IconSpec\n): Exclude<IconSpec, ConditionalIconItem | ConditionalStringValue> {\n let value = iconSpec;\n while (true) {\n if (ConditionalIconItem.isConditionalIconItem(value)) {\n value = ConditionalIconItem.getValue(value);\n continue;\n }\n if (value instanceof ConditionalStringValue) {\n value = ConditionalStringValue.getValue(value);\n break;\n }\n break;\n }\n return value;\n}\n"]}
1
+ {"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAA+D;AAE/D,oEAAoD;AACpD,+DAA4D;AA0B5D,qDAAqD;AACrD,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,aAAa,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,aAAa,CAAC;QACjC,MAAM,kBAAk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BAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAC/D,KAAK,EAAE,KAAK,CAAC,KAAK,IAEjB,aAAa,CACZ,CACL,CAAC;AACJ,CAAC;AA5DD,oBA4DC;AAED,SAAS,gBAAgB,CACvB,QAAkB;IAElB,IAAI,KAAK,GAAG,QAAQ,CAAC;IACrB,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,yCAAmB,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,KAAK,GAAG,yCAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,IAAI,KAAK,YAAY,uCAAsB,EAAE,CAAC;YAC5C,KAAK,GAAG,uCAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM;QACR,CAAC;QACD,MAAM;IACR,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 Icon\n */\n\nimport \"./IconComponent.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport { ConditionalIconItem } from \"./ConditionalIconItem\";\n\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\n * Strings are expected to be one of the following:\n * - Created by `IconSpecUtilities.createWebComponentIconSpec` in appui-abstract (deprecated).\n * - A URL to a SVG file (must end with \".svg\").\n * - A dataURI with MimeTypes `image/svg+xml` (ensure valid dataURI encoding) or `image/svg+xml;base64`;\n * - Anything else will be treated as a class name and be directly added to the `class` attribute.\n * @public\n */\nexport type IconSpec =\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem;\n\n/** Properties for the [[Icon]] React component\n * @public\n */\nexport interface IconProps extends CommonProps {\n /** CSS class name or SvgPath for icon. This is optional because it is improperly\n * used to extend other interfaces and changing it would break existing API.\n */\n iconSpec?: IconSpec;\n}\n\n/** Get the SVG Source from an svg-loader IconSpec */\nfunction getWebComponentSource(iconSpec: string): string | undefined {\n if (iconSpec.startsWith(\"webSvg:\") && iconSpec.length > 7) {\n return iconSpec.slice(7);\n }\n\n return undefined;\n}\n\n/** Icon Functional component displays an icon based on an [[IconSpec]].\n * @public\n */\nexport function Icon(props: IconProps) {\n if (!props.iconSpec) return null;\n\n const iconSpecValue = getIconSpecValue(props.iconSpec);\n if (typeof iconSpecValue === \"string\") {\n const iconString = iconSpecValue;\n const webComponentString = getWebComponentSource(iconString);\n\n if (\n iconString.startsWith(\"data:\") ||\n iconString.endsWith(\".svg\") ||\n webComponentString\n ) {\n const definitiveIconString = webComponentString\n ? webComponentString\n : iconString;\n const svgLoader = `<svg-loader src=\"${definitiveIconString}\"></svg-loader>`;\n const svgDiv = `<div>${svgLoader}</div>`;\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n const sanitizer = DOMPurify ?? DOMPurifyNS;\n\n const sanitizerConfig = {\n ALLOWED_TAGS: [\"svg-loader\"],\n ADD_URI_SAFE_ATTR: definitiveIconString.startsWith(\"data:\")\n ? [\"src\"]\n : [],\n };\n\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\n const webComponentNode = (\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n <div dangerouslySetInnerHTML={{ __html: sanitizedIconString }}></div>\n );\n return (\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)}>\n {webComponentNode}\n </i>\n );\n }\n\n // CSS icon\n return (\n <i\n className={classnames(\"icon\", iconString, props.className)}\n style={props.style}\n />\n );\n }\n\n // ReactNode icon\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {iconSpecValue}\n </i>\n );\n}\n\nfunction getIconSpecValue(\n iconSpec: IconSpec\n): Exclude<IconSpec, ConditionalIconItem | ConditionalStringValue> {\n let value = iconSpec;\n while (true) {\n if (ConditionalIconItem.isConditionalIconItem(value)) {\n value = ConditionalIconItem.getValue(value);\n continue;\n }\n if (value instanceof ConditionalStringValue) {\n value = ConditionalStringValue.getValue(value);\n break;\n }\n break;\n }\n return value;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCheckBox.d.ts","sourceRoot":"","sources":["../../../../src/core-react/imagecheckbox/ImageCheckBox.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,oCAAoC;IACpC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACnC,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,GAAG,CAAC;IACpC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACjC,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,K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C,aAAa,CAAC,kBAAkB,CAAC;IACxE,OAAO,CAAC,SAAS,CAMf;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,gBAAgB;IACA,MAAM;CAqCvB"}
@@ -21,21 +21,17 @@ class ImageCheckBox extends React.PureComponent {
21
21
  constructor() {
22
22
  super(...arguments);
23
23
  this._onChange = (e) => {
24
- // istanbul ignore next
25
24
  if (e && e.stopPropagation)
26
25
  e.stopPropagation();
27
- // istanbul ignore else
28
26
  if (this.props.onClick) {
29
27
  this.props.onClick(e.target.checked);
30
28
  }
31
29
  };
32
30
  this._onInputClick = (e) => {
33
- // istanbul ignore next
34
31
  if (e && e.stopPropagation)
35
32
  e.stopPropagation();
36
33
  };
37
34
  this._onLabelClick = (e) => {
38
- // istanbul ignore next
39
35
  if (e && e.stopPropagation)
40
36
  e.stopPropagation();
41
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCheckBox.js","sourceRoot":"","sources":["../../../../src/core-react/imagecheckbox/ImageCheckBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,2CAAoC;AACpC,+BAA+B;AAC/B,0DAA8C;AA8B9C;;;GAGG;AACH,mDAAmD;AACnD,MAAa,aAAc,SAAQ,KAAK,CAAC,aAAiC;IAA1E;;QACU,cAAS,GAAG,CAAC,CAAsC,EAAE,EAAE;YAC7D,uBAAuB;YACvB,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe;gBAAE,CAAC,CAAC,eAAe,EAAE,CAAC;YAEhD,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;QAEM,kBAAa,GAAG,CAAC,CAAqC,EAAE,EAAE;YAChE,uBAAuB;YACv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AE,UAAU;gBACzB,oBAAC,oBAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACvB,CACD,CACT,CAAC;IACJ,CAAC;CACF;AA3DD,sCA2DC","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 Checkbox\n */\n\nimport \"./ImageCheckBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Icon } from \"../icons/IconComponent\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for the [[ImageCheckBox]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link ImageCheckBox}.\n */\nexport interface ImageCheckBoxProps extends CommonProps {\n /** Image for the \"checked\" state */\n imageOn: string | React.ReactNode;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string | React.ReactNode;\n /** Determine if the item is checked or not */\n checked?: boolean;\n /** Determine if the item is disabled or not */\n disabled?: boolean;\n /** Function called when item is clicked. */\n onClick?: (checked: boolean) => any;\n /** Custom CSS class name for the checkbox input element */\n inputClassName?: string;\n /** Custom CSS Style for the checkbox input element */\n inputStyle?: React.CSSProperties;\n /** Tooltip to be displayed when mouse is hovered over the checkbox */\n tooltip?: string;\n /** If true, draw a border around the image checkbox */\n border?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n inputRef?: React.Ref<HTMLInputElement>;\n}\n\n/** ImageCheckBox React component shows a checked or unchecked image\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/checkbox iTwinUI checkbox} instead (custom icons are not supported at the moment, but feel free to submit your use cases).\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ImageCheckBox extends React.PureComponent<ImageCheckBoxProps> {\n private _onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore next\n if (e && e.stopPropagation) e.stopPropagation();\n\n // istanbul ignore else\n if (this.props.onClick) {\n this.props.onClick(e.target.checked);\n }\n };\n\n private _onInputClick = (e: React.MouseEvent<HTMLInputElement>) => {\n // istanbul ignore next\n if (e && e.stopPropagation) e.stopPropagation();\n };\n\n private _onLabelClick = (e: React.MouseEvent<HTMLLabelElement>) => {\n // istanbul ignore next\n if (e && e.stopPropagation) e.stopPropagation();\n };\n\n /** @internal */\n public override render() {\n const checkBoxClass = classnames(\n \"core-image-checkbox\",\n this.props.className\n );\n const imageClass = classnames(\n \"image\",\n this.props.border && \"image-checkbox-border\"\n );\n const iconSpec = this.props.checked\n ? this.props.imageOn\n : this.props.imageOff;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/label-has-associated-control, jsx-a11y/no-noninteractive-element-interactions\n <label\n className={checkBoxClass}\n style={this.props.style}\n onClick={this._onLabelClick}\n title={this.props.tooltip}\n >\n <input\n type=\"checkbox\"\n className={this.props.inputClassName}\n style={this.props.inputStyle}\n checked={this.props.checked}\n disabled={this.props.disabled}\n onChange={this._onChange}\n onClick={this._onInputClick}\n ref={this.props.inputRef}\n />\n <span className={imageClass}>\n <Icon iconSpec={iconSpec} />\n </span>\n </label>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ImageCheckBox.js","sourceRoot":"","sources":["../../../../src/core-react/imagecheckbox/ImageCheckBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,2CAAoC;AACpC,+BAA+B;AAC/B,0DAA8C;AA8B9C;;;GAGG;AACH,mDAAmD;AACnD,MAAa,aAAc,SAAQ,KAAK,CAAC,aAAiC;IAA1E;;QACU,cAAS,GAAG,CAAC,CAAsC,EAAE,EAAE;YAC7D,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe;gBAAE,CAAC,CAAC,eAAe,EAAE,CAAC;YAEhD,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACvB,IAAI,CAAC,KAAK,CAAC,OAAO,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xB,OAAO,EAAE,IAAI,CAAC,aAAa,EAC3B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GACxB;YACF,8BAAM,SAAS,EAAE,UAAU;gBACzB,oBAAC,oBAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACvB,CACD,CACT,CAAC;IACJ,CAAC;CACF;AAvDD,sCAuDC","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 Checkbox\n */\n\nimport \"./ImageCheckBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Icon } from \"../icons/IconComponent\";\nimport type { CommonProps } from \"../utils/Props\";\n\n/** Properties for the [[ImageCheckBox]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link ImageCheckBox}.\n */\nexport interface ImageCheckBoxProps extends CommonProps {\n /** Image for the \"checked\" state */\n imageOn: string | React.ReactNode;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string | React.ReactNode;\n /** Determine if the item is checked or not */\n checked?: boolean;\n /** Determine if the item is disabled or not */\n disabled?: boolean;\n /** Function called when item is clicked. */\n onClick?: (checked: boolean) => any;\n /** Custom CSS class name for the checkbox input element */\n inputClassName?: string;\n /** Custom CSS Style for the checkbox input element */\n inputStyle?: React.CSSProperties;\n /** Tooltip to be displayed when mouse is hovered over the checkbox */\n tooltip?: string;\n /** If true, draw a border around the image checkbox */\n border?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n inputRef?: React.Ref<HTMLInputElement>;\n}\n\n/** ImageCheckBox React component shows a checked or unchecked image\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/checkbox iTwinUI checkbox} instead (custom icons are not supported at the moment, but feel free to submit your use cases).\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ImageCheckBox extends React.PureComponent<ImageCheckBoxProps> {\n private _onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (e && e.stopPropagation) e.stopPropagation();\n\n if (this.props.onClick) {\n this.props.onClick(e.target.checked);\n }\n };\n\n private _onInputClick = (e: React.MouseEvent<HTMLInputElement>) => {\n if (e && e.stopPropagation) e.stopPropagation();\n };\n\n private _onLabelClick = (e: React.MouseEvent<HTMLLabelElement>) => {\n if (e && e.stopPropagation) e.stopPropagation();\n };\n\n /** @internal */\n public override render() {\n const checkBoxClass = classnames(\n \"core-image-checkbox\",\n this.props.className\n );\n const imageClass = classnames(\n \"image\",\n this.props.border && \"image-checkbox-border\"\n );\n const iconSpec = this.props.checked\n ? this.props.imageOn\n : this.props.imageOff;\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/label-has-associated-control, jsx-a11y/no-noninteractive-element-interactions\n <label\n className={checkBoxClass}\n style={this.props.style}\n onClick={this._onLabelClick}\n title={this.props.tooltip}\n >\n <input\n type=\"checkbox\"\n className={this.props.inputClassName}\n style={this.props.inputStyle}\n checked={this.props.checked}\n disabled={this.props.disabled}\n onChange={this._onChange}\n onClick={this._onInputClick}\n ref={this.props.inputRef}\n />\n <span className={imageClass}>\n <Icon iconSpec={iconSpec} />\n </span>\n </label>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/inputs/numberinput/NumberInput.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAS7C,KAAK,UAAU,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS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,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,+DAA+D;IAC/D,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAyQD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,CAExB,KAAK,EAAE,gBAAgB,KACpB,KAAK,CAAC,SAAiC,CAAC"}
@@ -111,7 +111,6 @@ const ForwardRefNumberInput = React.forwardRef(function ForwardRefNumberInput(pr
111
111
  updateValue,
112
112
  ]);
113
113
  const handleKeyDown = React.useCallback((event) => {
114
- // istanbul ignore else
115
114
  if (event.key === ts_key_enum_1.Key.Enter.valueOf()) {
116
115
  updateValueFromString(event.currentTarget.value);
117
116
  event.preventDefault();