@elliemae/ds-tooltip 2.2.0-alpha.3 → 3.0.0-next.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/cjs/index.js +23 -41
- package/cjs/v1/DSTooltip.js +105 -108
- package/cjs/v1/TooltipType.js +8 -36
- package/cjs/v2/DSTooltip.js +121 -117
- package/cjs/v2/DSTooltipArrow.js +38 -50
- package/cjs/v2/TooltipType.js +8 -36
- package/cjs/v2/index.d.js +2 -27
- package/cjs/v2/propTypes.js +25 -54
- package/cjs/v2/styles.js +59 -128
- package/cjs/v2/utils/setMultipleRefs.js +21 -41
- package/cjs/v2/utils/tooltipPositions.js +18 -46
- package/cjs/v3/TooltipV3DatatestId.js +8 -36
- package/cjs/v3/config/useWithDefaultProps.js +14 -40
- package/cjs/v3/index.d.js +2 -27
- package/cjs/v3/index.js +103 -90
- package/cjs/v3/propsTypes.js +94 -78
- package/cjs/v3/styleds.js +46 -69
- package/esm/index.js +5 -12
- package/esm/v1/DSTooltip.js +87 -88
- package/esm/v1/TooltipType.js +4 -7
- package/esm/v2/DSTooltip.js +97 -80
- package/esm/v2/DSTooltipArrow.js +30 -21
- package/esm/v2/TooltipType.js +4 -7
- package/esm/v2/index.d.js +1 -2
- package/esm/v2/propTypes.js +21 -25
- package/esm/v2/styles.js +47 -100
- package/esm/v2/utils/setMultipleRefs.js +18 -13
- package/esm/v2/utils/tooltipPositions.js +14 -17
- package/esm/v3/TooltipV3DatatestId.js +4 -7
- package/esm/v3/config/useWithDefaultProps.js +10 -11
- package/esm/v3/index.d.js +1 -2
- package/esm/v3/index.js +79 -54
- package/esm/v3/propsTypes.js +90 -49
- package/esm/v3/styleds.js +36 -41
- package/package.json +10 -10
- package/types/index.d.ts +1 -1
- package/cjs/index.js.map +0 -7
- package/cjs/v1/DSTooltip.js.map +0 -7
- package/cjs/v1/TooltipType.js.map +0 -7
- package/cjs/v2/DSTooltip.js.map +0 -7
- package/cjs/v2/DSTooltipArrow.js.map +0 -7
- package/cjs/v2/TooltipType.js.map +0 -7
- package/cjs/v2/index.d.js.map +0 -7
- package/cjs/v2/propTypes.js.map +0 -7
- package/cjs/v2/styles.js.map +0 -7
- package/cjs/v2/utils/setMultipleRefs.js.map +0 -7
- package/cjs/v2/utils/tooltipPositions.js.map +0 -7
- package/cjs/v3/TooltipV3DatatestId.js.map +0 -7
- package/cjs/v3/config/useWithDefaultProps.js.map +0 -7
- package/cjs/v3/index.d.js.map +0 -7
- package/cjs/v3/index.js.map +0 -7
- package/cjs/v3/propsTypes.js.map +0 -7
- package/cjs/v3/styleds.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/v1/DSTooltip.js.map +0 -7
- package/esm/v1/TooltipType.js.map +0 -7
- package/esm/v2/DSTooltip.js.map +0 -7
- package/esm/v2/DSTooltipArrow.js.map +0 -7
- package/esm/v2/TooltipType.js.map +0 -7
- package/esm/v2/index.d.js.map +0 -7
- package/esm/v2/propTypes.js.map +0 -7
- package/esm/v2/styles.js.map +0 -7
- package/esm/v2/utils/setMultipleRefs.js.map +0 -7
- package/esm/v2/utils/tooltipPositions.js.map +0 -7
- package/esm/v3/TooltipV3DatatestId.js.map +0 -7
- package/esm/v3/config/useWithDefaultProps.js.map +0 -7
- package/esm/v3/index.d.js.map +0 -7
- package/esm/v3/index.js.map +0 -7
- package/esm/v3/propsTypes.js.map +0 -7
- package/esm/v3/styleds.js.map +0 -7
package/esm/v2/styles.js
CHANGED
|
@@ -1,102 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import styled from
|
|
3
|
-
import { kfrm, css } from
|
|
4
|
-
const showAnimation = kfrm`
|
|
5
|
-
from {
|
|
6
|
-
opacity: 0;
|
|
7
|
-
transform: scale(0.8);
|
|
8
|
-
}
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { kfrm, css } from '@elliemae/ds-system';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
opacity: 1;
|
|
12
|
-
transform: scale(1);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
6
|
+
const showAnimation = kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n visibility: visible;\n }\n"])));
|
|
7
|
+
const hideAnimation = kfrm(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n opacity: 1;\n transform: scale(1);\n }\n\n 100% {\n opacity: 0;\n transform: scale(0.8);\n }\n"])));
|
|
8
|
+
const StyledTooltipContainer = /*#__PURE__*/styled.div.withConfig({
|
|
9
|
+
componentId: "sc-1dtjf9j-0"
|
|
10
|
+
})(["&[data-popper-reference-hidden='true']{display:none;pointer-events:none;}"]);
|
|
11
|
+
const StyledAnimatedTooltip = /*#__PURE__*/styled.div.withConfig({
|
|
12
|
+
componentId: "sc-1dtjf9j-1"
|
|
13
|
+
})(["text-align:center;min-width:", ";max-width:250px;min-height:24px;padding:", ";position:relative;background-color:white;border-radius:2px;font-size:13px;color:", ";box-shadow:0 1px 5px 0 rgb(0 0 0 / 13%),0 2px 4px 0 rgb(0 0 0 / 20%);filter:drop-shadow(0 4px 8px rgba(0,0,0,0.2));visibility:", ";", " transition:visibility 0.1s ease-in;"], _ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
return theme.space.l;
|
|
18
|
+
}, _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
theme
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return "".concat(theme.space.xxxs, " ").concat(theme.space.xs);
|
|
23
|
+
}, _ref3 => {
|
|
24
|
+
let {
|
|
25
|
+
theme
|
|
26
|
+
} = _ref3;
|
|
27
|
+
return theme.colors.neutral[600];
|
|
28
|
+
}, _ref4 => {
|
|
29
|
+
let {
|
|
30
|
+
showTooltip
|
|
31
|
+
} = _ref4;
|
|
32
|
+
return showTooltip ? 'visible' : 'hidden';
|
|
33
|
+
}, _ref5 => {
|
|
34
|
+
let {
|
|
35
|
+
showTooltip
|
|
36
|
+
} = _ref5;
|
|
37
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " 0.1s ease-in;\n "])), showTooltip ? showAnimation : hideAnimation);
|
|
38
|
+
});
|
|
39
|
+
const StyledTriggerComponentContainer = /*#__PURE__*/styled.div.withConfig({
|
|
40
|
+
componentId: "sc-1dtjf9j-2"
|
|
41
|
+
})(["display:inline-block;"]);
|
|
42
|
+
const StyledTooltipText = /*#__PURE__*/styled.div.withConfig({
|
|
43
|
+
componentId: "sc-1dtjf9j-3"
|
|
44
|
+
})(["white-space:normal;word-wrap:break-word;display:inline-block;"]);
|
|
45
|
+
const StyledTooltipArrow = /*#__PURE__*/styled.div.withConfig({
|
|
46
|
+
componentId: "sc-1dtjf9j-4"
|
|
47
|
+
})(["position:absolute;width:18px;height:18px;pointer-events:none;background-color:transparent;& .stroke{fill:white;}& .fill{fill:white;}&[data-placement^='top']{svg{transform:rotateZ(180deg);}top:98%;}&[data-placement^='right']{svg{transform:rotateZ(-90deg);}right:99.5%;}&[data-placement^='bottom']{bottom:97%;}&[data-placement^='left']{svg{transform:rotateZ(90deg);}left:99.5%;}"]);
|
|
21
48
|
|
|
22
|
-
|
|
23
|
-
opacity: 0;
|
|
24
|
-
transform: scale(0.8);
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
const StyledTooltipContainer = styled.div`
|
|
28
|
-
&[data-popper-reference-hidden='true'] {
|
|
29
|
-
display: none;
|
|
30
|
-
pointer-events: none;
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
const StyledAnimatedTooltip = styled.div`
|
|
34
|
-
text-align: center;
|
|
35
|
-
min-width: ${({ theme }) => theme.space.l};
|
|
36
|
-
max-width: 250px;
|
|
37
|
-
min-height: 24px;
|
|
38
|
-
padding: ${({ theme }) => `${theme.space.xxxs} ${theme.space.xs}`};
|
|
39
|
-
position: relative;
|
|
40
|
-
background-color: white;
|
|
41
|
-
border-radius: 2px;
|
|
42
|
-
font-size: 13px;
|
|
43
|
-
color: ${({ theme }) => theme.colors.neutral[600]};
|
|
44
|
-
box-shadow: 0 1px 5px 0 rgb(0 0 0 / 13%), 0 2px 4px 0 rgb(0 0 0 / 20%);
|
|
45
|
-
filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
|
|
46
|
-
visibility: ${({ showTooltip }) => showTooltip ? "visible" : "hidden"};
|
|
47
|
-
${({ showTooltip }) => css`
|
|
48
|
-
animation: ${showTooltip ? showAnimation : hideAnimation} 0.1s ease-in;
|
|
49
|
-
`}
|
|
50
|
-
transition: visibility 0.1s ease-in;
|
|
51
|
-
`;
|
|
52
|
-
const StyledTriggerComponentContainer = styled.div`
|
|
53
|
-
display: inline-block;
|
|
54
|
-
`;
|
|
55
|
-
const StyledTooltipText = styled.div`
|
|
56
|
-
white-space: normal;
|
|
57
|
-
word-wrap: break-word;
|
|
58
|
-
display: inline-block;
|
|
59
|
-
`;
|
|
60
|
-
const StyledTooltipArrow = styled.div`
|
|
61
|
-
position: absolute;
|
|
62
|
-
width: 18px;
|
|
63
|
-
height: 18px;
|
|
64
|
-
pointer-events: none;
|
|
65
|
-
background-color: transparent;
|
|
66
|
-
& .stroke {
|
|
67
|
-
fill: white;
|
|
68
|
-
}
|
|
69
|
-
& .fill {
|
|
70
|
-
fill: white;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&[data-placement^='top'] {
|
|
74
|
-
svg {
|
|
75
|
-
transform: rotateZ(180deg);
|
|
76
|
-
}
|
|
77
|
-
top: 98%;
|
|
78
|
-
}
|
|
79
|
-
&[data-placement^='right'] {
|
|
80
|
-
svg {
|
|
81
|
-
transform: rotateZ(-90deg);
|
|
82
|
-
}
|
|
83
|
-
right: 99.5%;
|
|
84
|
-
}
|
|
85
|
-
&[data-placement^='bottom'] {
|
|
86
|
-
bottom: 97%;
|
|
87
|
-
}
|
|
88
|
-
&[data-placement^='left'] {
|
|
89
|
-
svg {
|
|
90
|
-
transform: rotateZ(90deg);
|
|
91
|
-
}
|
|
92
|
-
left: 99.5%;
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
export {
|
|
96
|
-
StyledAnimatedTooltip,
|
|
97
|
-
StyledTooltipArrow,
|
|
98
|
-
StyledTooltipContainer,
|
|
99
|
-
StyledTooltipText,
|
|
100
|
-
StyledTriggerComponentContainer
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=styles.js.map
|
|
49
|
+
export { StyledAnimatedTooltip, StyledTooltipArrow, StyledTooltipContainer, StyledTooltipText, StyledTriggerComponentContainer };
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
|
|
7
|
+
const setMultipleRefs = function () {
|
|
8
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
+
refs[_key] = arguments[_key];
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
const filteredRefs = refs.filter(Boolean);
|
|
4
|
-
if (!filteredRefs.length)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
filteredRefs.forEach((refToBeUpdated) => {
|
|
10
|
-
if (typeof refToBeUpdated === "function") {
|
|
13
|
+
if (!filteredRefs.length) return null;
|
|
14
|
+
if (filteredRefs.length === 0) return filteredRefs[0];
|
|
15
|
+
return newRef => {
|
|
16
|
+
filteredRefs.forEach(refToBeUpdated => {
|
|
17
|
+
if (typeof refToBeUpdated === 'function') {
|
|
11
18
|
refToBeUpdated(newRef);
|
|
12
19
|
} else if (refToBeUpdated) {
|
|
13
20
|
refToBeUpdated.current = newRef;
|
|
@@ -15,7 +22,5 @@ const setMultipleRefs = (...refs) => {
|
|
|
15
22
|
});
|
|
16
23
|
};
|
|
17
24
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=setMultipleRefs.js.map
|
|
25
|
+
|
|
26
|
+
export { setMultipleRefs };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const tooltipPositions = {
|
|
3
|
-
TOP:
|
|
4
|
-
BOTTOM:
|
|
5
|
-
RIGHT:
|
|
6
|
-
LEFT:
|
|
7
|
-
TOP_START:
|
|
8
|
-
TOP_END:
|
|
9
|
-
BOTTOM_START:
|
|
10
|
-
BOTTOM_END:
|
|
11
|
-
RIGHT_START:
|
|
12
|
-
RIGHT_END:
|
|
13
|
-
LEFT_START:
|
|
14
|
-
LEFT_END:
|
|
2
|
+
TOP: 'top',
|
|
3
|
+
BOTTOM: 'bottom',
|
|
4
|
+
RIGHT: 'right',
|
|
5
|
+
LEFT: 'left',
|
|
6
|
+
TOP_START: 'top-start',
|
|
7
|
+
TOP_END: 'top-end',
|
|
8
|
+
BOTTOM_START: 'bottom-start',
|
|
9
|
+
BOTTOM_END: 'bottom-end',
|
|
10
|
+
RIGHT_START: 'right-start',
|
|
11
|
+
RIGHT_END: 'right-end',
|
|
12
|
+
LEFT_START: 'left-start',
|
|
13
|
+
LEFT_END: 'left-end'
|
|
15
14
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=tooltipPositions.js.map
|
|
15
|
+
|
|
16
|
+
export { tooltipPositions };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const TooltipV3DatatestId = {
|
|
3
|
-
TRIGGER_WRAPPER:
|
|
4
|
-
TOOLTIP_TEXT_WRAPPER:
|
|
2
|
+
TRIGGER_WRAPPER: 'ds-tooltip-v3-trigger-wrapper',
|
|
3
|
+
TOOLTIP_TEXT_WRAPPER: 'ds-tooltip-v3-tooltip-text-wrapper'
|
|
5
4
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=TooltipV3DatatestId.js.map
|
|
5
|
+
|
|
6
|
+
export { TooltipV3DatatestId };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
4
|
+
const noop = () => {};
|
|
5
|
+
|
|
5
6
|
const defaultProps = {
|
|
6
7
|
onOpen: noop,
|
|
7
8
|
onClose: noop,
|
|
8
|
-
id:
|
|
9
|
-
textAlign:
|
|
10
|
-
};
|
|
11
|
-
const useWithDefaultProps = (props) => useMemoMergePropsWithDefault(props, defaultProps);
|
|
12
|
-
export {
|
|
13
|
-
useWithDefaultProps
|
|
9
|
+
id: '',
|
|
10
|
+
textAlign: 'left'
|
|
14
11
|
};
|
|
15
|
-
|
|
12
|
+
const useWithDefaultProps = props => useMemoMergePropsWithDefault(props, defaultProps);
|
|
13
|
+
|
|
14
|
+
export { useWithDefaultProps };
|
package/esm/v3/index.d.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.d.js.map
|
|
1
|
+
|
package/esm/v3/index.js
CHANGED
|
@@ -1,27 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from
|
|
14
|
-
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
11
|
+
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
12
|
+
import { describe } from 'react-desc';
|
|
13
|
+
import { dsTooltipPropTypes } from './propsTypes.js';
|
|
14
|
+
import { useWithDefaultProps } from './config/useWithDefaultProps.js';
|
|
15
|
+
import { TooltipV3DatatestId } from './TooltipV3DatatestId.js';
|
|
16
|
+
import { StyledTriggerWrapper, StyledTooltipContainer, StyledTooltipText, StyledMouseOverDetectionBox } from './styleds.js';
|
|
17
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
18
|
+
|
|
19
|
+
var _StyledMouseOverDetec;
|
|
20
|
+
|
|
21
|
+
const _excluded = ["text", "children", "onOpen", "onClose", "id", "textAlign"];
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
+
|
|
27
|
+
const useGlobalKeyboardListener = func => {
|
|
15
28
|
useEffect(() => {
|
|
16
|
-
document.addEventListener(
|
|
17
|
-
return () => document.removeEventListener(
|
|
29
|
+
document.addEventListener('keydown', func);
|
|
30
|
+
return () => document.removeEventListener('keydown', func);
|
|
18
31
|
}, [func]);
|
|
19
32
|
};
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
|
|
34
|
+
const DSTooltipV3 = props => {
|
|
35
|
+
const _useWithDefaultProps = useWithDefaultProps(props),
|
|
36
|
+
{
|
|
37
|
+
text,
|
|
38
|
+
children,
|
|
39
|
+
onOpen,
|
|
40
|
+
onClose,
|
|
41
|
+
id,
|
|
42
|
+
textAlign
|
|
43
|
+
} = _useWithDefaultProps,
|
|
44
|
+
extraPopperJsProps = _objectWithoutProperties(_useWithDefaultProps, _excluded);
|
|
45
|
+
|
|
22
46
|
const [isFocused, setIsFocused] = useState(false);
|
|
23
47
|
const [isHover, setIsHover] = useState(false);
|
|
24
|
-
const [latestOpenInteraction, setLatestOpenInteraction] = useState(
|
|
48
|
+
const [latestOpenInteraction, setLatestOpenInteraction] = useState('');
|
|
25
49
|
const [referenceElement, setReferenceElement] = useState();
|
|
26
50
|
const [showPopover, setShowPopover] = useState(false);
|
|
27
51
|
const showTooltip = useCallback(() => {
|
|
@@ -34,58 +58,59 @@ const DSTooltipV3 = (props) => {
|
|
|
34
58
|
}, [onClose]);
|
|
35
59
|
const onFocus = useCallback(() => {
|
|
36
60
|
setIsFocused(true);
|
|
61
|
+
|
|
37
62
|
if (!showPopover) {
|
|
38
63
|
showTooltip();
|
|
39
|
-
setLatestOpenInteraction(
|
|
64
|
+
setLatestOpenInteraction('onFocus');
|
|
40
65
|
}
|
|
41
66
|
}, [showPopover, showTooltip]);
|
|
42
67
|
const onBlur = useCallback(() => {
|
|
43
68
|
setIsFocused(false);
|
|
44
|
-
if (!isHover || latestOpenInteraction ===
|
|
45
|
-
hideTooltip();
|
|
69
|
+
if (!isHover || latestOpenInteraction === 'onFocus') hideTooltip();
|
|
46
70
|
}, [hideTooltip, isHover, latestOpenInteraction]);
|
|
47
71
|
const onMouseEnter = useCallback(() => {
|
|
48
72
|
setIsHover(true);
|
|
73
|
+
|
|
49
74
|
if (!showPopover) {
|
|
50
75
|
showTooltip();
|
|
51
|
-
setLatestOpenInteraction(
|
|
76
|
+
setLatestOpenInteraction('onMouseEnter');
|
|
52
77
|
}
|
|
53
78
|
}, [showPopover, showTooltip]);
|
|
54
79
|
const onMouseLeave = useCallback(() => {
|
|
55
80
|
setIsHover(false);
|
|
56
|
-
if (!isFocused || latestOpenInteraction ===
|
|
57
|
-
hideTooltip();
|
|
81
|
+
if (!isFocused || latestOpenInteraction === 'onMouseEnter') hideTooltip();
|
|
58
82
|
}, [hideTooltip, isFocused, latestOpenInteraction]);
|
|
59
|
-
const handleEscKey = useCallback(
|
|
60
|
-
|
|
61
|
-
|
|
83
|
+
const handleEscKey = useCallback(_ref => {
|
|
84
|
+
let {
|
|
85
|
+
key
|
|
86
|
+
} = _ref;
|
|
87
|
+
if (key === 'Escape') hideTooltip();
|
|
62
88
|
}, [hideTooltip]);
|
|
63
89
|
useGlobalKeyboardListener(handleEscKey);
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
91
|
+
children: /*#__PURE__*/jsxs(StyledTriggerWrapper, {
|
|
92
|
+
onMouseEnter: onMouseEnter,
|
|
93
|
+
onMouseLeave: onMouseLeave,
|
|
94
|
+
onFocus: onFocus,
|
|
95
|
+
onBlur: onBlur,
|
|
96
|
+
ref: setReferenceElement,
|
|
97
|
+
"data-testid": "".concat(TooltipV3DatatestId.TRIGGER_WRAPPER).concat(id !== '' ? "_".concat(id) : ''),
|
|
98
|
+
children: [/*#__PURE__*/jsx(DSPopperJS, _objectSpread(_objectSpread({
|
|
99
|
+
referenceElement: referenceElement,
|
|
100
|
+
showPopover: showPopover,
|
|
101
|
+
withoutPortal: true
|
|
102
|
+
}, extraPopperJsProps), {}, {
|
|
103
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
104
|
+
"data-testid": "".concat(TooltipV3DatatestId.TOOLTIP_TEXT_WRAPPER).concat(id !== '' ? "_".concat(id) : '')
|
|
105
|
+
}, void 0, /*#__PURE__*/_jsx(StyledTooltipContainer, {}, void 0, /*#__PURE__*/_jsx(StyledTooltipText, {
|
|
106
|
+
textAlign: textAlign
|
|
107
|
+
}, void 0, text), _StyledMouseOverDetec || (_StyledMouseOverDetec = /*#__PURE__*/_jsx(StyledMouseOverDetectionBox, {}))))
|
|
108
|
+
})), children]
|
|
109
|
+
})
|
|
110
|
+
});
|
|
81
111
|
};
|
|
82
|
-
|
|
83
|
-
const DSTooltipV3WithSchema = describe(DSTooltipV3).description(
|
|
112
|
+
|
|
113
|
+
const DSTooltipV3WithSchema = describe(DSTooltipV3).description('A tooltip component');
|
|
84
114
|
DSTooltipV3WithSchema.propTypes = dsTooltipPropTypes;
|
|
85
|
-
|
|
86
|
-
export {
|
|
87
|
-
DSTooltipV3,
|
|
88
|
-
DSTooltipV3WithSchema,
|
|
89
|
-
v3_default as default
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=index.js.map
|
|
115
|
+
|
|
116
|
+
export { DSTooltipV3, DSTooltipV3WithSchema, DSTooltipV3 as default };
|
package/esm/v3/propsTypes.js
CHANGED
|
@@ -1,51 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
3
|
const dsTooltipPropTypes = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Tooltip text to be displayed on hover/focus
|
|
6
|
+
*/
|
|
7
|
+
text: PropTypes.string.description('Tooltip text to be displayed on hover/focus').isRequired,
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tooltip text alignment
|
|
11
|
+
*/
|
|
12
|
+
textAlign: PropTypes.oneOf(['left', 'right', 'center', 'justify', 'initial', 'inherit']).description('Tooltip text alignment').defaultValue('left'),
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Element to tie the tooltip to, must be a single node
|
|
16
|
+
*/
|
|
17
|
+
children: PropTypes.node.description('Element to tie the tooltip to, must be a single node').isRequired,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Wheter or not the tooltip content should appear in a DOM portal or not
|
|
21
|
+
*/
|
|
22
|
+
withoutPortal: PropTypes.bool.description('Whether or not the tooltip content should appear in a DOM portal or not').defaultValue(true),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Wheter or not the tooltip should use the arrow
|
|
26
|
+
*/
|
|
27
|
+
withoutArrow: PropTypes.bool.description('Whether or not the tooltip should use the arrow').defaultValue(false),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Bounding element to calculate upon, defaults to it is "clippingParents",
|
|
31
|
+
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
32
|
+
*/
|
|
33
|
+
boundaryElement: PropTypes.element.description('Bounding element to calculate upon, defaults to "clippingParents",' + 'which are the scrolling containers that may cause element to be partially or fully cut off').defaultValue(undefined),
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Whether or not the popper context menu should be animated
|
|
37
|
+
*/
|
|
38
|
+
withoutAnimation: PropTypes.bool.description('Whether or not the popper context menu should be animated').defaultValue(false),
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Popper context menus Animation duration in ms
|
|
42
|
+
*/
|
|
43
|
+
animationDuration: PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
47
|
+
*/
|
|
48
|
+
portalDOMContainer: PropTypes.element.description('When using portal, the container in which to append the DOM content, defaults to document body').defaultValue(undefined),
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* start placement preferences, as per popperjs placement option
|
|
52
|
+
*/
|
|
53
|
+
startPlacementPreference: PropTypes.oneOf(['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']).description('start placement preferences, as per popperjs placement option').defaultValue("'top'"),
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Array of placement preferences, as per popperjs "flip" placement option
|
|
57
|
+
*/
|
|
58
|
+
placementOrderPreference: PropTypes.arrayOf(PropTypes.oneOf(['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'])).description('Array of placement preferences, as per popperjs "flip" placement option').defaultValue("['top', 'bottom', 'left', 'right']"),
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* tooltip wrapper z-index
|
|
62
|
+
*/
|
|
63
|
+
zIndex: PropTypes.number.description('popperjs content z-index').defaultValue(1),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* placement offset array
|
|
67
|
+
*/
|
|
68
|
+
customOffset: PropTypes.arrayOf(PropTypes.number).description('placement offset array').defaultValue([0, 14]),
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* modifiers array for full-custom tooltip-js override
|
|
72
|
+
* https://tooltip.js.org/docs/v2/modifiers/
|
|
73
|
+
*/
|
|
74
|
+
modifiers: PropTypes.array.description('modifiers array for full-custom tooltip-js override, https://tooltip.js.org/docs/v2/modifiers/').defaultValue(1),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Optional id appended to data-testid
|
|
78
|
+
*/
|
|
79
|
+
id: PropTypes.string.description('Optional id appended to data-testid').defaultValue(''),
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Optional callback to be invoked when the tooltip opens
|
|
83
|
+
*/
|
|
84
|
+
onOpen: PropTypes.func.description('Optional callback to be invoked when the tooltip opens').defaultValue('() => {}'),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 'Optional callback to be invoked when the tooltip closes
|
|
88
|
+
*/
|
|
89
|
+
onClose: PropTypes.func.description('Optional callback to be invoked when the tooltip closes').defaultValue('() => {}')
|
|
47
90
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=propsTypes.js.map
|
|
91
|
+
|
|
92
|
+
export { dsTooltipPropTypes };
|