@cypress-design/react-tooltip 0.6.2 → 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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/Tooltip.tsx +2 -0
- package/TooltipReact.cy.tsx +90 -3
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/index.es.mjs +83 -0
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +83 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/Tooltip.rootstory.tsx +0 -67
package/dist/index.umd.js
CHANGED
|
@@ -650,6 +650,88 @@ const offset = function (value) {
|
|
|
650
650
|
};
|
|
651
651
|
};
|
|
652
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
|
+
|
|
653
735
|
function isWindow(value) {
|
|
654
736
|
return value && value.document && value.location && value.alert && value.setInterval;
|
|
655
737
|
}
|
|
@@ -33482,6 +33564,7 @@ var Tooltip = function (_a) {
|
|
|
33482
33564
|
: flip(),
|
|
33483
33565
|
offset(interactive ? 0 : 16),
|
|
33484
33566
|
arrow({ element: arrowRef, padding: 24 }),
|
|
33567
|
+
shift({ padding: 16 }),
|
|
33485
33568
|
],
|
|
33486
33569
|
whileElementsMounted: autoUpdate,
|
|
33487
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;
|