@cypress-design/react-tooltip 0.6.1 → 0.6.3

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.
package/dist/index.umd.js CHANGED
@@ -36,6 +36,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
36
36
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37
37
  PERFORMANCE OF THIS SOFTWARE.
38
38
  ***************************************************************************** */
39
+ /* global Reflect, Promise */
40
+
39
41
 
40
42
  var __assign = function() {
41
43
  __assign = Object.assign || function __assign(t) {
@@ -648,6 +650,88 @@ const offset = function (value) {
648
650
  };
649
651
  };
650
652
 
653
+ function getCrossAxis(axis) {
654
+ return axis === 'x' ? 'y' : 'x';
655
+ }
656
+
657
+ /**
658
+ * Shifts the floating element in order to keep it in view when it will overflow
659
+ * a clipping boundary.
660
+ * @see https://floating-ui.com/docs/shift
661
+ */
662
+ const shift = function (options) {
663
+ if (options === void 0) {
664
+ options = {};
665
+ }
666
+
667
+ return {
668
+ name: 'shift',
669
+ options,
670
+
671
+ async fn(middlewareArguments) {
672
+ const {
673
+ x,
674
+ y,
675
+ placement
676
+ } = middlewareArguments;
677
+ const {
678
+ mainAxis: checkMainAxis = true,
679
+ crossAxis: checkCrossAxis = false,
680
+ limiter = {
681
+ fn: _ref => {
682
+ let {
683
+ x,
684
+ y
685
+ } = _ref;
686
+ return {
687
+ x,
688
+ y
689
+ };
690
+ }
691
+ },
692
+ ...detectOverflowOptions
693
+ } = options;
694
+ const coords = {
695
+ x,
696
+ y
697
+ };
698
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
699
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
700
+ const crossAxis = getCrossAxis(mainAxis);
701
+ let mainAxisCoord = coords[mainAxis];
702
+ let crossAxisCoord = coords[crossAxis];
703
+
704
+ if (checkMainAxis) {
705
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
706
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
707
+ const min = mainAxisCoord + overflow[minSide];
708
+ const max = mainAxisCoord - overflow[maxSide];
709
+ mainAxisCoord = within(min, mainAxisCoord, max);
710
+ }
711
+
712
+ if (checkCrossAxis) {
713
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
714
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
715
+ const min = crossAxisCoord + overflow[minSide];
716
+ const max = crossAxisCoord - overflow[maxSide];
717
+ crossAxisCoord = within(min, crossAxisCoord, max);
718
+ }
719
+
720
+ const limitedCoords = limiter.fn({ ...middlewareArguments,
721
+ [mainAxis]: mainAxisCoord,
722
+ [crossAxis]: crossAxisCoord
723
+ });
724
+ return { ...limitedCoords,
725
+ data: {
726
+ x: limitedCoords.x - x,
727
+ y: limitedCoords.y - y
728
+ }
729
+ };
730
+ }
731
+
732
+ };
733
+ };
734
+
651
735
  function isWindow(value) {
652
736
  return value && value.document && value.location && value.alert && value.setInterval;
653
737
  }
@@ -33480,6 +33564,7 @@ var Tooltip = function (_a) {
33480
33564
  : flip(),
33481
33565
  offset(interactive ? 0 : 16),
33482
33566
  arrow({ element: arrowRef, padding: 24 }),
33567
+ shift({ padding: 16 }),
33483
33568
  ],
33484
33569
  whileElementsMounted: autoUpdate,
33485
33570
  }), x = _e.x, y = _e.y, reference = _e.reference, floating = _e.floating, strategy = _e.strategy, calculatedPlacement = _e.placement, context = _e.context, _f = _e.middlewareData.arrow, _g = _f === void 0 ? {} : _f, arrowX = _g.x, arrowY = _g.y;
@@ -33556,4 +33641,4 @@ var Tooltip = function (_a) {
33556
33641
  module.exports = Tooltip;
33557
33642
  //# sourceMappingURL=index.umd.js.map
33558
33643
 
33559
- /* <wind-keep class="container stroke-none fill-white text-gray-900 shadow-gray-100 border-transparent bg-white fill-gray-900 text-white shadow-gray-800 bg-gray-900 rounded shadow border invisible absolute z-10 text-[16px] leading-[24px] min-w-[160px] text-center p-[8px] relative z-20"> */
33644
+ /* <wind-keep class="container stroke-none fill-white block text-gray-900 shadow-gray-100 border-transparent bg-white fill-gray-900 text-white shadow-gray-800 bg-gray-900 rounded shadow border invisible absolute z-10 transform filter text-[16px] leading-[24px] min-w-[160px] text-center p-[8px] relative z-20 drop-shadow"> */