@elliemae/ds-tooltip 2.0.0-alpha.9 → 2.0.0-next.12
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/v1/DSTooltip.js +11 -11
- package/cjs/v2/DSTooltip.js +24 -17
- package/cjs/v2/DSTooltipArrow.js +22 -19
- package/cjs/v2/propTypes.js +1 -3
- package/cjs/v2/styles.js +31 -36
- package/cjs/v2/utils/setMultipleRefs.js +11 -1
- package/cjs/v3/config/useWithDefaultProps.js +2 -1
- package/cjs/v3/index.js +69 -22
- package/cjs/v3/propsTypes.js +17 -2
- package/cjs/v3/styleds.js +30 -8
- package/esm/v1/DSTooltip.js +9 -8
- package/esm/v2/DSTooltip.js +24 -17
- package/esm/v2/DSTooltipArrow.js +22 -19
- package/esm/v2/propTypes.js +1 -3
- package/esm/v2/styles.js +30 -36
- package/esm/v2/utils/setMultipleRefs.js +11 -1
- package/esm/v3/config/useWithDefaultProps.js +2 -1
- package/esm/v3/index.js +72 -25
- package/esm/v3/propsTypes.js +17 -2
- package/esm/v3/styleds.js +29 -9
- package/package.json +12 -9
- package/types/v3/propsTypes.d.ts +13 -1
- package/types/v3/styleds.d.ts +5 -1
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/v1/DSTooltip.js
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
12
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
13
|
require('react');
|
|
9
14
|
var reactDesc = require('react-desc');
|
|
10
15
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
11
|
-
var
|
|
16
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
12
17
|
var constants = require('@elliemae/ds-shared/constants');
|
|
13
18
|
var DSPopper = require('@elliemae/ds-popper');
|
|
14
|
-
var interaction = require('@elliemae/ds-popper/interaction');
|
|
15
|
-
var positions = require('@elliemae/ds-popper/positions');
|
|
16
19
|
var TooltipType = require('./TooltipType.js');
|
|
17
20
|
var jsxRuntime = require('react/jsx-runtime');
|
|
18
21
|
|
|
@@ -21,7 +24,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
24
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
25
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
23
26
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
24
|
-
var getComponentFromProps__default = /*#__PURE__*/_interopDefaultLegacy(getComponentFromProps);
|
|
25
27
|
var DSPopper__default = /*#__PURE__*/_interopDefaultLegacy(DSPopper);
|
|
26
28
|
|
|
27
29
|
const _excluded = ["containerProps", "innerRef", "placement", "title", "delayClose", "delayOpen", "interactionType", "triggerComponent", "className", "isOpen", "onOpen", "springAnimationComponent", "tooltipType", "showArrow", "zIndex"];
|
|
@@ -69,7 +71,7 @@ const DSTooltip = _ref => {
|
|
|
69
71
|
return /*#__PURE__*/_jsx__default["default"](DSPopper__default["default"], {
|
|
70
72
|
blockName: tooltipBlockName,
|
|
71
73
|
contentComponent: /*#__PURE__*/jsxRuntime.jsx(TooltipContainer, _objectSpread(_objectSpread(_objectSpread({}, containerProps), otherTooltipProps), {}, {
|
|
72
|
-
className:
|
|
74
|
+
className: "tooltip-container--".concat(tooltipType, " ").concat(className),
|
|
73
75
|
innerRef: innerRef,
|
|
74
76
|
children: Content
|
|
75
77
|
})),
|
|
@@ -81,21 +83,19 @@ const DSTooltip = _ref => {
|
|
|
81
83
|
placement: placement,
|
|
82
84
|
showArrow: tooltipType === TooltipType.TooltipType.TOOLTIP ? showArrow : false,
|
|
83
85
|
springAnimationComponent: springAnimationComponent,
|
|
84
|
-
triggerComponent:
|
|
86
|
+
triggerComponent: dsUtilities.getComponentFromProps(triggerComponent),
|
|
85
87
|
zIndex: zIndex
|
|
86
88
|
});
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
const tooltipProps = {
|
|
90
92
|
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
91
|
-
placement: reactDesc.PropTypes.oneOf(
|
|
93
|
+
placement: reactDesc.PropTypes.oneOf(DSPopper.positions).description('Tooltip position').defaultValue(DSPopper.PopperPositions.TOP),
|
|
92
94
|
title: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.element]).description('Tooltip content').isRequired,
|
|
93
95
|
delayClose: reactDesc.PropTypes.string.description('Delay to close the tooltip').defaultValue(constants.DEFAULT_DELAY_CLOSE),
|
|
94
96
|
delayOpen: reactDesc.PropTypes.string.description('Delay to open the tooltip ').defaultValue(constants.DEFAULT_DELAY_OPEN),
|
|
95
|
-
interactionType: reactDesc.PropTypes.oneOf(
|
|
96
|
-
triggerComponent: reactDesc.PropTypes.element.description(
|
|
97
|
-
Cannot be used with disabled elements.
|
|
98
|
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled`).isRequired,
|
|
97
|
+
interactionType: reactDesc.PropTypes.oneOf(DSPopper.interactions).description('A type indicating how to open/close the tooltip').defaultValue(DSPopper.PopperInteractions.HOVER),
|
|
98
|
+
triggerComponent: reactDesc.PropTypes.element.description("The component that will open/close the tooltip. \n Cannot be used with disabled elements. \n https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled").isRequired,
|
|
99
99
|
isOpen: reactDesc.PropTypes.bool.description('Whether the tooltip is visible or not').defaultValue(undefined),
|
|
100
100
|
onOpen: reactDesc.PropTypes.func.description('Handler when the tooltip opens'),
|
|
101
101
|
springAnimationComponent: reactDesc.PropTypes.element.description('Spring animation component'),
|
package/cjs/v2/DSTooltip.js
CHANGED
|
@@ -4,6 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
6
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
7
13
|
var react = require('react');
|
|
8
14
|
var reactDesc = require('react-desc');
|
|
9
15
|
var DSPortal = require('@elliemae/ds-portal');
|
|
@@ -27,23 +33,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
27
33
|
|
|
28
34
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
35
|
|
|
30
|
-
const DSTooltipV2 =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
const DSTooltipV2 = _ref => {
|
|
37
|
+
let {
|
|
38
|
+
containerProps = {},
|
|
39
|
+
innerRef,
|
|
40
|
+
placement = tooltipPositions.tooltipPositions.BOTTOM,
|
|
41
|
+
title = '',
|
|
42
|
+
delayClose = constants.DEFAULT_DELAY_CLOSE,
|
|
43
|
+
delayOpen = constants.DEFAULT_DELAY_OPEN,
|
|
44
|
+
triggerComponent = null,
|
|
45
|
+
className = '',
|
|
46
|
+
getIsOpen = () => null,
|
|
47
|
+
onOpen = () => null,
|
|
48
|
+
tooltipType = TooltipType.TooltipType.TOOLTIP,
|
|
49
|
+
showArrow = true,
|
|
50
|
+
offset = [0, 14],
|
|
51
|
+
zIndex = 10,
|
|
52
|
+
extraModifiers = {}
|
|
53
|
+
} = _ref;
|
|
47
54
|
const [showTooltip, setShowTooltip] = react.useState(false);
|
|
48
55
|
const [isAnimating, setIsAnimating] = react.useState(false);
|
|
49
56
|
const [referenceElement, setReferenceElement] = react.useState(triggerComponent);
|
package/cjs/v2/DSTooltipArrow.js
CHANGED
|
@@ -13,24 +13,27 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
13
13
|
|
|
14
14
|
var _svg;
|
|
15
15
|
|
|
16
|
-
const DSTooltipArrow =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
const DSTooltipArrow = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
placement,
|
|
19
|
+
style,
|
|
20
|
+
arrowElementRef
|
|
21
|
+
} = _ref;
|
|
22
|
+
return /*#__PURE__*/jsxRuntime.jsx(styles.StyledTooltipArrow, {
|
|
23
|
+
"data-placement": placement,
|
|
24
|
+
style: style,
|
|
25
|
+
ref: arrowElementRef,
|
|
26
|
+
"data-testid": "ds-tooltip-arrow",
|
|
27
|
+
children: _svg || (_svg = /*#__PURE__*/_jsx__default["default"]("svg", {
|
|
28
|
+
viewBox: "0 0 30 30"
|
|
29
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("path", {
|
|
30
|
+
className: "stroke",
|
|
31
|
+
d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z"
|
|
32
|
+
}), /*#__PURE__*/_jsx__default["default"]("path", {
|
|
33
|
+
className: "fill",
|
|
34
|
+
d: "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"
|
|
35
|
+
})))
|
|
36
|
+
}, "popper-arrow");
|
|
37
|
+
};
|
|
35
38
|
|
|
36
39
|
exports.DSTooltipArrow = DSTooltipArrow;
|
package/cjs/v2/propTypes.js
CHANGED
|
@@ -13,9 +13,7 @@ const tooltipV2Props = {
|
|
|
13
13
|
title: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.element]).description('Tooltip content').isRequired,
|
|
14
14
|
delayClose: reactDesc.PropTypes.number.description('Delay to close the tooltip').defaultValue(constants.DEFAULT_DELAY_CLOSE),
|
|
15
15
|
delayOpen: reactDesc.PropTypes.number.description('Delay to open the tooltip ').defaultValue(constants.DEFAULT_DELAY_OPEN),
|
|
16
|
-
triggerComponent: reactDesc.PropTypes.element.description(
|
|
17
|
-
Cannot be used with disabled elements.
|
|
18
|
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled`).isRequired,
|
|
16
|
+
triggerComponent: reactDesc.PropTypes.element.description("The component that will open/close the tooltip. \n Cannot be used with disabled elements. \n https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled").isRequired,
|
|
19
17
|
getIsOpen: reactDesc.PropTypes.func.description('Whether the tooltip is visible or not'),
|
|
20
18
|
onOpen: reactDesc.PropTypes.func.description('Callback when the tooltip opens'),
|
|
21
19
|
showArrow: reactDesc.PropTypes.bool.description('Whether to show an arrow or not').defaultValue(true),
|
package/cjs/v2/styles.js
CHANGED
|
@@ -2,54 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
5
6
|
var styled = require('styled-components');
|
|
6
7
|
var dsSystem = require('@elliemae/ds-system');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
10
|
|
|
11
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
10
12
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
from {
|
|
14
|
-
opacity: 0;
|
|
15
|
-
transform: scale(0.8);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
to {
|
|
19
|
-
opacity: 1;
|
|
20
|
-
transform: scale(1);
|
|
21
|
-
visibility: visible;
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
const hideAnimation = dsSystem.kfrm`
|
|
25
|
-
0% {
|
|
26
|
-
opacity: 1;
|
|
27
|
-
transform: scale(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
100% {
|
|
31
|
-
opacity: 0;
|
|
32
|
-
transform: scale(0.8);
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
15
|
+
const showAnimation = dsSystem.kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\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"])));
|
|
16
|
+
const hideAnimation = dsSystem.kfrm(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n 0% {\n opacity: 1;\n transform: scale(1);\n }\n\n 100% {\n opacity: 0;\n transform: scale(0.8);\n }\n"])));
|
|
35
17
|
const StyledTooltipContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
36
18
|
componentId: "sc-1dtjf9j-0"
|
|
37
19
|
})(["&[data-popper-reference-hidden='true']{display:none;pointer-events:none;}"]);
|
|
38
20
|
const StyledAnimatedTooltip = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
39
21
|
componentId: "sc-1dtjf9j-1"
|
|
40
|
-
})(["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;"],
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
})(["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 => {
|
|
23
|
+
let {
|
|
24
|
+
theme
|
|
25
|
+
} = _ref;
|
|
26
|
+
return theme.space.l;
|
|
27
|
+
}, _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
theme
|
|
30
|
+
} = _ref2;
|
|
31
|
+
return "".concat(theme.space.xxxs, " ").concat(theme.space.xs);
|
|
32
|
+
}, _ref3 => {
|
|
33
|
+
let {
|
|
34
|
+
theme
|
|
35
|
+
} = _ref3;
|
|
36
|
+
return theme.colors.neutral[600];
|
|
37
|
+
}, _ref4 => {
|
|
38
|
+
let {
|
|
39
|
+
showTooltip
|
|
40
|
+
} = _ref4;
|
|
41
|
+
return showTooltip ? 'visible' : 'hidden';
|
|
42
|
+
}, _ref5 => {
|
|
43
|
+
let {
|
|
44
|
+
showTooltip
|
|
45
|
+
} = _ref5;
|
|
46
|
+
return dsSystem.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n animation: ", " 0.1s ease-in;\n "])), showTooltip ? showAnimation : hideAnimation);
|
|
47
|
+
});
|
|
53
48
|
const StyledTriggerComponentContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
54
49
|
componentId: "sc-1dtjf9j-2"
|
|
55
50
|
})(["display:inline-block;"]);
|
|
@@ -2,7 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
|
|
11
|
+
const setMultipleRefs = function () {
|
|
12
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
|
+
refs[_key] = arguments[_key];
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
const filteredRefs = refs.filter(Boolean);
|
|
7
17
|
if (!filteredRefs.length) return null;
|
|
8
18
|
if (filteredRefs.length === 0) return filteredRefs[0];
|
package/cjs/v3/index.js
CHANGED
|
@@ -5,6 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
6
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
7
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
14
|
var react = require('react');
|
|
9
15
|
var dsPopperjs = require('@elliemae/ds-popperjs');
|
|
10
16
|
var reactDesc = require('react-desc');
|
|
@@ -20,12 +26,21 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
20
26
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
21
27
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
var _StyledMouseOverDetec;
|
|
30
|
+
|
|
31
|
+
const _excluded = ["text", "children", "onOpen", "onClose", "id", "textAlign"];
|
|
24
32
|
|
|
25
33
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
26
34
|
|
|
27
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
36
|
|
|
37
|
+
const useGlobalKeyboardListener = func => {
|
|
38
|
+
react.useEffect(() => {
|
|
39
|
+
document.addEventListener('keydown', func);
|
|
40
|
+
return () => document.removeEventListener('keydown', func);
|
|
41
|
+
}, [func]);
|
|
42
|
+
};
|
|
43
|
+
|
|
29
44
|
const DSTooltipV3 = props => {
|
|
30
45
|
const _useWithDefaultProps = useWithDefaultProps.useWithDefaultProps(props),
|
|
31
46
|
{
|
|
@@ -33,10 +48,14 @@ const DSTooltipV3 = props => {
|
|
|
33
48
|
children,
|
|
34
49
|
onOpen,
|
|
35
50
|
onClose,
|
|
36
|
-
id
|
|
51
|
+
id,
|
|
52
|
+
textAlign
|
|
37
53
|
} = _useWithDefaultProps,
|
|
38
54
|
extraPopperJsProps = _objectWithoutProperties__default["default"](_useWithDefaultProps, _excluded);
|
|
39
55
|
|
|
56
|
+
const [isFocused, setIsFocused] = react.useState(false);
|
|
57
|
+
const [isHover, setIsHover] = react.useState(false);
|
|
58
|
+
const [latestOpenInteraction, setLatestOpenInteraction] = react.useState('');
|
|
40
59
|
const [referenceElement, setReferenceElement] = react.useState();
|
|
41
60
|
const [showPopover, setShowPopover] = react.useState(false);
|
|
42
61
|
const showTooltip = react.useCallback(() => {
|
|
@@ -47,29 +66,57 @@ const DSTooltipV3 = props => {
|
|
|
47
66
|
setShowPopover(false);
|
|
48
67
|
onClose();
|
|
49
68
|
}, [onClose]);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
const onFocus = react.useCallback(() => {
|
|
70
|
+
setIsFocused(true);
|
|
71
|
+
|
|
72
|
+
if (!showPopover) {
|
|
73
|
+
showTooltip();
|
|
74
|
+
setLatestOpenInteraction('onFocus');
|
|
75
|
+
}
|
|
76
|
+
}, [showPopover, showTooltip]);
|
|
77
|
+
const onBlur = react.useCallback(() => {
|
|
78
|
+
setIsFocused(false);
|
|
79
|
+
if (!isHover || latestOpenInteraction === 'onFocus') hideTooltip();
|
|
80
|
+
}, [hideTooltip, isHover, latestOpenInteraction]);
|
|
81
|
+
const onMouseEnter = react.useCallback(() => {
|
|
82
|
+
setIsHover(true);
|
|
83
|
+
|
|
84
|
+
if (!showPopover) {
|
|
85
|
+
showTooltip();
|
|
86
|
+
setLatestOpenInteraction('onMouseEnter');
|
|
87
|
+
}
|
|
88
|
+
}, [showPopover, showTooltip]);
|
|
89
|
+
const onMouseLeave = react.useCallback(() => {
|
|
90
|
+
setIsHover(false);
|
|
91
|
+
if (!isFocused || latestOpenInteraction === 'onMouseEnter') hideTooltip();
|
|
92
|
+
}, [hideTooltip, isFocused, latestOpenInteraction]);
|
|
93
|
+
const handleEscKey = react.useCallback(_ref => {
|
|
94
|
+
let {
|
|
95
|
+
key
|
|
96
|
+
} = _ref;
|
|
53
97
|
if (key === 'Escape') hideTooltip();
|
|
54
98
|
}, [hideTooltip]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, void 0, /*#__PURE__*/_jsx__default["default"](styleds.StyledTooltipContainer, {}, void 0, /*#__PURE__*/_jsx__default["default"](styleds.StyledTooltipText, {}, void 0, text)))
|
|
63
|
-
})), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
64
|
-
onMouseOver: showTooltip,
|
|
65
|
-
onFocus: showTooltip,
|
|
66
|
-
onMouseOut: hideTooltip,
|
|
67
|
-
onBlur: hideTooltip,
|
|
68
|
-
onKeyDown: handleEscKey,
|
|
99
|
+
useGlobalKeyboardListener(handleEscKey);
|
|
100
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
101
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(styleds.StyledTriggerWrapper, {
|
|
102
|
+
onMouseEnter: onMouseEnter,
|
|
103
|
+
onMouseLeave: onMouseLeave,
|
|
104
|
+
onFocus: onFocus,
|
|
105
|
+
onBlur: onBlur,
|
|
69
106
|
ref: setReferenceElement,
|
|
70
|
-
"data-testid":
|
|
71
|
-
children:
|
|
72
|
-
|
|
107
|
+
"data-testid": "".concat(TooltipV3DatatestId.TooltipV3DatatestId.TRIGGER_WRAPPER).concat(id !== '' ? "_".concat(id) : ''),
|
|
108
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(dsPopperjs.DSPopperJS, _objectSpread(_objectSpread({
|
|
109
|
+
referenceElement: referenceElement,
|
|
110
|
+
showPopover: showPopover,
|
|
111
|
+
withoutPortal: true
|
|
112
|
+
}, extraPopperJsProps), {}, {
|
|
113
|
+
children: /*#__PURE__*/_jsx__default["default"]("div", {
|
|
114
|
+
"data-testid": "".concat(TooltipV3DatatestId.TooltipV3DatatestId.TOOLTIP_TEXT_WRAPPER).concat(id !== '' ? "_".concat(id) : '')
|
|
115
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](styleds.StyledTooltipContainer, {}, void 0, /*#__PURE__*/_jsx__default["default"](styleds.StyledTooltipText, {
|
|
116
|
+
textAlign: textAlign
|
|
117
|
+
}, void 0, text), _StyledMouseOverDetec || (_StyledMouseOverDetec = /*#__PURE__*/_jsx__default["default"](styleds.StyledMouseOverDetectionBox, {}))))
|
|
118
|
+
})), children]
|
|
119
|
+
})
|
|
73
120
|
});
|
|
74
121
|
};
|
|
75
122
|
|
package/cjs/v3/propsTypes.js
CHANGED
|
@@ -6,9 +6,14 @@ var reactDesc = require('react-desc');
|
|
|
6
6
|
|
|
7
7
|
const dsTooltipPropTypes = {
|
|
8
8
|
/**
|
|
9
|
-
* Tooltip text to be displayed on hover
|
|
9
|
+
* Tooltip text to be displayed on hover/focus
|
|
10
10
|
*/
|
|
11
|
-
text: reactDesc.PropTypes.string.description('Tooltip text to be displayed on hover').isRequired,
|
|
11
|
+
text: reactDesc.PropTypes.string.description('Tooltip text to be displayed on hover/focus').isRequired,
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Tooltip text alignment
|
|
15
|
+
*/
|
|
16
|
+
textAlign: reactDesc.PropTypes.oneOf(['left', 'right', 'center', 'justify', 'initial', 'inherit']).description('Tooltip text alignment').defaultValue('left'),
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* Element to tie the tooltip to, must be a single node
|
|
@@ -31,6 +36,16 @@ const dsTooltipPropTypes = {
|
|
|
31
36
|
*/
|
|
32
37
|
boundaryElement: reactDesc.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),
|
|
33
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Whether or not the popper context menu should be animated
|
|
41
|
+
*/
|
|
42
|
+
withoutAnimation: reactDesc.PropTypes.bool.description('Whether or not the popper context menu should be animated').defaultValue(false),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Popper context menus Animation duration in ms
|
|
46
|
+
*/
|
|
47
|
+
animationDuration: reactDesc.PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),
|
|
48
|
+
|
|
34
49
|
/**
|
|
35
50
|
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
36
51
|
*/
|
package/cjs/v3/styleds.js
CHANGED
|
@@ -10,16 +10,38 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
|
10
10
|
|
|
11
11
|
const StyledTooltipContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
12
12
|
componentId: "sc-18a4gem-0"
|
|
13
|
-
})(["text-align:center;min-width:", ";max-width:250px;min-height:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
})(["text-align:center;min-width:", ";max-width:250px;min-height:30px;display:grid;align-items:center;padding:", ";position:relative;background-color:white;border-radius:2px;font-size:13px;color:", ";"], _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
|
+
});
|
|
20
29
|
const StyledTooltipText = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
21
30
|
componentId: "sc-18a4gem-1"
|
|
22
|
-
})(["white-space:normal;word-wrap:break-word;display:inline-block;"]
|
|
31
|
+
})(["white-space:normal;word-wrap:break-word;display:inline-block;text-align:", ";"], _ref4 => {
|
|
32
|
+
let {
|
|
33
|
+
textAlign
|
|
34
|
+
} = _ref4;
|
|
35
|
+
return textAlign;
|
|
36
|
+
});
|
|
37
|
+
const StyledMouseOverDetectionBox = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
38
|
+
componentId: "sc-18a4gem-2"
|
|
39
|
+
})(["position:absolute;top:-15px;right:-15px;width:calc(100% + 30px);height:calc(100% + 30px);z-index:-1;"]);
|
|
40
|
+
const StyledTriggerWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
41
|
+
componentId: "sc-18a4gem-3"
|
|
42
|
+
})(["display:inline-block;width:100%;"]);
|
|
23
43
|
|
|
44
|
+
exports.StyledMouseOverDetectionBox = StyledMouseOverDetectionBox;
|
|
24
45
|
exports.StyledTooltipContainer = StyledTooltipContainer;
|
|
25
46
|
exports.StyledTooltipText = StyledTooltipText;
|
|
47
|
+
exports.StyledTriggerWrapper = StyledTriggerWrapper;
|
package/esm/v1/DSTooltip.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
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';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
9
|
import 'react';
|
|
5
10
|
import { PropTypes, describe } from 'react-desc';
|
|
6
11
|
import { aggregatedClasses, convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
7
|
-
import getComponentFromProps from '@elliemae/ds-utilities
|
|
12
|
+
import { getComponentFromProps } from '@elliemae/ds-utilities';
|
|
8
13
|
import { DEFAULT_DELAY_CLOSE, DEFAULT_DELAY_OPEN } from '@elliemae/ds-shared/constants';
|
|
9
|
-
import DSPopper, { PopperPositions, PopperInteractions } from '@elliemae/ds-popper';
|
|
10
|
-
import { interactions } from '@elliemae/ds-popper/interaction';
|
|
11
|
-
import { positions } from '@elliemae/ds-popper/positions';
|
|
14
|
+
import DSPopper, { positions, PopperPositions, interactions, PopperInteractions } from '@elliemae/ds-popper';
|
|
12
15
|
import { TooltipType } from './TooltipType.js';
|
|
13
16
|
import { jsx } from 'react/jsx-runtime';
|
|
14
17
|
|
|
@@ -57,7 +60,7 @@ const DSTooltip = _ref => {
|
|
|
57
60
|
return /*#__PURE__*/_jsx(DSPopper, {
|
|
58
61
|
blockName: tooltipBlockName,
|
|
59
62
|
contentComponent: /*#__PURE__*/jsx(TooltipContainer, _objectSpread(_objectSpread(_objectSpread({}, containerProps), otherTooltipProps), {}, {
|
|
60
|
-
className:
|
|
63
|
+
className: "tooltip-container--".concat(tooltipType, " ").concat(className),
|
|
61
64
|
innerRef: innerRef,
|
|
62
65
|
children: Content
|
|
63
66
|
})),
|
|
@@ -81,9 +84,7 @@ const tooltipProps = {
|
|
|
81
84
|
delayClose: PropTypes.string.description('Delay to close the tooltip').defaultValue(DEFAULT_DELAY_CLOSE),
|
|
82
85
|
delayOpen: PropTypes.string.description('Delay to open the tooltip ').defaultValue(DEFAULT_DELAY_OPEN),
|
|
83
86
|
interactionType: PropTypes.oneOf(interactions).description('A type indicating how to open/close the tooltip').defaultValue(PopperInteractions.HOVER),
|
|
84
|
-
triggerComponent: PropTypes.element.description(
|
|
85
|
-
Cannot be used with disabled elements.
|
|
86
|
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled`).isRequired,
|
|
87
|
+
triggerComponent: PropTypes.element.description("The component that will open/close the tooltip. \n Cannot be used with disabled elements. \n https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled").isRequired,
|
|
87
88
|
isOpen: PropTypes.bool.description('Whether the tooltip is visible or not').defaultValue(undefined),
|
|
88
89
|
onOpen: PropTypes.func.description('Handler when the tooltip opens'),
|
|
89
90
|
springAnimationComponent: PropTypes.element.description('Spring animation component'),
|
package/esm/v2/DSTooltip.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
9
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
4
10
|
import { describe } from 'react-desc';
|
|
5
11
|
import DSPortal from '@elliemae/ds-portal';
|
|
@@ -17,23 +23,24 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
23
|
|
|
18
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
25
|
|
|
20
|
-
const DSTooltipV2 =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
const DSTooltipV2 = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
containerProps = {},
|
|
29
|
+
innerRef,
|
|
30
|
+
placement = tooltipPositions.BOTTOM,
|
|
31
|
+
title = '',
|
|
32
|
+
delayClose = DEFAULT_DELAY_CLOSE,
|
|
33
|
+
delayOpen = DEFAULT_DELAY_OPEN,
|
|
34
|
+
triggerComponent = null,
|
|
35
|
+
className = '',
|
|
36
|
+
getIsOpen = () => null,
|
|
37
|
+
onOpen = () => null,
|
|
38
|
+
tooltipType = TooltipType.TOOLTIP,
|
|
39
|
+
showArrow = true,
|
|
40
|
+
offset = [0, 14],
|
|
41
|
+
zIndex = 10,
|
|
42
|
+
extraModifiers = {}
|
|
43
|
+
} = _ref;
|
|
37
44
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
38
45
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
39
46
|
const [referenceElement, setReferenceElement] = useState(triggerComponent);
|
package/esm/v2/DSTooltipArrow.js
CHANGED
|
@@ -5,24 +5,27 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
5
5
|
|
|
6
6
|
var _svg;
|
|
7
7
|
|
|
8
|
-
const DSTooltipArrow =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
const DSTooltipArrow = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
placement,
|
|
11
|
+
style,
|
|
12
|
+
arrowElementRef
|
|
13
|
+
} = _ref;
|
|
14
|
+
return /*#__PURE__*/jsx(StyledTooltipArrow, {
|
|
15
|
+
"data-placement": placement,
|
|
16
|
+
style: style,
|
|
17
|
+
ref: arrowElementRef,
|
|
18
|
+
"data-testid": "ds-tooltip-arrow",
|
|
19
|
+
children: _svg || (_svg = /*#__PURE__*/_jsx("svg", {
|
|
20
|
+
viewBox: "0 0 30 30"
|
|
21
|
+
}, void 0, /*#__PURE__*/_jsx("path", {
|
|
22
|
+
className: "stroke",
|
|
23
|
+
d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z"
|
|
24
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
25
|
+
className: "fill",
|
|
26
|
+
d: "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"
|
|
27
|
+
})))
|
|
28
|
+
}, "popper-arrow");
|
|
29
|
+
};
|
|
27
30
|
|
|
28
31
|
export { DSTooltipArrow };
|
package/esm/v2/propTypes.js
CHANGED
|
@@ -9,9 +9,7 @@ const tooltipV2Props = {
|
|
|
9
9
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).description('Tooltip content').isRequired,
|
|
10
10
|
delayClose: PropTypes.number.description('Delay to close the tooltip').defaultValue(DEFAULT_DELAY_CLOSE),
|
|
11
11
|
delayOpen: PropTypes.number.description('Delay to open the tooltip ').defaultValue(DEFAULT_DELAY_OPEN),
|
|
12
|
-
triggerComponent: PropTypes.element.description(
|
|
13
|
-
Cannot be used with disabled elements.
|
|
14
|
-
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled`).isRequired,
|
|
12
|
+
triggerComponent: PropTypes.element.description("The component that will open/close the tooltip. \n Cannot be used with disabled elements. \n https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled").isRequired,
|
|
15
13
|
getIsOpen: PropTypes.func.description('Whether the tooltip is visible or not'),
|
|
16
14
|
onOpen: PropTypes.func.description('Callback when the tooltip opens'),
|
|
17
15
|
showArrow: PropTypes.bool.description('Whether to show an arrow or not').defaultValue(true),
|
package/esm/v2/styles.js
CHANGED
|
@@ -1,47 +1,41 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
1
2
|
import styled from 'styled-components';
|
|
2
3
|
import { kfrm, css } from '@elliemae/ds-system';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
from {
|
|
6
|
-
opacity: 0;
|
|
7
|
-
transform: scale(0.8);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
to {
|
|
11
|
-
opacity: 1;
|
|
12
|
-
transform: scale(1);
|
|
13
|
-
visibility: visible;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
const hideAnimation = kfrm`
|
|
17
|
-
0% {
|
|
18
|
-
opacity: 1;
|
|
19
|
-
transform: scale(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
100% {
|
|
23
|
-
opacity: 0;
|
|
24
|
-
transform: scale(0.8);
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
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"])));
|
|
27
8
|
const StyledTooltipContainer = /*#__PURE__*/styled.div.withConfig({
|
|
28
9
|
componentId: "sc-1dtjf9j-0"
|
|
29
10
|
})(["&[data-popper-reference-hidden='true']{display:none;pointer-events:none;}"]);
|
|
30
11
|
const StyledAnimatedTooltip = /*#__PURE__*/styled.div.withConfig({
|
|
31
12
|
componentId: "sc-1dtjf9j-1"
|
|
32
|
-
})(["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;"],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
});
|
|
45
39
|
const StyledTriggerComponentContainer = /*#__PURE__*/styled.div.withConfig({
|
|
46
40
|
componentId: "sc-1dtjf9j-2"
|
|
47
41
|
})(["display:inline-block;"]);
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
2
12
|
const filteredRefs = refs.filter(Boolean);
|
|
3
13
|
if (!filteredRefs.length) return null;
|
|
4
14
|
if (filteredRefs.length === 0) return filteredRefs[0];
|
package/esm/v3/index.js
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
2
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
-
import
|
|
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';
|
|
5
11
|
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
6
12
|
import { describe } from 'react-desc';
|
|
7
13
|
import { dsTooltipPropTypes } from './propsTypes.js';
|
|
8
14
|
import { useWithDefaultProps } from './config/useWithDefaultProps.js';
|
|
9
15
|
import { TooltipV3DatatestId } from './TooltipV3DatatestId.js';
|
|
10
|
-
import { StyledTooltipContainer, StyledTooltipText } from './styleds.js';
|
|
11
|
-
import {
|
|
16
|
+
import { StyledTriggerWrapper, StyledTooltipContainer, StyledTooltipText, StyledMouseOverDetectionBox } from './styleds.js';
|
|
17
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
var _StyledMouseOverDetec;
|
|
20
|
+
|
|
21
|
+
const _excluded = ["text", "children", "onOpen", "onClose", "id", "textAlign"];
|
|
14
22
|
|
|
15
23
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
16
24
|
|
|
17
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
18
26
|
|
|
27
|
+
const useGlobalKeyboardListener = func => {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
document.addEventListener('keydown', func);
|
|
30
|
+
return () => document.removeEventListener('keydown', func);
|
|
31
|
+
}, [func]);
|
|
32
|
+
};
|
|
33
|
+
|
|
19
34
|
const DSTooltipV3 = props => {
|
|
20
35
|
const _useWithDefaultProps = useWithDefaultProps(props),
|
|
21
36
|
{
|
|
@@ -23,10 +38,14 @@ const DSTooltipV3 = props => {
|
|
|
23
38
|
children,
|
|
24
39
|
onOpen,
|
|
25
40
|
onClose,
|
|
26
|
-
id
|
|
41
|
+
id,
|
|
42
|
+
textAlign
|
|
27
43
|
} = _useWithDefaultProps,
|
|
28
44
|
extraPopperJsProps = _objectWithoutProperties(_useWithDefaultProps, _excluded);
|
|
29
45
|
|
|
46
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
47
|
+
const [isHover, setIsHover] = useState(false);
|
|
48
|
+
const [latestOpenInteraction, setLatestOpenInteraction] = useState('');
|
|
30
49
|
const [referenceElement, setReferenceElement] = useState();
|
|
31
50
|
const [showPopover, setShowPopover] = useState(false);
|
|
32
51
|
const showTooltip = useCallback(() => {
|
|
@@ -37,29 +56,57 @@ const DSTooltipV3 = props => {
|
|
|
37
56
|
setShowPopover(false);
|
|
38
57
|
onClose();
|
|
39
58
|
}, [onClose]);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
const onFocus = useCallback(() => {
|
|
60
|
+
setIsFocused(true);
|
|
61
|
+
|
|
62
|
+
if (!showPopover) {
|
|
63
|
+
showTooltip();
|
|
64
|
+
setLatestOpenInteraction('onFocus');
|
|
65
|
+
}
|
|
66
|
+
}, [showPopover, showTooltip]);
|
|
67
|
+
const onBlur = useCallback(() => {
|
|
68
|
+
setIsFocused(false);
|
|
69
|
+
if (!isHover || latestOpenInteraction === 'onFocus') hideTooltip();
|
|
70
|
+
}, [hideTooltip, isHover, latestOpenInteraction]);
|
|
71
|
+
const onMouseEnter = useCallback(() => {
|
|
72
|
+
setIsHover(true);
|
|
73
|
+
|
|
74
|
+
if (!showPopover) {
|
|
75
|
+
showTooltip();
|
|
76
|
+
setLatestOpenInteraction('onMouseEnter');
|
|
77
|
+
}
|
|
78
|
+
}, [showPopover, showTooltip]);
|
|
79
|
+
const onMouseLeave = useCallback(() => {
|
|
80
|
+
setIsHover(false);
|
|
81
|
+
if (!isFocused || latestOpenInteraction === 'onMouseEnter') hideTooltip();
|
|
82
|
+
}, [hideTooltip, isFocused, latestOpenInteraction]);
|
|
83
|
+
const handleEscKey = useCallback(_ref => {
|
|
84
|
+
let {
|
|
85
|
+
key
|
|
86
|
+
} = _ref;
|
|
43
87
|
if (key === 'Escape') hideTooltip();
|
|
44
88
|
}, [hideTooltip]);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, void 0, /*#__PURE__*/_jsx(StyledTooltipContainer, {}, void 0, /*#__PURE__*/_jsx(StyledTooltipText, {}, void 0, text)))
|
|
53
|
-
})), /*#__PURE__*/jsx("div", {
|
|
54
|
-
onMouseOver: showTooltip,
|
|
55
|
-
onFocus: showTooltip,
|
|
56
|
-
onMouseOut: hideTooltip,
|
|
57
|
-
onBlur: hideTooltip,
|
|
58
|
-
onKeyDown: handleEscKey,
|
|
89
|
+
useGlobalKeyboardListener(handleEscKey);
|
|
90
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
91
|
+
children: /*#__PURE__*/jsxs(StyledTriggerWrapper, {
|
|
92
|
+
onMouseEnter: onMouseEnter,
|
|
93
|
+
onMouseLeave: onMouseLeave,
|
|
94
|
+
onFocus: onFocus,
|
|
95
|
+
onBlur: onBlur,
|
|
59
96
|
ref: setReferenceElement,
|
|
60
|
-
"data-testid":
|
|
61
|
-
children:
|
|
62
|
-
|
|
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
|
+
})
|
|
63
110
|
});
|
|
64
111
|
};
|
|
65
112
|
|
package/esm/v3/propsTypes.js
CHANGED
|
@@ -2,9 +2,14 @@ import { PropTypes } from 'react-desc';
|
|
|
2
2
|
|
|
3
3
|
const dsTooltipPropTypes = {
|
|
4
4
|
/**
|
|
5
|
-
* Tooltip text to be displayed on hover
|
|
5
|
+
* Tooltip text to be displayed on hover/focus
|
|
6
6
|
*/
|
|
7
|
-
text: PropTypes.string.description('Tooltip text to be displayed on hover').isRequired,
|
|
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'),
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Element to tie the tooltip to, must be a single node
|
|
@@ -27,6 +32,16 @@ const dsTooltipPropTypes = {
|
|
|
27
32
|
*/
|
|
28
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),
|
|
29
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
|
+
|
|
30
45
|
/**
|
|
31
46
|
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
32
47
|
*/
|
package/esm/v3/styleds.js
CHANGED
|
@@ -2,15 +2,35 @@ import styled from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
const StyledTooltipContainer = /*#__PURE__*/styled.div.withConfig({
|
|
4
4
|
componentId: "sc-18a4gem-0"
|
|
5
|
-
})(["text-align:center;min-width:", ";max-width:250px;min-height:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
})(["text-align:center;min-width:", ";max-width:250px;min-height:30px;display:grid;align-items:center;padding:", ";position:relative;background-color:white;border-radius:2px;font-size:13px;color:", ";"], _ref => {
|
|
6
|
+
let {
|
|
7
|
+
theme
|
|
8
|
+
} = _ref;
|
|
9
|
+
return theme.space.l;
|
|
10
|
+
}, _ref2 => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref2;
|
|
14
|
+
return "".concat(theme.space.xxxs, " ").concat(theme.space.xs);
|
|
15
|
+
}, _ref3 => {
|
|
16
|
+
let {
|
|
17
|
+
theme
|
|
18
|
+
} = _ref3;
|
|
19
|
+
return theme.colors.neutral[600];
|
|
20
|
+
});
|
|
12
21
|
const StyledTooltipText = /*#__PURE__*/styled.div.withConfig({
|
|
13
22
|
componentId: "sc-18a4gem-1"
|
|
14
|
-
})(["white-space:normal;word-wrap:break-word;display:inline-block;"]
|
|
23
|
+
})(["white-space:normal;word-wrap:break-word;display:inline-block;text-align:", ";"], _ref4 => {
|
|
24
|
+
let {
|
|
25
|
+
textAlign
|
|
26
|
+
} = _ref4;
|
|
27
|
+
return textAlign;
|
|
28
|
+
});
|
|
29
|
+
const StyledMouseOverDetectionBox = /*#__PURE__*/styled.div.withConfig({
|
|
30
|
+
componentId: "sc-18a4gem-2"
|
|
31
|
+
})(["position:absolute;top:-15px;right:-15px;width:calc(100% + 30px);height:calc(100% + 30px);z-index:-1;"]);
|
|
32
|
+
const StyledTriggerWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
33
|
+
componentId: "sc-18a4gem-3"
|
|
34
|
+
})(["display:inline-block;width:100%;"]);
|
|
15
35
|
|
|
16
|
-
export { StyledTooltipContainer, StyledTooltipText };
|
|
36
|
+
export { StyledMouseOverDetectionBox, StyledTooltipContainer, StyledTooltipText, StyledTriggerWrapper };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-tooltip",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-next.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Tooltip",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -92,14 +92,17 @@
|
|
|
92
92
|
"build": "node ../../scripts/build/build.js"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@elliemae/ds-
|
|
96
|
-
"@elliemae/ds-
|
|
97
|
-
"@elliemae/ds-
|
|
98
|
-
"@elliemae/ds-
|
|
99
|
-
"@elliemae/ds-
|
|
100
|
-
"@
|
|
101
|
-
"
|
|
102
|
-
"
|
|
95
|
+
"@elliemae/ds-basic": "2.0.0-next.12",
|
|
96
|
+
"@elliemae/ds-classnames": "2.0.0-next.12",
|
|
97
|
+
"@elliemae/ds-popper": "2.0.0-next.12",
|
|
98
|
+
"@elliemae/ds-popperjs": "2.0.0-next.12",
|
|
99
|
+
"@elliemae/ds-portal": "2.0.0-next.12",
|
|
100
|
+
"@elliemae/ds-shared": "2.0.0-next.12",
|
|
101
|
+
"@elliemae/ds-system": "2.0.0-next.12",
|
|
102
|
+
"@elliemae/ds-utilities": "2.0.0-next.12",
|
|
103
|
+
"@popperjs/core": "~2.9.2",
|
|
104
|
+
"react-desc": "~4.1.3",
|
|
105
|
+
"react-popper": "~2.2.5"
|
|
103
106
|
},
|
|
104
107
|
"peerDependencies": {
|
|
105
108
|
"react": "^17.0.2",
|
package/types/v3/propsTypes.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export declare const dsTooltipPropTypes: {
|
|
2
2
|
/**
|
|
3
|
-
* Tooltip text to be displayed on hover
|
|
3
|
+
* Tooltip text to be displayed on hover/focus
|
|
4
4
|
*/
|
|
5
5
|
text: any;
|
|
6
|
+
/**
|
|
7
|
+
* Tooltip text alignment
|
|
8
|
+
*/
|
|
9
|
+
textAlign: any;
|
|
6
10
|
/**
|
|
7
11
|
* Element to tie the tooltip to, must be a single node
|
|
8
12
|
*/
|
|
@@ -20,6 +24,14 @@ export declare const dsTooltipPropTypes: {
|
|
|
20
24
|
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
21
25
|
*/
|
|
22
26
|
boundaryElement: any;
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not the popper context menu should be animated
|
|
29
|
+
*/
|
|
30
|
+
withoutAnimation: any;
|
|
31
|
+
/**
|
|
32
|
+
* Popper context menus Animation duration in ms
|
|
33
|
+
*/
|
|
34
|
+
animationDuration: any;
|
|
23
35
|
/**
|
|
24
36
|
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
25
37
|
*/
|
package/types/v3/styleds.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare const StyledTooltipContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const StyledTooltipText: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
export declare const StyledTooltipText: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
textAlign: string;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const StyledMouseOverDetectionBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledTriggerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/cjs/package.json
DELETED