@itwin/imodel-components-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 (200) hide show
  1. package/CHANGELOG.md +3 -8
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js +1 -2
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +0 -16
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  8. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +0 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +0 -1
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +0 -4
  16. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  17. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/HueSlider.js +0 -21
  19. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  21. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +0 -25
  22. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  23. package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
  24. package/lib/cjs/imodel-components-react/color/Swatch.js +0 -1
  25. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  27. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +2 -13
  28. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  30. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +2 -11
  31. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  32. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  33. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +0 -6
  34. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  36. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -15
  37. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  39. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +0 -1
  40. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  42. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +0 -9
  43. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  45. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +0 -1
  46. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  47. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  48. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -27
  49. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  51. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +9 -34
  52. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  54. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +0 -1
  55. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  57. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -6
  58. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  59. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  60. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +2 -12
  61. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  63. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +2 -7
  64. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  65. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  66. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +0 -7
  67. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +0 -1
  70. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  72. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +0 -1
  73. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  75. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -5
  76. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  77. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  78. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +6 -12
  79. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  80. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  81. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  82. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  84. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +2 -10
  85. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  87. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +0 -2
  88. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  90. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +0 -6
  91. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  93. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +0 -1
  94. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  96. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +0 -17
  97. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  99. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +0 -1
  100. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  101. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  102. package/lib/esm/imodel-components-react/UiIModelComponents.js +1 -2
  103. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  104. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  105. package/lib/esm/imodel-components-react/color/AlphaSlider.js +0 -16
  106. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  107. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  108. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +0 -1
  109. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  110. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  111. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +0 -1
  112. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  113. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  114. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +0 -4
  115. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  116. package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  117. package/lib/esm/imodel-components-react/color/HueSlider.js +0 -21
  118. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  119. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  120. package/lib/esm/imodel-components-react/color/SaturationPicker.js +0 -25
  121. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  122. package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
  123. package/lib/esm/imodel-components-react/color/Swatch.js +0 -1
  124. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  125. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  126. package/lib/esm/imodel-components-react/editors/ColorEditor.js +2 -13
  127. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  128. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  129. package/lib/esm/imodel-components-react/editors/WeightEditor.js +2 -11
  130. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  131. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  132. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +0 -6
  133. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  134. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  135. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -15
  136. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  137. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  138. package/lib/esm/imodel-components-react/lineweight/Swatch.js +0 -1
  139. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  140. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  141. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +0 -9
  142. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  143. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  144. package/lib/esm/imodel-components-react/navigationaids/Cube.js +0 -1
  145. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  146. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  147. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -27
  148. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  149. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  150. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +9 -34
  151. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  152. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  153. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +0 -1
  154. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  155. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  156. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -6
  157. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  158. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  159. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +2 -12
  160. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  161. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  162. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +2 -7
  163. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  164. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  165. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +0 -7
  166. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  167. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  168. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +0 -1
  169. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  170. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  171. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +0 -1
  172. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  173. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  174. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -5
  175. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  176. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  177. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +6 -12
  178. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  179. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  180. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  181. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  182. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  183. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +2 -10
  184. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  185. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  186. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +0 -2
  187. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  188. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  189. package/lib/esm/imodel-components-react/timeline/Scrubber.js +0 -6
  190. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  191. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  192. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +0 -1
  193. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  194. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  195. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +0 -17
  196. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  197. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  198. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +0 -1
  199. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  200. package/package.json +5 -5
@@ -43,7 +43,6 @@ const ViewportComponentEvents_1 = require("./ViewportComponentEvents");
43
43
  */
44
44
  function ViewportComponent(props) {
45
45
  const { viewState, imodel, viewDefinitionId, getViewOverlay, viewManagerOverride, tentativePointOverride, onContextMenu, style, className, screenViewportOverride, controlId, viewportRef, } = props;
46
- // istanbul ignore next
47
46
  const viewManagerRef = React.useRef(viewManagerOverride ?? core_frontend_1.IModelApp.viewManager);
48
47
  const tentativePointOverrideRef = React.useRef(tentativePointOverride);
49
48
  const screenViewportCreated = React.useRef(false);
@@ -52,9 +51,7 @@ function ViewportComponent(props) {
52
51
  const isMounted = React.useRef(false);
53
52
  const viewClassFullName = React.useRef("");
54
53
  const viewId = React.useRef("0");
55
- // istanbul ignore next
56
54
  const handleViewChanged = (vp) => {
57
- // istanbul ignore next
58
55
  if (!(vp.iModel.isOpen || vp.iModel.isBlank))
59
56
  return;
60
57
  ViewportComponentEvents_1.ViewportComponentEvents.setViewMatrix(vp);
@@ -105,17 +102,13 @@ function ViewportComponent(props) {
105
102
  const targetPoint = React.useRef(null);
106
103
  const getRotatePoint = (vp) => {
107
104
  const lastTargetPoint = targetPoint.current;
108
- // istanbul ignore next
109
105
  const tentativePoint = tentativePointOverrideRef.current ?? core_frontend_1.IModelApp.tentativePoint;
110
- // istanbul ignore else
111
106
  if (tentativePoint.isActive)
112
107
  return tentativePoint.getPoint();
113
- // istanbul ignore else
114
108
  if (null !== lastTargetPoint) {
115
109
  const testPt = vp.worldToView(lastTargetPoint);
116
110
  const viewRect = vp.viewRect.clone();
117
111
  viewRect.scaleAboutCenter(0.25, 0.25);
118
- // istanbul ignore next hard to reach because of mocks
119
112
  if (viewRect.containsPoint(testPt))
120
113
  return lastTargetPoint;
121
114
  targetPoint.current = null;
@@ -123,18 +116,15 @@ function ViewportComponent(props) {
123
116
  const visiblePoint = vp.pickNearestVisibleGeometry(vp.npcToWorld(core_common_1.NpcCenter), vp.pixelsFromInches(core_frontend_1.ToolSettings.viewToolPickRadiusInches));
124
117
  targetPoint.current =
125
118
  undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();
126
- // istanbul ignore next
127
119
  return targetPoint.current ?? vp.view.getCenter();
128
120
  };
129
121
  // eslint-disable-next-line deprecation/deprecation
130
122
  const handleCubeRotationChangeEvent = (args) => {
131
123
  const viewManager = viewManagerRef.current;
132
124
  const currentScreenViewport = screenViewportRef.current;
133
- // istanbul ignore else
134
125
  if (currentScreenViewport &&
135
126
  viewManager.selectedView === currentScreenViewport) {
136
127
  const rotMatrix = args.rotMatrix;
137
- // istanbul ignore else
138
128
  if (currentScreenViewport.rotation !== rotMatrix) {
139
129
  const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...
140
130
  const center = getRotatePoint(currentScreenViewport);
@@ -160,7 +150,6 @@ function ViewportComponent(props) {
160
150
  viewManager.dropViewport(screenViewport, true);
161
151
  }
162
152
  };
163
- // istanbul ignore next
164
153
  const handleWindowUnload = () => {
165
154
  const parentDiv = viewportDiv.current;
166
155
  if (parentDiv) {
@@ -171,7 +160,6 @@ function ViewportComponent(props) {
171
160
  }
172
161
  };
173
162
  const getScreenViewport = (parentDiv, inViewState) => {
174
- // istanbul ignore next
175
163
  const screenViewportFactory = screenViewportOverride
176
164
  ? screenViewportOverride
177
165
  : core_frontend_1.ScreenViewport;
@@ -217,20 +205,17 @@ function ViewportComponent(props) {
217
205
  else if (viewDefinitionId && imodel) {
218
206
  try {
219
207
  currentViewState = await imodel.views.load(viewDefinitionId);
220
- // istanbul ignore next
221
208
  if (!currentViewState) {
222
209
  core_bentley_1.Logger.logError("ViewportComponent", `Viewstate failed to load`);
223
210
  }
224
211
  }
225
212
  catch (_e) {
226
- // istanbul ignore next
227
213
  core_bentley_1.Logger.logError("ViewportComponent", `Viewstate failed to load`);
228
214
  }
229
215
  }
230
216
  else {
231
217
  core_bentley_1.Logger.logError("ViewportComponent", `A Viewstate or a viewId and imodel must be provided`);
232
218
  }
233
- // istanbul ignore next
234
219
  if (isMounted.current &&
235
220
  (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)) {
236
221
  setInitialViewState(currentViewState?.clone());
@@ -244,7 +229,6 @@ function ViewportComponent(props) {
244
229
  React.useEffect(() => {
245
230
  const parentDiv = viewportDiv.current;
246
231
  const viewManager = viewManagerRef.current;
247
- // istanbul ignore next
248
232
  if (parentDiv &&
249
233
  initialViewState &&
250
234
  (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)) {
@@ -259,7 +243,6 @@ function ViewportComponent(props) {
259
243
  setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);
260
244
  }
261
245
  else {
262
- // istanbul ignore next
263
246
  screenViewportRef.current?.changeView(initialViewState);
264
247
  }
265
248
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,sDAA6C;AAE7C,wDAAiD;AACjD,oDAA+C;AAQ/C,wDAK8B;AAQ9B,uEAAoE;AAkCpE;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,MAAM,EACJ,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,WAAW,GACZ,GAAG,KA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5C,GAAG,KAAK;QACR,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KACd,CAAC;IAEF,OAAO,CACL,6BAAK,KAAK,EAAE,cAAc,kBAAgB,SAAS;QACjD,6BACE,GAAG,EAAE,WAAW,iBACJ,oBAAoB,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,iBAAiB,GAChC;QACD,WAAW,CACR,CACP,CAAC;AACJ,CAAC;AA5UD,8CA4UC","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 Viewport\n */\n\nimport * as React from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Point3d } from \"@itwin/core-geometry\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport { NpcCenter } from \"@itwin/core-common\";\nimport type {\n IModelConnection,\n TentativePoint,\n ViewManager,\n Viewport,\n ViewState,\n} from \"@itwin/core-frontend\";\nimport {\n IModelApp,\n ScreenViewport,\n StandardView,\n ToolSettings,\n} from \"@itwin/core-frontend\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n CubeRotationChangeEventArgs,\n DrawingViewportChangeEventArgs,\n StandardRotationChangeEventArgs,\n} from \"./ViewportComponentEvents\";\nimport { ViewportComponentEvents } from \"./ViewportComponentEvents\";\n\n/** Type for a ViewState prop\n * @public\n */\nexport type ViewStateProp = ViewState | (() => ViewState);\n\n/**\n * Properties for [[ViewportComponent]] component.\n * @public\n */\nexport interface ViewportProps extends CommonProps {\n /** IModel to display */\n imodel: IModelConnection;\n /** Id of a default view definition to load as a starting point */\n viewDefinitionId?: Id64String;\n /** ViewState to use as a starting point */\n viewState?: ViewStateProp;\n /** Function to get a reference to the ScreenViewport */\n viewportRef?: (v: ScreenViewport) => void;\n /** controlId for this content component @internal */\n controlId?: string;\n /** @internal */\n onContextMenu?: (e: React.MouseEvent) => boolean;\n /** @internal */\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\n /** @internal used only for testing */\n viewManagerOverride?: ViewManager;\n /** @internal used only for testing */\n screenViewportOverride?: typeof ScreenViewport;\n /** @internal used only for testing */\n tentativePointOverride?: TentativePoint;\n}\n\n/**\n * A viewport React component that creates a ScreenViewport.\n * @public\n */\nexport function ViewportComponent(props: ViewportProps) {\n const {\n viewState,\n imodel,\n viewDefinitionId,\n getViewOverlay,\n viewManagerOverride,\n tentativePointOverride,\n onContextMenu,\n style,\n className,\n screenViewportOverride,\n controlId,\n viewportRef,\n } = props;\n // istanbul ignore next\n const viewManagerRef = React.useRef(\n viewManagerOverride ?? IModelApp.viewManager\n );\n const tentativePointOverrideRef = React.useRef(tentativePointOverride);\n const screenViewportCreated = React.useRef(false);\n const viewportDiv = React.useRef<HTMLDivElement>(null);\n const screenViewportRef = React.useRef<ScreenViewport | null>(null);\n const isMounted = React.useRef(false);\n const viewClassFullName = React.useRef(\"\");\n const viewId = React.useRef(\"0\");\n\n // istanbul ignore next\n const handleViewChanged = (vp: Viewport) => {\n // istanbul ignore next\n if (!(vp.iModel.isOpen || vp.iModel.isBlank)) return;\n ViewportComponentEvents.setViewMatrix(vp);\n if (viewClassFullName.current !== vp.view.classFullName) {\n setTimeout(() => {\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({\n viewport: vp,\n oldName: viewClassFullName.current,\n newName: vp.view.classFullName,\n });\n viewClassFullName.current = vp.view.classFullName;\n });\n }\n if (viewId.current !== vp.view.id) {\n setTimeout(() => {\n ViewportComponentEvents.onViewIdChangedEvent.emit({\n viewport: vp,\n oldId: viewId.current,\n newId: vp.view.id,\n });\n viewId.current = vp.view.id;\n });\n }\n };\n\n const handleStandardRotationChangeEvent = (\n args: StandardRotationChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setRotationAboutPoint(\n StandardView.getStandardRotation(args.standardRotation)\n );\n currentScreenViewport.synchWithView();\n }\n };\n\n const handleDrawingViewportChangeEvent = (\n args: DrawingViewportChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setOrigin(args.origin);\n currentScreenViewport.view.setRotation(args.rotation);\n currentScreenViewport.synchWithView({\n noSaveInUndo: args.complete !== true,\n });\n }\n };\n\n const targetPoint = React.useRef<Point3d | null>(null);\n\n const getRotatePoint = (vp: ScreenViewport): Point3d => {\n const lastTargetPoint = targetPoint.current;\n // istanbul ignore next\n const tentativePoint =\n tentativePointOverrideRef.current ?? IModelApp.tentativePoint;\n // istanbul ignore else\n if (tentativePoint.isActive) return tentativePoint.getPoint();\n\n // istanbul ignore else\n if (null !== lastTargetPoint) {\n const testPt = vp.worldToView(lastTargetPoint);\n const viewRect = vp.viewRect.clone();\n viewRect.scaleAboutCenter(0.25, 0.25);\n // istanbul ignore next hard to reach because of mocks\n if (viewRect.containsPoint(testPt)) return lastTargetPoint;\n targetPoint.current = null;\n }\n\n const visiblePoint = vp.pickNearestVisibleGeometry(\n vp.npcToWorld(NpcCenter),\n vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches)\n );\n targetPoint.current =\n undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();\n // istanbul ignore next\n return targetPoint.current ?? vp.view.getCenter();\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n // istanbul ignore else\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n const rotMatrix = args.rotMatrix;\n // istanbul ignore else\n if (currentScreenViewport.rotation !== rotMatrix) {\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\n const center = getRotatePoint(currentScreenViewport);\n const targetMatrix = inverse.multiplyMatrixMatrix(\n currentScreenViewport.view.getRotation()\n );\n const worldTransform = Transform.createFixedPointAndMatrix(\n center,\n targetMatrix\n );\n const frustum = currentScreenViewport.getWorldFrustum();\n frustum.multiply(worldTransform);\n currentScreenViewport.view.setupFromFrustum(frustum);\n currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });\n }\n }\n };\n\n const handleDisconnectFromViewManager = () => {\n const screenViewport = screenViewportRef.current;\n if (screenViewport) {\n const viewManager = IModelApp.viewManager;\n screenViewport.onViewChanged.removeListener(handleViewChanged);\n screenViewportRef.current = null;\n screenViewportCreated.current = false;\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(\n handleStandardRotationChangeEvent\n );\n viewManager.dropViewport(screenViewport, true);\n }\n };\n\n // istanbul ignore next\n const handleWindowUnload = () => {\n const parentDiv = viewportDiv.current;\n if (parentDiv) {\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n if (parentWindow !== window) {\n handleDisconnectFromViewManager();\n }\n }\n };\n\n const getScreenViewport = (\n parentDiv: HTMLDivElement,\n inViewState: ViewState\n ) => {\n // istanbul ignore next\n const screenViewportFactory = screenViewportOverride\n ? screenViewportOverride\n : ScreenViewport;\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n parentWindow.addEventListener(\"unload\", handleWindowUnload, {\n once: true,\n capture: true,\n }); // by specifying 'once', listener clears after being called\n ViewportComponentEvents.initialize();\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(\n handleStandardRotationChangeEvent\n );\n const screenViewport = screenViewportFactory.create(parentDiv, inViewState);\n screenViewportCreated.current = true;\n viewClassFullName.current = screenViewport.view.classFullName;\n viewId.current = screenViewport.view.id;\n screenViewport.onViewChanged.addListener(handleViewChanged);\n return screenViewport;\n };\n\n React.useEffect(() => {\n isMounted.current = true;\n Logger.logInfo(\n \"ViewportComponent\",\n `mounting ViewportComponent for controlId=${controlId}`\n );\n\n return () => {\n isMounted.current = false;\n Logger.logInfo(\n \"ViewportComponent\",\n `un-mounting ViewportComponent for controlId=${controlId}`\n );\n handleDisconnectFromViewManager();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const [initialViewState, setInitialViewState] = React.useState<\n ViewState | undefined\n >(undefined);\n React.useEffect(() => {\n setInitialViewState(undefined);\n }, [viewDefinitionId, viewState]);\n React.useEffect(() => {\n async function fetchInitialViewstate() {\n let currentViewState: ViewState | undefined;\n if (viewState) {\n if (typeof viewState === \"function\") currentViewState = viewState();\n else currentViewState = viewState;\n } else if (viewDefinitionId && imodel) {\n try {\n currentViewState = await imodel.views.load(viewDefinitionId);\n // istanbul ignore next\n if (!currentViewState) {\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } catch (_e) {\n // istanbul ignore next\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } else {\n Logger.logError(\n \"ViewportComponent\",\n `A Viewstate or a viewId and imodel must be provided`\n );\n }\n // istanbul ignore next\n if (\n isMounted.current &&\n (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)\n ) {\n setInitialViewState(currentViewState?.clone());\n }\n }\n if (undefined === initialViewState) void fetchInitialViewstate();\n }, [imodel, initialViewState, viewDefinitionId, viewState]);\n\n const [viewOverlay, setViewOverlay] = React.useState<React.ReactNode>(null);\n\n // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.\n React.useEffect(() => {\n const parentDiv = viewportDiv.current;\n const viewManager = viewManagerRef.current;\n // istanbul ignore next\n if (\n parentDiv &&\n initialViewState &&\n (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)\n ) {\n if (!screenViewportCreated.current) {\n const screenViewport = getScreenViewport(parentDiv, initialViewState);\n screenViewportRef.current = screenViewport;\n\n if (viewportRef) viewportRef(screenViewport);\n\n Logger.logInfo(\n \"ViewportComponent\",\n `processing viewManager.addViewport for controlId=${controlId}`\n );\n viewManager.addViewport(screenViewport);\n\n // overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.\n setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);\n } else {\n // istanbul ignore next\n screenViewportRef.current?.changeView(initialViewState);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [controlId, initialViewState, viewportRef]);\n\n const handleContextMenu = React.useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n if (onContextMenu) onContextMenu(e);\n },\n [onContextMenu]\n );\n\n const parentDivStyle: React.CSSProperties = {\n height: \"100%\",\n width: \"100%\",\n position: \"relative\",\n };\n\n const viewportDivStyle: React.CSSProperties = {\n ...style,\n height: \"100%\",\n width: \"100%\",\n };\n\n return (\n <div style={parentDivStyle} data-item-id={controlId}>\n <div\n ref={viewportDiv}\n data-testid=\"viewport-component\"\n className={className}\n style={viewportDivStyle}\n onContextMenu={handleContextMenu}\n />\n {viewOverlay}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"ViewportComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,sDAA6C;AAE7C,wDAAiD;AACjD,oDAA+C;AAQ/C,wDAK8B;AAQ9B,uEAAoE;AAkCpE;;;GAGG;AACH,SAAgB,iBAA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;KACd,CAAC;IAEF,OAAO,CACL,6BAAK,KAAK,EAAE,cAAc,kBAAgB,SAAS;QACjD,6BACE,GAAG,EAAE,WAAW,iBACJ,oBAAoB,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,iBAAiB,GAChC;QACD,WAAW,CACR,CACP,CAAC;AACJ,CAAC;AA3TD,8CA2TC","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 Viewport\n */\n\nimport * as React from \"react\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Point3d } from \"@itwin/core-geometry\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport { NpcCenter } from \"@itwin/core-common\";\nimport type {\n IModelConnection,\n TentativePoint,\n ViewManager,\n Viewport,\n ViewState,\n} from \"@itwin/core-frontend\";\nimport {\n IModelApp,\n ScreenViewport,\n StandardView,\n ToolSettings,\n} from \"@itwin/core-frontend\";\n\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n CubeRotationChangeEventArgs,\n DrawingViewportChangeEventArgs,\n StandardRotationChangeEventArgs,\n} from \"./ViewportComponentEvents\";\nimport { ViewportComponentEvents } from \"./ViewportComponentEvents\";\n\n/** Type for a ViewState prop\n * @public\n */\nexport type ViewStateProp = ViewState | (() => ViewState);\n\n/**\n * Properties for [[ViewportComponent]] component.\n * @public\n */\nexport interface ViewportProps extends CommonProps {\n /** IModel to display */\n imodel: IModelConnection;\n /** Id of a default view definition to load as a starting point */\n viewDefinitionId?: Id64String;\n /** ViewState to use as a starting point */\n viewState?: ViewStateProp;\n /** Function to get a reference to the ScreenViewport */\n viewportRef?: (v: ScreenViewport) => void;\n /** controlId for this content component @internal */\n controlId?: string;\n /** @internal */\n onContextMenu?: (e: React.MouseEvent) => boolean;\n /** @internal */\n getViewOverlay?: (viewport: ScreenViewport) => React.ReactNode;\n /** @internal used only for testing */\n viewManagerOverride?: ViewManager;\n /** @internal used only for testing */\n screenViewportOverride?: typeof ScreenViewport;\n /** @internal used only for testing */\n tentativePointOverride?: TentativePoint;\n}\n\n/**\n * A viewport React component that creates a ScreenViewport.\n * @public\n */\nexport function ViewportComponent(props: ViewportProps) {\n const {\n viewState,\n imodel,\n viewDefinitionId,\n getViewOverlay,\n viewManagerOverride,\n tentativePointOverride,\n onContextMenu,\n style,\n className,\n screenViewportOverride,\n controlId,\n viewportRef,\n } = props;\n const viewManagerRef = React.useRef(\n viewManagerOverride ?? IModelApp.viewManager\n );\n const tentativePointOverrideRef = React.useRef(tentativePointOverride);\n const screenViewportCreated = React.useRef(false);\n const viewportDiv = React.useRef<HTMLDivElement>(null);\n const screenViewportRef = React.useRef<ScreenViewport | null>(null);\n const isMounted = React.useRef(false);\n const viewClassFullName = React.useRef(\"\");\n const viewId = React.useRef(\"0\");\n\n const handleViewChanged = (vp: Viewport) => {\n if (!(vp.iModel.isOpen || vp.iModel.isBlank)) return;\n ViewportComponentEvents.setViewMatrix(vp);\n if (viewClassFullName.current !== vp.view.classFullName) {\n setTimeout(() => {\n ViewportComponentEvents.onViewClassFullNameChangedEvent.emit({\n viewport: vp,\n oldName: viewClassFullName.current,\n newName: vp.view.classFullName,\n });\n viewClassFullName.current = vp.view.classFullName;\n });\n }\n if (viewId.current !== vp.view.id) {\n setTimeout(() => {\n ViewportComponentEvents.onViewIdChangedEvent.emit({\n viewport: vp,\n oldId: viewId.current,\n newId: vp.view.id,\n });\n viewId.current = vp.view.id;\n });\n }\n };\n\n const handleStandardRotationChangeEvent = (\n args: StandardRotationChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setRotationAboutPoint(\n StandardView.getStandardRotation(args.standardRotation)\n );\n currentScreenViewport.synchWithView();\n }\n };\n\n const handleDrawingViewportChangeEvent = (\n args: DrawingViewportChangeEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n currentScreenViewport.view.setOrigin(args.origin);\n currentScreenViewport.view.setRotation(args.rotation);\n currentScreenViewport.synchWithView({\n noSaveInUndo: args.complete !== true,\n });\n }\n };\n\n const targetPoint = React.useRef<Point3d | null>(null);\n\n const getRotatePoint = (vp: ScreenViewport): Point3d => {\n const lastTargetPoint = targetPoint.current;\n const tentativePoint =\n tentativePointOverrideRef.current ?? IModelApp.tentativePoint;\n if (tentativePoint.isActive) return tentativePoint.getPoint();\n\n if (null !== lastTargetPoint) {\n const testPt = vp.worldToView(lastTargetPoint);\n const viewRect = vp.viewRect.clone();\n viewRect.scaleAboutCenter(0.25, 0.25);\n if (viewRect.containsPoint(testPt)) return lastTargetPoint;\n targetPoint.current = null;\n }\n\n const visiblePoint = vp.pickNearestVisibleGeometry(\n vp.npcToWorld(NpcCenter),\n vp.pixelsFromInches(ToolSettings.viewToolPickRadiusInches)\n );\n targetPoint.current =\n undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();\n return targetPoint.current ?? vp.view.getCenter();\n };\n\n // eslint-disable-next-line deprecation/deprecation\n const handleCubeRotationChangeEvent = (args: CubeRotationChangeEventArgs) => {\n const viewManager = viewManagerRef.current;\n const currentScreenViewport = screenViewportRef.current;\n if (\n currentScreenViewport &&\n viewManager.selectedView === currentScreenViewport\n ) {\n const rotMatrix = args.rotMatrix;\n if (currentScreenViewport.rotation !== rotMatrix) {\n const inverse = rotMatrix.transpose(); // rotation is from current nav cube state...\n const center = getRotatePoint(currentScreenViewport);\n const targetMatrix = inverse.multiplyMatrixMatrix(\n currentScreenViewport.view.getRotation()\n );\n const worldTransform = Transform.createFixedPointAndMatrix(\n center,\n targetMatrix\n );\n const frustum = currentScreenViewport.getWorldFrustum();\n frustum.multiply(worldTransform);\n currentScreenViewport.view.setupFromFrustum(frustum);\n currentScreenViewport.synchWithView({ noSaveInUndo: !args.complete });\n }\n }\n };\n\n const handleDisconnectFromViewManager = () => {\n const screenViewport = screenViewportRef.current;\n if (screenViewport) {\n const viewManager = IModelApp.viewManager;\n screenViewport.onViewChanged.removeListener(handleViewChanged);\n screenViewportRef.current = null;\n screenViewportCreated.current = false;\n ViewportComponentEvents.onDrawingViewportChangeEvent.removeListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.removeListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.removeListener(\n handleStandardRotationChangeEvent\n );\n viewManager.dropViewport(screenViewport, true);\n }\n };\n\n const handleWindowUnload = () => {\n const parentDiv = viewportDiv.current;\n if (parentDiv) {\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n if (parentWindow !== window) {\n handleDisconnectFromViewManager();\n }\n }\n };\n\n const getScreenViewport = (\n parentDiv: HTMLDivElement,\n inViewState: ViewState\n ) => {\n const screenViewportFactory = screenViewportOverride\n ? screenViewportOverride\n : ScreenViewport;\n const parentWindow = parentDiv.ownerDocument.defaultView as Window;\n parentWindow.addEventListener(\"unload\", handleWindowUnload, {\n once: true,\n capture: true,\n }); // by specifying 'once', listener clears after being called\n ViewportComponentEvents.initialize();\n ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(\n handleDrawingViewportChangeEvent\n );\n ViewportComponentEvents.onCubeRotationChangeEvent.addListener(\n handleCubeRotationChangeEvent\n );\n ViewportComponentEvents.onStandardRotationChangeEvent.addListener(\n handleStandardRotationChangeEvent\n );\n const screenViewport = screenViewportFactory.create(parentDiv, inViewState);\n screenViewportCreated.current = true;\n viewClassFullName.current = screenViewport.view.classFullName;\n viewId.current = screenViewport.view.id;\n screenViewport.onViewChanged.addListener(handleViewChanged);\n return screenViewport;\n };\n\n React.useEffect(() => {\n isMounted.current = true;\n Logger.logInfo(\n \"ViewportComponent\",\n `mounting ViewportComponent for controlId=${controlId}`\n );\n\n return () => {\n isMounted.current = false;\n Logger.logInfo(\n \"ViewportComponent\",\n `un-mounting ViewportComponent for controlId=${controlId}`\n );\n handleDisconnectFromViewManager();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const [initialViewState, setInitialViewState] = React.useState<\n ViewState | undefined\n >(undefined);\n React.useEffect(() => {\n setInitialViewState(undefined);\n }, [viewDefinitionId, viewState]);\n React.useEffect(() => {\n async function fetchInitialViewstate() {\n let currentViewState: ViewState | undefined;\n if (viewState) {\n if (typeof viewState === \"function\") currentViewState = viewState();\n else currentViewState = viewState;\n } else if (viewDefinitionId && imodel) {\n try {\n currentViewState = await imodel.views.load(viewDefinitionId);\n if (!currentViewState) {\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } catch (_e) {\n Logger.logError(\"ViewportComponent\", `Viewstate failed to load`);\n }\n } else {\n Logger.logError(\n \"ViewportComponent\",\n `A Viewstate or a viewId and imodel must be provided`\n );\n }\n if (\n isMounted.current &&\n (currentViewState?.iModel.isOpen || currentViewState?.iModel.isBlank)\n ) {\n setInitialViewState(currentViewState?.clone());\n }\n }\n if (undefined === initialViewState) void fetchInitialViewstate();\n }, [imodel, initialViewState, viewDefinitionId, viewState]);\n\n const [viewOverlay, setViewOverlay] = React.useState<React.ReactNode>(null);\n\n // This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.\n React.useEffect(() => {\n const parentDiv = viewportDiv.current;\n const viewManager = viewManagerRef.current;\n if (\n parentDiv &&\n initialViewState &&\n (initialViewState?.iModel.isOpen || initialViewState?.iModel.isBlank)\n ) {\n if (!screenViewportCreated.current) {\n const screenViewport = getScreenViewport(parentDiv, initialViewState);\n screenViewportRef.current = screenViewport;\n\n if (viewportRef) viewportRef(screenViewport);\n\n Logger.logInfo(\n \"ViewportComponent\",\n `processing viewManager.addViewport for controlId=${controlId}`\n );\n viewManager.addViewport(screenViewport);\n\n // overlay component is set up once a ScreenViewport is available. The overlay component must handle any view changes itself.\n setViewOverlay(getViewOverlay ? getViewOverlay(screenViewport) : null);\n } else {\n screenViewportRef.current?.changeView(initialViewState);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [controlId, initialViewState, viewportRef]);\n\n const handleContextMenu = React.useCallback(\n (e: React.MouseEvent) => {\n e.preventDefault();\n if (onContextMenu) onContextMenu(e);\n },\n [onContextMenu]\n );\n\n const parentDivStyle: React.CSSProperties = {\n height: \"100%\",\n width: \"100%\",\n position: \"relative\",\n };\n\n const viewportDivStyle: React.CSSProperties = {\n ...style,\n height: \"100%\",\n width: \"100%\",\n };\n\n return (\n <div style={parentDivStyle} data-item-id={controlId}>\n <div\n ref={viewportDiv}\n data-testid=\"viewport-component\"\n className={className}\n style={viewportDivStyle}\n onContextMenu={handleContextMenu}\n />\n {viewOverlay}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewportComponentEvents.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAEV,cAAc,EACd,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AAEH,qBAAa,0BAA2B,SAAQ,OAAO,CAAC,8BAA8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WAA6B;IAClE,gBAAuB,4BAA4B,6BAChB;IACnC,gBAAuB,yBAAyB,0BAChB;IAChC,gBAAuB,6BAA6B,8BAChB;IACpC,gBAAuB,yBAAyB,0BAChB;IAChC,gBAAuB,+BAA+B,gCAChB;IAEtC,gBAAuB,oBAAoB,qBAA4B;IAEvE,OAAO,CAAC,MAAM,CAAC,6BAA6B;WAM9B,aAAa,CACzB,SAAS,EAAE,QAAQ,EACnB,IAAI,OAAY,EAChB,QAAQ,GAAE,OAAe,GACxB,IAAI;WAMO,uBAAuB,CACnC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,OAAe,GACxB,IAAI;WAIO,mBAAmB,CAAC,gBAAgB,EAAE,cAAc,GAAG,IAAI;WAI3D,aAAa,CACzB,QAAQ,EAAE,QAAQ,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI;CAaR"}
1
+ {"version":3,"file":"ViewportComponentEvents.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAEV,cAAc,EACd,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AAEH,qBAAa,0BAA2B,SAAQ,OAAO,CAAC,8BAA8B,CAAC;CAAG;AAE1F;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,QAAQ,CAAC;IACpB,IAA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IACpC,gBAAuB,yBAAyB,0BAChB;IAChC,gBAAuB,+BAA+B,gCAChB;IAEtC,gBAAuB,oBAAoB,qBAA4B;IAEvE,OAAO,CAAC,MAAM,CAAC,6BAA6B;WAM9B,aAAa,CACzB,SAAS,EAAE,QAAQ,EACnB,IAAI,OAAY,EAChB,QAAQ,GAAE,OAAe,GACxB,IAAI;WAMO,uBAAuB,CACnC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,OAAe,GACxB,IAAI;WAIO,mBAAmB,CAAC,gBAAgB,EAAE,cAAc,GAAG,IAAI;WAI3D,aAAa,CACzB,QAAQ,EAAE,QAAQ,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI;CAYR"}
@@ -95,7 +95,6 @@ class ViewportComponentEvents {
95
95
  static setViewMatrix(viewport, animationTime) {
96
96
  // When handling onViewChanged, use setTimeout
97
97
  setTimeout(() => {
98
- // istanbul ignore next
99
98
  if (viewport.view) {
100
99
  this.origin.setFrom(viewport.view.getOrigin());
101
100
  this.extents.setFrom(viewport.view.getExtents());
@@ -1 +1 @@
1
- {"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponentEvents.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,wDAAmE;AAMnE,wDAAiD;AACjD,0DAAgD;AAChD,iDAA8C;AAY9C;;;GAGG;AACH,mDAAmD;AACnD,MAAa,0BAA2B,SAAQ,wBAAuC;CAAG;AAA1F,gEAA0F;AAY1F;;;GAGG;AACH,mDAAmD;AACnD,MAAa,uBAAwB,SAAQ,wBAAoC;CAAG;AAApF,0DAAoF;AAUpF;;;GAGG;AACH,mDAAmD;AACnD,MAAa,2BAA4B,SAAQ,wBAAwC;CAAG;AAA5F,kEAA4F;AAW5F;;;GAGG;AACH,mDAAmD;AACnD,MAAa,uBAAwB,SAAQ,wBAAoC;CAAG;AAApF,0DAAoF;A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4CAAoB,GAAG,IAAI,kBAAkB,EAAE,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 Viewport\n */\n\nimport { Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\nimport type {\n SelectedViewportChangedArgs,\n StandardViewId,\n Viewport,\n} from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UiEvent } from \"@itwin/appui-abstract\";\nimport { Face } from \"../navigationaids/Cube\";\n\n/** Arguments for [[DrawingViewportChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface DrawingViewportChangeEventArgs {\n rotation: Matrix3d;\n origin: Point3d;\n complete: boolean;\n}\n\n/** Drawing View Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class DrawingViewportChangeEvent extends UiEvent<DrawingViewportChangeEventArgs> {}\n\n/** Arguments for [[CubeRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface CubeRotationChangeEventArgs {\n rotMatrix: Matrix3d;\n face: Face;\n complete?: boolean;\n}\n\n/** 3d Cube Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class CubeRotationChangeEvent extends UiEvent<CubeRotationChangeEventArgs> {}\n\n/** Arguments for [[StandardRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface StandardRotationChangeEventArgs {\n standardRotation: StandardViewId;\n}\n\n/** Standard Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class StandardRotationChangeEvent extends UiEvent<StandardRotationChangeEventArgs> {}\n\n/** Arguments for [[ViewRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewRotationChangeEventArgs {\n viewport: Viewport;\n animationTime?: number;\n}\n\n/** View Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewRotationChangeEvent extends UiEvent<ViewRotationChangeEventArgs> {}\n\n/** Arguments for [[ViewClassFullNameChangedEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewClassFullNameChangedEventArgs {\n viewport: Viewport;\n oldName: string;\n newName: string;\n}\n\n/** View Class Full Name Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewClassFullNameChangedEvent extends UiEvent<ViewClassFullNameChangedEventArgs> {}\n\n/** Arguments for [[ViewIdChangedEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewIdChangedEventArgs {\n viewport: Viewport;\n oldId: string;\n newId: string;\n}\n\n/** View Id Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewIdChangedEvent extends UiEvent<ViewIdChangedEventArgs> {}\n\n/** Viewport Rotation events and methods\n * @public\n */\nexport class ViewportComponentEvents {\n private static _removeListener?: () => void;\n\n public static initialize() {\n if (undefined !== this._removeListener) return;\n\n this._removeListener =\n IModelApp.viewManager.onSelectedViewportChanged.addListener(\n ViewportComponentEvents.handleSelectedViewportChanged\n );\n }\n\n /** @internal - for unit testing */\n public static terminate() {\n if (this._removeListener) {\n this._removeListener();\n this._removeListener = undefined;\n }\n }\n\n public static face = Face.None;\n public static readonly origin = Point3d.createZero();\n public static readonly extents = Vector3d.createZero();\n public static readonly rotationMatrix = Matrix3d.createIdentity();\n public static readonly onDrawingViewportChangeEvent =\n new DrawingViewportChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onCubeRotationChangeEvent =\n new CubeRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onStandardRotationChangeEvent =\n new StandardRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onViewRotationChangeEvent =\n new ViewRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onViewClassFullNameChangedEvent =\n new ViewClassFullNameChangedEvent(); // eslint-disable-line deprecation/deprecation\n // eslint-disable-next-line deprecation/deprecation\n public static readonly onViewIdChangedEvent = new ViewIdChangedEvent();\n\n private static handleSelectedViewportChanged(\n args: SelectedViewportChangedArgs\n ): void {\n if (args.current) ViewportComponentEvents.setViewMatrix(args.current);\n }\n\n public static setCubeMatrix(\n rotMatrix: Matrix3d,\n face = Face.None,\n complete: boolean = false\n ): void {\n this.rotationMatrix.setFrom(rotMatrix);\n this.face = face;\n this.onCubeRotationChangeEvent.emit({ rotMatrix, complete, face });\n }\n\n public static setDrawingViewportState(\n origin: Point3d,\n rotation: Matrix3d,\n complete: boolean = false\n ): void {\n this.onDrawingViewportChangeEvent.emit({ origin, rotation, complete });\n }\n\n public static setStandardRotation(standardRotation: StandardViewId): void {\n this.onStandardRotationChangeEvent.emit({ standardRotation });\n }\n\n public static setViewMatrix(\n viewport: Viewport,\n animationTime?: number\n ): void {\n // When handling onViewChanged, use setTimeout\n setTimeout(() => {\n // istanbul ignore next\n if (viewport.view) {\n this.origin.setFrom(viewport.view.getOrigin());\n this.extents.setFrom(viewport.view.getExtents());\n }\n this.rotationMatrix.setFrom(viewport.rotation);\n\n this.onViewRotationChangeEvent.emit({ viewport, animationTime });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ViewportComponentEvents.js","sourceRoot":"","s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M,GAAG,uBAAO,CAAC,UAAU,EAAE,CAAC;AAC9B,+BAAO,GAAG,wBAAQ,CAAC,UAAU,EAAE,CAAC;AAChC,sCAAc,GAAG,wBAAQ,CAAC,cAAc,EAAE,CAAC;AAC3C,oDAA4B,GACjD,IAAI,0BAA0B,EAAE,CAAC,CAAC,8CAA8C;AAC3D,iDAAyB,GAC9C,IAAI,uBAAuB,EAAE,CAAC,CAAC,8CAA8C;AACxD,qDAA6B,GAClD,IAAI,2BAA2B,EAAE,CAAC,CAAC,8CAA8C;AAC5D,iDAAyB,GAC9C,IAAI,uBAAuB,EAAE,CAAC,CAAC,8CAA8C;AACxD,uDAA+B,GACpD,IAAI,6BAA6B,EAAE,CAAC,CAAC,8CAA8C;AACrF,mDAAmD;AAC5B,4CAAoB,GAAG,IAAI,kBAAkB,EAAE,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 Viewport\n */\n\nimport { Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\nimport type {\n SelectedViewportChangedArgs,\n StandardViewId,\n Viewport,\n} from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UiEvent } from \"@itwin/appui-abstract\";\nimport { Face } from \"../navigationaids/Cube\";\n\n/** Arguments for [[DrawingViewportChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface DrawingViewportChangeEventArgs {\n rotation: Matrix3d;\n origin: Point3d;\n complete: boolean;\n}\n\n/** Drawing View Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class DrawingViewportChangeEvent extends UiEvent<DrawingViewportChangeEventArgs> {}\n\n/** Arguments for [[CubeRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface CubeRotationChangeEventArgs {\n rotMatrix: Matrix3d;\n face: Face;\n complete?: boolean;\n}\n\n/** 3d Cube Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class CubeRotationChangeEvent extends UiEvent<CubeRotationChangeEventArgs> {}\n\n/** Arguments for [[StandardRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface StandardRotationChangeEventArgs {\n standardRotation: StandardViewId;\n}\n\n/** Standard Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class StandardRotationChangeEvent extends UiEvent<StandardRotationChangeEventArgs> {}\n\n/** Arguments for [[ViewRotationChangeEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewRotationChangeEventArgs {\n viewport: Viewport;\n animationTime?: number;\n}\n\n/** View Rotation Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewRotationChangeEvent extends UiEvent<ViewRotationChangeEventArgs> {}\n\n/** Arguments for [[ViewClassFullNameChangedEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewClassFullNameChangedEventArgs {\n viewport: Viewport;\n oldName: string;\n newName: string;\n}\n\n/** View Class Full Name Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewClassFullNameChangedEvent extends UiEvent<ViewClassFullNameChangedEventArgs> {}\n\n/** Arguments for [[ViewIdChangedEvent]]\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ViewIdChangedEventArgs {\n viewport: Viewport;\n oldId: string;\n newId: string;\n}\n\n/** View Id Change event\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ViewIdChangedEvent extends UiEvent<ViewIdChangedEventArgs> {}\n\n/** Viewport Rotation events and methods\n * @public\n */\nexport class ViewportComponentEvents {\n private static _removeListener?: () => void;\n\n public static initialize() {\n if (undefined !== this._removeListener) return;\n\n this._removeListener =\n IModelApp.viewManager.onSelectedViewportChanged.addListener(\n ViewportComponentEvents.handleSelectedViewportChanged\n );\n }\n\n /** @internal - for unit testing */\n public static terminate() {\n if (this._removeListener) {\n this._removeListener();\n this._removeListener = undefined;\n }\n }\n\n public static face = Face.None;\n public static readonly origin = Point3d.createZero();\n public static readonly extents = Vector3d.createZero();\n public static readonly rotationMatrix = Matrix3d.createIdentity();\n public static readonly onDrawingViewportChangeEvent =\n new DrawingViewportChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onCubeRotationChangeEvent =\n new CubeRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onStandardRotationChangeEvent =\n new StandardRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onViewRotationChangeEvent =\n new ViewRotationChangeEvent(); // eslint-disable-line deprecation/deprecation\n public static readonly onViewClassFullNameChangedEvent =\n new ViewClassFullNameChangedEvent(); // eslint-disable-line deprecation/deprecation\n // eslint-disable-next-line deprecation/deprecation\n public static readonly onViewIdChangedEvent = new ViewIdChangedEvent();\n\n private static handleSelectedViewportChanged(\n args: SelectedViewportChangedArgs\n ): void {\n if (args.current) ViewportComponentEvents.setViewMatrix(args.current);\n }\n\n public static setCubeMatrix(\n rotMatrix: Matrix3d,\n face = Face.None,\n complete: boolean = false\n ): void {\n this.rotationMatrix.setFrom(rotMatrix);\n this.face = face;\n this.onCubeRotationChangeEvent.emit({ rotMatrix, complete, face });\n }\n\n public static setDrawingViewportState(\n origin: Point3d,\n rotation: Matrix3d,\n complete: boolean = false\n ): void {\n this.onDrawingViewportChangeEvent.emit({ origin, rotation, complete });\n }\n\n public static setStandardRotation(standardRotation: StandardViewId): void {\n this.onStandardRotationChangeEvent.emit({ standardRotation });\n }\n\n public static setViewMatrix(\n viewport: Viewport,\n animationTime?: number\n ): void {\n // When handling onViewChanged, use setTimeout\n setTimeout(() => {\n if (viewport.view) {\n this.origin.setFrom(viewport.view.getOrigin());\n this.extents.setFrom(viewport.view.getExtents());\n }\n this.rotationMatrix.setFrom(viewport.rotation);\n\n this.onViewRotationChangeEvent.emit({ viewport, animationTime });\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UiIModelComponents.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/UiIModelComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IAEpC;;OAEG;WACiB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB/C,gEAAgE;WAClD,SAAS;IAQvB,4DAA4D;IAC5D,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAgBvD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
1
+ {"version":3,"file":"UiIModelComponents.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/UiIModelComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IAEpC;;OAEG;WACiB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB/C,gEAAgE;WAClD,SAAS;IAQvB,4DAA4D;IAC5D,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAavD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
@@ -57,8 +57,7 @@ export class UiIModelComponents {
57
57
  * @internal
58
58
  */
59
59
  static translate(key) {
60
- if (!UiIModelComponents.initialized ||
61
- /* istanbul ignore next */ !IModelApp.localization) {
60
+ if (!UiIModelComponents.initialized || !IModelApp.localization) {
62
61
  Logger.logError(UiIModelComponents.loggerCategory(this), `translate: IModelApp.localization has not been setup. Returning blank string.`);
63
62
  return "";
64
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UiIModelComponents.js","sourceRoot":"","sources":["../../../src/imodel-components-react/UiIModelComponents.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAG7B;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU;QAC5B,IAAI,kBAAkB,CAAC,YAAY,EAAE,CAAC;YACpC,MAAM,CAAC,OAAO,CACZ,kBAAkB,CAAC,cAAc,CAAC,kBAAkB,CAAC,EACrD,8CAA8C,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S,CAAC,YAAY,CAAC,kBAAkB,CAC9C,GAAG,kBAAkB,CAAC,qBAAqB,IAAI,GAAG,EAAE,CACrD,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GACZ,kBAAkB,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA/Ec,+BAAY,GAAG,KAAK,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 Common\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UiComponents } from \"@itwin/components-react\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\nimport { getObjectClassName } from \"@itwin/core-react\";\n/**\n * Manages the localization service for the imodel-components-react package.\n * @public\n */\nexport class UiIModelComponents {\n private static _initialized = false;\n\n /**\n * initialize UiIModelComponents.\n */\n public static async initialize(): Promise<void> {\n if (UiIModelComponents._initialized) {\n Logger.logInfo(\n UiIModelComponents.loggerCategory(UiIModelComponents),\n `UiIModelComponents.initialize already called`\n );\n return;\n }\n\n await IModelApp.localization?.registerNamespace(\n UiIModelComponents.localizationNamespace\n );\n\n if (!IModelApp.localization) {\n // it should only get here in unit test where IModelApp is not setup\n const localization = new EmptyLocalization();\n await localization.initialize();\n await UiComponents.initialize(localization);\n } else {\n await UiComponents.initialize(IModelApp.localization);\n }\n\n UiIModelComponents._initialized = true;\n }\n\n /** Unregisters the UiIModelComponents localization namespace */\n public static terminate() {\n IModelApp.localization?.unregisterNamespace(\n UiIModelComponents.localizationNamespace\n );\n UiComponents.terminate();\n UiIModelComponents._initialized = false;\n }\n\n /** Determines if UiIModelComponents has been initialized */\n public static get initialized(): boolean {\n return UiIModelComponents._initialized;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiIModelComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"imodel-components-react\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiIModelComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (\n !UiIModelComponents.initialized ||\n /* istanbul ignore next */ !IModelApp.localization\n ) {\n Logger.logError(\n UiIModelComponents.loggerCategory(this),\n `translate: IModelApp.localization has not been setup. Returning blank string.`\n );\n return \"\";\n }\n return IModelApp.localization.getLocalizedString(\n `${UiIModelComponents.localizationNamespace}:${key}`\n );\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category =\n UiIModelComponents.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
1
+ {"version":3,"file":"UiIModelComponents.js","sourceRoot":"","sources":["../../../src/imodel-components-react/UiIModelComponents.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAG7B;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU;QAC5B,IAAI,kBAAkB,CAAC,YAAY,EAAE,CAAC;YACpC,MAAM,CAAC,OAAO,CACZ,kBAAkB,CAAC,cAAc,CAAC,kBAAkB,C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AO,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAC9C,GAAG,kBAAkB,CAAC,qBAAqB,IAAI,GAAG,EAAE,CACrD,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GACZ,kBAAkB,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AA5Ec,+BAAY,GAAG,KAAK,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 Common\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UiComponents } from \"@itwin/components-react\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\nimport { getObjectClassName } from \"@itwin/core-react\";\n/**\n * Manages the localization service for the imodel-components-react package.\n * @public\n */\nexport class UiIModelComponents {\n private static _initialized = false;\n\n /**\n * initialize UiIModelComponents.\n */\n public static async initialize(): Promise<void> {\n if (UiIModelComponents._initialized) {\n Logger.logInfo(\n UiIModelComponents.loggerCategory(UiIModelComponents),\n `UiIModelComponents.initialize already called`\n );\n return;\n }\n\n await IModelApp.localization?.registerNamespace(\n UiIModelComponents.localizationNamespace\n );\n\n if (!IModelApp.localization) {\n // it should only get here in unit test where IModelApp is not setup\n const localization = new EmptyLocalization();\n await localization.initialize();\n await UiComponents.initialize(localization);\n } else {\n await UiComponents.initialize(IModelApp.localization);\n }\n\n UiIModelComponents._initialized = true;\n }\n\n /** Unregisters the UiIModelComponents localization namespace */\n public static terminate() {\n IModelApp.localization?.unregisterNamespace(\n UiIModelComponents.localizationNamespace\n );\n UiComponents.terminate();\n UiIModelComponents._initialized = false;\n }\n\n /** Determines if UiIModelComponents has been initialized */\n public static get initialized(): boolean {\n return UiIModelComponents._initialized;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiIModelComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"imodel-components-react\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiIModelComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiIModelComponents.initialized || !IModelApp.localization) {\n Logger.logError(\n UiIModelComponents.loggerCategory(this),\n `translate: IModelApp.localization has not been setup. Returning blank string.`\n );\n return \"\";\n }\n return IModelApp.localization.getLocalizedString(\n `${UiIModelComponents.localizationNamespace}:${key}`\n );\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category =\n UiIModelComponents.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AlphaSlider.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAC1C,WAAW;IACb,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AAEH,qBAAa,WAAY,SAAQ,KAAK,CA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,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,qBAAqB;IAK7B,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CA0C1C"}
@@ -29,12 +29,10 @@ export class AlphaSlider extends React.PureComponent {
29
29
  x = e.pageX;
30
30
  }
31
31
  else {
32
- // istanbul ignore if
33
32
  if (undefined === e.touches)
34
33
  return undefined;
35
34
  x = e.touches[0].pageX;
36
35
  }
37
- // istanbul ignore if
38
36
  if (undefined === x)
39
37
  return undefined;
40
38
  let y = 0;
@@ -42,19 +40,16 @@ export class AlphaSlider extends React.PureComponent {
42
40
  y = e.pageY;
43
41
  }
44
42
  else {
45
- // istanbul ignore if
46
43
  if (undefined === e.touches)
47
44
  return;
48
45
  y = e.touches[0].pageY;
49
46
  }
50
- // istanbul ignore if
51
47
  if (undefined === y)
52
48
  return undefined;
53
49
  const left = x - (container.getBoundingClientRect().left + window.scrollX);
54
50
  const top = y - (container.getBoundingClientRect().top + window.scrollY);
55
51
  let t = 0;
56
52
  if (!isHorizontal) {
57
- // istanbul ignore next
58
53
  if (top < 0) {
59
54
  t = 1;
60
55
  }
@@ -67,7 +62,6 @@ export class AlphaSlider extends React.PureComponent {
67
62
  }
68
63
  else {
69
64
  // horizontal
70
- // istanbul ignore next
71
65
  if (left < 0) {
72
66
  t = 0;
73
67
  }
@@ -78,17 +72,13 @@ export class AlphaSlider extends React.PureComponent {
78
72
  t = left / containerWidth;
79
73
  }
80
74
  }
81
- // istanbul ignore if
82
75
  if (t < 0)
83
76
  t = 0;
84
- // istanbul ignore if
85
77
  if (t > 1)
86
78
  t = 1;
87
- // istanbul ignore next
88
79
  return alpha !== t ? t : undefined;
89
80
  };
90
81
  this._onChange = (e) => {
91
- // istanbul ignore else
92
82
  if (this._container && this.props.onAlphaChange) {
93
83
  const change = this._calculateChange(e, this.props.isHorizontal ? this.props.isHorizontal : false, this.props.alpha, this._container);
94
84
  undefined !== change &&
@@ -98,7 +88,6 @@ export class AlphaSlider extends React.PureComponent {
98
88
  };
99
89
  this._onMouseDown = (e) => {
100
90
  this._onChange(e);
101
- // istanbul ignore else
102
91
  if (this._container)
103
92
  this._container.focus();
104
93
  window.addEventListener("mousemove", this._onChange);
@@ -124,20 +113,15 @@ export class AlphaSlider extends React.PureComponent {
124
113
  newTransparency = 0;
125
114
  }
126
115
  else {
127
- // istanbul ignore else
128
116
  if (evt.key === Key.End.valueOf()) {
129
117
  newTransparency = 1;
130
118
  }
131
119
  }
132
- // istanbul ignore else
133
120
  if (undefined !== newTransparency) {
134
- // istanbul ignore if
135
121
  if (newTransparency > 1)
136
122
  newTransparency = 1;
137
- // istanbul ignore if
138
123
  if (newTransparency < 0)
139
124
  newTransparency = 0;
140
- // istanbul ignore else
141
125
  if (this.props.onAlphaChange)
142
126
  this.props.onAlphaChange(newTransparency);
143
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AlphaSlider.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAiB3D;;;GAGG;AACH,mDAAmD;AACnD,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAA+B;IAGpE,gBAAgB;IAChB,mDAAmD;IACnD,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QALP,eAAU,GAA0B,IAAI,CAAC;QAQzC,qBAAgB,GAAG,CACzB,CAAsE,EACtE,YAAqB,EACrB,KAAa,EACb,SAAyB,EACL,EAAE;YACtB,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAA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AC3B,CACE,CACF,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Color\n */\n\nimport \"./AlphaSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties for the [[AlphaSlider]] React component\n * @public\n * @deprecated in 4.11.x. Props of deprecated component {@link AlphaSlider}.\n */\nexport interface AlphaSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user selects color swatch */\n onAlphaChange?: ((alpha: number) => void) | undefined;\n /** Alpha value between 0 (transparent) and 1 (opaque) */\n alpha: number;\n}\n\n/** AlphaSlider component used to set the alpha value.\n * @public\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: AlphaSliderProps) {\n super(props);\n }\n\n private _calculateChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n alpha: number,\n container: HTMLDivElement\n ): number | undefined => {\n e.preventDefault();\n const { width: containerWidth, height: containerHeight } =\n container.getBoundingClientRect();\n\n let x = 0;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n // istanbul ignore if\n if (undefined === e.touches) return undefined;\n x = e.touches[0].pageX;\n }\n // istanbul ignore if\n if (undefined === x) return undefined;\n\n let y = 0;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n // istanbul ignore if\n if (undefined === e.touches) return;\n y = e.touches[0].pageY;\n }\n // istanbul ignore if\n if (undefined === y) return undefined;\n\n const left = x - (container.getBoundingClientRect().left + window.scrollX);\n const top = y - (container.getBoundingClientRect().top + window.scrollY);\n\n let t = 0;\n\n if (!isHorizontal) {\n // istanbul ignore next\n if (top < 0) {\n t = 1;\n } else if (top > containerHeight) {\n t = 0;\n } else {\n t = 1 - top / containerHeight;\n }\n } else {\n // horizontal\n // istanbul ignore next\n if (left < 0) {\n t = 0;\n } else if (left > containerWidth) {\n t = 1;\n } else {\n t = left / containerWidth;\n }\n }\n\n // istanbul ignore if\n if (t < 0) t = 0;\n // istanbul ignore if\n if (t > 1) t = 1;\n // istanbul ignore next\n return alpha !== t ? t : undefined;\n };\n\n /** @internal */\n public override componentWillUnmount() {\n this._unbindEventListeners();\n }\n\n private _onChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n // istanbul ignore else\n if (this._container && this.props.onAlphaChange) {\n const change = this._calculateChange(\n e,\n this.props.isHorizontal ? this.props.isHorizontal : false,\n this.props.alpha,\n this._container\n );\n undefined !== change &&\n typeof this.props.onAlphaChange === \"function\" &&\n this.props.onAlphaChange(change);\n }\n };\n\n private _onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {\n this._onChange(e);\n // istanbul ignore else\n if (this._container) this._container.focus();\n window.addEventListener(\"mousemove\", this._onChange as any);\n window.addEventListener(\"mouseup\", this._onMouseUp);\n };\n\n private _onKeyDown = (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newTransparency: number | undefined;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.Home.valueOf()) {\n newTransparency = 0;\n } else {\n // istanbul ignore else\n if (evt.key === Key.End.valueOf()) {\n newTransparency = 1;\n }\n }\n\n // istanbul ignore else\n if (undefined !== newTransparency) {\n // istanbul ignore if\n if (newTransparency > 1) newTransparency = 1;\n // istanbul ignore if\n if (newTransparency < 0) newTransparency = 0;\n // istanbul ignore else\n if (this.props.onAlphaChange) this.props.onAlphaChange(newTransparency);\n }\n };\n\n private _onMouseUp = () => {\n this._unbindEventListeners();\n };\n\n private _unbindEventListeners() {\n window.removeEventListener(\"mousemove\", this._onChange as any);\n window.removeEventListener(\"mouseup\", this._onMouseUp);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const containerClasses = classnames(\n this.props.isHorizontal\n ? \"components-alpha-container-horizontal\"\n : \"components-alpha-container-vertical\",\n this.props.className\n );\n\n const pointerStyle: React.CSSProperties = this.props.isHorizontal\n ? { left: `${this.props.alpha * 100}%` }\n : { left: `0px`, top: `${-(this.props.alpha * 100) + 100}%` };\n\n return (\n <div\n className={containerClasses}\n style={this.props.style}\n data-testid=\"alpha-container\"\n >\n <div\n data-testid=\"alpha-slider\"\n role=\"slider\"\n aria-label={UiIModelComponents.translate(\"color.transparency\")}\n aria-valuemin={0}\n aria-valuemax={1}\n aria-valuenow={this.props.alpha}\n className=\"components-alpha-slider\"\n ref={(container) => (this._container = container)}\n onMouseDown={this._onMouseDown}\n onTouchMove={this._onChange}\n onTouchStart={this._onChange}\n tabIndex={0}\n onKeyDown={this._onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-alpha-pointer\"\n data-testid=\"alpha-pointer\"\n />\n </div>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,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CAAC,oBAAoB,CAAC,mBAC/C,CAAC,mBACD,CAAC,mBACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAC/B,SAAS,EAAC,yBAAyB,EACnC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,EACjD,WAAW,EAAE,IAAI,CAAC,YAAY,EAC9B,WAAW,EAAE,IAAI,CAAC,SAAS,EAC3B,YAAY,EAAE,IAAI,CAAC,SAAS,EAC5B,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,IAAI,CAAC,UAAU;gBAE1B,6BACE,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,0BAA0B,iBACxB,eAAe,GAC3B,CACE,CACF,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Color\n */\n\nimport \"./AlphaSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties for the [[AlphaSlider]] React component\n * @public\n * @deprecated in 4.11.x. Props of deprecated component {@link AlphaSlider}.\n */\nexport interface AlphaSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user selects color swatch */\n onAlphaChange?: ((alpha: number) => void) | undefined;\n /** Alpha value between 0 (transparent) and 1 (opaque) */\n alpha: number;\n}\n\n/** AlphaSlider component used to set the alpha value.\n * @public\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: AlphaSliderProps) {\n super(props);\n }\n\n private _calculateChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n alpha: number,\n container: HTMLDivElement\n ): number | undefined => {\n e.preventDefault();\n const { width: containerWidth, height: containerHeight } =\n container.getBoundingClientRect();\n\n let x = 0;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n if (undefined === e.touches) return undefined;\n x = e.touches[0].pageX;\n }\n if (undefined === x) return undefined;\n\n let y = 0;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n if (undefined === e.touches) return;\n y = e.touches[0].pageY;\n }\n if (undefined === y) return undefined;\n\n const left = x - (container.getBoundingClientRect().left + window.scrollX);\n const top = y - (container.getBoundingClientRect().top + window.scrollY);\n\n let t = 0;\n\n if (!isHorizontal) {\n if (top < 0) {\n t = 1;\n } else if (top > containerHeight) {\n t = 0;\n } else {\n t = 1 - top / containerHeight;\n }\n } else {\n // horizontal\n if (left < 0) {\n t = 0;\n } else if (left > containerWidth) {\n t = 1;\n } else {\n t = left / containerWidth;\n }\n }\n\n if (t < 0) t = 0;\n if (t > 1) t = 1;\n return alpha !== t ? t : undefined;\n };\n\n /** @internal */\n public override componentWillUnmount() {\n this._unbindEventListeners();\n }\n\n private _onChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (this._container && this.props.onAlphaChange) {\n const change = this._calculateChange(\n e,\n this.props.isHorizontal ? this.props.isHorizontal : false,\n this.props.alpha,\n this._container\n );\n undefined !== change &&\n typeof this.props.onAlphaChange === \"function\" &&\n this.props.onAlphaChange(change);\n }\n };\n\n private _onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {\n this._onChange(e);\n if (this._container) this._container.focus();\n window.addEventListener(\"mousemove\", this._onChange as any);\n window.addEventListener(\"mouseup\", this._onMouseUp);\n };\n\n private _onKeyDown = (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newTransparency: number | undefined;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.Home.valueOf()) {\n newTransparency = 0;\n } else {\n if (evt.key === Key.End.valueOf()) {\n newTransparency = 1;\n }\n }\n\n if (undefined !== newTransparency) {\n if (newTransparency > 1) newTransparency = 1;\n if (newTransparency < 0) newTransparency = 0;\n if (this.props.onAlphaChange) this.props.onAlphaChange(newTransparency);\n }\n };\n\n private _onMouseUp = () => {\n this._unbindEventListeners();\n };\n\n private _unbindEventListeners() {\n window.removeEventListener(\"mousemove\", this._onChange as any);\n window.removeEventListener(\"mouseup\", this._onMouseUp);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const containerClasses = classnames(\n this.props.isHorizontal\n ? \"components-alpha-container-horizontal\"\n : \"components-alpha-container-vertical\",\n this.props.className\n );\n\n const pointerStyle: React.CSSProperties = this.props.isHorizontal\n ? { left: `${this.props.alpha * 100}%` }\n : { left: `0px`, top: `${-(this.props.alpha * 100) + 100}%` };\n\n return (\n <div\n className={containerClasses}\n style={this.props.style}\n data-testid=\"alpha-container\"\n >\n <div\n data-testid=\"alpha-slider\"\n role=\"slider\"\n aria-label={UiIModelComponents.translate(\"color.transparency\")}\n aria-valuemin={0}\n aria-valuemax={1}\n aria-valuenow={this.props.alpha}\n className=\"components-alpha-slider\"\n ref={(container) => (this._container = container)}\n onMouseDown={this._onMouseDown}\n onTouchMove={this._onChange}\n onTouchStart={this._onChange}\n tabIndex={0}\n onKeyDown={this._onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-alpha-pointer\"\n data-testid=\"alpha-pointer\"\n />\n </div>\n </div>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+CrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,WAAW;IACb,mBAAmB;IACnB,YAAY,EAAE,QAAQ,CAAC;IACvB,uBAAuB;IACvB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,qDAAqD;IACrD,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAE9B,KAAK,EAAE,gBAAgB,KACpB,KAAK,CAAC,SAAuC,CAAC"}
1
+ {"version":3,"file":"ColorPickerButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+CrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,WAAW;IACb,mBAAmB;IACnB,YAAY,EAAE,QAAQ,CAAC;IACvB,uBAAuB;IACvB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,qDAAqD;IACrD,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAmID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAE9B,KAAK,EAAE,gBAAgB,KACpB,KAAK,CAAC,SAAuC,CAAC"}
@@ -61,7 +61,6 @@ const ForwardRefColorPickerButton = React.forwardRef(function ForwardRefColorPic
61
61
  }, [showPopup]);
62
62
  const handleColorPicked = React.useCallback((color) => {
63
63
  closePopup();
64
- // istanbul ignore else
65
64
  if (!color.equals(colorDef)) {
66
65
  setColorDef(color);
67
66
  onColorPick && onColorPick(color);
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEhF,4BAA4B;AAE5B,SAAS,YAAY,CAAC,EACpB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,KAAK,EACL,KAAK,GAON;IACC,MAAM,cAAc,GAAwB;QAC1C,mBAAmB,EAAE,UAAU,UAAU,QAAQ;KAClD,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,wCAAwC;QACpD,KAAK,IAAI,gCAAK,KAAK,CAAM;QAC1B,4CACc,qCAAqC,EACjD,SAAS,EAAC,qCAAqC,EAC/C,KAAK,EAAE,cAAc,IAEpB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7B,mDAAmD;QACnD,oBAAC,WAAW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3B,KAAK,EAAE,CAAC,CAAC,KAAK,EACd,KAAK,EAAE,aAAa,GACpB,CACI,CACP,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAGP,2BAA2B,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 Color\n */\n\nimport \"./ColorPickerButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport { ColorSwatch } from \"./Swatch\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\n\n// cSpell:ignore colorpicker\n\nfunction ColorOptions({\n handleColorPicked,\n options,\n numColumns,\n round,\n title,\n}: {\n handleColorPicked: (color: ColorDef) => void;\n options: ColorDef[];\n numColumns: number;\n round: boolean;\n title?: string;\n}) {\n const containerStyle: React.CSSProperties = {\n gridTemplateColumns: `repeat(${numColumns}, 1fr)`,\n };\n return (\n <div className=\"components-colorpicker-popup-container\">\n {title && <h4>{title}</h4>}\n <div\n data-testid=\"components-colorpicker-popup-colors\"\n className=\"components-colorpicker-popup-colors\"\n style={containerStyle}\n >\n {options.map((color, index) => (\n // eslint-disable-next-line deprecation/deprecation\n <ColorSwatch\n className=\"components-colorpicker-swatch\"\n key={index}\n colorDef={color}\n onColorPick={handleColorPicked}\n round={round}\n />\n ))}\n </div>\n </div>\n );\n}\n\n/** Properties for the [[ColorPickerButton]] React component\n * @beta\n * @deprecated in 4.11.x. Props of deprecated component {@link ColorPickerButton}.\n */\nexport interface ColorPickerProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** Active color */\n initialColor: ColorDef;\n /** Available colors */\n colorDefs?: ColorDef[];\n /** Function to run when user selects color swatch */\n onColorPick?: ((color: ColorDef) => void) | undefined;\n /** Show swatches as squares unless round is set to true */\n round?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** Title to show at top of DropDown */\n dropDownTitle?: string;\n /** Number of columns */\n numColumns?: number;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n}\n\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\nconst ForwardRefColorPickerButton = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerProps\n>(function ForwardRefColorPickerButton(\n {\n className,\n colorDefs,\n disabled,\n dropDownTitle,\n initialColor,\n numColumns,\n onColorPick,\n readonly,\n round,\n showCaret,\n style,\n },\n ref\n) {\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(initialColor);\n\n // See if new initialColor props have changed since component mounted\n React.useEffect(() => {\n setColorDef(initialColor);\n }, [initialColor]);\n\n const defaultColors = React.useRef([\n ColorDef.create(ColorByName.red),\n ColorDef.create(ColorByName.orange),\n ColorDef.create(ColorByName.yellow),\n ColorDef.create(ColorByName.green),\n ColorDef.create(ColorByName.blue),\n ColorDef.create(ColorByName.indigo),\n ColorDef.create(ColorByName.violet),\n ColorDef.create(ColorByName.black),\n ColorDef.create(ColorByName.white),\n ColorDef.create(ColorByName.cyan),\n ColorDef.create(ColorByName.fuchsia),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.gray),\n ColorDef.create(ColorByName.brown),\n ColorDef.create(ColorByName.purple),\n ColorDef.create(ColorByName.olive),\n ]);\n\n const closePopup = React.useCallback(() => {\n setShowPopup(false);\n }, []);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorPicked = React.useCallback(\n (color: ColorDef) => {\n closePopup();\n\n // istanbul ignore else\n if (!color.equals(colorDef)) {\n setColorDef(color);\n onColorPick && onColorPick(color);\n }\n },\n [closePopup, colorDef, onColorPick]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n\n const buttonClassNames = classnames(\n \"components-colorpicker-button\",\n round && \"round\",\n readonly && \"readonly\",\n className\n );\n\n const colorOptions =\n colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\n return (\n <>\n <button\n data-testid=\"components-colorpicker-button\"\n data-value={rgbaString}\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={disabled}\n ref={refs}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={RelativePosition.BottomLeft}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <ColorOptions\n handleColorPicked={handleColorPicked}\n options={colorOptions}\n numColumns={numColumns ?? 4}\n round={!!round}\n title={dropDownTitle}\n />\n </Popup>\n </>\n );\n});\n\n/** ColorPickerButton component\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @beta\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerButton: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerProps\n) => React.ReactNode = ForwardRefColorPickerButton;\n"]}
1
+ {"version":3,"file":"ColorPickerButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEhF,4BAA4B;AAE5B,SAAS,YAAY,CAAC,EACpB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,KAAK,EACL,KAAK,GAON;IACC,MAAM,cAAc,GAAwB;QAC1C,mBAAmB,EAAE,UAAU,UAAU,QAAQ;KAClD,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,wCAAwC;QACpD,KAAK,IAAI,gCAAK,KAAK,CAAM;QAC1B,4CACc,qCAAqC,EACjD,SAAS,EAAC,qCAAqC,EAC/C,KAAK,EAAE,cAAc,IAEpB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7B,mDAAmD;QACnD,oBAAC,WAAW,IACV,SAAS,EAAC,+BAA+B,EACzC,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,iBAA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EH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAGP,2BAA2B,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 Color\n */\n\nimport \"./ColorPickerButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport { ColorSwatch } from \"./Swatch\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\n\n// cSpell:ignore colorpicker\n\nfunction ColorOptions({\n handleColorPicked,\n options,\n numColumns,\n round,\n title,\n}: {\n handleColorPicked: (color: ColorDef) => void;\n options: ColorDef[];\n numColumns: number;\n round: boolean;\n title?: string;\n}) {\n const containerStyle: React.CSSProperties = {\n gridTemplateColumns: `repeat(${numColumns}, 1fr)`,\n };\n return (\n <div className=\"components-colorpicker-popup-container\">\n {title && <h4>{title}</h4>}\n <div\n data-testid=\"components-colorpicker-popup-colors\"\n className=\"components-colorpicker-popup-colors\"\n style={containerStyle}\n >\n {options.map((color, index) => (\n // eslint-disable-next-line deprecation/deprecation\n <ColorSwatch\n className=\"components-colorpicker-swatch\"\n key={index}\n colorDef={color}\n onColorPick={handleColorPicked}\n round={round}\n />\n ))}\n </div>\n </div>\n );\n}\n\n/** Properties for the [[ColorPickerButton]] React component\n * @beta\n * @deprecated in 4.11.x. Props of deprecated component {@link ColorPickerButton}.\n */\nexport interface ColorPickerProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** Active color */\n initialColor: ColorDef;\n /** Available colors */\n colorDefs?: ColorDef[];\n /** Function to run when user selects color swatch */\n onColorPick?: ((color: ColorDef) => void) | undefined;\n /** Show swatches as squares unless round is set to true */\n round?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** Title to show at top of DropDown */\n dropDownTitle?: string;\n /** Number of columns */\n numColumns?: number;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n}\n\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\nconst ForwardRefColorPickerButton = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerProps\n>(function ForwardRefColorPickerButton(\n {\n className,\n colorDefs,\n disabled,\n dropDownTitle,\n initialColor,\n numColumns,\n onColorPick,\n readonly,\n round,\n showCaret,\n style,\n },\n ref\n) {\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(initialColor);\n\n // See if new initialColor props have changed since component mounted\n React.useEffect(() => {\n setColorDef(initialColor);\n }, [initialColor]);\n\n const defaultColors = React.useRef([\n ColorDef.create(ColorByName.red),\n ColorDef.create(ColorByName.orange),\n ColorDef.create(ColorByName.yellow),\n ColorDef.create(ColorByName.green),\n ColorDef.create(ColorByName.blue),\n ColorDef.create(ColorByName.indigo),\n ColorDef.create(ColorByName.violet),\n ColorDef.create(ColorByName.black),\n ColorDef.create(ColorByName.white),\n ColorDef.create(ColorByName.cyan),\n ColorDef.create(ColorByName.fuchsia),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.gray),\n ColorDef.create(ColorByName.brown),\n ColorDef.create(ColorByName.purple),\n ColorDef.create(ColorByName.olive),\n ]);\n\n const closePopup = React.useCallback(() => {\n setShowPopup(false);\n }, []);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorPicked = React.useCallback(\n (color: ColorDef) => {\n closePopup();\n\n if (!color.equals(colorDef)) {\n setColorDef(color);\n onColorPick && onColorPick(color);\n }\n },\n [closePopup, colorDef, onColorPick]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n\n const buttonClassNames = classnames(\n \"components-colorpicker-button\",\n round && \"round\",\n readonly && \"readonly\",\n className\n );\n\n const colorOptions =\n colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\n return (\n <>\n <button\n data-testid=\"components-colorpicker-button\"\n data-value={rgbaString}\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={disabled}\n ref={refs}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={RelativePosition.BottomLeft}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <ColorOptions\n handleColorPicked={handleColorPicked}\n options={colorOptions}\n numColumns={numColumns ?? 4}\n round={!!round}\n title={dropDownTitle}\n />\n </Popup>\n </>\n );\n});\n\n/** ColorPickerButton component\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @beta\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerButton: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerProps\n) => React.ReactNode = ForwardRefColorPickerButton;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerDialog.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAS9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,mCAAmC;IACnC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,6FAA6F;IAC7F,cAAc,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,KAAK,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,GACf,EACD,sBAAsB,qBA2DrB"}
1
+ {"version":3,"file":"ColorPickerDialog.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAS9C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC9C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,mCAAmC;IACnC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,6FAA6F;IAC7F,cAAc,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,KAAK,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,cAAc,GACf,EACD,sBAAsB,qBA0DrB"}
@@ -22,7 +22,6 @@ export function ColorPickerDialog({ dialogTitle, color, onOkResult, onCancelResu
22
22
  onOkResult(activeColor);
23
23
  }, [onOkResult, activeColor]);
24
24
  const handleCancel = React.useCallback(() => {
25
- // istanbul ignore else
26
25
  if (onCancelResult)
27
26
  onCancelResult();
28
27
  }, [onCancelResult]);