react-zoom-pan-pinch 2.2.1 → 2.3.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 (81) hide show
  1. package/dist/components/transform-component.d.ts +10 -0
  2. package/dist/components/transform-wrapper.d.ts +8 -0
  3. package/dist/constants/state.constants.d.ts +6 -0
  4. package/dist/core/animations/animations.constants.d.ts +16 -0
  5. package/dist/core/animations/animations.utils.d.ts +4 -0
  6. package/dist/core/bounds/bounds.types.d.ts +8 -0
  7. package/dist/core/bounds/bounds.utils.d.ts +15 -0
  8. package/dist/core/double-click/double-click.logic.d.ts +3 -0
  9. package/dist/core/handlers/handlers.logic.d.ts +8 -0
  10. package/dist/core/handlers/handlers.utils.d.ts +13 -0
  11. package/dist/core/instance.core.d.ts +68 -0
  12. package/dist/core/pan/panning.logic.d.ts +5 -0
  13. package/dist/core/pan/panning.utils.d.ts +10 -0
  14. package/dist/core/pan/velocity.logic.d.ts +5 -0
  15. package/dist/core/pan/velocity.utils.d.ts +5 -0
  16. package/dist/core/pinch/pinch.logic.d.ts +4 -0
  17. package/dist/core/pinch/pinch.utils.d.ts +6 -0
  18. package/dist/core/wheel/wheel.logic.d.ts +4 -0
  19. package/dist/core/wheel/wheel.utils.d.ts +7 -0
  20. package/dist/core/zoom/zoom.logic.d.ts +3 -0
  21. package/dist/core/zoom/zoom.utils.d.ts +3 -0
  22. package/dist/hooks/use-transform-context.d.ts +3 -0
  23. package/dist/index.cjs.js +270 -267
  24. package/dist/index.cjs.js.map +1 -1
  25. package/dist/index.d.ts +63 -57
  26. package/dist/index.esm.js +270 -267
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/models/calculations.model.d.ts +25 -0
  29. package/dist/models/context.model.d.ts +117 -0
  30. package/dist/models/helpers.model.d.ts +5 -0
  31. package/dist/models/index.d.ts +3 -0
  32. package/dist/stories/docs/handlers.d.ts +12 -0
  33. package/dist/stories/docs/props.d.ts +14 -0
  34. package/dist/stories/examples/content-rerendering/example.d.ts +2 -0
  35. package/dist/stories/examples/stress/example.d.ts +2 -0
  36. package/dist/stories/examples/zoom-to-element/example.d.ts +2 -0
  37. package/dist/stories/types/args.types.d.ts +268 -0
  38. package/dist/stories/utils/args.utils.d.ts +3 -0
  39. package/dist/stories/utils/code.utils.d.ts +6 -0
  40. package/dist/stories/utils/controls.utils.d.ts +3 -0
  41. package/dist/stories/utils/index.d.ts +3 -0
  42. package/dist/utils/calculations.utils.d.ts +11 -0
  43. package/dist/utils/callback.utils.d.ts +2 -0
  44. package/dist/utils/context.utils.d.ts +2 -0
  45. package/dist/utils/event.utils.d.ts +1 -0
  46. package/dist/utils/helpers.utils.d.ts +2 -0
  47. package/dist/utils/index.d.ts +7 -0
  48. package/dist/utils/state.utils.d.ts +3 -0
  49. package/dist/utils/styles.utils.d.ts +3 -0
  50. package/package.json +30 -25
  51. package/src/.eslintrc.json +90 -0
  52. package/src/components/transform-component.tsx +2 -1
  53. package/src/components/transform-wrapper.tsx +27 -5
  54. package/src/constants/state.constants.ts +0 -2
  55. package/src/core/animations/animations.constants.ts +14 -12
  56. package/src/core/animations/animations.utils.ts +15 -11
  57. package/src/core/bounds/bounds.utils.ts +20 -20
  58. package/src/core/double-click/double-click.logic.ts +6 -12
  59. package/src/core/handlers/handlers.logic.ts +98 -89
  60. package/src/core/handlers/handlers.utils.ts +22 -24
  61. package/src/{components/transform-context.tsx → core/instance.core.ts} +85 -118
  62. package/src/core/pan/panning.logic.ts +20 -19
  63. package/src/core/pan/panning.utils.ts +4 -7
  64. package/src/core/pan/velocity.logic.ts +1 -0
  65. package/src/core/pinch/pinch.logic.ts +4 -6
  66. package/src/core/pinch/pinch.utils.ts +2 -2
  67. package/src/core/wheel/wheel.logic.ts +1 -0
  68. package/src/core/wheel/wheel.utils.ts +12 -11
  69. package/src/core/zoom/zoom.logic.ts +29 -29
  70. package/src/core/zoom/zoom.utils.ts +2 -2
  71. package/src/hooks/use-transform-context.tsx +3 -2
  72. package/src/models/context.model.ts +6 -2
  73. package/src/stories/docs/handlers.tsx +30 -30
  74. package/src/stories/examples/content-rerendering/content-updating.stories.mdx +3 -0
  75. package/src/stories/examples/stress/example.tsx +24 -0
  76. package/src/stories/examples/stress/stress-test.stories.mdx +28 -0
  77. package/src/stories/examples/zoom-to-element/example.tsx +4 -0
  78. package/src/stories/utils/code.utils.tsx +1 -0
  79. package/src/stories/utils/controls.utils.tsx +21 -4
  80. package/src/stories/utils/styles.module.css +5 -0
  81. package/src/.eslintrc.js +0 -36
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import React, { Component, useState, useImperativeHandle, useContext, useRef, useEffect } from 'react';
1
+ import React, { useRef, useMemo, useImperativeHandle, useContext, useEffect } from 'react';
2
2
 
3
- /*! *****************************************************************************
3
+ /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
5
5
 
6
6
  Permission to use, copy, modify, and/or distribute this software for any
@@ -14,22 +14,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- /* global Reflect, Promise */
18
-
19
- var extendStatics = function(d, b) {
20
- extendStatics = Object.setPrototypeOf ||
21
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
- return extendStatics(d, b);
24
- };
25
-
26
- function __extends(d, b) {
27
- if (typeof b !== "function" && b !== null)
28
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29
- extendStatics(d, b);
30
- function __() { this.constructor = d; }
31
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
- }
33
17
 
34
18
  var __assign = function() {
35
19
  __assign = Object.assign || function __assign(t) {
@@ -49,7 +33,7 @@ function __spreadArray(to, from, pack) {
49
33
  ar[i] = from[i];
50
34
  }
51
35
  }
52
- return to.concat(ar || from);
36
+ return to.concat(ar || Array.prototype.slice.call(from));
53
37
  }
54
38
 
55
39
  /**
@@ -74,6 +58,8 @@ var handleCallback = function (context, event, callback) {
74
58
  }
75
59
  };
76
60
 
61
+ /* eslint-disable no-plusplus */
62
+ /* eslint-disable no-param-reassign */
77
63
  /**
78
64
  * Functions should return denominator of the target value, which is the next animation step.
79
65
  * t is a value from 0 to 1, reflecting the percentage of animation status.
@@ -150,6 +136,7 @@ var animations = {
150
136
  easeInOutQuint: easeInOutQuint,
151
137
  };
152
138
 
139
+ /* eslint-disable no-param-reassign */
153
140
  var handleCancelAnimationFrame = function (animation) {
154
141
  if (typeof animation === "number") {
155
142
  cancelAnimationFrame(animation);
@@ -191,6 +178,15 @@ function handleSetupAnimation(contextInstance, animationName, animationTime, cal
191
178
  };
192
179
  requestAnimationFrame(contextInstance.animation);
193
180
  }
181
+ function isValidTargetState(targetState) {
182
+ var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
183
+ if (Number.isNaN(scale) ||
184
+ Number.isNaN(positionX) ||
185
+ Number.isNaN(positionY)) {
186
+ return false;
187
+ }
188
+ return true;
189
+ }
194
190
  function animate(contextInstance, targetState, animationTime, animationName) {
195
191
  var isValid = isValidTargetState(targetState);
196
192
  if (!contextInstance.mounted || !isValid)
@@ -213,14 +209,8 @@ function animate(contextInstance, targetState, animationTime, animationName) {
213
209
  });
214
210
  }
215
211
  }
216
- function isValidTargetState(targetState) {
217
- var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
218
- if (isNaN(scale) || isNaN(positionX) || isNaN(positionY)) {
219
- return false;
220
- }
221
- return true;
222
- }
223
212
 
213
+ /* eslint-disable no-param-reassign */
224
214
  function getComponentsSizes(wrapperComponent, contentComponent, newScale) {
225
215
  var wrapperWidth = wrapperComponent.offsetWidth;
226
216
  var wrapperHeight = wrapperComponent.offsetHeight;
@@ -262,6 +252,22 @@ var calculateBounds = function (contextInstance, newScale) {
262
252
  var bounds = getBounds(wrapperWidth, newContentWidth, newDiffWidth, wrapperHeight, newContentHeight, newDiffHeight, Boolean(centerZoomedOut));
263
253
  return bounds;
264
254
  };
255
+ /**
256
+ * Keeps value between given bounds, used for limiting view to given boundaries
257
+ * 1# eg. boundLimiter(2, 0, 3, true) => 2
258
+ * 2# eg. boundLimiter(4, 0, 3, true) => 3
259
+ * 3# eg. boundLimiter(-2, 0, 3, true) => 0
260
+ * 4# eg. boundLimiter(10, 0, 3, false) => 10
261
+ */
262
+ var boundLimiter = function (value, minBound, maxBound, isActive) {
263
+ if (!isActive)
264
+ return roundNumber(value, 2);
265
+ if (value < minBound)
266
+ return roundNumber(minBound, 2);
267
+ if (value > maxBound)
268
+ return roundNumber(maxBound, 2);
269
+ return roundNumber(value, 2);
270
+ };
265
271
  var handleCalculateBounds = function (contextInstance, newScale) {
266
272
  var bounds = calculateBounds(contextInstance, newScale);
267
273
  // Save bounds
@@ -280,22 +286,6 @@ function getMouseBoundedPosition(positionX, positionY, bounds, limitToBounds, pa
280
286
  var y = boundLimiter(positionY, minPositionY - paddingY, maxPositionY + paddingY, limitToBounds);
281
287
  return { x: x, y: y };
282
288
  }
283
- /**
284
- * Keeps value between given bounds, used for limiting view to given boundaries
285
- * 1# eg. boundLimiter(2, 0, 3, true) => 2
286
- * 2# eg. boundLimiter(4, 0, 3, true) => 3
287
- * 3# eg. boundLimiter(-2, 0, 3, true) => 0
288
- * 4# eg. boundLimiter(10, 0, 3, false) => 10
289
- */
290
- var boundLimiter = function (value, minBound, maxBound, isActive) {
291
- if (!isActive)
292
- return roundNumber(value, 2);
293
- if (value < minBound)
294
- return roundNumber(minBound, 2);
295
- if (value > maxBound)
296
- return roundNumber(maxBound, 2);
297
- return roundNumber(value, 2);
298
- };
299
289
 
300
290
  function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds) {
301
291
  var _a = contextInstance.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
@@ -314,9 +304,9 @@ function handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale,
314
304
  function checkZoomBounds(zoom, minScale, maxScale, zoomPadding, enablePadding) {
315
305
  var scalePadding = enablePadding ? zoomPadding : 0;
316
306
  var minScaleWithPadding = minScale - scalePadding;
317
- if (!isNaN(maxScale) && zoom >= maxScale)
307
+ if (!Number.isNaN(maxScale) && zoom >= maxScale)
318
308
  return maxScale;
319
- if (!isNaN(minScale) && zoom <= minScaleWithPadding)
309
+ if (!Number.isNaN(minScale) && zoom <= minScaleWithPadding)
320
310
  return minScaleWithPadding;
321
311
  return zoom;
322
312
  }
@@ -558,6 +548,18 @@ function handlePanningStart(contextInstance, event) {
558
548
  handlePanningSetup(contextInstance, event);
559
549
  }
560
550
  }
551
+ function handleAlignToBounds(contextInstance) {
552
+ var scale = contextInstance.transformState.scale;
553
+ var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
554
+ var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
555
+ var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
556
+ if (isDisabled)
557
+ return;
558
+ var targetState = handlePanToBounds(contextInstance);
559
+ if (targetState) {
560
+ animate(contextInstance, targetState, animationTime, animationType);
561
+ }
562
+ }
561
563
  function handlePanning(contextInstance, clientX, clientY) {
562
564
  var startCoords = contextInstance.startCoords, setup = contextInstance.setup;
563
565
  var _a = setup.alignmentAnimation, sizeX = _a.sizeX, sizeY = _a.sizeY;
@@ -592,19 +594,14 @@ function handlePanningEnd(contextInstance) {
592
594
  }
593
595
  }
594
596
  }
595
- function handleAlignToBounds(contextInstance) {
596
- var scale = contextInstance.transformState.scale;
597
- var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
598
- var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
599
- var isDisabled = disabled || scale < minScale || (!sizeX && !sizeY);
600
- if (isDisabled)
601
- return;
602
- var targetState = handlePanToBounds(contextInstance);
603
- if (targetState) {
604
- animate(contextInstance, targetState, animationTime, animationType);
605
- }
606
- }
607
597
 
598
+ function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
599
+ var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
600
+ var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
601
+ var bounds = handleCalculateBounds(contextInstance, newScale);
602
+ var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
603
+ return { scale: newScale, positionX: x, positionY: y };
604
+ }
608
605
  function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePositionY) {
609
606
  var scale = contextInstance.transformState.scale;
610
607
  var wrapperComponent = contextInstance.wrapperComponent;
@@ -624,13 +621,6 @@ function handleAlignToScaleBounds(contextInstance, mousePositionX, mousePosition
624
621
  animate(contextInstance, targetState, animationTime, animationType);
625
622
  }
626
623
  }
627
- function handleZoomToPoint(contextInstance, scale, mouseX, mouseY) {
628
- var _a = contextInstance.setup, minScale = _a.minScale, maxScale = _a.maxScale, limitToBounds = _a.limitToBounds;
629
- var newScale = checkZoomBounds(roundNumber(scale, 2), minScale, maxScale, 0, false);
630
- var bounds = handleCalculateBounds(contextInstance, newScale);
631
- var _b = handleCalculateZoomPositions(contextInstance, mouseX, mouseY, newScale, bounds, limitToBounds), x = _b.x, y = _b.y;
632
- return { scale: newScale, positionX: x, positionY: y };
633
- }
634
624
 
635
625
  var initialState = {
636
626
  previousScale: 1,
@@ -725,7 +715,7 @@ var createSetup = function (props) {
725
715
  newSetup[key] = __assign(__assign({}, initialSetup[key]), props[key]);
726
716
  }
727
717
  else if (isArray) {
728
- newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key]), props[key]);
718
+ newSetup[key] = __spreadArray(__spreadArray([], initialSetup[key], true), props[key], true);
729
719
  }
730
720
  else {
731
721
  newSetup[key] = props[key];
@@ -784,6 +774,20 @@ function resetTransformations(contextInstance, animationTime, animationType) {
784
774
  }
785
775
  animate(contextInstance, newState, animationTime, animationType);
786
776
  }
777
+ function getOffset(element) {
778
+ var el = element;
779
+ var offsetLeft = 0;
780
+ var offsetTop = 0;
781
+ while (el) {
782
+ offsetLeft += el.offsetLeft;
783
+ offsetTop += el.offsetTop;
784
+ el = el.offsetParent;
785
+ }
786
+ return {
787
+ x: offsetLeft - window.scrollX,
788
+ y: offsetTop - window.scrollY,
789
+ };
790
+ }
787
791
  function calculateZoomToNode(contextInstance, node, customZoom) {
788
792
  var wrapperComponent = contextInstance.wrapperComponent;
789
793
  var _a = contextInstance.setup, limitToBounds = _a.limitToBounds, minScale = _a.minScale, maxScale = _a.maxScale;
@@ -806,88 +810,85 @@ function calculateZoomToNode(contextInstance, node, customZoom) {
806
810
  var _b = getMouseBoundedPosition(newPositionX, newPositionY, bounds, limitToBounds, 0, 0, wrapperComponent), x = _b.x, y = _b.y;
807
811
  return { positionX: x, positionY: y, scale: newScale };
808
812
  }
809
- function getOffset(element) {
810
- var el = element;
811
- var offsetLeft = 0;
812
- var offsetTop = 0;
813
- while (el) {
814
- offsetLeft += el.offsetLeft;
815
- offsetTop += el.offsetTop;
816
- el = el.offsetParent;
817
- }
818
- return {
819
- x: offsetLeft - window.scrollX,
820
- y: offsetTop - window.scrollY,
821
- };
822
- }
823
813
  function isValidZoomNode(node) {
824
814
  if (!node) {
825
815
  console.error("Zoom node not found");
826
816
  return false;
827
817
  }
828
- else if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined ||
829
- (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
818
+ if ((node === null || node === void 0 ? void 0 : node.offsetWidth) === undefined || (node === null || node === void 0 ? void 0 : node.offsetHeight) === undefined) {
830
819
  console.error("Zoom node is not valid - it must contain offsetWidth and offsetHeight");
831
820
  return false;
832
821
  }
833
822
  return true;
834
823
  }
835
824
 
836
- var zoomIn = function (contextInstance) { return function (step, animationTime, animationType) {
837
- if (step === void 0) { step = 0.5; }
838
- if (animationTime === void 0) { animationTime = 300; }
839
- if (animationType === void 0) { animationType = "easeOut"; }
840
- handleZoomToViewCenter(contextInstance, 1, step, animationTime, animationType);
841
- }; };
842
- var zoomOut = function (contextInstance) { return function (step, animationTime, animationType) {
843
- if (step === void 0) { step = 0.5; }
844
- if (animationTime === void 0) { animationTime = 300; }
845
- if (animationType === void 0) { animationType = "easeOut"; }
846
- handleZoomToViewCenter(contextInstance, -1, step, animationTime, animationType);
847
- }; };
848
- var setTransform = function (contextInstance) { return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
849
- if (animationTime === void 0) { animationTime = 300; }
850
- if (animationType === void 0) { animationType = "easeOut"; }
851
- var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
852
- var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
853
- var disabled = contextInstance.setup.disabled;
854
- if (disabled || !wrapperComponent || !contentComponent)
855
- return;
856
- var targetState = {
857
- positionX: isNaN(newPositionX) ? positionX : newPositionX,
858
- positionY: isNaN(newPositionY) ? positionY : newPositionY,
859
- scale: isNaN(newScale) ? scale : newScale,
825
+ var zoomIn = function (contextInstance) {
826
+ return function (step, animationTime, animationType) {
827
+ if (step === void 0) { step = 0.5; }
828
+ if (animationTime === void 0) { animationTime = 300; }
829
+ if (animationType === void 0) { animationType = "easeOut"; }
830
+ handleZoomToViewCenter(contextInstance, 1, step, animationTime, animationType);
860
831
  };
861
- animate(contextInstance, targetState, animationTime, animationType);
862
- }; };
863
- var resetTransform = function (contextInstance) { return function (animationTime, animationType) {
864
- if (animationTime === void 0) { animationTime = 200; }
865
- if (animationType === void 0) { animationType = "easeOut"; }
866
- resetTransformations(contextInstance, animationTime, animationType);
867
- }; };
868
- var centerView = function (contextInstance) { return function (scale, animationTime, animationType) {
869
- if (animationTime === void 0) { animationTime = 200; }
870
- if (animationType === void 0) { animationType = "easeOut"; }
871
- var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
872
- if (wrapperComponent && contentComponent) {
873
- var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
874
- animate(contextInstance, targetState, animationTime, animationType);
875
- }
876
- }; };
877
- var zoomToElement = function (contextInstance) { return function (node, scale, animationTime, animationType) {
878
- if (animationTime === void 0) { animationTime = 600; }
879
- if (animationType === void 0) { animationType = "easeOut"; }
880
- handleCancelAnimation(contextInstance);
881
- var wrapperComponent = contextInstance.wrapperComponent;
882
- var target = typeof node === "string" ? document.getElementById(node) : node;
883
- if (wrapperComponent &&
884
- isValidZoomNode(target) &&
885
- target &&
886
- wrapperComponent.contains(target)) {
887
- var targetState = calculateZoomToNode(contextInstance, target, scale);
832
+ };
833
+ var zoomOut = function (contextInstance) {
834
+ return function (step, animationTime, animationType) {
835
+ if (step === void 0) { step = 0.5; }
836
+ if (animationTime === void 0) { animationTime = 300; }
837
+ if (animationType === void 0) { animationType = "easeOut"; }
838
+ handleZoomToViewCenter(contextInstance, -1, step, animationTime, animationType);
839
+ };
840
+ };
841
+ var setTransform = function (contextInstance) {
842
+ return function (newPositionX, newPositionY, newScale, animationTime, animationType) {
843
+ if (animationTime === void 0) { animationTime = 300; }
844
+ if (animationType === void 0) { animationType = "easeOut"; }
845
+ var _a = contextInstance.transformState, positionX = _a.positionX, positionY = _a.positionY, scale = _a.scale;
846
+ var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
847
+ var disabled = contextInstance.setup.disabled;
848
+ if (disabled || !wrapperComponent || !contentComponent)
849
+ return;
850
+ var targetState = {
851
+ positionX: Number.isNaN(newPositionX) ? positionX : newPositionX,
852
+ positionY: Number.isNaN(newPositionY) ? positionY : newPositionY,
853
+ scale: Number.isNaN(newScale) ? scale : newScale,
854
+ };
888
855
  animate(contextInstance, targetState, animationTime, animationType);
889
- }
890
- }; };
856
+ };
857
+ };
858
+ var resetTransform = function (contextInstance) {
859
+ return function (animationTime, animationType) {
860
+ if (animationTime === void 0) { animationTime = 200; }
861
+ if (animationType === void 0) { animationType = "easeOut"; }
862
+ resetTransformations(contextInstance, animationTime, animationType);
863
+ };
864
+ };
865
+ var centerView = function (contextInstance) {
866
+ return function (scale, animationTime, animationType) {
867
+ if (animationTime === void 0) { animationTime = 200; }
868
+ if (animationType === void 0) { animationType = "easeOut"; }
869
+ var transformState = contextInstance.transformState, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
870
+ if (wrapperComponent && contentComponent) {
871
+ var targetState = getCenterPosition(scale || transformState.scale, wrapperComponent, contentComponent);
872
+ animate(contextInstance, targetState, animationTime, animationType);
873
+ }
874
+ };
875
+ };
876
+ var zoomToElement = function (contextInstance) {
877
+ return function (node, scale, animationTime, animationType) {
878
+ if (animationTime === void 0) { animationTime = 600; }
879
+ if (animationType === void 0) { animationType = "easeOut"; }
880
+ handleCancelAnimation(contextInstance);
881
+ var wrapperComponent = contextInstance.wrapperComponent;
882
+ var target = typeof node === "string" ? document.getElementById(node) : node;
883
+ if (wrapperComponent &&
884
+ isValidZoomNode(target) &&
885
+ target &&
886
+ wrapperComponent.contains(target)) {
887
+ var targetState = calculateZoomToNode(contextInstance, target, scale);
888
+ animate(contextInstance, targetState, animationTime, animationType);
889
+ }
890
+ };
891
+ };
891
892
 
892
893
  var getContext = function (contextInstance) {
893
894
  return {
@@ -951,7 +952,7 @@ var getTransformStyles = function (x, y, scale) {
951
952
  var d = scale;
952
953
  var tx = x;
953
954
  var ty = y;
954
- return "matrix3d(" + a + ", " + b + ", 0, 0, " + c + ", " + d + ", 0, 0, 0, 0, 1, 0, " + tx + ", " + ty + ", 0, 1)";
955
+ return "matrix3d(".concat(a, ", ").concat(b, ", 0, 0, ").concat(c, ", ").concat(d, ", 0, 0, 0, 0, 1, 0, ").concat(tx, ", ").concat(ty, ", 0, 1)");
955
956
  };
956
957
  var getCenterPosition = function (scale, wrapperComponent, contentComponent) {
957
958
  var contentWidth = contentComponent.offsetWidth * scale;
@@ -982,8 +983,14 @@ var isWheelAllowed = function (contextInstance, event) {
982
983
  return false;
983
984
  return true;
984
985
  };
986
+ var getDeltaY = function (event) {
987
+ if (event) {
988
+ return event.deltaY < 0 ? 1 : -1;
989
+ }
990
+ return 0;
991
+ };
985
992
  function getDelta(event, customDelta) {
986
- var deltaY = event ? (event.deltaY < 0 ? 1 : -1) : 0;
993
+ var deltaY = getDeltaY(event);
987
994
  var delta = checkIsNumber(customDelta, deltaY);
988
995
  return delta;
989
996
  }
@@ -1001,7 +1008,7 @@ function getMousePosition(event, contentComponent, scale) {
1001
1008
  mouseX = (touch.clientX - contentRect.left) / scale;
1002
1009
  mouseY = (touch.clientY - contentRect.top) / scale;
1003
1010
  }
1004
- if (isNaN(mouseX) || isNaN(mouseY))
1011
+ if (Number.isNaN(mouseX) || Number.isNaN(mouseY))
1005
1012
  console.error("No mouse or touch offset found");
1006
1013
  return {
1007
1014
  x: mouseX,
@@ -1075,8 +1082,8 @@ var calculateTouchMidPoint = function (event, scale, contentComponent) {
1075
1082
  };
1076
1083
  };
1077
1084
  var getTouchDistance = function (event) {
1078
- return Math.sqrt(Math.pow(event.touches[0].pageX - event.touches[1].pageX, 2) +
1079
- Math.pow(event.touches[0].pageY - event.touches[1].pageY, 2));
1085
+ return Math.sqrt(Math.pow((event.touches[0].pageX - event.touches[1].pageX), 2) +
1086
+ Math.pow((event.touches[0].pageY - event.touches[1].pageY), 2));
1080
1087
  };
1081
1088
  var calculatePinchZoom = function (contextInstance, currentDistance) {
1082
1089
  var pinchStartScale = contextInstance.pinchStartScale, pinchStartDistance = contextInstance.pinchStartDistance, setup = contextInstance.setup;
@@ -1172,7 +1179,7 @@ var handlePinchZoom = function (contextInstance, event) {
1172
1179
  return;
1173
1180
  var midPoint = calculateTouchMidPoint(event, scale, contentComponent);
1174
1181
  // if touches goes off of the wrapper element
1175
- if (!isFinite(midPoint.x) || !isFinite(midPoint.y))
1182
+ if (!Number.isFinite(midPoint.x) || !Number.isFinite(midPoint.y))
1176
1183
  return;
1177
1184
  var currentDistance = getTouchDistance(event);
1178
1185
  var newScale = calculatePinchZoom(contextInstance, currentDistance);
@@ -1232,45 +1239,52 @@ var isDoubleClickAllowed = function (contextInstance, event) {
1232
1239
  return true;
1233
1240
  };
1234
1241
 
1235
- var Context = React.createContext(contextInitialState);
1236
- var TransformContext = /** @class */ (function (_super) {
1237
- __extends(TransformContext, _super);
1238
- function TransformContext() {
1239
- var _this = _super !== null && _super.apply(this, arguments) || this;
1240
- _this.mounted = true;
1241
- _this.transformState = createState(_this.props);
1242
- _this.setup = createSetup(_this.props);
1242
+ var ZoomPanPinch = /** @class */ (function () {
1243
+ function ZoomPanPinch(props) {
1244
+ var _this = this;
1245
+ this.props = props;
1246
+ this.mounted = true;
1243
1247
  // Components
1244
- _this.wrapperComponent = null;
1245
- _this.contentComponent = null;
1248
+ this.wrapperComponent = null;
1249
+ this.contentComponent = null;
1246
1250
  // Initialization
1247
- _this.isInitialized = false;
1248
- _this.bounds = null;
1251
+ this.isInitialized = false;
1252
+ this.bounds = null;
1249
1253
  // wheel helpers
1250
- _this.previousWheelEvent = null;
1251
- _this.wheelStopEventTimer = null;
1252
- _this.wheelAnimationTimer = null;
1254
+ this.previousWheelEvent = null;
1255
+ this.wheelStopEventTimer = null;
1256
+ this.wheelAnimationTimer = null;
1253
1257
  // panning helpers
1254
- _this.isPanning = false;
1255
- _this.startCoords = null;
1256
- _this.lastTouch = null;
1258
+ this.isPanning = false;
1259
+ this.startCoords = null;
1260
+ this.lastTouch = null;
1257
1261
  // pinch helpers
1258
- _this.distance = null;
1259
- _this.lastDistance = null;
1260
- _this.pinchStartDistance = null;
1261
- _this.pinchStartScale = null;
1262
- _this.pinchMidpoint = null;
1262
+ this.distance = null;
1263
+ this.lastDistance = null;
1264
+ this.pinchStartDistance = null;
1265
+ this.pinchStartScale = null;
1266
+ this.pinchMidpoint = null;
1263
1267
  // velocity helpers
1264
- _this.velocity = null;
1265
- _this.velocityTime = null;
1266
- _this.lastMousePosition = null;
1268
+ this.velocity = null;
1269
+ this.velocityTime = null;
1270
+ this.lastMousePosition = null;
1267
1271
  // animations helpers
1268
- _this.animate = false;
1269
- _this.animation = null;
1270
- _this.maxBounds = null;
1272
+ this.animate = false;
1273
+ this.animation = null;
1274
+ this.maxBounds = null;
1271
1275
  // key press
1272
- _this.pressedKeys = {};
1273
- _this.initializeWindowEvents = function () {
1276
+ this.pressedKeys = {};
1277
+ this.mount = function () {
1278
+ _this.initializeWindowEvents();
1279
+ };
1280
+ this.unmount = function () {
1281
+ _this.cleanupWindowEvents();
1282
+ };
1283
+ this.update = function (newProps) {
1284
+ handleCalculateBounds(_this, _this.transformState.scale);
1285
+ _this.setup = createSetup(newProps);
1286
+ };
1287
+ this.initializeWindowEvents = function () {
1274
1288
  var _a;
1275
1289
  var passive = makePassiveEventOption();
1276
1290
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
@@ -1282,10 +1296,9 @@ var TransformContext = /** @class */ (function (_super) {
1282
1296
  currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.addEventListener("mouseleave", _this.clearPanning, passive);
1283
1297
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keyup", _this.setKeyUnPressed, passive);
1284
1298
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.addEventListener("keydown", _this.setKeyPressed, passive);
1285
- _this.handleRef();
1286
1299
  };
1287
- _this.cleanupWindowEvents = function () {
1288
- var _a;
1300
+ this.cleanupWindowEvents = function () {
1301
+ var _a, _b;
1289
1302
  var passive = makePassiveEventOption();
1290
1303
  var currentDocument = (_a = _this.wrapperComponent) === null || _a === void 0 ? void 0 : _a.ownerDocument;
1291
1304
  var currentWindow = currentDocument === null || currentDocument === void 0 ? void 0 : currentDocument.defaultView;
@@ -1297,8 +1310,9 @@ var TransformContext = /** @class */ (function (_super) {
1297
1310
  currentWindow === null || currentWindow === void 0 ? void 0 : currentWindow.removeEventListener("keydown", _this.setKeyPressed, passive);
1298
1311
  document.removeEventListener("mouseleave", _this.clearPanning, passive);
1299
1312
  handleCancelAnimation(_this);
1313
+ (_b = _this.observer) === null || _b === void 0 ? void 0 : _b.disconnect();
1300
1314
  };
1301
- _this.handleInitializeWrapperEvents = function (wrapper) {
1315
+ this.handleInitializeWrapperEvents = function (wrapper) {
1302
1316
  // Zooming events on wrapper
1303
1317
  var passive = makePassiveEventOption();
1304
1318
  wrapper.addEventListener("wheel", _this.onWheelZoom, passive);
@@ -1307,34 +1321,24 @@ var TransformContext = /** @class */ (function (_super) {
1307
1321
  wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
1308
1322
  wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
1309
1323
  };
1310
- _this.handleInitialize = function () {
1324
+ this.handleInitialize = function (contentComponent) {
1311
1325
  var centerOnInit = _this.setup.centerOnInit;
1312
1326
  _this.applyTransformation();
1313
- _this.forceUpdate();
1314
1327
  if (centerOnInit) {
1315
- // this has to be redone once the right solution is found
1316
- // problem is - we need to execute it after mounted component specify it's height / width, images are fetched async so it's tricky
1317
- setTimeout(function () {
1318
- if (_this.mounted) {
1319
- _this.setCenter();
1320
- }
1321
- }, 50);
1322
- setTimeout(function () {
1323
- if (_this.mounted) {
1324
- _this.setCenter();
1325
- }
1326
- }, 100);
1327
- setTimeout(function () {
1328
- if (_this.mounted) {
1329
- _this.setCenter();
1330
- }
1331
- }, 200);
1328
+ _this.setCenter();
1329
+ _this.observer = new ResizeObserver(function () {
1330
+ var _a;
1331
+ _this.setCenter();
1332
+ (_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
1333
+ });
1334
+ // Start observing the target node for configured mutations
1335
+ _this.observer.observe(contentComponent);
1332
1336
  }
1333
1337
  };
1334
- //////////
1338
+ /// ///////
1335
1339
  // Zoom
1336
- //////////
1337
- _this.onWheelZoom = function (event) {
1340
+ /// ///////
1341
+ this.onWheelZoom = function (event) {
1338
1342
  var disabled = _this.setup.disabled;
1339
1343
  if (disabled)
1340
1344
  return;
@@ -1348,10 +1352,10 @@ var TransformContext = /** @class */ (function (_super) {
1348
1352
  handleWheelZoom(_this, event);
1349
1353
  handleWheelStop(_this, event);
1350
1354
  };
1351
- //////////
1355
+ /// ///////
1352
1356
  // Pan
1353
- //////////
1354
- _this.onPanningStart = function (event) {
1357
+ /// ///////
1358
+ this.onPanningStart = function (event) {
1355
1359
  var disabled = _this.setup.disabled;
1356
1360
  var onPanningStart = _this.props.onPanningStart;
1357
1361
  if (disabled)
@@ -1368,7 +1372,7 @@ var TransformContext = /** @class */ (function (_super) {
1368
1372
  handlePanningStart(_this, event);
1369
1373
  handleCallback(getContext(_this), event, onPanningStart);
1370
1374
  };
1371
- _this.onPanning = function (event) {
1375
+ this.onPanning = function (event) {
1372
1376
  var disabled = _this.setup.disabled;
1373
1377
  var onPanning = _this.props.onPanning;
1374
1378
  if (disabled)
@@ -1384,17 +1388,17 @@ var TransformContext = /** @class */ (function (_super) {
1384
1388
  handlePanning(_this, event.clientX, event.clientY);
1385
1389
  handleCallback(getContext(_this), event, onPanning);
1386
1390
  };
1387
- _this.onPanningStop = function (event) {
1391
+ this.onPanningStop = function (event) {
1388
1392
  var onPanningStop = _this.props.onPanningStop;
1389
1393
  if (_this.isPanning) {
1390
1394
  handlePanningEnd(_this);
1391
1395
  handleCallback(getContext(_this), event, onPanningStop);
1392
1396
  }
1393
1397
  };
1394
- //////////
1398
+ /// ///////
1395
1399
  // Pinch
1396
- //////////
1397
- _this.onPinchStart = function (event) {
1400
+ /// ///////
1401
+ this.onPinchStart = function (event) {
1398
1402
  var disabled = _this.setup.disabled;
1399
1403
  var _a = _this.props, onPinchingStart = _a.onPinchingStart, onZoomStart = _a.onZoomStart;
1400
1404
  if (disabled)
@@ -1407,7 +1411,7 @@ var TransformContext = /** @class */ (function (_super) {
1407
1411
  handleCallback(getContext(_this), event, onPinchingStart);
1408
1412
  handleCallback(getContext(_this), event, onZoomStart);
1409
1413
  };
1410
- _this.onPinch = function (event) {
1414
+ this.onPinch = function (event) {
1411
1415
  var disabled = _this.setup.disabled;
1412
1416
  var _a = _this.props, onPinching = _a.onPinching, onZoom = _a.onZoom;
1413
1417
  if (disabled)
@@ -1421,7 +1425,7 @@ var TransformContext = /** @class */ (function (_super) {
1421
1425
  handleCallback(getContext(_this), event, onPinching);
1422
1426
  handleCallback(getContext(_this), event, onZoom);
1423
1427
  };
1424
- _this.onPinchStop = function (event) {
1428
+ this.onPinchStop = function (event) {
1425
1429
  var _a = _this.props, onPinchingStop = _a.onPinchingStop, onZoomStop = _a.onZoomStop;
1426
1430
  if (_this.pinchStartScale) {
1427
1431
  handlePinchStop(_this);
@@ -1429,10 +1433,10 @@ var TransformContext = /** @class */ (function (_super) {
1429
1433
  handleCallback(getContext(_this), event, onZoomStop);
1430
1434
  }
1431
1435
  };
1432
- //////////
1436
+ /// ///////
1433
1437
  // Touch
1434
- //////////
1435
- _this.onTouchPanningStart = function (event) {
1438
+ /// ///////
1439
+ this.onTouchPanningStart = function (event) {
1436
1440
  var disabled = _this.setup.disabled;
1437
1441
  var onPanningStart = _this.props.onPanningStart;
1438
1442
  if (disabled)
@@ -1460,7 +1464,7 @@ var TransformContext = /** @class */ (function (_super) {
1460
1464
  }
1461
1465
  }
1462
1466
  };
1463
- _this.onTouchPanning = function (event) {
1467
+ this.onTouchPanning = function (event) {
1464
1468
  var disabled = _this.setup.disabled;
1465
1469
  var onPanning = _this.props.onPanning;
1466
1470
  if (_this.isPanning && event.touches.length === 1) {
@@ -1479,14 +1483,14 @@ var TransformContext = /** @class */ (function (_super) {
1479
1483
  _this.onPinch(event);
1480
1484
  }
1481
1485
  };
1482
- _this.onTouchPanningStop = function (event) {
1486
+ this.onTouchPanningStop = function (event) {
1483
1487
  _this.onPanningStop(event);
1484
1488
  _this.onPinchStop(event);
1485
1489
  };
1486
- //////////
1490
+ /// ///////
1487
1491
  // Double Click
1488
- //////////
1489
- _this.onDoubleClick = function (event) {
1492
+ /// ///////
1493
+ this.onDoubleClick = function (event) {
1490
1494
  var disabled = _this.setup.disabled;
1491
1495
  if (disabled)
1492
1496
  return;
@@ -1495,41 +1499,31 @@ var TransformContext = /** @class */ (function (_super) {
1495
1499
  return;
1496
1500
  handleDoubleClick(_this, event);
1497
1501
  };
1498
- //////////
1502
+ /// ///////
1499
1503
  // Helpers
1500
- //////////
1501
- _this.clearPanning = function (event) {
1504
+ /// ///////
1505
+ this.clearPanning = function (event) {
1502
1506
  if (_this.isPanning) {
1503
1507
  _this.onPanningStop(event);
1504
1508
  }
1505
1509
  };
1506
- _this.setKeyPressed = function (e) {
1510
+ this.setKeyPressed = function (e) {
1507
1511
  _this.pressedKeys[e.key] = true;
1508
1512
  };
1509
- _this.setKeyUnPressed = function (e) {
1513
+ this.setKeyUnPressed = function (e) {
1510
1514
  _this.pressedKeys[e.key] = false;
1511
1515
  };
1512
- _this.isPressingKeys = function (keys) {
1516
+ this.isPressingKeys = function (keys) {
1513
1517
  if (!keys.length) {
1514
1518
  return true;
1515
1519
  }
1516
1520
  return Boolean(keys.find(function (key) { return _this.pressedKeys[key]; }));
1517
1521
  };
1518
- _this.setComponents = function (wrapperComponent, contentComponent) {
1519
- _this.cleanupWindowEvents();
1520
- _this.wrapperComponent = wrapperComponent;
1521
- _this.contentComponent = contentComponent;
1522
- handleCalculateBounds(_this, _this.transformState.scale);
1523
- _this.handleInitializeWrapperEvents(wrapperComponent);
1524
- _this.initializeWindowEvents();
1525
- _this.handleInitialize();
1526
- _this.handleRef();
1527
- _this.isInitialized = true;
1528
- handleCallback(getContext(_this), undefined, _this.props.onInit);
1529
- };
1530
- _this.setTransformState = function (scale, positionX, positionY) {
1522
+ this.setTransformState = function (scale, positionX, positionY) {
1531
1523
  var onTransformed = _this.props.onTransformed;
1532
- if (!isNaN(scale) && !isNaN(positionX) && !isNaN(positionY)) {
1524
+ if (!Number.isNaN(scale) &&
1525
+ !Number.isNaN(positionX) &&
1526
+ !Number.isNaN(positionY)) {
1533
1527
  if (scale !== _this.transformState.scale) {
1534
1528
  _this.transformState.previousScale = _this.transformState.scale;
1535
1529
  _this.transformState.scale = scale;
@@ -1543,50 +1537,58 @@ var TransformContext = /** @class */ (function (_super) {
1543
1537
  console.error("Detected NaN set state values");
1544
1538
  }
1545
1539
  };
1546
- _this.setCenter = function () {
1540
+ this.setCenter = function () {
1547
1541
  if (_this.wrapperComponent && _this.contentComponent) {
1548
1542
  var targetState = getCenterPosition(_this.transformState.scale, _this.wrapperComponent, _this.contentComponent);
1549
1543
  _this.setTransformState(targetState.scale, targetState.positionX, targetState.positionY);
1550
1544
  }
1551
1545
  };
1552
- _this.applyTransformation = function () {
1546
+ this.applyTransformation = function () {
1553
1547
  if (!_this.mounted || !_this.contentComponent)
1554
1548
  return;
1555
1549
  var _a = _this.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
1556
1550
  var transform = getTransformStyles(positionX, positionY, scale);
1557
1551
  _this.contentComponent.style.transform = transform;
1558
- _this.handleRef();
1559
1552
  };
1560
- _this.handleRef = function () {
1561
- _this.props.setRef(getContext(_this));
1553
+ this.getContext = function () {
1554
+ return getContext(_this);
1562
1555
  };
1563
- return _this;
1556
+ /**
1557
+ * Initialization
1558
+ */
1559
+ this.init = function (wrapperComponent, contentComponent) {
1560
+ _this.cleanupWindowEvents();
1561
+ _this.wrapperComponent = wrapperComponent;
1562
+ _this.contentComponent = contentComponent;
1563
+ handleCalculateBounds(_this, _this.transformState.scale);
1564
+ _this.handleInitializeWrapperEvents(wrapperComponent);
1565
+ _this.handleInitialize(contentComponent);
1566
+ _this.initializeWindowEvents();
1567
+ _this.isInitialized = true;
1568
+ handleCallback(getContext(_this), undefined, _this.props.onInit);
1569
+ };
1570
+ this.setup = createSetup(this.props);
1571
+ this.transformState = createState(this.props);
1564
1572
  }
1565
- TransformContext.prototype.componentDidMount = function () {
1566
- this.initializeWindowEvents();
1567
- };
1568
- TransformContext.prototype.componentWillUnmount = function () {
1569
- this.cleanupWindowEvents();
1570
- };
1571
- TransformContext.prototype.componentDidUpdate = function (oldProps) {
1572
- if (oldProps !== this.props) {
1573
- handleCalculateBounds(this, this.transformState.scale);
1574
- this.setup = createSetup(this.props);
1575
- }
1576
- };
1577
- TransformContext.prototype.render = function () {
1578
- var value = getContext(this);
1579
- var children = this.props.children;
1580
- var content = typeof children === "function" ? children(value) : children;
1581
- return (React.createElement(Context.Provider, { value: __assign(__assign({}, this.transformState), { setComponents: this.setComponents, contextInstance: this }) }, content));
1582
- };
1583
- return TransformContext;
1584
- }(Component));
1573
+ return ZoomPanPinch;
1574
+ }());
1585
1575
 
1576
+ var Context = React.createContext(contextInitialState);
1586
1577
  var TransformWrapper = React.forwardRef(function (props, ref) {
1587
- var _a = useState(null), innerRef = _a[0], setRef = _a[1];
1588
- useImperativeHandle(ref, function () { return innerRef; }, [innerRef]);
1589
- return React.createElement(TransformContext, __assign({}, props, { setRef: setRef }));
1578
+ var children = props.children;
1579
+ var instance = useRef(new ZoomPanPinch(props)).current;
1580
+ var content = useMemo(function () {
1581
+ if (typeof children === "function") {
1582
+ return children(getContext(instance));
1583
+ }
1584
+ return children;
1585
+ }, [children, instance]);
1586
+ var value = useMemo(function () {
1587
+ return __assign(__assign({}, instance.transformState), { setComponents: instance.init, contextInstance: instance });
1588
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1589
+ }, [JSON.stringify(instance.transformState)]);
1590
+ useImperativeHandle(ref, function () { return getContext(instance); }, [instance]);
1591
+ return React.createElement(Context.Provider, { value: value }, content);
1590
1592
  });
1591
1593
 
1592
1594
  function styleInject(css, ref) {
@@ -1616,10 +1618,11 @@ function styleInject(css, ref) {
1616
1618
  }
1617
1619
  }
1618
1620
 
1619
- var css_248z = ".transform-component-module_wrapper__1_Fgj {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\n margin: 0;\n padding: 0;\n}\n.transform-component-module_content__2jYgh {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__2jYgh img {\n pointer-events: none;\n}\n";
1620
- var styles = {"wrapper":"transform-component-module_wrapper__1_Fgj","content":"transform-component-module_content__2jYgh"};
1621
+ var css_248z = ".transform-component-module_wrapper__7HFJe {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\n margin: 0;\n padding: 0;\n}\n.transform-component-module_content__uCDPE {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__uCDPE img {\n pointer-events: none;\n}\n";
1622
+ var styles = {"wrapper":"transform-component-module_wrapper__7HFJe","content":"transform-component-module_content__uCDPE"};
1621
1623
  styleInject(css_248z);
1622
1624
 
1625
+ /* eslint-disable react/require-default-props */
1623
1626
  var TransformComponent = function (_a) {
1624
1627
  var children = _a.children, _b = _a.wrapperClass, wrapperClass = _b === void 0 ? "" : _b, _c = _a.contentClass, contentClass = _c === void 0 ? "" : _c, wrapperStyle = _a.wrapperStyle, contentStyle = _a.contentStyle;
1625
1628
  var setComponents = useContext(Context).setComponents;
@@ -1632,8 +1635,8 @@ var TransformComponent = function (_a) {
1632
1635
  setComponents(wrapper, content);
1633
1636
  }
1634
1637
  }, []);
1635
- return (React.createElement("div", { ref: wrapperRef, className: "react-transform-wrapper " + styles.wrapper + " " + wrapperClass, style: wrapperStyle },
1636
- React.createElement("div", { ref: contentRef, className: "react-transform-component " + styles.content + " " + contentClass, style: contentStyle }, children)));
1638
+ return (React.createElement("div", { ref: wrapperRef, className: "react-transform-wrapper ".concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle },
1639
+ React.createElement("div", { ref: contentRef, className: "react-transform-component ".concat(styles.content, " ").concat(contentClass), style: contentStyle }, children)));
1637
1640
  };
1638
1641
 
1639
1642
  var useTransformContext = function () {