@elliemae/ds-tooltip 2.0.0-alpha.1 → 2.0.0-alpha.13

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.
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var styled = require('styled-components');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
+
11
+ const StyledTooltipContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
12
+ componentId: "sc-18a4gem-0"
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
+ });
29
+ const StyledTooltipText = /*#__PURE__*/styled__default["default"].div.withConfig({
30
+ componentId: "sc-18a4gem-1"
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%;"]);
43
+
44
+ exports.StyledMouseOverDetectionBox = StyledMouseOverDetectionBox;
45
+ exports.StyledTooltipContainer = StyledTooltipContainer;
46
+ exports.StyledTooltipText = StyledTooltipText;
47
+ exports.StyledTriggerWrapper = StyledTriggerWrapper;
package/esm/index.js CHANGED
@@ -2,3 +2,4 @@ export { DSTooltip, TooltipContainer, TooltipText, TooltipWithSchema, DSTooltip
2
2
  export { DSTooltipV2, TooltipV2WithSchema } from './v2/DSTooltip.js';
3
3
  export { tooltipPositions } from './v2/utils/tooltipPositions.js';
4
4
  export { TooltipType } from './v2/TooltipType.js';
5
+ export { DSTooltipV3, DSTooltipV3WithSchema } from './v3/index.js';
@@ -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/getComponentFromProps';
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: `tooltip-container--${tooltipType} ${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(`The component that will open/close the tooltip.
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'),
@@ -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
- containerProps = {},
22
- innerRef,
23
- placement = tooltipPositions.BOTTOM,
24
- title = '',
25
- delayClose = DEFAULT_DELAY_CLOSE,
26
- delayOpen = DEFAULT_DELAY_OPEN,
27
- triggerComponent = null,
28
- className = '',
29
- getIsOpen = () => null,
30
- onOpen = () => null,
31
- tooltipType = TooltipType.TOOLTIP,
32
- showArrow = true,
33
- offset = [0, 14],
34
- zIndex = 10,
35
- extraModifiers = {}
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);
@@ -5,24 +5,27 @@ import { jsx } from 'react/jsx-runtime';
5
5
 
6
6
  var _svg;
7
7
 
8
- const DSTooltipArrow = ({
9
- placement,
10
- style,
11
- arrowElementRef
12
- }) => /*#__PURE__*/jsx(StyledTooltipArrow, {
13
- "data-placement": placement,
14
- style: style,
15
- ref: arrowElementRef,
16
- "data-testid": "ds-tooltip-arrow",
17
- children: _svg || (_svg = /*#__PURE__*/_jsx("svg", {
18
- viewBox: "0 0 30 30"
19
- }, void 0, /*#__PURE__*/_jsx("path", {
20
- className: "stroke",
21
- 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"
22
- }), /*#__PURE__*/_jsx("path", {
23
- className: "fill",
24
- 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"
25
- })))
26
- }, "popper-arrow");
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 };
@@ -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(`The component that will open/close the tooltip.
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
- const showAnimation = kfrm`
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
- theme
34
- }) => theme.space.l, ({
35
- theme
36
- }) => `${theme.space.xxxs} ${theme.space.xs}`, ({
37
- theme
38
- }) => theme.colors.neutral[600], ({
39
- showTooltip
40
- }) => showTooltip ? 'visible' : 'hidden', ({
41
- showTooltip
42
- }) => css`
43
- animation: ${showTooltip ? showAnimation : hideAnimation} 0.1s ease-in;
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
- const setMultipleRefs = (...refs) => {
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];
@@ -0,0 +1,6 @@
1
+ const TooltipV3DatatestId = {
2
+ TRIGGER_WRAPPER: 'ds-tooltip-v3-trigger-wrapper',
3
+ TOOLTIP_TEXT_WRAPPER: 'ds-tooltip-v3-tooltip-text-wrapper'
4
+ };
5
+
6
+ export { TooltipV3DatatestId };
@@ -0,0 +1,14 @@
1
+ import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
4
+ const noop = () => {};
5
+
6
+ const defaultProps = {
7
+ onOpen: noop,
8
+ onClose: noop,
9
+ id: '',
10
+ textAlign: 'left'
11
+ };
12
+ const useWithDefaultProps = props => useMemoMergePropsWithDefault(props, defaultProps);
13
+
14
+ export { useWithDefaultProps };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,116 @@
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); if (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 = 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; }
26
+
27
+ const useGlobalKeyboardListener = func => {
28
+ useEffect(() => {
29
+ document.addEventListener('keydown', func);
30
+ return () => document.removeEventListener('keydown', func);
31
+ }, [func]);
32
+ };
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
+
46
+ const [isFocused, setIsFocused] = useState(false);
47
+ const [isHover, setIsHover] = useState(false);
48
+ const [latestOpenInteraction, setLatestOpenInteraction] = useState('');
49
+ const [referenceElement, setReferenceElement] = useState();
50
+ const [showPopover, setShowPopover] = useState(false);
51
+ const showTooltip = useCallback(() => {
52
+ setShowPopover(true);
53
+ onOpen();
54
+ }, [onOpen]);
55
+ const hideTooltip = useCallback(() => {
56
+ setShowPopover(false);
57
+ onClose();
58
+ }, [onClose]);
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;
87
+ if (key === 'Escape') hideTooltip();
88
+ }, [hideTooltip]);
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,
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
+ });
111
+ };
112
+
113
+ const DSTooltipV3WithSchema = describe(DSTooltipV3).description('A tooltip component');
114
+ DSTooltipV3WithSchema.propTypes = dsTooltipPropTypes;
115
+
116
+ export { DSTooltipV3, DSTooltipV3WithSchema, DSTooltipV3 as default };
@@ -0,0 +1,92 @@
1
+ import { PropTypes } from 'react-desc';
2
+
3
+ const dsTooltipPropTypes = {
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('() => {}')
90
+ };
91
+
92
+ export { dsTooltipPropTypes };
@@ -0,0 +1,36 @@
1
+ import styled from 'styled-components';
2
+
3
+ const StyledTooltipContainer = /*#__PURE__*/styled.div.withConfig({
4
+ componentId: "sc-18a4gem-0"
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
+ });
21
+ const StyledTooltipText = /*#__PURE__*/styled.div.withConfig({
22
+ componentId: "sc-18a4gem-1"
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%;"]);
35
+
36
+ export { StyledMouseOverDetectionBox, StyledTooltipContainer, StyledTooltipText, StyledTriggerWrapper };