glints-aries 4.0.194 → 4.0.196
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/es/@next/Alert/AlertProvider.js +3 -1
- package/es/@next/Modal/ModalProvider.js +3 -1
- package/es/@next/Tooltip/Tooltip.d.ts +10 -0
- package/es/@next/Tooltip/Tooltip.js +133 -0
- package/es/@next/Tooltip/Tooltip.stories.d.ts +4 -0
- package/es/@next/Tooltip/TooltipAdaptiveBottom.stories.d.ts +6 -0
- package/es/@next/Tooltip/TooltipAdaptiveLeft.stories.d.ts +6 -0
- package/es/@next/Tooltip/TooltipAdaptiveRight.stories.d.ts +6 -0
- package/es/@next/Tooltip/TooltipAdaptiveTop.stories.d.ts +6 -0
- package/es/@next/Tooltip/TooltipStyle.d.ts +3 -0
- package/es/@next/Tooltip/TooltipStyle.js +22 -0
- package/es/@next/Tooltip/index.d.ts +1 -0
- package/es/@next/Tooltip/index.js +1 -0
- package/es/@next/Tooltip/positionResolver.d.ts +6 -0
- package/es/@next/Tooltip/positionResolver.js +181 -0
- package/es/@next/Tooltip/positionResolverHelper.d.ts +37 -0
- package/es/@next/Tooltip/positionResolverHelper.js +106 -0
- package/es/@next/index.d.ts +1 -0
- package/es/@next/index.js +1 -0
- package/es/helpers/viewPort.d.ts +4 -0
- package/es/helpers/viewPort.js +8 -0
- package/lib/@next/Alert/AlertProvider.js +3 -1
- package/lib/@next/Modal/ModalProvider.js +3 -1
- package/lib/@next/Tooltip/Tooltip.d.ts +10 -0
- package/lib/@next/Tooltip/Tooltip.js +140 -0
- package/lib/@next/Tooltip/Tooltip.stories.d.ts +4 -0
- package/lib/@next/Tooltip/TooltipAdaptiveBottom.stories.d.ts +6 -0
- package/lib/@next/Tooltip/TooltipAdaptiveLeft.stories.d.ts +6 -0
- package/lib/@next/Tooltip/TooltipAdaptiveRight.stories.d.ts +6 -0
- package/lib/@next/Tooltip/TooltipAdaptiveTop.stories.d.ts +6 -0
- package/lib/@next/Tooltip/TooltipStyle.d.ts +3 -0
- package/lib/@next/Tooltip/TooltipStyle.js +32 -0
- package/lib/@next/Tooltip/index.d.ts +1 -0
- package/lib/@next/Tooltip/index.js +9 -0
- package/lib/@next/Tooltip/positionResolver.d.ts +6 -0
- package/lib/@next/Tooltip/positionResolver.js +189 -0
- package/lib/@next/Tooltip/positionResolverHelper.d.ts +37 -0
- package/lib/@next/Tooltip/positionResolverHelper.js +130 -0
- package/lib/@next/index.d.ts +1 -0
- package/lib/@next/index.js +5 -1
- package/lib/helpers/viewPort.d.ts +4 -0
- package/lib/helpers/viewPort.js +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.Tooltip = void 0;
|
|
5
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _Portal = require("../Portal/Portal");
|
|
7
|
+
var _Typography = require("../Typography");
|
|
8
|
+
var _positionResolver = require("./positionResolver");
|
|
9
|
+
var _positionResolverHelper = require("./positionResolverHelper");
|
|
10
|
+
var _TooltipStyle = require("./TooltipStyle");
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
var topPositions = ['top-center', 'top-left', 'top-right'];
|
|
14
|
+
var bottomPositions = ['bottom-center', 'bottom-left', 'bottom-right'];
|
|
15
|
+
var rightPositions = ['right-middle', 'right-top', 'right-bottom'];
|
|
16
|
+
var leftPositions = ['left-middle', 'left-top', 'left-bottom'];
|
|
17
|
+
var allPositions = [].concat(topPositions, bottomPositions, rightPositions, leftPositions);
|
|
18
|
+
var tooltipPositionResolvers = {
|
|
19
|
+
'top-center': function topCenter(tooltipRect, elementRect) {
|
|
20
|
+
return (0, _positionResolver.topPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignRight]);
|
|
21
|
+
},
|
|
22
|
+
'top-left': function topLeft(tooltipRect, elementRect) {
|
|
23
|
+
return (0, _positionResolver.topPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignRight]);
|
|
24
|
+
},
|
|
25
|
+
'top-right': function topRight(tooltipRect, elementRect) {
|
|
26
|
+
return (0, _positionResolver.topPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignRight, _positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft]);
|
|
27
|
+
},
|
|
28
|
+
'bottom-center': function bottomCenter(tooltipRect, elementRect) {
|
|
29
|
+
return (0, _positionResolver.bottomPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignRight]);
|
|
30
|
+
},
|
|
31
|
+
'bottom-left': function bottomLeft(tooltipRect, elementRect) {
|
|
32
|
+
return (0, _positionResolver.bottomPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignRight]);
|
|
33
|
+
},
|
|
34
|
+
'bottom-right': function bottomRight(tooltipRect, elementRect) {
|
|
35
|
+
return (0, _positionResolver.bottomPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignRight, _positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft]);
|
|
36
|
+
},
|
|
37
|
+
'right-middle': function rightMiddle(tooltipRect, elementRect) {
|
|
38
|
+
return (0, _positionResolver.rightPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignBottom]);
|
|
39
|
+
},
|
|
40
|
+
'right-top': function rightTop(tooltipRect, elementRect) {
|
|
41
|
+
return (0, _positionResolver.rightPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignBottom]);
|
|
42
|
+
},
|
|
43
|
+
'right-bottom': function rightBottom(tooltipRect, elementRect) {
|
|
44
|
+
return (0, _positionResolver.rightPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignBottom, _positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop]);
|
|
45
|
+
},
|
|
46
|
+
'left-middle': function leftMiddle(tooltipRect, elementRect) {
|
|
47
|
+
return (0, _positionResolver.leftPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignBottom]);
|
|
48
|
+
},
|
|
49
|
+
'left-top': function leftTop(tooltipRect, elementRect) {
|
|
50
|
+
return (0, _positionResolver.leftPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignBottom]);
|
|
51
|
+
},
|
|
52
|
+
'left-bottom': function leftBottom(tooltipRect, elementRect) {
|
|
53
|
+
return (0, _positionResolver.leftPositionResolver)(tooltipRect, elementRect, [_positionResolverHelper.canAlignBottom, _positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop]);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var defaultPosition = 'top-center';
|
|
57
|
+
var Tooltip = function Tooltip(_ref) {
|
|
58
|
+
var children = _ref.children,
|
|
59
|
+
content = _ref.content,
|
|
60
|
+
_ref$preferredPositio = _ref.preferredPosition,
|
|
61
|
+
preferredPosition = _ref$preferredPositio === void 0 ? defaultPosition : _ref$preferredPositio;
|
|
62
|
+
var tooltipRef = (0, _react.useRef)(null);
|
|
63
|
+
var elRef = (0, _react.useRef)(null);
|
|
64
|
+
var tooltipPositionsHandlerRef = (0, _react.useRef)(null);
|
|
65
|
+
var _useState = (0, _react.useState)(null),
|
|
66
|
+
toolTipCoord = _useState[0],
|
|
67
|
+
setToolTipCoord = _useState[1];
|
|
68
|
+
var _useState2 = (0, _react.useState)(false),
|
|
69
|
+
isActive = _useState2[0],
|
|
70
|
+
setIsActive = _useState2[1];
|
|
71
|
+
var _useState3 = (0, _react.useState)(null),
|
|
72
|
+
overridePosition = _useState3[0],
|
|
73
|
+
setOverridePosition = _useState3[1];
|
|
74
|
+
if (!allPositions.includes(preferredPosition)) {
|
|
75
|
+
preferredPosition = defaultPosition;
|
|
76
|
+
console.warn("\"" + preferredPosition + "\" is not a valid tooltip positon, \"" + defaultPosition + "\" will be used instead");
|
|
77
|
+
}
|
|
78
|
+
var position = overridePosition || preferredPosition;
|
|
79
|
+
var handleTooltipPositions = function handleTooltipPositions(tooltipRect, elRect, currentPosition) {
|
|
80
|
+
var resolver = tooltipPositionResolvers[position] || tooltipPositionResolvers[defaultPosition];
|
|
81
|
+
var newLeft = 0;
|
|
82
|
+
var newTop = 0;
|
|
83
|
+
if (position.startsWith('top')) {
|
|
84
|
+
newTop = elRect.top - tooltipRect.height - _positionResolverHelper.verticalBuffer;
|
|
85
|
+
newLeft = elRect.left + elRect.width / 2;
|
|
86
|
+
}
|
|
87
|
+
if (position.startsWith('bottom')) {
|
|
88
|
+
newTop = elRect.top + elRect.height + _positionResolverHelper.verticalBuffer;
|
|
89
|
+
newLeft = elRect.left + elRect.width / 2;
|
|
90
|
+
}
|
|
91
|
+
if (position.startsWith('left')) {
|
|
92
|
+
newTop = elRect.top + elRect.height / 2;
|
|
93
|
+
newLeft = elRect.left - tooltipRect.width - _positionResolverHelper.horizontalBuffer;
|
|
94
|
+
}
|
|
95
|
+
if (position.startsWith('right')) {
|
|
96
|
+
newTop = elRect.top + elRect.height / 2;
|
|
97
|
+
newLeft = elRect.left + elRect.width + _positionResolverHelper.horizontalBuffer;
|
|
98
|
+
}
|
|
99
|
+
setToolTipCoord({
|
|
100
|
+
top: newTop,
|
|
101
|
+
left: newLeft
|
|
102
|
+
});
|
|
103
|
+
var tooltipRectNew = new DOMRect(newLeft, newTop, tooltipRect.width, tooltipRect.height);
|
|
104
|
+
var resolvedPosition = resolver(tooltipRectNew, elRect);
|
|
105
|
+
if (!overridePosition && resolvedPosition !== currentPosition) {
|
|
106
|
+
setOverridePosition(resolvedPosition);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
tooltipPositionsHandlerRef.current = handleTooltipPositions;
|
|
110
|
+
(0, _react.useEffect)(function () {
|
|
111
|
+
if (isActive) {
|
|
112
|
+
var _tooltipRef$current, _elRef$current;
|
|
113
|
+
tooltipPositionsHandlerRef.current(tooltipRef == null ? void 0 : (_tooltipRef$current = tooltipRef.current) == null ? void 0 : _tooltipRef$current.getClientRects()[0], elRef == null ? void 0 : (_elRef$current = elRef.current) == null ? void 0 : _elRef$current.getClientRects()[0], position);
|
|
114
|
+
}
|
|
115
|
+
}, [isActive, position]);
|
|
116
|
+
var contentMarkup = typeof content === 'string' ? /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
|
|
117
|
+
as: "div",
|
|
118
|
+
variant: "body1"
|
|
119
|
+
}, content) : content;
|
|
120
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_TooltipStyle.StyledTooltipContainer, {
|
|
121
|
+
ref: elRef,
|
|
122
|
+
onMouseEnter: function onMouseEnter() {
|
|
123
|
+
return setIsActive(true);
|
|
124
|
+
},
|
|
125
|
+
onMouseLeave: function onMouseLeave() {
|
|
126
|
+
return setIsActive(false);
|
|
127
|
+
}
|
|
128
|
+
}, children), isActive && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, null, /*#__PURE__*/_react["default"].createElement(_TooltipStyle.StyledTooltip, {
|
|
129
|
+
"data-position": position,
|
|
130
|
+
ref: tooltipRef,
|
|
131
|
+
style: {
|
|
132
|
+
top: (toolTipCoord == null ? void 0 : toolTipCoord.top) + 'px',
|
|
133
|
+
left: (toolTipCoord == null ? void 0 : toolTipCoord.left) + 'px',
|
|
134
|
+
visibility: toolTipCoord ? 'visible' : 'hidden'
|
|
135
|
+
}
|
|
136
|
+
}, /*#__PURE__*/_react["default"].createElement(_TooltipStyle.StyledTooltipArrow, {
|
|
137
|
+
className: "arrow"
|
|
138
|
+
}), contentMarkup)));
|
|
139
|
+
};
|
|
140
|
+
exports.Tooltip = Tooltip;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const AdaptiveBottomCenter: any;
|
|
5
|
+
export declare const AdaptiveBottomLeft: any;
|
|
6
|
+
export declare const AdaptiveBottomRight: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const AdaptiveLeftMiddle: any;
|
|
5
|
+
export declare const AdaptiveLeftTop: any;
|
|
6
|
+
export declare const AdaptiveLeftBottom: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const AdaptiveRightMiddle: any;
|
|
5
|
+
export declare const AdaptiveRightTop: any;
|
|
6
|
+
export declare const AdaptiveRightBottom: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const AdaptiveTopCenter: any;
|
|
5
|
+
export declare const AdaptiveTopLeft: any;
|
|
6
|
+
export declare const AdaptiveTopRight: any;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const StyledTooltipContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const StyledTooltipArrow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.StyledTooltipContainer = exports.StyledTooltipArrow = exports.StyledTooltip = void 0;
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
|
+
var Breakpoints = _interopRequireWildcard(require("../utilities/breakpoints"));
|
|
8
|
+
var _borderRadius = require("../utilities/borderRadius");
|
|
9
|
+
var _colors = require("../utilities/colors");
|
|
10
|
+
var _spacing = require("../utilities/spacing");
|
|
11
|
+
var _positionResolverHelper = require("./positionResolverHelper");
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
var verticalMargin = _positionResolverHelper.verticalBuffer + "px";
|
|
15
|
+
var arrowSize = '6px';
|
|
16
|
+
var nonCentralArrowMargin = _positionResolverHelper.nonCenterArrowSpace + "px";
|
|
17
|
+
var background = _colors.Neutral.B18;
|
|
18
|
+
var StyledTooltipContainer = _styledComponents["default"].div.withConfig({
|
|
19
|
+
displayName: "TooltipStyle__StyledTooltipContainer",
|
|
20
|
+
componentId: "sc-37e5z7-0"
|
|
21
|
+
})(["display:inline-block;position:relative;*{display:block;}"]);
|
|
22
|
+
exports.StyledTooltipContainer = StyledTooltipContainer;
|
|
23
|
+
var StyledTooltip = _styledComponents["default"].div.withConfig({
|
|
24
|
+
displayName: "TooltipStyle__StyledTooltip",
|
|
25
|
+
componentId: "sc-37e5z7-1"
|
|
26
|
+
})(["position:absolute;text-align:left;height:fit-content;width:fit-content;max-width:320px;border-radius:", ";gap:10px;left:50%;transform:translateX(-50%);padding:", " ", ";color:", ";background:", ";z-index:100;overflow-wrap:break-word;line-height:1;&[data-position='top-left'],&[data-position='bottom-left']{transform:translateX( calc(100% * -1 + ", " + ", ") );}&[data-position='top-right'],&[data-position='bottom-right']{transform:translateX(calc((", " + ", ") * -1));}&[data-position='right-middle']{transform:translateX(0) translateY(-50%);}&[data-position='left-bottom'],&[data-position='right-bottom']{transform:translateY(calc((", " + ", ") * -1));}&[data-position='left-top'],&[data-position='right-top']{transform:translateY( calc(100% * -1 + (", " + ", ")) );}&[data-position='bottom-center'],&[data-position='bottom-left'],&[data-position='bottom-right']{top:calc((100% + ", "));}&[data-position='left-middle']{transform:translateX(0) translateY(-50%);}&[data-position='top-center'] .arrow,&[data-position='top-left'] .arrow,&[data-position='top-right'] .arrow{top:100%;border-top-color:", ";}&[data-position='top-left'] .arrow,&[data-position='bottom-left'] .arrow{left:calc(100% - ", " - ", ");}&[data-position='top-right'] .arrow,&[data-position='bottom-right'] .arrow{left:calc(", " + ", ");}&[data-position='right-middle'] .arrow,&[data-position='right-top'] .arrow,&[data-position='right-bottom'] .arrow{top:50%;left:calc(", " * -1);border-right-color:", ";}&[data-position='right-middle'] .arrow{transform:translateX(0) translateY(-50%);}&[data-position='left-bottom'] .arrow,&[data-position='right-bottom'] .arrow{top:", ";}&[data-position='bottom-center'] .arrow,&[data-position='bottom-left'] .arrow,&[data-position='bottom-right'] .arrow{bottom:100%;border-bottom-color:", ";}&[data-position='left-middle'] .arrow,&[data-position='left-top'] .arrow,&[data-position='left-bottom'] .arrow{left:auto;right:calc(", " * -2);border-left-color:", ";}&[data-position='left-middle'] .arrow{top:50%;transform:translateX(0) translateY(-50%);}&[data-position='left-top'] .arrow,&[data-position='right-top'] .arrow{top:unset;bottom:", ";}@media (max-width:", "){min-width:69px;}"], _borderRadius.borderRadius2, _spacing.space8, _spacing.space12, _colors.Neutral.B100, background, arrowSize, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, arrowSize, verticalMargin, background, arrowSize, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, arrowSize, background, nonCentralArrowMargin, background, arrowSize, background, nonCentralArrowMargin, Breakpoints.large);
|
|
27
|
+
exports.StyledTooltip = StyledTooltip;
|
|
28
|
+
var StyledTooltipArrow = _styledComponents["default"].div.withConfig({
|
|
29
|
+
displayName: "TooltipStyle__StyledTooltipArrow",
|
|
30
|
+
componentId: "sc-37e5z7-2"
|
|
31
|
+
})(["content:' ';left:50%;border:solid transparent;height:0;width:0;position:absolute;pointer-events:none;border-width:", ";margin-left:calc(", " * -1);"], arrowSize, arrowSize);
|
|
32
|
+
exports.StyledTooltipArrow = StyledTooltipArrow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _Tooltip = require("./Tooltip");
|
|
5
|
+
Object.keys(_Tooltip).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _Tooltip[key]) return;
|
|
8
|
+
exports[key] = _Tooltip[key];
|
|
9
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PreferredHorizontalAligmentFuncsType, PreferredVerticalAligmentFuncsType } from './positionResolverHelper';
|
|
2
|
+
import { TooltipPosition } from './Tooltip';
|
|
3
|
+
export declare const topPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredHorizontalAligmentFuncsType[]) => TooltipPosition;
|
|
4
|
+
export declare const bottomPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredHorizontalAligmentFuncsType[]) => TooltipPosition;
|
|
5
|
+
export declare const leftPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredVerticalAligmentFuncsType[]) => TooltipPosition;
|
|
6
|
+
export declare const rightPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredVerticalAligmentFuncsType[]) => TooltipPosition;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.topPositionResolver = exports.rightPositionResolver = exports.leftPositionResolver = exports.bottomPositionResolver = void 0;
|
|
5
|
+
var _positionResolverHelper = require("./positionResolverHelper");
|
|
6
|
+
var topPositionResolver = function topPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
7
|
+
var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
8
|
+
var verticalPreferredAligmentFuncs = [_positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignBottom];
|
|
9
|
+
if ((0, _positionResolverHelper.canStayOnTop)(tooltipRect)) {
|
|
10
|
+
var alignResult = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
11
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
12
|
+
tooltipRect: tooltipRect,
|
|
13
|
+
elRect: elRect
|
|
14
|
+
});
|
|
15
|
+
if (alignResult) {
|
|
16
|
+
return "top-" + alignResult;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if ((0, _positionResolverHelper.canFitOnTheLeft)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
20
|
+
var _alignResult = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
21
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
22
|
+
tooltipRect: tooltipRect,
|
|
23
|
+
elRect: elRect
|
|
24
|
+
});
|
|
25
|
+
if (_alignResult) {
|
|
26
|
+
return "left-" + _alignResult;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if ((0, _positionResolverHelper.canFitOnTheRight)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
30
|
+
var _alignResult2 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
31
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
32
|
+
tooltipRect: tooltipRect,
|
|
33
|
+
elRect: elRect
|
|
34
|
+
});
|
|
35
|
+
if (_alignResult2) {
|
|
36
|
+
return "right-" + _alignResult2;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if ((0, _positionResolverHelper.canFitBelow)(tooltipRect, elRect, _positionResolverHelper.verticalBuffer)) {
|
|
40
|
+
var _alignResult3 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
41
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
42
|
+
tooltipRect: tooltipRect,
|
|
43
|
+
elRect: elRect
|
|
44
|
+
});
|
|
45
|
+
if (_alignResult3) {
|
|
46
|
+
return "bottom-" + _alignResult3;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 'top-center';
|
|
50
|
+
};
|
|
51
|
+
exports.topPositionResolver = topPositionResolver;
|
|
52
|
+
var bottomPositionResolver = function bottomPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
53
|
+
var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
54
|
+
var verticalPreferredAligmentFuncs = [_positionResolverHelper.canAlignMiddle, _positionResolverHelper.canAlignTop, _positionResolverHelper.canAlignBottom];
|
|
55
|
+
if ((0, _positionResolverHelper.canStayOnBottom)(tooltipRect)) {
|
|
56
|
+
var alignResult = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
57
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
58
|
+
tooltipRect: tooltipRect,
|
|
59
|
+
elRect: elRect
|
|
60
|
+
});
|
|
61
|
+
if (alignResult) {
|
|
62
|
+
return "bottom-" + alignResult;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if ((0, _positionResolverHelper.canFitOnTheLeft)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
66
|
+
var _alignResult4 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
67
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
68
|
+
tooltipRect: tooltipRect,
|
|
69
|
+
elRect: elRect
|
|
70
|
+
});
|
|
71
|
+
if (_alignResult4) {
|
|
72
|
+
return "left-" + _alignResult4;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if ((0, _positionResolverHelper.canFitOnTheRight)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
76
|
+
var _alignResult5 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
77
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
78
|
+
tooltipRect: tooltipRect,
|
|
79
|
+
elRect: elRect
|
|
80
|
+
});
|
|
81
|
+
if (_alignResult5) {
|
|
82
|
+
return "right-" + _alignResult5;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if ((0, _positionResolverHelper.canFitOnTheTop)(tooltipRect, elRect, _positionResolverHelper.verticalBuffer)) {
|
|
86
|
+
var _alignResult6 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
87
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
88
|
+
tooltipRect: tooltipRect,
|
|
89
|
+
elRect: elRect
|
|
90
|
+
});
|
|
91
|
+
if (_alignResult6) {
|
|
92
|
+
return "top-" + _alignResult6;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return 'bottom-center';
|
|
96
|
+
};
|
|
97
|
+
exports.bottomPositionResolver = bottomPositionResolver;
|
|
98
|
+
var leftPositionResolver = function leftPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
99
|
+
var horizontalPreferredAligmentFuncs = [_positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignRight];
|
|
100
|
+
var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
101
|
+
if ((0, _positionResolverHelper.canStayOnLeft)(tooltipRect)) {
|
|
102
|
+
var alignResult = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
103
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
104
|
+
tooltipRect: tooltipRect,
|
|
105
|
+
elRect: elRect
|
|
106
|
+
});
|
|
107
|
+
if (alignResult) {
|
|
108
|
+
return "left-" + alignResult;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if ((0, _positionResolverHelper.canFitOnTheTop)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
112
|
+
var _alignResult7 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
113
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
114
|
+
tooltipRect: tooltipRect,
|
|
115
|
+
elRect: elRect
|
|
116
|
+
});
|
|
117
|
+
if (_alignResult7) {
|
|
118
|
+
return "top-" + _alignResult7;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if ((0, _positionResolverHelper.canFitOnTheRight)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
122
|
+
var _alignResult8 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
123
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
124
|
+
tooltipRect: tooltipRect,
|
|
125
|
+
elRect: elRect
|
|
126
|
+
});
|
|
127
|
+
if (_alignResult8) {
|
|
128
|
+
return "right-" + _alignResult8;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if ((0, _positionResolverHelper.canFitBelow)(tooltipRect, elRect, _positionResolverHelper.verticalBuffer)) {
|
|
132
|
+
var _alignResult9 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
133
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
134
|
+
tooltipRect: tooltipRect,
|
|
135
|
+
elRect: elRect
|
|
136
|
+
});
|
|
137
|
+
if (_alignResult9) {
|
|
138
|
+
return "bottom-" + _alignResult9;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return 'left-middle';
|
|
142
|
+
};
|
|
143
|
+
exports.leftPositionResolver = leftPositionResolver;
|
|
144
|
+
var rightPositionResolver = function rightPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
145
|
+
var horizontalPreferredAligmentFuncs = [_positionResolverHelper.canAlignCenter, _positionResolverHelper.canAlignLeft, _positionResolverHelper.canAlignRight];
|
|
146
|
+
var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
147
|
+
if ((0, _positionResolverHelper.canStayOnRight)(tooltipRect)) {
|
|
148
|
+
var alignResult = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
149
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
150
|
+
tooltipRect: tooltipRect,
|
|
151
|
+
elRect: elRect
|
|
152
|
+
});
|
|
153
|
+
if (alignResult) {
|
|
154
|
+
return "right-" + alignResult;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if ((0, _positionResolverHelper.canFitOnTheTop)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
158
|
+
var _alignResult10 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
159
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
160
|
+
tooltipRect: tooltipRect,
|
|
161
|
+
elRect: elRect
|
|
162
|
+
});
|
|
163
|
+
if (_alignResult10) {
|
|
164
|
+
return "top-" + _alignResult10;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if ((0, _positionResolverHelper.canFitOnTheLeft)(tooltipRect, elRect, _positionResolverHelper.horizontalBuffer)) {
|
|
168
|
+
var _alignResult11 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
169
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
170
|
+
tooltipRect: tooltipRect,
|
|
171
|
+
elRect: elRect
|
|
172
|
+
});
|
|
173
|
+
if (_alignResult11) {
|
|
174
|
+
return "left-" + _alignResult11;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if ((0, _positionResolverHelper.canFitBelow)(tooltipRect, elRect, _positionResolverHelper.verticalBuffer)) {
|
|
178
|
+
var _alignResult12 = (0, _positionResolverHelper.tryCalculateAligment)({
|
|
179
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
180
|
+
tooltipRect: tooltipRect,
|
|
181
|
+
elRect: elRect
|
|
182
|
+
});
|
|
183
|
+
if (_alignResult12) {
|
|
184
|
+
return "bottom-" + _alignResult12;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return 'right-middle';
|
|
188
|
+
};
|
|
189
|
+
exports.rightPositionResolver = rightPositionResolver;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const verticalBuffer = 8;
|
|
2
|
+
export declare const horizontalBuffer = 8;
|
|
3
|
+
export declare const nonCenterArrowSpace = 12;
|
|
4
|
+
export declare type HorizontalAlignmentType = 'center' | 'left' | 'right';
|
|
5
|
+
export declare type VerticalAlignmentType = 'middle' | 'top' | 'bottom';
|
|
6
|
+
export declare type HorizontalAlignmentCalculatorResult = {
|
|
7
|
+
type: HorizontalAlignmentType;
|
|
8
|
+
result: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare type VerticalAlignmentCalculatorResult = {
|
|
11
|
+
type: VerticalAlignmentType;
|
|
12
|
+
result: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare type PreferredHorizontalAligmentFuncsType = (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
|
|
15
|
+
export declare type PreferredVerticalAligmentFuncsType = (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
|
|
16
|
+
export declare type TryCalculateAlignmentArgs<T extends HorizontalAlignmentType | VerticalAlignmentType> = {
|
|
17
|
+
preferredAlignmentFuncs: T extends HorizontalAlignmentType ? PreferredHorizontalAligmentFuncsType[] : PreferredVerticalAligmentFuncsType[];
|
|
18
|
+
tooltipRect: DOMRect;
|
|
19
|
+
elRect: DOMRect;
|
|
20
|
+
};
|
|
21
|
+
export declare const getElementCenterPosition: (elRect: DOMRect) => number;
|
|
22
|
+
export declare const getElementMiddlePosition: (elRect: DOMRect) => number;
|
|
23
|
+
export declare const canFitOnTheTop: (tooltipRect: DOMRect, elRect: DOMRect, verticalMargin: number) => boolean;
|
|
24
|
+
export declare const canFitBelow: (tooltipRect: DOMRect, elRect: DOMRect, verticalMargin: number) => boolean;
|
|
25
|
+
export declare const canFitOnTheLeft: (tooltipRect: DOMRect, elRect: DOMRect, horizontalMargin: number) => boolean;
|
|
26
|
+
export declare const canFitOnTheRight: (tooltipRect: DOMRect, elRect: DOMRect, horizontalMargin: number) => boolean;
|
|
27
|
+
export declare const canAlignLeft: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
|
|
28
|
+
export declare const canAlignRight: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
|
|
29
|
+
export declare const canAlignCenter: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
|
|
30
|
+
export declare const canAlignTop: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
|
|
31
|
+
export declare const canAlignBottom: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
|
|
32
|
+
export declare const canAlignMiddle: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
|
|
33
|
+
export declare const canStayOnTop: (tooltipRect: DOMRect) => boolean;
|
|
34
|
+
export declare const canStayOnBottom: (tooltipRect: DOMRect) => boolean;
|
|
35
|
+
export declare const canStayOnLeft: (tooltipRect: DOMRect) => boolean;
|
|
36
|
+
export declare const canStayOnRight: (tooltipRect: DOMRect) => boolean;
|
|
37
|
+
export declare const tryCalculateAligment: <T extends HorizontalAlignmentType | VerticalAlignmentType>(args: TryCalculateAlignmentArgs<T>) => HorizontalAlignmentType | VerticalAlignmentType;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.verticalBuffer = exports.tryCalculateAligment = exports.nonCenterArrowSpace = exports.horizontalBuffer = exports.getElementMiddlePosition = exports.getElementCenterPosition = exports.canStayOnTop = exports.canStayOnRight = exports.canStayOnLeft = exports.canStayOnBottom = exports.canFitOnTheTop = exports.canFitOnTheRight = exports.canFitOnTheLeft = exports.canFitBelow = exports.canAlignTop = exports.canAlignRight = exports.canAlignMiddle = exports.canAlignLeft = exports.canAlignCenter = exports.canAlignBottom = void 0;
|
|
5
|
+
var _viewPort = require("../../helpers/viewPort");
|
|
6
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
var verticalBuffer = 8;
|
|
10
|
+
exports.verticalBuffer = verticalBuffer;
|
|
11
|
+
var horizontalBuffer = 8;
|
|
12
|
+
exports.horizontalBuffer = horizontalBuffer;
|
|
13
|
+
var nonCenterArrowSpace = 12;
|
|
14
|
+
// for non center position the position of the arrow is 12px from the most left or right, setting it to 14 to make sure it's nicely visible
|
|
15
|
+
exports.nonCenterArrowSpace = nonCenterArrowSpace;
|
|
16
|
+
var marginBuffer = nonCenterArrowSpace + 2;
|
|
17
|
+
var getElementCenterPosition = function getElementCenterPosition(elRect) {
|
|
18
|
+
return elRect.left + elRect.width / 2;
|
|
19
|
+
};
|
|
20
|
+
exports.getElementCenterPosition = getElementCenterPosition;
|
|
21
|
+
var getElementMiddlePosition = function getElementMiddlePosition(elRect) {
|
|
22
|
+
return elRect.bottom + elRect.height / 2;
|
|
23
|
+
};
|
|
24
|
+
exports.getElementMiddlePosition = getElementMiddlePosition;
|
|
25
|
+
var canFitOnTheTop = function canFitOnTheTop(tooltipRect, elRect, verticalMargin) {
|
|
26
|
+
return elRect.top - (verticalMargin + tooltipRect.height) > 0;
|
|
27
|
+
};
|
|
28
|
+
exports.canFitOnTheTop = canFitOnTheTop;
|
|
29
|
+
var canFitBelow = function canFitBelow(tooltipRect, elRect, verticalMargin) {
|
|
30
|
+
return elRect.bottom + verticalMargin + tooltipRect.height < (0, _viewPort.getViewportDimensions)().height;
|
|
31
|
+
};
|
|
32
|
+
exports.canFitBelow = canFitBelow;
|
|
33
|
+
var canFitOnTheLeft = function canFitOnTheLeft(tooltipRect, elRect, horizontalMargin) {
|
|
34
|
+
return elRect.left - (horizontalMargin + tooltipRect.width) > 0;
|
|
35
|
+
};
|
|
36
|
+
exports.canFitOnTheLeft = canFitOnTheLeft;
|
|
37
|
+
var canFitOnTheRight = function canFitOnTheRight(tooltipRect, elRect, horizontalMargin) {
|
|
38
|
+
return elRect.right + horizontalMargin + tooltipRect.width < (0, _viewPort.getViewportDimensions)().width;
|
|
39
|
+
};
|
|
40
|
+
exports.canFitOnTheRight = canFitOnTheRight;
|
|
41
|
+
var canAlignLeft = function canAlignLeft(tooltipRect, elRect) {
|
|
42
|
+
var centerPosition = getElementCenterPosition(elRect);
|
|
43
|
+
var hasSpaceOnTheLeftSideOfArrow = centerPosition - (tooltipRect.width - marginBuffer) > 0;
|
|
44
|
+
var hasSpaceOnTheRightSideOfArrow = centerPosition + marginBuffer < (0, _viewPort.getViewportDimensions)().width;
|
|
45
|
+
return {
|
|
46
|
+
type: 'left',
|
|
47
|
+
result: hasSpaceOnTheLeftSideOfArrow && hasSpaceOnTheRightSideOfArrow
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.canAlignLeft = canAlignLeft;
|
|
51
|
+
var canAlignRight = function canAlignRight(tooltipRect, elRect) {
|
|
52
|
+
var centerPosition = getElementCenterPosition(elRect);
|
|
53
|
+
var hasSpaceOnTheRightSideOfArrow = centerPosition + (tooltipRect.width - marginBuffer) < (0, _viewPort.getViewportDimensions)().width;
|
|
54
|
+
var hasSpaceOnTheLeftSideOfArrow = centerPosition - marginBuffer > 0;
|
|
55
|
+
return {
|
|
56
|
+
type: 'right',
|
|
57
|
+
result: hasSpaceOnTheLeftSideOfArrow && hasSpaceOnTheRightSideOfArrow
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.canAlignRight = canAlignRight;
|
|
61
|
+
var canAlignCenter = function canAlignCenter(tooltipRect, elRect) {
|
|
62
|
+
var centerPosition = elRect.left + elRect.width / 2;
|
|
63
|
+
return {
|
|
64
|
+
type: 'center',
|
|
65
|
+
result: centerPosition - tooltipRect.width / 2 > 0 && centerPosition + tooltipRect.width / 2 < (0, _viewPort.getViewportDimensions)().width
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.canAlignCenter = canAlignCenter;
|
|
69
|
+
var canAlignTop = function canAlignTop(tooltipRect, elRect) {
|
|
70
|
+
var middlePosition = getElementMiddlePosition(elRect);
|
|
71
|
+
var hasSpaceOnTheTopOfArrow = middlePosition - (tooltipRect.height - marginBuffer) > 0;
|
|
72
|
+
var hasSpaceBelowTheArrow = middlePosition + marginBuffer < (0, _viewPort.getViewportDimensions)().width;
|
|
73
|
+
return {
|
|
74
|
+
type: 'top',
|
|
75
|
+
result: hasSpaceOnTheTopOfArrow && hasSpaceBelowTheArrow
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.canAlignTop = canAlignTop;
|
|
79
|
+
var canAlignBottom = function canAlignBottom(tooltipRect, elRect) {
|
|
80
|
+
var middlePosition = getElementMiddlePosition(elRect);
|
|
81
|
+
var hasSpaceOnTopOfArrow = middlePosition + (tooltipRect.height - marginBuffer) < (0, _viewPort.getViewportDimensions)().height;
|
|
82
|
+
var hasSpaceBelowTheArrow = middlePosition - marginBuffer > 0;
|
|
83
|
+
return {
|
|
84
|
+
type: 'bottom',
|
|
85
|
+
result: hasSpaceBelowTheArrow && hasSpaceOnTopOfArrow
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
exports.canAlignBottom = canAlignBottom;
|
|
89
|
+
var canAlignMiddle = function canAlignMiddle(tooltipRect, elRect) {
|
|
90
|
+
var middlePosition = elRect.top + elRect.height / 2;
|
|
91
|
+
return {
|
|
92
|
+
type: 'middle',
|
|
93
|
+
result: middlePosition - tooltipRect.height / 2 > 0 && middlePosition + tooltipRect.height / 2 < (0, _viewPort.getViewportDimensions)().height
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.canAlignMiddle = canAlignMiddle;
|
|
97
|
+
var canStayOnTop = function canStayOnTop(tooltipRect) {
|
|
98
|
+
return tooltipRect.top > 0;
|
|
99
|
+
};
|
|
100
|
+
exports.canStayOnTop = canStayOnTop;
|
|
101
|
+
var canStayOnBottom = function canStayOnBottom(tooltipRect) {
|
|
102
|
+
console.log('tooltipRect:', tooltipRect);
|
|
103
|
+
console.log('getViewportDimensions().height: ', (0, _viewPort.getViewportDimensions)().height);
|
|
104
|
+
return tooltipRect.bottom < (0, _viewPort.getViewportDimensions)().height;
|
|
105
|
+
};
|
|
106
|
+
exports.canStayOnBottom = canStayOnBottom;
|
|
107
|
+
var canStayOnLeft = function canStayOnLeft(tooltipRect) {
|
|
108
|
+
return tooltipRect.left > 0;
|
|
109
|
+
};
|
|
110
|
+
exports.canStayOnLeft = canStayOnLeft;
|
|
111
|
+
var canStayOnRight = function canStayOnRight(tooltipRect) {
|
|
112
|
+
return tooltipRect.right < (0, _viewPort.getViewportDimensions)().width;
|
|
113
|
+
};
|
|
114
|
+
exports.canStayOnRight = canStayOnRight;
|
|
115
|
+
var tryCalculateAligment = function tryCalculateAligment(args) {
|
|
116
|
+
var preferredAlignmentFuncs = args.preferredAlignmentFuncs,
|
|
117
|
+
tooltipRect = args.tooltipRect,
|
|
118
|
+
elRect = args.elRect;
|
|
119
|
+
for (var _iterator = _createForOfIteratorHelperLoose(preferredAlignmentFuncs), _step; !(_step = _iterator()).done;) {
|
|
120
|
+
var alignmentFunc = _step.value;
|
|
121
|
+
var _alignmentFunc = alignmentFunc(tooltipRect, elRect),
|
|
122
|
+
result = _alignmentFunc.result,
|
|
123
|
+
type = _alignmentFunc.type;
|
|
124
|
+
if (result) {
|
|
125
|
+
return type;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
};
|
|
130
|
+
exports.tryCalculateAligment = tryCalculateAligment;
|
package/lib/@next/index.d.ts
CHANGED
|
@@ -25,5 +25,6 @@ export { Spinner, SpinnerProps } from './Spinner';
|
|
|
25
25
|
export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
|
|
26
26
|
export { Tag, TagProps } from './Tag';
|
|
27
27
|
export { TextInput, TextInputProps } from './TextInput';
|
|
28
|
+
export { Tooltip, TooltipPosition, TooltipProps } from './Tooltip';
|
|
28
29
|
export { Typography, TypographyProps } from './Typography';
|
|
29
30
|
export { Breakpoints, BorderRadius, Colors, DropShadow, Fonts, Spacing };
|
package/lib/@next/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.useModal = exports.useIndexResourceState = exports.useAlert = exports.TypographyProps = exports.Typography = exports.TextInputProps = exports.TextInput = exports.TagProps = exports.Tag = exports.TabsProps = exports.Tabs = exports.TabProps = exports.TabModel = exports.Tab = exports.SpinnerProps = exports.Spinner = exports.Spacing = exports.SimplePagination = exports.RadioButtonProps = exports.RadioButton = exports.PrimaryButton = exports.PopoverProps = exports.Popover = exports.PaginationProps = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.NumberInputProps = exports.NumberInput = exports.ModalProvider = exports.ModalProps = exports.ModalContext = exports.Modal = exports.IndexTableProps = exports.IndexTable = exports.IconProps = exports.Icon = exports.Fonts = exports.EmptyState = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.CurrencyInputProps = exports.CurrencyInput = exports.Colors = exports.CheckboxProps = exports.Checkbox = exports.ButtonProps = exports.ButtonGroupProps = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.BannerProps = exports.Banner = exports.BadgeProps = exports.Badge = exports.AvatarProps = exports.Avatar = exports.AlertWithProvider = exports.AlertProvider = exports.AlertProps = exports.AlertContextProps = exports.AlertContext = exports.Alert = void 0;
|
|
4
|
+
exports.useModal = exports.useIndexResourceState = exports.useAlert = exports.TypographyProps = exports.Typography = exports.TooltipProps = exports.TooltipPosition = exports.Tooltip = exports.TextInputProps = exports.TextInput = exports.TagProps = exports.Tag = exports.TabsProps = exports.Tabs = exports.TabProps = exports.TabModel = exports.Tab = exports.SpinnerProps = exports.Spinner = exports.Spacing = exports.SimplePagination = exports.RadioButtonProps = exports.RadioButton = exports.PrimaryButton = exports.PopoverProps = exports.Popover = exports.PaginationProps = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.NumberInputProps = exports.NumberInput = exports.ModalProvider = exports.ModalProps = exports.ModalContext = exports.Modal = exports.IndexTableProps = exports.IndexTable = exports.IconProps = exports.Icon = exports.Fonts = exports.EmptyState = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.CurrencyInputProps = exports.CurrencyInput = exports.Colors = exports.CheckboxProps = exports.Checkbox = exports.ButtonProps = exports.ButtonGroupProps = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.BannerProps = exports.Banner = exports.BadgeProps = exports.Badge = exports.AvatarProps = exports.Avatar = exports.AlertWithProvider = exports.AlertProvider = exports.AlertProps = exports.AlertContextProps = exports.AlertContext = exports.Alert = void 0;
|
|
5
5
|
var BorderRadius = _interopRequireWildcard(require("./utilities/borderRadius"));
|
|
6
6
|
exports.BorderRadius = BorderRadius;
|
|
7
7
|
var Breakpoints = _interopRequireWildcard(require("./utilities/breakpoints"));
|
|
@@ -92,6 +92,10 @@ exports.TagProps = _Tag.TagProps;
|
|
|
92
92
|
var _TextInput = require("./TextInput");
|
|
93
93
|
exports.TextInput = _TextInput.TextInput;
|
|
94
94
|
exports.TextInputProps = _TextInput.TextInputProps;
|
|
95
|
+
var _Tooltip = require("./Tooltip");
|
|
96
|
+
exports.Tooltip = _Tooltip.Tooltip;
|
|
97
|
+
exports.TooltipPosition = _Tooltip.TooltipPosition;
|
|
98
|
+
exports.TooltipProps = _Tooltip.TooltipProps;
|
|
95
99
|
var _Typography = require("./Typography");
|
|
96
100
|
exports.Typography = _Typography.Typography;
|
|
97
101
|
exports.TypographyProps = _Typography.TypographyProps;
|