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
|
@@ -3,7 +3,9 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { AlertContext } from './AlertContext';
|
|
4
4
|
export var AlertProvider = function AlertProvider(_ref) {
|
|
5
5
|
var children = _ref.children;
|
|
6
|
-
var _useState = useState(
|
|
6
|
+
var _useState = useState({
|
|
7
|
+
show: false
|
|
8
|
+
}),
|
|
7
9
|
state = _useState[0],
|
|
8
10
|
setState = _useState[1];
|
|
9
11
|
var open = function open(props) {
|
|
@@ -3,7 +3,9 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import { ModalContext } from './ModalContext';
|
|
4
4
|
export var ModalProvider = function ModalProvider(_ref) {
|
|
5
5
|
var children = _ref.children;
|
|
6
|
-
var _useState = useState(
|
|
6
|
+
var _useState = useState({
|
|
7
|
+
isOpen: false
|
|
8
|
+
}),
|
|
7
9
|
state = _useState[0],
|
|
8
10
|
setState = _useState[1];
|
|
9
11
|
var open = function open(props) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const allPositions: readonly ["top-center", "top-left", "top-right", "bottom-center", "bottom-left", "bottom-right", "right-middle", "right-top", "right-bottom", "left-middle", "left-top", "left-bottom"];
|
|
3
|
+
export declare type TooltipPosition = typeof allPositions[number];
|
|
4
|
+
export declare type TooltipProps = {
|
|
5
|
+
preferredPosition?: TooltipPosition;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const Tooltip: ({ children, content, preferredPosition, }: TooltipProps) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Portal } from '../Portal/Portal';
|
|
3
|
+
import { Typography } from '../Typography';
|
|
4
|
+
import { bottomPositionResolver, leftPositionResolver, rightPositionResolver, topPositionResolver } from './positionResolver';
|
|
5
|
+
import { canAlignBottom, canAlignCenter, canAlignLeft, canAlignMiddle, canAlignRight, canAlignTop, horizontalBuffer, verticalBuffer } from './positionResolverHelper';
|
|
6
|
+
import { StyledTooltip, StyledTooltipArrow, StyledTooltipContainer } from './TooltipStyle';
|
|
7
|
+
var topPositions = ['top-center', 'top-left', 'top-right'];
|
|
8
|
+
var bottomPositions = ['bottom-center', 'bottom-left', 'bottom-right'];
|
|
9
|
+
var rightPositions = ['right-middle', 'right-top', 'right-bottom'];
|
|
10
|
+
var leftPositions = ['left-middle', 'left-top', 'left-bottom'];
|
|
11
|
+
var allPositions = [].concat(topPositions, bottomPositions, rightPositions, leftPositions);
|
|
12
|
+
var tooltipPositionResolvers = {
|
|
13
|
+
'top-center': function topCenter(tooltipRect, elementRect) {
|
|
14
|
+
return topPositionResolver(tooltipRect, elementRect, [canAlignCenter, canAlignLeft, canAlignRight]);
|
|
15
|
+
},
|
|
16
|
+
'top-left': function topLeft(tooltipRect, elementRect) {
|
|
17
|
+
return topPositionResolver(tooltipRect, elementRect, [canAlignLeft, canAlignCenter, canAlignRight]);
|
|
18
|
+
},
|
|
19
|
+
'top-right': function topRight(tooltipRect, elementRect) {
|
|
20
|
+
return topPositionResolver(tooltipRect, elementRect, [canAlignRight, canAlignCenter, canAlignLeft]);
|
|
21
|
+
},
|
|
22
|
+
'bottom-center': function bottomCenter(tooltipRect, elementRect) {
|
|
23
|
+
return bottomPositionResolver(tooltipRect, elementRect, [canAlignCenter, canAlignLeft, canAlignRight]);
|
|
24
|
+
},
|
|
25
|
+
'bottom-left': function bottomLeft(tooltipRect, elementRect) {
|
|
26
|
+
return bottomPositionResolver(tooltipRect, elementRect, [canAlignLeft, canAlignCenter, canAlignRight]);
|
|
27
|
+
},
|
|
28
|
+
'bottom-right': function bottomRight(tooltipRect, elementRect) {
|
|
29
|
+
return bottomPositionResolver(tooltipRect, elementRect, [canAlignRight, canAlignCenter, canAlignLeft]);
|
|
30
|
+
},
|
|
31
|
+
'right-middle': function rightMiddle(tooltipRect, elementRect) {
|
|
32
|
+
return rightPositionResolver(tooltipRect, elementRect, [canAlignMiddle, canAlignTop, canAlignBottom]);
|
|
33
|
+
},
|
|
34
|
+
'right-top': function rightTop(tooltipRect, elementRect) {
|
|
35
|
+
return rightPositionResolver(tooltipRect, elementRect, [canAlignTop, canAlignMiddle, canAlignBottom]);
|
|
36
|
+
},
|
|
37
|
+
'right-bottom': function rightBottom(tooltipRect, elementRect) {
|
|
38
|
+
return rightPositionResolver(tooltipRect, elementRect, [canAlignBottom, canAlignMiddle, canAlignTop]);
|
|
39
|
+
},
|
|
40
|
+
'left-middle': function leftMiddle(tooltipRect, elementRect) {
|
|
41
|
+
return leftPositionResolver(tooltipRect, elementRect, [canAlignMiddle, canAlignTop, canAlignBottom]);
|
|
42
|
+
},
|
|
43
|
+
'left-top': function leftTop(tooltipRect, elementRect) {
|
|
44
|
+
return leftPositionResolver(tooltipRect, elementRect, [canAlignTop, canAlignMiddle, canAlignBottom]);
|
|
45
|
+
},
|
|
46
|
+
'left-bottom': function leftBottom(tooltipRect, elementRect) {
|
|
47
|
+
return leftPositionResolver(tooltipRect, elementRect, [canAlignBottom, canAlignMiddle, canAlignTop]);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var defaultPosition = 'top-center';
|
|
51
|
+
export var Tooltip = function Tooltip(_ref) {
|
|
52
|
+
var children = _ref.children,
|
|
53
|
+
content = _ref.content,
|
|
54
|
+
_ref$preferredPositio = _ref.preferredPosition,
|
|
55
|
+
preferredPosition = _ref$preferredPositio === void 0 ? defaultPosition : _ref$preferredPositio;
|
|
56
|
+
var tooltipRef = useRef(null);
|
|
57
|
+
var elRef = useRef(null);
|
|
58
|
+
var tooltipPositionsHandlerRef = useRef(null);
|
|
59
|
+
var _useState = useState(null),
|
|
60
|
+
toolTipCoord = _useState[0],
|
|
61
|
+
setToolTipCoord = _useState[1];
|
|
62
|
+
var _useState2 = useState(false),
|
|
63
|
+
isActive = _useState2[0],
|
|
64
|
+
setIsActive = _useState2[1];
|
|
65
|
+
var _useState3 = useState(null),
|
|
66
|
+
overridePosition = _useState3[0],
|
|
67
|
+
setOverridePosition = _useState3[1];
|
|
68
|
+
if (!allPositions.includes(preferredPosition)) {
|
|
69
|
+
preferredPosition = defaultPosition;
|
|
70
|
+
console.warn("\"" + preferredPosition + "\" is not a valid tooltip positon, \"" + defaultPosition + "\" will be used instead");
|
|
71
|
+
}
|
|
72
|
+
var position = overridePosition || preferredPosition;
|
|
73
|
+
var handleTooltipPositions = function handleTooltipPositions(tooltipRect, elRect, currentPosition) {
|
|
74
|
+
var resolver = tooltipPositionResolvers[position] || tooltipPositionResolvers[defaultPosition];
|
|
75
|
+
var newLeft = 0;
|
|
76
|
+
var newTop = 0;
|
|
77
|
+
if (position.startsWith('top')) {
|
|
78
|
+
newTop = elRect.top - tooltipRect.height - verticalBuffer;
|
|
79
|
+
newLeft = elRect.left + elRect.width / 2;
|
|
80
|
+
}
|
|
81
|
+
if (position.startsWith('bottom')) {
|
|
82
|
+
newTop = elRect.top + elRect.height + verticalBuffer;
|
|
83
|
+
newLeft = elRect.left + elRect.width / 2;
|
|
84
|
+
}
|
|
85
|
+
if (position.startsWith('left')) {
|
|
86
|
+
newTop = elRect.top + elRect.height / 2;
|
|
87
|
+
newLeft = elRect.left - tooltipRect.width - horizontalBuffer;
|
|
88
|
+
}
|
|
89
|
+
if (position.startsWith('right')) {
|
|
90
|
+
newTop = elRect.top + elRect.height / 2;
|
|
91
|
+
newLeft = elRect.left + elRect.width + horizontalBuffer;
|
|
92
|
+
}
|
|
93
|
+
setToolTipCoord({
|
|
94
|
+
top: newTop,
|
|
95
|
+
left: newLeft
|
|
96
|
+
});
|
|
97
|
+
var tooltipRectNew = new DOMRect(newLeft, newTop, tooltipRect.width, tooltipRect.height);
|
|
98
|
+
var resolvedPosition = resolver(tooltipRectNew, elRect);
|
|
99
|
+
if (!overridePosition && resolvedPosition !== currentPosition) {
|
|
100
|
+
setOverridePosition(resolvedPosition);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
tooltipPositionsHandlerRef.current = handleTooltipPositions;
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
if (isActive) {
|
|
106
|
+
var _tooltipRef$current, _elRef$current;
|
|
107
|
+
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);
|
|
108
|
+
}
|
|
109
|
+
}, [isActive, position]);
|
|
110
|
+
var contentMarkup = typeof content === 'string' ? /*#__PURE__*/React.createElement(Typography, {
|
|
111
|
+
as: "div",
|
|
112
|
+
variant: "body1"
|
|
113
|
+
}, content) : content;
|
|
114
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledTooltipContainer, {
|
|
115
|
+
ref: elRef,
|
|
116
|
+
onMouseEnter: function onMouseEnter() {
|
|
117
|
+
return setIsActive(true);
|
|
118
|
+
},
|
|
119
|
+
onMouseLeave: function onMouseLeave() {
|
|
120
|
+
return setIsActive(false);
|
|
121
|
+
}
|
|
122
|
+
}, children), isActive && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledTooltip, {
|
|
123
|
+
"data-position": position,
|
|
124
|
+
ref: tooltipRef,
|
|
125
|
+
style: {
|
|
126
|
+
top: (toolTipCoord == null ? void 0 : toolTipCoord.top) + 'px',
|
|
127
|
+
left: (toolTipCoord == null ? void 0 : toolTipCoord.left) + 'px',
|
|
128
|
+
visibility: toolTipCoord ? 'visible' : 'hidden'
|
|
129
|
+
}
|
|
130
|
+
}, /*#__PURE__*/React.createElement(StyledTooltipArrow, {
|
|
131
|
+
className: "arrow"
|
|
132
|
+
}), contentMarkup)));
|
|
133
|
+
};
|
|
@@ -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,22 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import * as Breakpoints from '../utilities/breakpoints';
|
|
3
|
+
import { borderRadius2 } from '../utilities/borderRadius';
|
|
4
|
+
import { Neutral } from '../utilities/colors';
|
|
5
|
+
import { space12, space8 } from '../utilities/spacing';
|
|
6
|
+
import { nonCenterArrowSpace, verticalBuffer } from './positionResolverHelper';
|
|
7
|
+
var verticalMargin = verticalBuffer + "px";
|
|
8
|
+
var arrowSize = '6px';
|
|
9
|
+
var nonCentralArrowMargin = nonCenterArrowSpace + "px";
|
|
10
|
+
var background = Neutral.B18;
|
|
11
|
+
export var StyledTooltipContainer = styled.div.withConfig({
|
|
12
|
+
displayName: "TooltipStyle__StyledTooltipContainer",
|
|
13
|
+
componentId: "sc-37e5z7-0"
|
|
14
|
+
})(["display:inline-block;position:relative;*{display:block;}"]);
|
|
15
|
+
export var StyledTooltip = styled.div.withConfig({
|
|
16
|
+
displayName: "TooltipStyle__StyledTooltip",
|
|
17
|
+
componentId: "sc-37e5z7-1"
|
|
18
|
+
})(["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;}"], borderRadius2, space8, space12, 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);
|
|
19
|
+
export var StyledTooltipArrow = styled.div.withConfig({
|
|
20
|
+
displayName: "TooltipStyle__StyledTooltipArrow",
|
|
21
|
+
componentId: "sc-37e5z7-2"
|
|
22
|
+
})(["content:' ';left:50%;border:solid transparent;height:0;width:0;position:absolute;pointer-events:none;border-width:", ";margin-left:calc(", " * -1);"], arrowSize, arrowSize);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Tooltip';
|
|
@@ -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,181 @@
|
|
|
1
|
+
import { canAlignLeft, canAlignRight, canAlignCenter, canStayOnTop, canFitOnTheLeft, horizontalBuffer, canFitOnTheRight, canFitBelow, verticalBuffer, tryCalculateAligment, canAlignMiddle, canAlignTop, canAlignBottom, canStayOnBottom, canFitOnTheTop, canStayOnLeft, canStayOnRight } from './positionResolverHelper';
|
|
2
|
+
export var topPositionResolver = function topPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
3
|
+
var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
4
|
+
var verticalPreferredAligmentFuncs = [canAlignMiddle, canAlignTop, canAlignBottom];
|
|
5
|
+
if (canStayOnTop(tooltipRect)) {
|
|
6
|
+
var alignResult = tryCalculateAligment({
|
|
7
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
8
|
+
tooltipRect: tooltipRect,
|
|
9
|
+
elRect: elRect
|
|
10
|
+
});
|
|
11
|
+
if (alignResult) {
|
|
12
|
+
return "top-" + alignResult;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
|
|
16
|
+
var _alignResult = tryCalculateAligment({
|
|
17
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
18
|
+
tooltipRect: tooltipRect,
|
|
19
|
+
elRect: elRect
|
|
20
|
+
});
|
|
21
|
+
if (_alignResult) {
|
|
22
|
+
return "left-" + _alignResult;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
|
|
26
|
+
var _alignResult2 = tryCalculateAligment({
|
|
27
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
28
|
+
tooltipRect: tooltipRect,
|
|
29
|
+
elRect: elRect
|
|
30
|
+
});
|
|
31
|
+
if (_alignResult2) {
|
|
32
|
+
return "right-" + _alignResult2;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
|
|
36
|
+
var _alignResult3 = tryCalculateAligment({
|
|
37
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
38
|
+
tooltipRect: tooltipRect,
|
|
39
|
+
elRect: elRect
|
|
40
|
+
});
|
|
41
|
+
if (_alignResult3) {
|
|
42
|
+
return "bottom-" + _alignResult3;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return 'top-center';
|
|
46
|
+
};
|
|
47
|
+
export var bottomPositionResolver = function bottomPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
48
|
+
var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
49
|
+
var verticalPreferredAligmentFuncs = [canAlignMiddle, canAlignTop, canAlignBottom];
|
|
50
|
+
if (canStayOnBottom(tooltipRect)) {
|
|
51
|
+
var alignResult = tryCalculateAligment({
|
|
52
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
53
|
+
tooltipRect: tooltipRect,
|
|
54
|
+
elRect: elRect
|
|
55
|
+
});
|
|
56
|
+
if (alignResult) {
|
|
57
|
+
return "bottom-" + alignResult;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
|
|
61
|
+
var _alignResult4 = tryCalculateAligment({
|
|
62
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
63
|
+
tooltipRect: tooltipRect,
|
|
64
|
+
elRect: elRect
|
|
65
|
+
});
|
|
66
|
+
if (_alignResult4) {
|
|
67
|
+
return "left-" + _alignResult4;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
|
|
71
|
+
var _alignResult5 = tryCalculateAligment({
|
|
72
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
73
|
+
tooltipRect: tooltipRect,
|
|
74
|
+
elRect: elRect
|
|
75
|
+
});
|
|
76
|
+
if (_alignResult5) {
|
|
77
|
+
return "right-" + _alignResult5;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (canFitOnTheTop(tooltipRect, elRect, verticalBuffer)) {
|
|
81
|
+
var _alignResult6 = tryCalculateAligment({
|
|
82
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
83
|
+
tooltipRect: tooltipRect,
|
|
84
|
+
elRect: elRect
|
|
85
|
+
});
|
|
86
|
+
if (_alignResult6) {
|
|
87
|
+
return "top-" + _alignResult6;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return 'bottom-center';
|
|
91
|
+
};
|
|
92
|
+
export var leftPositionResolver = function leftPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
93
|
+
var horizontalPreferredAligmentFuncs = [canAlignCenter, canAlignLeft, canAlignRight];
|
|
94
|
+
var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
95
|
+
if (canStayOnLeft(tooltipRect)) {
|
|
96
|
+
var alignResult = tryCalculateAligment({
|
|
97
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
98
|
+
tooltipRect: tooltipRect,
|
|
99
|
+
elRect: elRect
|
|
100
|
+
});
|
|
101
|
+
if (alignResult) {
|
|
102
|
+
return "left-" + alignResult;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (canFitOnTheTop(tooltipRect, elRect, horizontalBuffer)) {
|
|
106
|
+
var _alignResult7 = tryCalculateAligment({
|
|
107
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
108
|
+
tooltipRect: tooltipRect,
|
|
109
|
+
elRect: elRect
|
|
110
|
+
});
|
|
111
|
+
if (_alignResult7) {
|
|
112
|
+
return "top-" + _alignResult7;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
|
|
116
|
+
var _alignResult8 = tryCalculateAligment({
|
|
117
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
118
|
+
tooltipRect: tooltipRect,
|
|
119
|
+
elRect: elRect
|
|
120
|
+
});
|
|
121
|
+
if (_alignResult8) {
|
|
122
|
+
return "right-" + _alignResult8;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
|
|
126
|
+
var _alignResult9 = tryCalculateAligment({
|
|
127
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
128
|
+
tooltipRect: tooltipRect,
|
|
129
|
+
elRect: elRect
|
|
130
|
+
});
|
|
131
|
+
if (_alignResult9) {
|
|
132
|
+
return "bottom-" + _alignResult9;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return 'left-middle';
|
|
136
|
+
};
|
|
137
|
+
export var rightPositionResolver = function rightPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
|
|
138
|
+
var horizontalPreferredAligmentFuncs = [canAlignCenter, canAlignLeft, canAlignRight];
|
|
139
|
+
var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
|
|
140
|
+
if (canStayOnRight(tooltipRect)) {
|
|
141
|
+
var alignResult = tryCalculateAligment({
|
|
142
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
143
|
+
tooltipRect: tooltipRect,
|
|
144
|
+
elRect: elRect
|
|
145
|
+
});
|
|
146
|
+
if (alignResult) {
|
|
147
|
+
return "right-" + alignResult;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (canFitOnTheTop(tooltipRect, elRect, horizontalBuffer)) {
|
|
151
|
+
var _alignResult10 = tryCalculateAligment({
|
|
152
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
153
|
+
tooltipRect: tooltipRect,
|
|
154
|
+
elRect: elRect
|
|
155
|
+
});
|
|
156
|
+
if (_alignResult10) {
|
|
157
|
+
return "top-" + _alignResult10;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
|
|
161
|
+
var _alignResult11 = tryCalculateAligment({
|
|
162
|
+
preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
|
|
163
|
+
tooltipRect: tooltipRect,
|
|
164
|
+
elRect: elRect
|
|
165
|
+
});
|
|
166
|
+
if (_alignResult11) {
|
|
167
|
+
return "left-" + _alignResult11;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
|
|
171
|
+
var _alignResult12 = tryCalculateAligment({
|
|
172
|
+
preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
|
|
173
|
+
tooltipRect: tooltipRect,
|
|
174
|
+
elRect: elRect
|
|
175
|
+
});
|
|
176
|
+
if (_alignResult12) {
|
|
177
|
+
return "bottom-" + _alignResult12;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return 'right-middle';
|
|
181
|
+
};
|
|
@@ -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,106 @@
|
|
|
1
|
+
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."); }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
import { getViewportDimensions } from '../../helpers/viewPort';
|
|
5
|
+
export var verticalBuffer = 8;
|
|
6
|
+
export var horizontalBuffer = 8;
|
|
7
|
+
export var nonCenterArrowSpace = 12;
|
|
8
|
+
// 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
|
|
9
|
+
var marginBuffer = nonCenterArrowSpace + 2;
|
|
10
|
+
export var getElementCenterPosition = function getElementCenterPosition(elRect) {
|
|
11
|
+
return elRect.left + elRect.width / 2;
|
|
12
|
+
};
|
|
13
|
+
export var getElementMiddlePosition = function getElementMiddlePosition(elRect) {
|
|
14
|
+
return elRect.bottom + elRect.height / 2;
|
|
15
|
+
};
|
|
16
|
+
export var canFitOnTheTop = function canFitOnTheTop(tooltipRect, elRect, verticalMargin) {
|
|
17
|
+
return elRect.top - (verticalMargin + tooltipRect.height) > 0;
|
|
18
|
+
};
|
|
19
|
+
export var canFitBelow = function canFitBelow(tooltipRect, elRect, verticalMargin) {
|
|
20
|
+
return elRect.bottom + verticalMargin + tooltipRect.height < getViewportDimensions().height;
|
|
21
|
+
};
|
|
22
|
+
export var canFitOnTheLeft = function canFitOnTheLeft(tooltipRect, elRect, horizontalMargin) {
|
|
23
|
+
return elRect.left - (horizontalMargin + tooltipRect.width) > 0;
|
|
24
|
+
};
|
|
25
|
+
export var canFitOnTheRight = function canFitOnTheRight(tooltipRect, elRect, horizontalMargin) {
|
|
26
|
+
return elRect.right + horizontalMargin + tooltipRect.width < getViewportDimensions().width;
|
|
27
|
+
};
|
|
28
|
+
export var canAlignLeft = function canAlignLeft(tooltipRect, elRect) {
|
|
29
|
+
var centerPosition = getElementCenterPosition(elRect);
|
|
30
|
+
var hasSpaceOnTheLeftSideOfArrow = centerPosition - (tooltipRect.width - marginBuffer) > 0;
|
|
31
|
+
var hasSpaceOnTheRightSideOfArrow = centerPosition + marginBuffer < getViewportDimensions().width;
|
|
32
|
+
return {
|
|
33
|
+
type: 'left',
|
|
34
|
+
result: hasSpaceOnTheLeftSideOfArrow && hasSpaceOnTheRightSideOfArrow
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var canAlignRight = function canAlignRight(tooltipRect, elRect) {
|
|
38
|
+
var centerPosition = getElementCenterPosition(elRect);
|
|
39
|
+
var hasSpaceOnTheRightSideOfArrow = centerPosition + (tooltipRect.width - marginBuffer) < getViewportDimensions().width;
|
|
40
|
+
var hasSpaceOnTheLeftSideOfArrow = centerPosition - marginBuffer > 0;
|
|
41
|
+
return {
|
|
42
|
+
type: 'right',
|
|
43
|
+
result: hasSpaceOnTheLeftSideOfArrow && hasSpaceOnTheRightSideOfArrow
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export var canAlignCenter = function canAlignCenter(tooltipRect, elRect) {
|
|
47
|
+
var centerPosition = elRect.left + elRect.width / 2;
|
|
48
|
+
return {
|
|
49
|
+
type: 'center',
|
|
50
|
+
result: centerPosition - tooltipRect.width / 2 > 0 && centerPosition + tooltipRect.width / 2 < getViewportDimensions().width
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export var canAlignTop = function canAlignTop(tooltipRect, elRect) {
|
|
54
|
+
var middlePosition = getElementMiddlePosition(elRect);
|
|
55
|
+
var hasSpaceOnTheTopOfArrow = middlePosition - (tooltipRect.height - marginBuffer) > 0;
|
|
56
|
+
var hasSpaceBelowTheArrow = middlePosition + marginBuffer < getViewportDimensions().width;
|
|
57
|
+
return {
|
|
58
|
+
type: 'top',
|
|
59
|
+
result: hasSpaceOnTheTopOfArrow && hasSpaceBelowTheArrow
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export var canAlignBottom = function canAlignBottom(tooltipRect, elRect) {
|
|
63
|
+
var middlePosition = getElementMiddlePosition(elRect);
|
|
64
|
+
var hasSpaceOnTopOfArrow = middlePosition + (tooltipRect.height - marginBuffer) < getViewportDimensions().height;
|
|
65
|
+
var hasSpaceBelowTheArrow = middlePosition - marginBuffer > 0;
|
|
66
|
+
return {
|
|
67
|
+
type: 'bottom',
|
|
68
|
+
result: hasSpaceBelowTheArrow && hasSpaceOnTopOfArrow
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export var canAlignMiddle = function canAlignMiddle(tooltipRect, elRect) {
|
|
72
|
+
var middlePosition = elRect.top + elRect.height / 2;
|
|
73
|
+
return {
|
|
74
|
+
type: 'middle',
|
|
75
|
+
result: middlePosition - tooltipRect.height / 2 > 0 && middlePosition + tooltipRect.height / 2 < getViewportDimensions().height
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export var canStayOnTop = function canStayOnTop(tooltipRect) {
|
|
79
|
+
return tooltipRect.top > 0;
|
|
80
|
+
};
|
|
81
|
+
export var canStayOnBottom = function canStayOnBottom(tooltipRect) {
|
|
82
|
+
console.log('tooltipRect:', tooltipRect);
|
|
83
|
+
console.log('getViewportDimensions().height: ', getViewportDimensions().height);
|
|
84
|
+
return tooltipRect.bottom < getViewportDimensions().height;
|
|
85
|
+
};
|
|
86
|
+
export var canStayOnLeft = function canStayOnLeft(tooltipRect) {
|
|
87
|
+
return tooltipRect.left > 0;
|
|
88
|
+
};
|
|
89
|
+
export var canStayOnRight = function canStayOnRight(tooltipRect) {
|
|
90
|
+
return tooltipRect.right < getViewportDimensions().width;
|
|
91
|
+
};
|
|
92
|
+
export var tryCalculateAligment = function tryCalculateAligment(args) {
|
|
93
|
+
var preferredAlignmentFuncs = args.preferredAlignmentFuncs,
|
|
94
|
+
tooltipRect = args.tooltipRect,
|
|
95
|
+
elRect = args.elRect;
|
|
96
|
+
for (var _iterator = _createForOfIteratorHelperLoose(preferredAlignmentFuncs), _step; !(_step = _iterator()).done;) {
|
|
97
|
+
var alignmentFunc = _step.value;
|
|
98
|
+
var _alignmentFunc = alignmentFunc(tooltipRect, elRect),
|
|
99
|
+
result = _alignmentFunc.result,
|
|
100
|
+
type = _alignmentFunc.type;
|
|
101
|
+
if (result) {
|
|
102
|
+
return type;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
};
|
package/es/@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/es/@next/index.js
CHANGED
|
@@ -26,5 +26,6 @@ export { Spinner, SpinnerProps } from './Spinner';
|
|
|
26
26
|
export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
|
|
27
27
|
export { Tag, TagProps } from './Tag';
|
|
28
28
|
export { TextInput, TextInputProps } from './TextInput';
|
|
29
|
+
export { Tooltip, TooltipPosition, TooltipProps } from './Tooltip';
|
|
29
30
|
export { Typography, TypographyProps } from './Typography';
|
|
30
31
|
export { Breakpoints, BorderRadius, Colors, DropShadow, Fonts, Spacing };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var getViewportDimensions = function getViewportDimensions() {
|
|
2
|
+
var width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
|
3
|
+
var height = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
|
4
|
+
return {
|
|
5
|
+
width: width,
|
|
6
|
+
height: height
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -10,7 +10,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
10
10
|
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; }
|
|
11
11
|
var AlertProvider = function AlertProvider(_ref) {
|
|
12
12
|
var children = _ref.children;
|
|
13
|
-
var _useState = (0, _react.useState)(
|
|
13
|
+
var _useState = (0, _react.useState)({
|
|
14
|
+
show: false
|
|
15
|
+
}),
|
|
14
16
|
state = _useState[0],
|
|
15
17
|
setState = _useState[1];
|
|
16
18
|
var open = function open(props) {
|
|
@@ -10,7 +10,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
10
10
|
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; }
|
|
11
11
|
var ModalProvider = function ModalProvider(_ref) {
|
|
12
12
|
var children = _ref.children;
|
|
13
|
-
var _useState = (0, _react.useState)(
|
|
13
|
+
var _useState = (0, _react.useState)({
|
|
14
|
+
isOpen: false
|
|
15
|
+
}),
|
|
14
16
|
state = _useState[0],
|
|
15
17
|
setState = _useState[1];
|
|
16
18
|
var open = function open(props) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const allPositions: readonly ["top-center", "top-left", "top-right", "bottom-center", "bottom-left", "bottom-right", "right-middle", "right-top", "right-bottom", "left-middle", "left-top", "left-bottom"];
|
|
3
|
+
export declare type TooltipPosition = typeof allPositions[number];
|
|
4
|
+
export declare type TooltipProps = {
|
|
5
|
+
preferredPosition?: TooltipPosition;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const Tooltip: ({ children, content, preferredPosition, }: TooltipProps) => JSX.Element;
|
|
10
|
+
export {};
|