@paubox/ui 0.20.0 → 0.21.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.
- package/index.esm.js +17 -89
- package/package.json +1 -1
- package/src/lib/Tooltip/Tooltip.d.ts +2 -2
package/index.esm.js
CHANGED
|
@@ -34592,9 +34592,10 @@ function _templateObject() {
|
|
|
34592
34592
|
"\n background-color: ",
|
|
34593
34593
|
";\n border-radius: 0.25rem;\n padding: 0.25rem 0.5rem;\n font-size: ",
|
|
34594
34594
|
";\n color: ",
|
|
34595
|
-
";\n
|
|
34596
|
-
";\n width: ",
|
|
34597
|
-
";\n position:
|
|
34595
|
+
";\n white-space: 'wrap';\n word-wrap: break-word;\n display: ",
|
|
34596
|
+
";\n min-height: 100%;\n width: ",
|
|
34597
|
+
";\n height: fit-content;\n position: absolute;\n display: flex;\n align-items: center;\n\n ",
|
|
34598
|
+
"\n margin-top: auto;\n margin-bottom: auto;\n"
|
|
34598
34599
|
]);
|
|
34599
34600
|
_templateObject = function _templateObject() {
|
|
34600
34601
|
return data;
|
|
@@ -34613,7 +34614,7 @@ function _templateObject1() {
|
|
|
34613
34614
|
}
|
|
34614
34615
|
function _templateObject2() {
|
|
34615
34616
|
var data = _tagged_template_literal([
|
|
34616
|
-
"\n position: absolute;\n ",
|
|
34617
|
+
"\n margin: auto;\n position: absolute;\n inset: 0;\n\n ",
|
|
34617
34618
|
"\n"
|
|
34618
34619
|
]);
|
|
34619
34620
|
_templateObject2 = function _templateObject() {
|
|
@@ -34623,10 +34624,13 @@ function _templateObject2() {
|
|
|
34623
34624
|
}
|
|
34624
34625
|
var TooltipWrapper = styled.div(_templateObject(), neutral900, $paragraph300Regular, textPrimaryWhite, function(param) {
|
|
34625
34626
|
var hover = param.hover;
|
|
34626
|
-
return hover ? '
|
|
34627
|
+
return hover ? 'block' : 'none';
|
|
34627
34628
|
}, function(param) {
|
|
34628
34629
|
var size = param.size;
|
|
34629
34630
|
return size === 'small' ? 'min-content' : 'max-content';
|
|
34631
|
+
}, function(param) {
|
|
34632
|
+
var _param_x = param.x, x = _param_x === void 0 ? 'bottom' : _param_x, _param_y = param.y, y = _param_y === void 0 ? 'left' : _param_y;
|
|
34633
|
+
return "\n margin-right: ".concat(x === 'left' ? '100%' : 'auto', ";\n margin-left: ").concat(x === 'right' ? '100%' : 'auto', ";\n z-index: 50;\n top: ").concat(y === 'bottom' ? '150%' : y === 'center' ? '0rem' : 'auto', ";\n bottom: ").concat(y === 'top' ? '150%' : y === 'center' ? '0rem' : 'auto', ";\n left: ").concat(y === 'center' ? x === 'right' ? '1rem' : 'auto' : x === 'right' ? '-1.5rem' : x === 'center' ? '0' : 'auto', ";\n right: ").concat(y === 'center' ? x === 'left' ? '1rem' : 'auto' : x === 'left' ? '-1.5rem' : x === 'center' ? '0' : 'auto', ";\n ");
|
|
34630
34634
|
});
|
|
34631
34635
|
var TooltipContainer = styled.div(_templateObject1(), function(param) {
|
|
34632
34636
|
var hover = param.hover;
|
|
@@ -34648,110 +34652,34 @@ var Triangle = function(param) {
|
|
|
34648
34652
|
});
|
|
34649
34653
|
};
|
|
34650
34654
|
var ToolTipTriangle = styled(Triangle)(_templateObject2(), function(param) {
|
|
34651
|
-
var
|
|
34652
|
-
|
|
34653
|
-
return "\n bottom: -0.375rem;\n left: 50%;\n transform: translateX(-50%) rotate(180deg);\n display: block;\n ";
|
|
34654
|
-
}
|
|
34655
|
-
if (placement === 'bottom') {
|
|
34656
|
-
return "\n top: -0.375rem;\n left: 50%;\n transform: translateX(-50%) rotate(0deg);\n display: block;\n ";
|
|
34657
|
-
}
|
|
34658
|
-
if (placement === 'left') {
|
|
34659
|
-
return "\n right: -0.375rem;\n top: 50%;\n transform: translateY(-50%) rotate(90deg);\n display: block;\n ";
|
|
34660
|
-
}
|
|
34661
|
-
if (placement === 'right') {
|
|
34662
|
-
return "\n left: -0.375rem;\n top: 50%;\n transform: translateY(-50%) rotate(-90deg);\n display: block;\n ";
|
|
34663
|
-
}
|
|
34664
|
-
return '';
|
|
34655
|
+
var _param_x = param.x, x = _param_x === void 0 ? 'bottom' : _param_x, _param_y = param.y, y = _param_y === void 0 ? 'left' : _param_y;
|
|
34656
|
+
return "\n\n top: ".concat(y === 'bottom' ? '-0.375rem' : y === 'center' ? '0' : 'auto', ";\n bottom: ").concat(y === 'top' ? '-0.375rem' : y === 'center' ? '0' : 'auto', ";\n left: ").concat(y === 'center' ? x === 'right' ? '-0.4rem' : 'auto' : x === 'right' ? '0.5rem' : x === 'center' ? '50%' : 'auto', ";\n right: ").concat(y === 'center' ? x === 'left' ? '-0.4rem' : 'auto' : x === 'left' ? '0.5rem' : x === 'center' ? '50%' : 'auto', ";\n\n display: ").concat(y === 'center' && x === 'center' ? 'none' : 'block', ";\n transform: ").concat(y === 'top' ? 'rotate(180deg)' : y === 'bottom' ? 'rotate(0deg)' : x === 'left' ? 'rotate(90deg)' : x === 'right' ? 'rotate(-90deg)' : 'rotate(0deg)', ";\n ");
|
|
34665
34657
|
});
|
|
34666
34658
|
var Tooltip = function(_param) {
|
|
34667
|
-
var children = _param.children, content = _param.content,
|
|
34659
|
+
var children = _param.children, content = _param.content, rest = _object_without_properties(_param, [
|
|
34668
34660
|
"children",
|
|
34669
|
-
"content"
|
|
34670
|
-
"className",
|
|
34671
|
-
"placement"
|
|
34661
|
+
"content"
|
|
34672
34662
|
]);
|
|
34673
|
-
var
|
|
34674
|
-
var childRef = useRef(null);
|
|
34675
|
-
var _useState = _sliced_to_array(useState({
|
|
34676
|
-
top: 0,
|
|
34677
|
-
left: 0
|
|
34678
|
-
}), 2), position = _useState[0], setPosition = _useState[1];
|
|
34679
|
-
var _useState1 = _sliced_to_array(useState(false), 2), hover = _useState1[0], setHover = _useState1[1];
|
|
34663
|
+
var _useState = _sliced_to_array(useState(false), 2), hover = _useState[0], setHover = _useState[1];
|
|
34680
34664
|
var handleMouseEnter = function() {
|
|
34681
34665
|
setHover(true);
|
|
34682
34666
|
};
|
|
34683
34667
|
var handleMouseLeave = function() {
|
|
34684
34668
|
setHover(false);
|
|
34685
34669
|
};
|
|
34686
|
-
useEffect(function() {
|
|
34687
|
-
var updatePosition = function() {
|
|
34688
|
-
if (!childRef.current || !tooltipRef.current) return;
|
|
34689
|
-
var childRect = childRef.current.getBoundingClientRect();
|
|
34690
|
-
var tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
34691
|
-
var scrollX = window.scrollX || window.pageXOffset;
|
|
34692
|
-
var scrollY = window.scrollY || window.pageYOffset;
|
|
34693
|
-
var top = 0, left = 0;
|
|
34694
|
-
switch(placement || 'bottom'){
|
|
34695
|
-
case 'top':
|
|
34696
|
-
top = childRect.top + scrollY - tooltipRect.height - 5;
|
|
34697
|
-
left = childRect.left + scrollX + (childRect.width - tooltipRect.width) / 2;
|
|
34698
|
-
break;
|
|
34699
|
-
case 'bottom':
|
|
34700
|
-
top = childRect.bottom + scrollY + 5;
|
|
34701
|
-
left = childRect.left + scrollX + (childRect.width - tooltipRect.width) / 2;
|
|
34702
|
-
break;
|
|
34703
|
-
case 'left':
|
|
34704
|
-
top = childRect.top + scrollY + (childRect.height - tooltipRect.height) / 2;
|
|
34705
|
-
left = childRect.left + scrollX - tooltipRect.width - 5;
|
|
34706
|
-
break;
|
|
34707
|
-
case 'right':
|
|
34708
|
-
top = childRect.top + scrollY + (childRect.height - tooltipRect.height) / 2;
|
|
34709
|
-
left = childRect.right + scrollX + 5;
|
|
34710
|
-
break;
|
|
34711
|
-
}
|
|
34712
|
-
setPosition({
|
|
34713
|
-
top: top,
|
|
34714
|
-
left: left
|
|
34715
|
-
});
|
|
34716
|
-
};
|
|
34717
|
-
if (hover) {
|
|
34718
|
-
updatePosition();
|
|
34719
|
-
window.addEventListener('resize', updatePosition);
|
|
34720
|
-
window.addEventListener('scroll', updatePosition);
|
|
34721
|
-
}
|
|
34722
|
-
return function() {
|
|
34723
|
-
window.removeEventListener('resize', updatePosition);
|
|
34724
|
-
window.removeEventListener('scroll', updatePosition);
|
|
34725
|
-
};
|
|
34726
|
-
}, [
|
|
34727
|
-
hover,
|
|
34728
|
-
placement
|
|
34729
|
-
]);
|
|
34730
34670
|
return /*#__PURE__*/ jsxs(TooltipContainer, {
|
|
34731
34671
|
onMouseEnter: handleMouseEnter,
|
|
34732
34672
|
onMouseLeave: handleMouseLeave,
|
|
34733
34673
|
hover: hover,
|
|
34734
34674
|
children: [
|
|
34735
34675
|
/*#__PURE__*/ jsx("div", {
|
|
34736
|
-
ref: childRef,
|
|
34737
34676
|
children: children
|
|
34738
34677
|
}),
|
|
34739
|
-
/*#__PURE__*/ jsxs(TooltipWrapper, _object_spread_props(_object_spread({
|
|
34740
|
-
className: className,
|
|
34741
|
-
ref: tooltipRef,
|
|
34742
|
-
style: {
|
|
34743
|
-
top: position.top,
|
|
34744
|
-
left: position.left
|
|
34745
|
-
}
|
|
34746
|
-
}, rest), {
|
|
34678
|
+
/*#__PURE__*/ jsxs(TooltipWrapper, _object_spread_props(_object_spread({}, rest), {
|
|
34747
34679
|
hover: hover,
|
|
34748
34680
|
children: [
|
|
34749
|
-
|
|
34750
|
-
|
|
34751
|
-
}),
|
|
34752
|
-
/*#__PURE__*/ jsx(ToolTipTriangle, _object_spread({
|
|
34753
|
-
placement: placement
|
|
34754
|
-
}, rest))
|
|
34681
|
+
content,
|
|
34682
|
+
/*#__PURE__*/ jsx(ToolTipTriangle, _object_spread({}, rest))
|
|
34755
34683
|
]
|
|
34756
34684
|
}))
|
|
34757
34685
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
2
|
-
|
|
2
|
+
y?: 'top' | 'bottom' | 'center';
|
|
3
|
+
x?: 'left' | 'right' | 'center';
|
|
3
4
|
size?: 'small' | 'large';
|
|
4
|
-
className?: string;
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
content: string;
|
|
7
7
|
}
|