@elliemae/ds-truncated-tooltip-text 2.2.0-next.3 → 2.3.0-alpha.1
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/DSTruncateTextWithTooltip.js +68 -57
- package/cjs/DSTruncateTextWithTooltip.js.map +7 -0
- package/cjs/DSTruncatedTooltipText.js +100 -93
- package/cjs/DSTruncatedTooltipText.js.map +7 -0
- package/cjs/SimpleTruncatedTooltipText.js +114 -125
- package/cjs/SimpleTruncatedTooltipText.js.map +7 -0
- package/cjs/TooltipTextProvider.js +60 -64
- package/cjs/TooltipTextProvider.js.map +7 -0
- package/cjs/index.js +45 -19
- package/cjs/index.js.map +7 -0
- package/esm/DSTruncateTextWithTooltip.js +38 -46
- package/esm/DSTruncateTextWithTooltip.js.map +7 -0
- package/esm/DSTruncatedTooltipText.js +68 -78
- package/esm/DSTruncatedTooltipText.js.map +7 -0
- package/esm/SimpleTruncatedTooltipText.js +83 -111
- package/esm/SimpleTruncatedTooltipText.js.map +7 -0
- package/esm/TooltipTextProvider.js +29 -48
- package/esm/TooltipTextProvider.js.map +7 -0
- package/esm/index.js +16 -4
- package/esm/index.js.map +7 -0
- package/package.json +5 -5
- package/types/DSTruncatedTooltipText.d.ts +1 -6
- package/types/index.d.ts +4 -5
|
@@ -1,75 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var DSTruncateTextWithTooltip_exports = {};
|
|
29
|
+
__export(DSTruncateTextWithTooltip_exports, {
|
|
30
|
+
DSTruncateTextWithTooltip: () => DSTruncateTextWithTooltip,
|
|
31
|
+
DSTruncateTextWithTooltipDatatestId: () => DSTruncateTextWithTooltipDatatestId
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_ds_tooltip = require("@elliemae/ds-tooltip");
|
|
36
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
37
|
+
const Text = import_styled_components.default.span`
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
display: inline-block;
|
|
42
|
+
max-width: 100%;
|
|
43
|
+
:focus {
|
|
44
|
+
border: none;
|
|
45
|
+
outline: none;
|
|
46
|
+
background: ${(props) => props.theme.colors.brand["200"]};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const DSTruncateTextWithTooltipDatatestId = "DS-TruncateTextWithTooltip";
|
|
50
|
+
const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }) => {
|
|
51
|
+
const [textWrapperEl, setTextWrapperEl] = (0, import_react.useState)();
|
|
52
|
+
const [isShowingEllipsis, setIsShowingEllipsis] = (0, import_react.useState)(false);
|
|
53
|
+
const resizeObserver = (0, import_react.useMemo)(() => new ResizeObserver((entries) => {
|
|
39
54
|
if (entries.length) {
|
|
40
55
|
const [textWrapperEntry] = entries;
|
|
41
56
|
const el = textWrapperEntry.target;
|
|
42
|
-
setIsShowingEllipsis(
|
|
57
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
|
43
58
|
}
|
|
44
59
|
}), []);
|
|
45
|
-
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
46
61
|
if (textWrapperEl) {
|
|
47
|
-
setIsShowingEllipsis(
|
|
62
|
+
setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
|
|
48
63
|
resizeObserver.observe(textWrapperEl);
|
|
49
64
|
}
|
|
50
|
-
|
|
51
65
|
return () => {
|
|
52
66
|
if (textWrapperEl) {
|
|
53
67
|
resizeObserver.unobserve(textWrapperEl);
|
|
54
68
|
}
|
|
55
69
|
};
|
|
56
70
|
}, [resizeObserver, textWrapperEl]);
|
|
57
|
-
if (isShowingEllipsis)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
if (isShowingEllipsis)
|
|
72
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ds_tooltip.DSTooltipV3, {
|
|
73
|
+
text,
|
|
74
|
+
...tooltipProps
|
|
75
|
+
}, /* @__PURE__ */ import_react.default.createElement(Text, {
|
|
61
76
|
ref: setTextWrapperEl,
|
|
62
77
|
tabIndex: 0,
|
|
63
|
-
"data-testid": DSTruncateTextWithTooltipDatatestId
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}));
|
|
67
|
-
return /*#__PURE__*/jsxRuntime.jsx(Text, {
|
|
78
|
+
"data-testid": DSTruncateTextWithTooltipDatatestId
|
|
79
|
+
}, text));
|
|
80
|
+
return /* @__PURE__ */ import_react.default.createElement(Text, {
|
|
68
81
|
ref: setTextWrapperEl,
|
|
69
|
-
"data-testid": DSTruncateTextWithTooltipDatatestId
|
|
70
|
-
|
|
71
|
-
});
|
|
82
|
+
"data-testid": DSTruncateTextWithTooltipDatatestId
|
|
83
|
+
}, text);
|
|
72
84
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
exports.DSTruncateTextWithTooltipDatatestId = DSTruncateTextWithTooltipDatatestId;
|
|
85
|
+
module.exports = __toCommonJS(DSTruncateTextWithTooltip_exports);
|
|
86
|
+
//# sourceMappingURL=DSTruncateTextWithTooltip.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSTruncateTextWithTooltip.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useMemo, useEffect, useRef } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport styled from 'styled-components';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n :focus {\n border: none;\n outline: none;\n background: ${(props) => props.theme.colors.brand['200']};\n }\n`;\ninterface PropsT {\n text: string;\n tooltipProps?: Record<string, unknown>;\n}\nexport const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';\nexport const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }: PropsT): JSX.Element => {\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement>();\n // const textWrapperEl = useRef<HTMLSpanElement>();\n const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);\n // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n useEffect(() => {\n if (textWrapperEl) {\n setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);\n resizeObserver.observe(textWrapperEl);\n }\n return () => {\n if (textWrapperEl) {\n resizeObserver.unobserve(textWrapperEl);\n }\n };\n }, [resizeObserver, textWrapperEl]);\n\n if (isShowingEllipsis)\n return (\n <DSTooltipV3 text={text} {...tooltipProps}>\n <Text ref={setTextWrapperEl} tabIndex={0} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|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|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var DSTruncatedTooltipText_exports = {};
|
|
29
|
+
__export(DSTruncatedTooltipText_exports, {
|
|
30
|
+
DSTruncatedTooltipText: () => DSTruncatedTooltipText,
|
|
31
|
+
TruncatedTooltipTextWithSchema: () => TruncatedTooltipTextWithSchema,
|
|
32
|
+
default: () => DSTruncatedTooltipText_default
|
|
33
|
+
});
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_react_desc = require("react-desc");
|
|
37
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
38
|
+
var import_ds_popper = require("@elliemae/ds-popper");
|
|
39
|
+
var import_TooltipTextProvider = require("./TooltipTextProvider");
|
|
40
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
|
41
|
+
const Text = import_styled_components.default.span`
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
display: inline-block;
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
`;
|
|
48
|
+
const DSTruncatedTooltipText = ({
|
|
49
|
+
containerProps = {},
|
|
50
|
+
value = "",
|
|
51
|
+
zIndex = 110,
|
|
52
|
+
...otherTextProps
|
|
53
|
+
}) => {
|
|
54
|
+
const tooltipContext = (0, import_react.useContext)(import_TooltipTextProvider.TruncatedTooltipContext);
|
|
55
|
+
(0, import_react.useEffect)(() => {
|
|
56
|
+
if (zIndex && tooltipContext)
|
|
57
|
+
tooltipContext.setZIndex(zIndex);
|
|
55
58
|
}, [zIndex]);
|
|
56
|
-
if (!tooltipContext)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const handleMouseEnter = e => {
|
|
63
|
-
const {
|
|
64
|
-
target
|
|
65
|
-
} = e;
|
|
66
|
-
|
|
59
|
+
if (!tooltipContext)
|
|
60
|
+
return value;
|
|
61
|
+
const { showTooltip, hideTooltip } = tooltipContext;
|
|
62
|
+
const handleMouseEnter = (e) => {
|
|
63
|
+
const { target } = e;
|
|
67
64
|
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
|
68
65
|
showTooltip({
|
|
69
66
|
value,
|
|
@@ -71,42 +68,52 @@ const DSTruncatedTooltipText = _ref2 => {
|
|
|
71
68
|
}, e);
|
|
72
69
|
}
|
|
73
70
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
hideTooltip({
|
|
77
|
-
reference: e.target
|
|
78
|
-
});
|
|
71
|
+
const handleMouseLeave = (e) => {
|
|
72
|
+
hideTooltip({ reference: e.target });
|
|
79
73
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
children: value
|
|
87
|
-
}));
|
|
74
|
+
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(Text, {
|
|
76
|
+
...containerProps,
|
|
77
|
+
...otherTextProps,
|
|
78
|
+
...handlers
|
|
79
|
+
}, value);
|
|
88
80
|
};
|
|
89
|
-
|
|
90
81
|
DSTruncatedTooltipText.defaultProps = {
|
|
91
|
-
value:
|
|
82
|
+
value: "",
|
|
92
83
|
zIndex: 110
|
|
93
84
|
};
|
|
94
85
|
const truncatedTooltipTextProps = {
|
|
95
|
-
containerProps:
|
|
96
|
-
value:
|
|
97
|
-
tooltipPlacement:
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
containerProps: import_react_desc.PropTypes.object.description("Set of Properties attached to the main container"),
|
|
87
|
+
value: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("Text that when truncated will trigger the tooltip interaction"),
|
|
88
|
+
tooltipPlacement: import_react_desc.PropTypes.oneOf([
|
|
89
|
+
import_ds_popper.PopperPositions.AUTO_START,
|
|
90
|
+
import_ds_popper.PopperPositions.AUTO_END,
|
|
91
|
+
import_ds_popper.PopperPositions.AUTO,
|
|
92
|
+
import_ds_popper.PopperPositions.TOP_START,
|
|
93
|
+
import_ds_popper.PopperPositions.TOP,
|
|
94
|
+
import_ds_popper.PopperPositions.TOP_END,
|
|
95
|
+
import_ds_popper.PopperPositions.RIGHT_START,
|
|
96
|
+
import_ds_popper.PopperPositions.RIGHT,
|
|
97
|
+
import_ds_popper.PopperPositions.RIGHT_END,
|
|
98
|
+
import_ds_popper.PopperPositions.BOTTOM_START,
|
|
99
|
+
import_ds_popper.PopperPositions.BOTTOM,
|
|
100
|
+
import_ds_popper.PopperPositions.BOTTOM_END,
|
|
101
|
+
import_ds_popper.PopperPositions.LEFT_START,
|
|
102
|
+
import_ds_popper.PopperPositions.LEFT,
|
|
103
|
+
import_ds_popper.PopperPositions.LEFT_END
|
|
104
|
+
]).description("Position of the tooltip"),
|
|
105
|
+
tooltipDelay: import_react_desc.PropTypes.number.description("Delay to show the tooltip"),
|
|
106
|
+
zIndex: import_react_desc.PropTypes.number.description("override default zIndex").defaultValue(110)
|
|
100
107
|
};
|
|
101
108
|
DSTruncatedTooltipText.defaultProps = {
|
|
102
109
|
containerProps: {},
|
|
103
|
-
value:
|
|
104
|
-
tooltipPlacement:
|
|
105
|
-
tooltipDelay:
|
|
110
|
+
value: "",
|
|
111
|
+
tooltipPlacement: void 0,
|
|
112
|
+
tooltipDelay: void 0
|
|
106
113
|
};
|
|
107
|
-
|
|
114
|
+
DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
|
|
115
|
+
const TruncatedTooltipTextWithSchema = (0, import_react_desc.describe)(DSTruncatedTooltipText);
|
|
108
116
|
TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
|
|
109
|
-
|
|
110
|
-
exports
|
|
111
|
-
|
|
112
|
-
exports["default"] = DSTruncatedTooltipText;
|
|
117
|
+
var DSTruncatedTooltipText_default = DSTruncatedTooltipText;
|
|
118
|
+
module.exports = __toCommonJS(DSTruncatedTooltipText_exports);
|
|
119
|
+
//# sourceMappingURL=DSTruncatedTooltipText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSTruncatedTooltipText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport styled from 'styled-components';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) =>\n offsetWidth < scrollWidth;\n\n// reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n`;\n\nconst DSTruncatedTooltipText = ({\n containerProps = {},\n value = '',\n zIndex = 110, // https://jira.elliemae.io/browse/PUI-1755\n ...otherTextProps\n}) => {\n const tooltipContext = useContext(TruncatedTooltipContext);\n useEffect(() => {\n if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);\n }, [zIndex]);\n\n if (!tooltipContext) return value;\n\n const { showTooltip, hideTooltip } = tooltipContext;\n\n const handleMouseEnter = (e) => {\n const { target } = e;\n if (target && isEllipsisActive(target, target.getBoundingClientRect())) {\n showTooltip(\n {\n value,\n reference: target,\n },\n e,\n );\n }\n };\n\n const handleMouseLeave = (e) => {\n hideTooltip({ reference: e.target });\n };\n\n const handlers = showTooltip\n ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }\n : {};\n return (\n <Text {...containerProps} {...otherTextProps} {...handlers}>\n {value}\n </Text>\n );\n};\n\nDSTruncatedTooltipText.defaultProps = {\n value: '',\n zIndex: 110,\n};\n\nconst truncatedTooltipTextProps = {\n containerProps: PropTypes.object.description(\n 'Set of Properties attached to the main container',\n ),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n tooltipPlacement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]).description('Position of the tooltip'),\n tooltipDelay: PropTypes.number.description('Delay to show the tooltip'),\n zIndex: PropTypes.number\n .description('override default zIndex')\n .defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\n\nconst TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);\nTruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;\n\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };\nexport default DSTruncatedTooltipText;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA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