@elliemae/ds-truncated-tooltip-text 3.4.3-rc.0 → 3.4.4-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DSTruncatedTooltipText.js +20 -10
- package/dist/cjs/DSTruncatedTooltipText.js.map +2 -2
- package/dist/cjs/SimpleTruncatedTooltipText.js +63 -31
- package/dist/cjs/SimpleTruncatedTooltipText.js.map +2 -2
- package/dist/cjs/TooltipTextProvider.js +30 -19
- package/dist/cjs/TooltipTextProvider.js.map +2 -2
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +4 -1
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +29 -19
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/defaultProps.js +4 -1
- package/dist/cjs/truncateTextWithTooltip/defaultProps.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/index.js +4 -1
- package/dist/cjs/truncateTextWithTooltip/index.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/propTypes.js +7 -2
- package/dist/cjs/truncateTextWithTooltip/propTypes.js.map +1 -1
- package/dist/cjs/truncateTextWithTooltip/styles.js +4 -1
- package/dist/cjs/truncateTextWithTooltip/styles.js.map +1 -1
- package/dist/esm/DSTruncatedTooltipText.js +16 -9
- package/dist/esm/DSTruncatedTooltipText.js.map +1 -1
- package/dist/esm/SimpleTruncatedTooltipText.js +59 -30
- package/dist/esm/SimpleTruncatedTooltipText.js.map +1 -1
- package/dist/esm/TooltipTextProvider.js +26 -18
- package/dist/esm/TooltipTextProvider.js.map +2 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +1 -1
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +25 -18
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +1 -1
- package/dist/esm/truncateTextWithTooltip/defaultProps.js.map +1 -1
- package/dist/esm/truncateTextWithTooltip/index.js.map +1 -1
- package/dist/esm/truncateTextWithTooltip/propTypes.js +3 -1
- package/dist/esm/truncateTextWithTooltip/propTypes.js.map +1 -1
- package/dist/esm/truncateTextWithTooltip/styles.js.map +1 -1
- package/package.json +6 -6
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var DSTruncatedTooltipText_exports = {};
|
23
26
|
__export(DSTruncatedTooltipText_exports, {
|
@@ -27,7 +30,8 @@ __export(DSTruncatedTooltipText_exports, {
|
|
27
30
|
});
|
28
31
|
module.exports = __toCommonJS(DSTruncatedTooltipText_exports);
|
29
32
|
var React = __toESM(require("react"));
|
30
|
-
var
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
34
|
+
var import_react = require("react");
|
31
35
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
32
36
|
var import_ds_system = require("@elliemae/ds-system");
|
33
37
|
var import_ds_popper = require("@elliemae/ds-popper");
|
@@ -57,21 +61,25 @@ const DSTruncatedTooltipText = ({
|
|
57
61
|
const handleMouseEnter = (e) => {
|
58
62
|
const { target } = e;
|
59
63
|
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
60
|
-
showTooltip(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
showTooltip(
|
65
|
+
{
|
66
|
+
value,
|
67
|
+
reference: target
|
68
|
+
},
|
69
|
+
e
|
70
|
+
);
|
64
71
|
}
|
65
72
|
};
|
66
73
|
const handleMouseLeave = (e) => {
|
67
74
|
hideTooltip({ reference: e.target });
|
68
75
|
};
|
69
76
|
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
70
|
-
return /* @__PURE__ */
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
71
78
|
...containerProps,
|
72
79
|
...otherTextProps,
|
73
|
-
...handlers
|
74
|
-
|
80
|
+
...handlers,
|
81
|
+
children: value
|
82
|
+
});
|
75
83
|
};
|
76
84
|
DSTruncatedTooltipText.defaultProps = {
|
77
85
|
value: "",
|
@@ -79,7 +87,9 @@ DSTruncatedTooltipText.defaultProps = {
|
|
79
87
|
};
|
80
88
|
const truncatedTooltipTextProps = {
|
81
89
|
containerProps: import_ds_utilities.PropTypes.object.description("Set of Properties attached to the main container"),
|
82
|
-
value: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.string, import_ds_utilities.PropTypes.number]).description(
|
90
|
+
value: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.string, import_ds_utilities.PropTypes.number]).description(
|
91
|
+
"Text that when truncated will trigger the tooltip interaction"
|
92
|
+
),
|
83
93
|
tooltipPlacement: import_ds_utilities.PropTypes.oneOf([
|
84
94
|
import_ds_popper.PopperPositions.AUTO_START,
|
85
95
|
import_ds_popper.PopperPositions.AUTO_END,
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/DSTruncatedTooltipText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-utilities';\nimport { styled } from '@elliemae/ds-system';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => 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 = 3000, // https://jira.elliemae.io/browse/PUI-1755 https://jira.elliemae.io/browse/PUI-8732\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 ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};\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('Set of Properties attached to the main container'),\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.description('override default zIndex').defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\nDSTruncatedTooltipText.displayName = 'DSTruncatedTooltipText';\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": "
|
6
|
-
"names": []
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA6C;AAC7C,0BAAoC;AACpC,uBAAuB;AACvB,uBAA6C;AAC7C,iCAAwC;AAExC,MAAM,mBAAmB,CAAC,EAAE,aAAa,YAAY,MAAM,cAAc;AAGzE,MAAM,OAAO,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,yBAAyB,CAAC;AAAA,EAC9B,iBAAiB,CAAC;AAAA,EAClB,QAAQ;AAAA,EACR,SAAS;AAAA,KACN;AACL,MAAM;AACJ,QAAM,qBAAiB,yBAAW,kDAAuB;AACzD,8BAAU,MAAM;AACd,QAAI,UAAU;AAAgB,qBAAe,UAAU,MAAM;AAAA,EAC/D,GAAG,CAAC,MAAM,CAAC;AAEX,MAAI,CAAC;AAAgB,WAAO;AAE5B,QAAM,EAAE,aAAa,YAAY,IAAI;AAErC,QAAM,mBAAmB,CAAC,MAAM;AAC9B,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,UAAU,iBAAiB,QAAQ,OAAO,sBAAsB,CAAC,GAAG;AACtE;AAAA,QACE;AAAA,UACE;AAAA,UACA,WAAW;AAAA,QACb;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAmB,CAAC,MAAM;AAC9B,gBAAY,EAAE,WAAW,EAAE,OAAO,CAAC;AAAA,EACrC;AAEA,QAAM,WAAW,cAAc,EAAE,cAAc,kBAAkB,cAAc,iBAAiB,IAAI,CAAC;AACrG,SACE,4CAAC;AAAA,IAAM,GAAG;AAAA,IAAiB,GAAG;AAAA,IAAiB,GAAG;AAAA,IAC/C;AAAA,GACH;AAEJ;AAEA,uBAAuB,eAAe;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ;AACV;AAEA,MAAM,4BAA4B;AAAA,EAChC,gBAAgB,8BAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,OAAO,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,MAAM,CAAC,EAAE;AAAA,IAC/D;AAAA,EACF;AAAA,EACA,kBAAkB,8BAAU,MAAM;AAAA,IAChC,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,EACZ,CAAC,EAAE,YAAY,yBAAyB;AAAA,EACxC,cAAc,8BAAU,OAAO,YAAY,2BAA2B;AAAA,EACtE,QAAQ,8BAAU,OAAO,YAAY,yBAAyB,EAAE,aAAa,GAAG;AAClF;AAEA,uBAAuB,eAAe;AAAA,EACpC,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAChB;AAEA,uBAAuB,YAAY;AACnC,uBAAuB,cAAc;AACrC,MAAM,qCAAiC,8BAAS,sBAAsB;AACtE,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
|
6
|
+
"names": ["positions"]
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var SimpleTruncatedTooltipText_exports = {};
|
23
26
|
__export(SimpleTruncatedTooltipText_exports, {
|
@@ -26,7 +29,8 @@ __export(SimpleTruncatedTooltipText_exports, {
|
|
26
29
|
});
|
27
30
|
module.exports = __toCommonJS(SimpleTruncatedTooltipText_exports);
|
28
31
|
var React = __toESM(require("react"));
|
29
|
-
var
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
33
|
+
var import_react = require("react");
|
30
34
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
31
35
|
var import_prop_types = __toESM(require("prop-types"));
|
32
36
|
var import_ds_system = require("@elliemae/ds-system");
|
@@ -49,20 +53,29 @@ const Text = import_ds_system.styled.span`
|
|
49
53
|
const SimpleTruncatedTooltipText = (props) => {
|
50
54
|
const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
|
51
55
|
const [tooltipState, setTooltipState] = (0, import_react.useState)(initialTooltipState(value, tooltipOptions));
|
52
|
-
const show = (0, import_react.useCallback)(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
const show = (0, import_react.useCallback)(
|
57
|
+
(newState) => {
|
58
|
+
setTooltipState({ ...tooltipState, ...newState, visible: true });
|
59
|
+
},
|
60
|
+
[tooltipState]
|
61
|
+
);
|
62
|
+
const hideTooltip = (0, import_react.useCallback)(
|
63
|
+
(newState) => {
|
64
|
+
setTooltipState({ ...tooltipState, ...newState, visible: false });
|
65
|
+
},
|
66
|
+
[tooltipState]
|
67
|
+
);
|
58
68
|
const [showTooltip, cancelShowTooltip] = (0, import_ds_utilities.useCancellableDelayedCallback)(show, tooltipDelay);
|
59
|
-
const handleMouseEnter = (0, import_react.useCallback)(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
69
|
+
const handleMouseEnter = (0, import_react.useCallback)(
|
70
|
+
(e) => {
|
71
|
+
const { target } = e;
|
72
|
+
const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
|
73
|
+
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
74
|
+
showTooltip({ value, reference: SimpleTruncatedTextEl });
|
75
|
+
}
|
76
|
+
},
|
77
|
+
[showTooltip, value]
|
78
|
+
);
|
66
79
|
const handleMouseLeave = (0, import_react.useCallback)(() => {
|
67
80
|
cancelShowTooltip();
|
68
81
|
hideTooltip({ reference: null });
|
@@ -76,22 +89,41 @@ const SimpleTruncatedTooltipText = (props) => {
|
|
76
89
|
};
|
77
90
|
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
78
91
|
const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
|
79
|
-
const PurePopover = (0, import_react.useMemo)(
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
const PurePopover = (0, import_react.useMemo)(
|
93
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
94
|
+
children: tooltipState.visible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_popover.DSPopover, {
|
95
|
+
boundaries: "window",
|
96
|
+
style: { pointerEvents: "none", zIndex: zIndex ?? theme.zIndex.tooltip },
|
97
|
+
placement,
|
98
|
+
content: tooltipState.value,
|
99
|
+
referenceEl: tooltipState.reference,
|
100
|
+
visible: tooltipState.visible,
|
101
|
+
showArrow: true
|
102
|
+
}) : null
|
103
|
+
}),
|
104
|
+
[tooltipState, placement, zIndex]
|
105
|
+
);
|
106
|
+
const PureText = (0, import_react.useMemo)(
|
107
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
109
|
+
...containerProps && { ...containerProps },
|
110
|
+
...textOptions && { ...textOptions },
|
111
|
+
...handlers && { ...handlers },
|
112
|
+
"data-testid": dsTestId,
|
113
|
+
children: value
|
114
|
+
})
|
115
|
+
}),
|
116
|
+
[containerProps, textOptions, handlers, value]
|
117
|
+
);
|
118
|
+
const PureSimpleTruncatedTooltipText = (0, import_react.useMemo)(
|
119
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
120
|
+
children: [
|
121
|
+
PureText,
|
122
|
+
PurePopover
|
123
|
+
]
|
124
|
+
}),
|
125
|
+
[PureText, PurePopover]
|
126
|
+
);
|
95
127
|
return PureSimpleTruncatedTooltipText;
|
96
128
|
};
|
97
129
|
SimpleTruncatedTooltipText.propTypes = {
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/SimpleTruncatedTooltipText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["/* eslint-disable max-lines */\nimport React, { useCallback, useContext, useMemo, useState } from 'react';\nimport { useCancellableDelayedCallback } from '@elliemae/ds-utilities';\nimport PropTypes from 'prop-types';\nimport { styled, ThemeContext } from '@elliemae/ds-system';\nimport { DSPopover, PopperPositions as positions } from '@elliemae/ds-popover';\n\nconst dsTestId = 'DS-SimpleTruncateText';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;\n\nconst initialTooltipState = (value = '', options = {}) => ({\n reference: null,\n visible: false,\n value,\n options,\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 SimpleTruncatedTooltipText = (props) => {\n const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;\n // not using \"usePopoverProviderState\" because usePopoverState has memory leak issues\n const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));\n const show = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: true });\n },\n [tooltipState],\n );\n const hideTooltip = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: false });\n },\n [tooltipState],\n );\n const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);\n\n const handleMouseEnter = useCallback(\n (e) => {\n const { target } = e;\n // we search for the closest parent with data-testid matching this component\n // this is required because the target may not be this component itself\n // when the user gives JSX as a value.\n // JSX as a value is required for features like text highlight during research\n // wich would still allow the truncation behaviour (see tree view for example)\n // when the target has the test-id itself target===SimpleTruncatedTextEl\n const SimpleTruncatedTextEl = target.closest(`[data-testid=\"${dsTestId}\"]`);\n if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {\n showTooltip({ value, reference: SimpleTruncatedTextEl });\n }\n },\n [showTooltip, value],\n );\n\n const handleMouseLeave = useCallback(() => {\n cancelShowTooltip();\n hideTooltip({ reference: null });\n }, [hideTooltip, cancelShowTooltip]);\n\n const handlers = useMemo(() => {\n if (!showTooltip) return {};\n return {\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n };\n }, [showTooltip, handleMouseEnter, handleMouseLeave]);\n\n const theme = useContext(ThemeContext);\n\n const PurePopover = useMemo(\n () => (\n <>\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n style={{ pointerEvents: 'none', zIndex: zIndex ?? theme.zIndex.tooltip }}\n placement={placement}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n visible={tooltipState.visible}\n showArrow\n />\n ) : null}\n </>\n ),\n [tooltipState, placement, zIndex],\n );\n const PureText = useMemo(\n () => (\n <>\n <Text\n {...(containerProps && { ...containerProps })}\n {...(textOptions && { ...textOptions })}\n {...(handlers && { ...handlers })}\n data-testid={dsTestId} // this is used by mouse enter too. required to support value as JSX\n >\n {value}\n </Text>\n </>\n ),\n [containerProps, textOptions, handlers, value],\n );\n\n const PureSimpleTruncatedTooltipText = useMemo(\n () => (\n <>\n {PureText}\n {PurePopover}\n </>\n ),\n [PureText, PurePopover],\n );\n\n return PureSimpleTruncatedTooltipText;\n};\n\nSimpleTruncatedTooltipText.propTypes = {\n containerProps: PropTypes.object,\n tooltipOptions: PropTypes.object,\n textOptions: PropTypes.object,\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),\n /** Position of the tooltip */\n placement: 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 ]),\n /** Delay to show the tooltip */\n tooltipDelay: PropTypes.number,\n /** override default zIndex */\n zIndex: PropTypes.number,\n};\n\nSimpleTruncatedTooltipText.defaultProps = {\n containerProps: {},\n tooltipOptions: {},\n textOptions: {},\n value: '',\n placement: positions.TOP,\n tooltipDelay: 200,\n};\n\nexport { SimpleTruncatedTooltipText };\nexport default SimpleTruncatedTooltipText;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
6
|
-
"names": []
|
5
|
+
"mappings": "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",
|
6
|
+
"names": ["PropTypes", "positions"]
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var TooltipTextProvider_exports = {};
|
23
26
|
__export(TooltipTextProvider_exports, {
|
@@ -27,6 +30,7 @@ __export(TooltipTextProvider_exports, {
|
|
27
30
|
});
|
28
31
|
module.exports = __toCommonJS(TooltipTextProvider_exports);
|
29
32
|
var React = __toESM(require("react"));
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
30
34
|
var import_react = __toESM(require("react"));
|
31
35
|
var import_ds_popover = require("@elliemae/ds-popover");
|
32
36
|
const TruncatedTooltipContext = import_react.default.createContext();
|
@@ -38,24 +42,31 @@ function TooltipTextProvider({ children, tooltipDelay = 200, placement = "top",
|
|
38
42
|
state: tooltipState
|
39
43
|
} = (0, import_ds_popover.usePopoverProviderState)({ delay: tooltipDelay });
|
40
44
|
const [zIndex, setZIndex] = (0, import_react.useState)(110);
|
41
|
-
const value = (0, import_react.useMemo)(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
const value = (0, import_react.useMemo)(
|
46
|
+
() => ({
|
47
|
+
showTooltip,
|
48
|
+
hideTooltip,
|
49
|
+
setZIndex
|
50
|
+
}),
|
51
|
+
[]
|
52
|
+
);
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Provider, {
|
54
|
+
value,
|
55
|
+
children: [
|
56
|
+
children,
|
57
|
+
tooltipState.visible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_popover.DSPopover, {
|
58
|
+
boundaries: "window",
|
59
|
+
placement,
|
60
|
+
showArrow: true,
|
61
|
+
...tooltipOptions,
|
62
|
+
...tooltipState.options || {},
|
63
|
+
content: tooltipState.value,
|
64
|
+
referenceEl: tooltipState.reference,
|
65
|
+
style: { pointerEvents: "none", zIndex },
|
66
|
+
visible: tooltipState.visible
|
67
|
+
}) : null
|
68
|
+
]
|
69
|
+
});
|
59
70
|
}
|
60
71
|
TooltipTextProvider.propTypes = {};
|
61
72
|
TooltipTextProvider.defaultProps = {};
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/TooltipTextProvider.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["/* eslint-disable react/prop-types */\nimport React, { useMemo, useState } from 'react';\nimport { DSPopover, usePopoverProviderState } from '@elliemae/ds-popover';\n\nconst TruncatedTooltipContext = React.createContext();\n\nconst { Provider } = TruncatedTooltipContext;\n\nfunction TooltipTextProvider({ children, tooltipDelay = 200, placement = 'top', ...tooltipOptions }) {\n const {\n show: showTooltip,\n hide: hideTooltip,\n state: tooltipState,\n } = usePopoverProviderState({ delay: tooltipDelay });\n const [zIndex, setZIndex] = useState(110);\n\n const value = useMemo(\n () => ({\n showTooltip,\n hideTooltip,\n setZIndex,\n }),\n [],\n );\n\n return (\n <Provider value={value}>\n {children}\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n placement={placement}\n showArrow\n {...tooltipOptions}\n {...(tooltipState.options || {})}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n style={{ pointerEvents: 'none', zIndex }}\n visible={tooltipState.visible}\n />\n ) : null}\n </Provider>\n );\n}\n\nTooltipTextProvider.propTypes = {};\nTooltipTextProvider.defaultProps = {};\n\nexport { TooltipTextProvider, TruncatedTooltipContext };\nexport default TooltipTextProvider;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
6
|
-
"names": []
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAyC;AACzC,wBAAmD;AAEnD,MAAM,0BAA0B,aAAAA,QAAM,cAAc;AAEpD,MAAM,EAAE,SAAS,IAAI;AAErB,SAAS,oBAAoB,EAAE,UAAU,eAAe,KAAK,YAAY,UAAU,eAAe,GAAG;AACnG,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT,QAAI,2CAAwB,EAAE,OAAO,aAAa,CAAC;AACnD,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,GAAG;AAExC,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SACE,6CAAC;AAAA,IAAS;AAAA,IACP;AAAA;AAAA,MACA,aAAa,UACZ,4CAAC;AAAA,QACC,YAAW;AAAA,QACX;AAAA,QACA,WAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAI,aAAa,WAAW,CAAC;AAAA,QAC9B,SAAS,aAAa;AAAA,QACtB,aAAa,aAAa;AAAA,QAC1B,OAAO,EAAE,eAAe,QAAQ,OAAO;AAAA,QACvC,SAAS,aAAa;AAAA,OACxB,IACE;AAAA;AAAA,GACN;AAEJ;AAEA,oBAAoB,YAAY,CAAC;AACjC,oBAAoB,eAAe,CAAC;AAGpC,IAAO,8BAAQ;",
|
6
|
+
"names": ["React"]
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var src_exports = {};
|
23
26
|
__export(src_exports, {
|
package/dist/cjs/index.js.map
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';\nexport { DSTruncateTextWithTooltipDatatestid, DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema } from './truncateTextWithTooltip';\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAA6D;AAC7D,wCAA2C;AAC3C,oCAAgF;AAChF,qCAAoH;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var DSTruncateTextWIthTooltipDatatestid_exports = {};
|
23
26
|
__export(DSTruncateTextWIthTooltipDatatestid_exports, {
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["export const DSTruncateTextWithTooltipDatatestid = {\n TEXT: 'ds-truncatetextwithtooltip-text',\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,sCAAsC;AAAA,EACjD,MAAM;AACR;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var DSTruncateTextWithTooltip_exports = {};
|
23
26
|
__export(DSTruncateTextWithTooltip_exports, {
|
@@ -26,7 +29,8 @@ __export(DSTruncateTextWithTooltip_exports, {
|
|
26
29
|
});
|
27
30
|
module.exports = __toCommonJS(DSTruncateTextWithTooltip_exports);
|
28
31
|
var React = __toESM(require("react"));
|
29
|
-
var
|
32
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
33
|
+
var import_react = require("react");
|
30
34
|
var import_ds_tooltip = require("@elliemae/ds-tooltip");
|
31
35
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
32
36
|
var import_defaultProps = require("./defaultProps");
|
@@ -39,13 +43,16 @@ const DSTruncateTextWithTooltip = (props) => {
|
|
39
43
|
const { text, tooltipProps } = propsWithDefault;
|
40
44
|
const [textWrapperEl, setTextWrapperEl] = (0, import_react.useState)(null);
|
41
45
|
const [isShowingEllipsis, setIsShowingEllipsis] = (0, import_react.useState)(false);
|
42
|
-
const resizeObserver = (0, import_react.useMemo)(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
const resizeObserver = (0, import_react.useMemo)(
|
47
|
+
() => new ResizeObserver((entries) => {
|
48
|
+
if (entries.length) {
|
49
|
+
const [textWrapperEntry] = entries;
|
50
|
+
const el = textWrapperEntry.target;
|
51
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
52
|
+
}
|
53
|
+
}),
|
54
|
+
[]
|
55
|
+
);
|
49
56
|
(0, import_react.useEffect)(() => {
|
50
57
|
if (textWrapperEl) {
|
51
58
|
setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
|
@@ -58,18 +65,21 @@ const DSTruncateTextWithTooltip = (props) => {
|
|
58
65
|
};
|
59
66
|
}, [resizeObserver, textWrapperEl]);
|
60
67
|
if (isShowingEllipsis)
|
61
|
-
return /* @__PURE__ */
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, {
|
62
69
|
text,
|
63
|
-
...tooltipProps
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
...tooltipProps,
|
71
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Text, {
|
72
|
+
ref: setTextWrapperEl,
|
73
|
+
tabIndex: 0,
|
74
|
+
"data-testid": import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid.TEXT,
|
75
|
+
children: text
|
76
|
+
})
|
77
|
+
});
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Text, {
|
70
79
|
ref: setTextWrapperEl,
|
71
|
-
"data-testid": import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid.TEXT
|
72
|
-
|
80
|
+
"data-testid": import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid.TEXT,
|
81
|
+
children: text
|
82
|
+
});
|
73
83
|
};
|
74
84
|
const DSTruncateTextWithTooltipWithSchema = (0, import_ds_utilities.describe)(DSTruncateTextWithTooltip);
|
75
85
|
DSTruncateTextWithTooltipWithSchema.propTypes = import_propTypes.propTypes;
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/DSTruncateTextWithTooltip.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["import React, { useState, useMemo, useEffect } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-utilities';\nimport { defaultProps } from './defaultProps';\nimport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid';\nimport { propTypes } from './propTypes';\nimport { Text } from './styles';\nimport type { DSTruncateTextWithTooltipT } from './propTypes';\n\nconst DSTruncateTextWithTooltip = (props: DSTruncateTextWithTooltipT.Props): JSX.Element => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTruncateTextWithTooltipT.Props>(props, defaultProps);\n\n useValidateTypescriptPropTypes(propsWithDefault, propTypes);\n\n const { text, tooltipProps } = propsWithDefault;\n\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement | null>(null);\n const [isShowingEllipsis, setIsShowingEllipsis] = useState<boolean>(false);\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\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.TEXT}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestid.TEXT}>\n {text}\n </Text>\n );\n};\n\nconst DSTruncateTextWithTooltipWithSchema = describe<DSTruncateTextWithTooltipT.Props>(DSTruncateTextWithTooltip);\n\nDSTruncateTextWithTooltipWithSchema.propTypes = propTypes;\n\nexport { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAAoD;AACpD,wBAA4B;AAC5B,0BAAuF;AACvF,0BAA6B;AAC7B,iDAAoD;AACpD,uBAA0B;AAC1B,oBAAqB;AAGrB,MAAM,4BAA4B,CAAC,UAAyD;AAC1F,QAAM,uBAAmB,kDAA+D,OAAO,gCAAY;AAE3G,0DAA+B,kBAAkB,0BAAS;AAE1D,QAAM,EAAE,MAAM,aAAa,IAAI;AAE/B,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAiC,IAAI;AAC/E,QAAM,CAAC,mBAAmB,oBAAoB,QAAI,uBAAkB,KAAK;AAEzE,QAAM,qBAAiB;AAAA,IACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,UAAI,QAAQ,QAAQ;AAClB,cAAM,CAAC,gBAAgB,IAAI;AAC3B,cAAM,KAAK,iBAAiB;AAC5B,6BAAqB,IAAI,cAAc,IAAI,WAAW;AAAA,MACxD;AAAA,IACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,8BAAU,MAAM;AACd,QAAI,eAAe;AACjB,2BAAqB,eAAe,cAAc,eAAe,WAAW;AAC5E,qBAAe,QAAQ,aAAa;AAAA,IACtC;AACA,WAAO,MAAM;AACX,UAAI,eAAe;AACjB,uBAAe,UAAU,aAAa;AAAA,MACxC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,aAAa,CAAC;AAElC,MAAI;AACF,WACE,4CAAC;AAAA,MAAY;AAAA,MAAa,GAAG;AAAA,MAC3B,sDAAC;AAAA,QAAK,KAAK;AAAA,QAAkB,UAAU;AAAA,QAAG,eAAa,+EAAoC;AAAA,QACxF;AAAA,OACH;AAAA,KACF;AAGJ,SACE,4CAAC;AAAA,IAAK,KAAK;AAAA,IAAkB,eAAa,+EAAoC;AAAA,IAC3E;AAAA,GACH;AAEJ;AAEA,MAAM,0CAAsC,8BAA2C,yBAAyB;AAEhH,oCAAoC,YAAY;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var defaultProps_exports = {};
|
23
26
|
__export(defaultProps_exports, {
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/defaultProps.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["import type { DSTruncateTextWithTooltipT } from './propTypes';\n\nexport const defaultProps: DSTruncateTextWithTooltipT.DefaultProps = {\n tooltipProps: {},\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,MAAM,eAAwD;AAAA,EACnE,cAAc,CAAC;AACjB;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -14,7 +14,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
14
14
|
return to;
|
15
15
|
};
|
16
16
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
18
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
19
|
+
mod
|
20
|
+
));
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
22
|
var truncateTextWithTooltip_exports = {};
|
20
23
|
module.exports = __toCommonJS(truncateTextWithTooltip_exports);
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["export * from './DSTruncateTextWithTooltip';\nexport * from './DSTruncateTextWIthTooltipDatatestid';\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;ADAvB,4CAAc,wCAAd;AACA,4CAAc,kDADd;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var propTypes_exports = {};
|
23
26
|
__export(propTypes_exports, {
|
@@ -28,6 +31,8 @@ var React = __toESM(require("react"));
|
|
28
31
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
29
32
|
const propTypes = {
|
30
33
|
text: import_ds_utilities.PropTypes.string.description("Text to show.").isRequired,
|
31
|
-
tooltipProps: import_ds_utilities.PropTypes.object.description(
|
34
|
+
tooltipProps: import_ds_utilities.PropTypes.object.description(
|
35
|
+
"This component uses DSTooltip component, you can set properties directly to this component with this property."
|
36
|
+
).defaultValue({})
|
32
37
|
};
|
33
38
|
//# sourceMappingURL=propTypes.js.map
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/propTypes.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["/* eslint-disable max-len */\nimport { PropTypes } from '@elliemae/ds-utilities';\n\nexport declare namespace DSTruncateTextWithTooltipT {\n export interface PropsRequired {\n text: string;\n }\n\n export interface DefaultProps {\n tooltipProps: Record<string, unknown>;\n }\n\n export interface Props extends DefaultProps, PropsRequired {}\n}\n\nexport const propTypes = {\n text: PropTypes.string.description('Text to show.').isRequired,\n tooltipProps: PropTypes.object\n .description(\n 'This component uses DSTooltip component, you can set properties directly to this component with this property.',\n )\n .defaultValue({}),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,0BAA0B;AAcnB,MAAM,YAAY;AAAA,EACvB,MAAM,8BAAU,OAAO,YAAY,eAAe,EAAE;AAAA,EACpD,cAAc,8BAAU,OACrB;AAAA,IACC;AAAA,EACF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
22
25
|
var styles_exports = {};
|
23
26
|
__export(styles_exports, {
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/truncateTextWithTooltip/styles.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
4
|
"sourcesContent": ["import { styled } from '@elliemae/ds-system';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nexport const 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: ${({ theme }) => theme.colors.brand[200]};\n }\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAuB;AAGhB,MAAM,OAAO,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
3
|
+
import { useContext, useEffect } from "react";
|
3
4
|
import { describe, PropTypes } from "@elliemae/ds-utilities";
|
4
5
|
import { styled } from "@elliemae/ds-system";
|
5
6
|
import { PopperPositions as positions } from "@elliemae/ds-popper";
|
@@ -29,21 +30,25 @@ const DSTruncatedTooltipText = ({
|
|
29
30
|
const handleMouseEnter = (e) => {
|
30
31
|
const { target } = e;
|
31
32
|
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
32
|
-
showTooltip(
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
showTooltip(
|
34
|
+
{
|
35
|
+
value,
|
36
|
+
reference: target
|
37
|
+
},
|
38
|
+
e
|
39
|
+
);
|
36
40
|
}
|
37
41
|
};
|
38
42
|
const handleMouseLeave = (e) => {
|
39
43
|
hideTooltip({ reference: e.target });
|
40
44
|
};
|
41
45
|
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
42
|
-
return /* @__PURE__ */
|
46
|
+
return /* @__PURE__ */ jsx(Text, {
|
43
47
|
...containerProps,
|
44
48
|
...otherTextProps,
|
45
|
-
...handlers
|
46
|
-
|
49
|
+
...handlers,
|
50
|
+
children: value
|
51
|
+
});
|
47
52
|
};
|
48
53
|
DSTruncatedTooltipText.defaultProps = {
|
49
54
|
value: "",
|
@@ -51,7 +56,9 @@ DSTruncatedTooltipText.defaultProps = {
|
|
51
56
|
};
|
52
57
|
const truncatedTooltipTextProps = {
|
53
58
|
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
54
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(
|
59
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(
|
60
|
+
"Text that when truncated will trigger the tooltip interaction"
|
61
|
+
),
|
55
62
|
tooltipPlacement: PropTypes.oneOf([
|
56
63
|
positions.AUTO_START,
|
57
64
|
positions.AUTO_END,
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncatedTooltipText.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-utilities';\nimport { styled } from '@elliemae/ds-system';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => 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 = 3000, // https://jira.elliemae.io/browse/PUI-1755 https://jira.elliemae.io/browse/PUI-8732\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 ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};\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('Set of Properties attached to the main container'),\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.description('override default zIndex').defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\nDSTruncatedTooltipText.displayName = 'DSTruncatedTooltipText';\nconst TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);\nTruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;\n\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };\nexport default DSTruncatedTooltipText;\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,YAAY,iBAAiB;AAC7C,SAAS,UAAU,iBAAiB;AACpC,SAAS,cAAc;AACvB,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,+BAA+B;AAExC,MAAM,mBAAmB,CAAC,EAAE,aAAa,YAAY,MAAM,cAAc;AAGzE,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,yBAAyB,CAAC;AAAA,EAC9B,iBAAiB,CAAC;AAAA,EAClB,QAAQ;AAAA,EACR,SAAS;AAAA,KACN;AACL,MAAM;AACJ,QAAM,iBAAiB,WAAW,uBAAuB;AACzD,YAAU,MAAM;AACd,QAAI,UAAU;AAAgB,qBAAe,UAAU,MAAM;AAAA,EAC/D,GAAG,CAAC,MAAM,CAAC;AAEX,MAAI,CAAC;AAAgB,WAAO;AAE5B,QAAM,EAAE,aAAa,YAAY,IAAI;AAErC,QAAM,mBAAmB,CAAC,MAAM;AAC9B,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,UAAU,iBAAiB,QAAQ,OAAO,sBAAsB,CAAC,GAAG;AACtE;AAAA,QACE;AAAA,UACE;AAAA,UACA,WAAW;AAAA,QACb;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,mBAAmB,CAAC,MAAM;AAC9B,gBAAY,EAAE,WAAW,EAAE,OAAO,CAAC;AAAA,EACrC;AAEA,QAAM,WAAW,cAAc,EAAE,cAAc,kBAAkB,cAAc,iBAAiB,IAAI,CAAC;AACrG,SACE,oBAAC;AAAA,IAAM,GAAG;AAAA,IAAiB,GAAG;AAAA,IAAiB,GAAG;AAAA,IAC/C;AAAA,GACH;AAEJ;AAEA,uBAAuB,eAAe;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ;AACV;AAEA,MAAM,4BAA4B;AAAA,EAChC,gBAAgB,UAAU,OAAO,YAAY,kDAAkD;AAAA,EAC/F,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC,EAAE;AAAA,IAC/D;AAAA,EACF;AAAA,EACA,kBAAkB,UAAU,MAAM;AAAA,IAChC,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC,EAAE,YAAY,yBAAyB;AAAA,EACxC,cAAc,UAAU,OAAO,YAAY,2BAA2B;AAAA,EACtE,QAAQ,UAAU,OAAO,YAAY,yBAAyB,EAAE,aAAa,GAAG;AAClF;AAEA,uBAAuB,eAAe;AAAA,EACpC,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAChB;AAEA,uBAAuB,YAAY;AACnC,uBAAuB,cAAc;AACrC,MAAM,iCAAiC,SAAS,sBAAsB;AACtE,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import { useCallback, useContext, useMemo, useState } from "react";
|
3
4
|
import { useCancellableDelayedCallback } from "@elliemae/ds-utilities";
|
4
5
|
import PropTypes from "prop-types";
|
5
6
|
import { styled, ThemeContext } from "@elliemae/ds-system";
|
@@ -22,20 +23,29 @@ const Text = styled.span`
|
|
22
23
|
const SimpleTruncatedTooltipText = (props) => {
|
23
24
|
const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
|
24
25
|
const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
|
25
|
-
const show = useCallback(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
const show = useCallback(
|
27
|
+
(newState) => {
|
28
|
+
setTooltipState({ ...tooltipState, ...newState, visible: true });
|
29
|
+
},
|
30
|
+
[tooltipState]
|
31
|
+
);
|
32
|
+
const hideTooltip = useCallback(
|
33
|
+
(newState) => {
|
34
|
+
setTooltipState({ ...tooltipState, ...newState, visible: false });
|
35
|
+
},
|
36
|
+
[tooltipState]
|
37
|
+
);
|
31
38
|
const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
|
32
|
-
const handleMouseEnter = useCallback(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
const handleMouseEnter = useCallback(
|
40
|
+
(e) => {
|
41
|
+
const { target } = e;
|
42
|
+
const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
|
43
|
+
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
44
|
+
showTooltip({ value, reference: SimpleTruncatedTextEl });
|
45
|
+
}
|
46
|
+
},
|
47
|
+
[showTooltip, value]
|
48
|
+
);
|
39
49
|
const handleMouseLeave = useCallback(() => {
|
40
50
|
cancelShowTooltip();
|
41
51
|
hideTooltip({ reference: null });
|
@@ -49,22 +59,41 @@ const SimpleTruncatedTooltipText = (props) => {
|
|
49
59
|
};
|
50
60
|
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
51
61
|
const theme = useContext(ThemeContext);
|
52
|
-
const PurePopover = useMemo(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
const PurePopover = useMemo(
|
63
|
+
() => /* @__PURE__ */ jsx(Fragment, {
|
64
|
+
children: tooltipState.visible ? /* @__PURE__ */ jsx(DSPopover, {
|
65
|
+
boundaries: "window",
|
66
|
+
style: { pointerEvents: "none", zIndex: zIndex ?? theme.zIndex.tooltip },
|
67
|
+
placement,
|
68
|
+
content: tooltipState.value,
|
69
|
+
referenceEl: tooltipState.reference,
|
70
|
+
visible: tooltipState.visible,
|
71
|
+
showArrow: true
|
72
|
+
}) : null
|
73
|
+
}),
|
74
|
+
[tooltipState, placement, zIndex]
|
75
|
+
);
|
76
|
+
const PureText = useMemo(
|
77
|
+
() => /* @__PURE__ */ jsx(Fragment, {
|
78
|
+
children: /* @__PURE__ */ jsx(Text, {
|
79
|
+
...containerProps && { ...containerProps },
|
80
|
+
...textOptions && { ...textOptions },
|
81
|
+
...handlers && { ...handlers },
|
82
|
+
"data-testid": dsTestId,
|
83
|
+
children: value
|
84
|
+
})
|
85
|
+
}),
|
86
|
+
[containerProps, textOptions, handlers, value]
|
87
|
+
);
|
88
|
+
const PureSimpleTruncatedTooltipText = useMemo(
|
89
|
+
() => /* @__PURE__ */ jsxs(Fragment, {
|
90
|
+
children: [
|
91
|
+
PureText,
|
92
|
+
PurePopover
|
93
|
+
]
|
94
|
+
}),
|
95
|
+
[PureText, PurePopover]
|
96
|
+
);
|
68
97
|
return PureSimpleTruncatedTooltipText;
|
69
98
|
};
|
70
99
|
SimpleTruncatedTooltipText.propTypes = {
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/SimpleTruncatedTooltipText.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useCallback, useContext, useMemo, useState } from 'react';\nimport { useCancellableDelayedCallback } from '@elliemae/ds-utilities';\nimport PropTypes from 'prop-types';\nimport { styled, ThemeContext } from '@elliemae/ds-system';\nimport { DSPopover, PopperPositions as positions } from '@elliemae/ds-popover';\n\nconst dsTestId = 'DS-SimpleTruncateText';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;\n\nconst initialTooltipState = (value = '', options = {}) => ({\n reference: null,\n visible: false,\n value,\n options,\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 SimpleTruncatedTooltipText = (props) => {\n const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;\n // not using \"usePopoverProviderState\" because usePopoverState has memory leak issues\n const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));\n const show = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: true });\n },\n [tooltipState],\n );\n const hideTooltip = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: false });\n },\n [tooltipState],\n );\n const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);\n\n const handleMouseEnter = useCallback(\n (e) => {\n const { target } = e;\n // we search for the closest parent with data-testid matching this component\n // this is required because the target may not be this component itself\n // when the user gives JSX as a value.\n // JSX as a value is required for features like text highlight during research\n // wich would still allow the truncation behaviour (see tree view for example)\n // when the target has the test-id itself target===SimpleTruncatedTextEl\n const SimpleTruncatedTextEl = target.closest(`[data-testid=\"${dsTestId}\"]`);\n if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {\n showTooltip({ value, reference: SimpleTruncatedTextEl });\n }\n },\n [showTooltip, value],\n );\n\n const handleMouseLeave = useCallback(() => {\n cancelShowTooltip();\n hideTooltip({ reference: null });\n }, [hideTooltip, cancelShowTooltip]);\n\n const handlers = useMemo(() => {\n if (!showTooltip) return {};\n return {\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n };\n }, [showTooltip, handleMouseEnter, handleMouseLeave]);\n\n const theme = useContext(ThemeContext);\n\n const PurePopover = useMemo(\n () => (\n <>\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n style={{ pointerEvents: 'none', zIndex: zIndex ?? theme.zIndex.tooltip }}\n placement={placement}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n visible={tooltipState.visible}\n showArrow\n />\n ) : null}\n </>\n ),\n [tooltipState, placement, zIndex],\n );\n const PureText = useMemo(\n () => (\n <>\n <Text\n {...(containerProps && { ...containerProps })}\n {...(textOptions && { ...textOptions })}\n {...(handlers && { ...handlers })}\n data-testid={dsTestId} // this is used by mouse enter too. required to support value as JSX\n >\n {value}\n </Text>\n </>\n ),\n [containerProps, textOptions, handlers, value],\n );\n\n const PureSimpleTruncatedTooltipText = useMemo(\n () => (\n <>\n {PureText}\n {PurePopover}\n </>\n ),\n [PureText, PurePopover],\n );\n\n return PureSimpleTruncatedTooltipText;\n};\n\nSimpleTruncatedTooltipText.propTypes = {\n containerProps: PropTypes.object,\n tooltipOptions: PropTypes.object,\n textOptions: PropTypes.object,\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),\n /** Position of the tooltip */\n placement: 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 ]),\n /** Delay to show the tooltip */\n tooltipDelay: PropTypes.number,\n /** override default zIndex */\n zIndex: PropTypes.number,\n};\n\nSimpleTruncatedTooltipText.defaultProps = {\n containerProps: {},\n tooltipOptions: {},\n textOptions: {},\n value: '',\n placement: positions.TOP,\n tooltipDelay: 200,\n};\n\nexport { SimpleTruncatedTooltipText };\nexport default SimpleTruncatedTooltipText;\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "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",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
2
3
|
import React2, { useMemo, useState } from "react";
|
3
4
|
import { DSPopover, usePopoverProviderState } from "@elliemae/ds-popover";
|
4
5
|
const TruncatedTooltipContext = React2.createContext();
|
@@ -10,24 +11,31 @@ function TooltipTextProvider({ children, tooltipDelay = 200, placement = "top",
|
|
10
11
|
state: tooltipState
|
11
12
|
} = usePopoverProviderState({ delay: tooltipDelay });
|
12
13
|
const [zIndex, setZIndex] = useState(110);
|
13
|
-
const value = useMemo(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
const value = useMemo(
|
15
|
+
() => ({
|
16
|
+
showTooltip,
|
17
|
+
hideTooltip,
|
18
|
+
setZIndex
|
19
|
+
}),
|
20
|
+
[]
|
21
|
+
);
|
22
|
+
return /* @__PURE__ */ jsxs(Provider, {
|
23
|
+
value,
|
24
|
+
children: [
|
25
|
+
children,
|
26
|
+
tooltipState.visible ? /* @__PURE__ */ jsx(DSPopover, {
|
27
|
+
boundaries: "window",
|
28
|
+
placement,
|
29
|
+
showArrow: true,
|
30
|
+
...tooltipOptions,
|
31
|
+
...tooltipState.options || {},
|
32
|
+
content: tooltipState.value,
|
33
|
+
referenceEl: tooltipState.reference,
|
34
|
+
style: { pointerEvents: "none", zIndex },
|
35
|
+
visible: tooltipState.visible
|
36
|
+
}) : null
|
37
|
+
]
|
38
|
+
});
|
31
39
|
}
|
32
40
|
TooltipTextProvider.propTypes = {};
|
33
41
|
TooltipTextProvider.defaultProps = {};
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TooltipTextProvider.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useMemo, useState } from 'react';\nimport { DSPopover, usePopoverProviderState } from '@elliemae/ds-popover';\n\nconst TruncatedTooltipContext = React.createContext();\n\nconst { Provider } = TruncatedTooltipContext;\n\nfunction TooltipTextProvider({ children, tooltipDelay = 200, placement = 'top', ...tooltipOptions }) {\n const {\n show: showTooltip,\n hide: hideTooltip,\n state: tooltipState,\n } = usePopoverProviderState({ delay: tooltipDelay });\n const [zIndex, setZIndex] = useState(110);\n\n const value = useMemo(\n () => ({\n showTooltip,\n hideTooltip,\n setZIndex,\n }),\n [],\n );\n\n return (\n <Provider value={value}>\n {children}\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n placement={placement}\n showArrow\n {...tooltipOptions}\n {...(tooltipState.options || {})}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n style={{ pointerEvents: 'none', zIndex }}\n visible={tooltipState.visible}\n />\n ) : null}\n </Provider>\n );\n}\n\nTooltipTextProvider.propTypes = {};\nTooltipTextProvider.defaultProps = {};\n\nexport { TooltipTextProvider, TruncatedTooltipContext };\nexport default TooltipTextProvider;\n"],
|
5
|
-
"mappings": "AAAA;
|
6
|
-
"names": []
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,OAAOA,UAAS,SAAS,gBAAgB;AACzC,SAAS,WAAW,+BAA+B;AAEnD,MAAM,0BAA0BA,OAAM,cAAc;AAEpD,MAAM,EAAE,SAAS,IAAI;AAErB,SAAS,oBAAoB,EAAE,UAAU,eAAe,KAAK,YAAY,UAAU,eAAe,GAAG;AACnG,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT,IAAI,wBAAwB,EAAE,OAAO,aAAa,CAAC;AACnD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,GAAG;AAExC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SACE,qBAAC;AAAA,IAAS;AAAA,IACP;AAAA;AAAA,MACA,aAAa,UACZ,oBAAC;AAAA,QACC,YAAW;AAAA,QACX;AAAA,QACA,WAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAI,aAAa,WAAW,CAAC;AAAA,QAC9B,SAAS,aAAa;AAAA,QACtB,aAAa,aAAa;AAAA,QAC1B,OAAO,EAAE,eAAe,QAAQ,OAAO;AAAA,QACvC,SAAS,aAAa;AAAA,OACxB,IACE;AAAA;AAAA,GACN;AAEJ;AAEA,oBAAoB,YAAY,CAAC;AACjC,oBAAoB,eAAe,CAAC;AAGpC,IAAO,8BAAQ;",
|
6
|
+
"names": ["React"]
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';\nexport { DSTruncateTextWithTooltipDatatestid, DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema } from './truncateTextWithTooltip';\n"],
|
5
|
-
"mappings": "AAAA;
|
6
|
-
"names": []
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB,+BAA+B;AAC7D,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB,gCAAgC,WAAAA,gBAAe;AAChF,SAAS,qCAAqC,2BAA2B,2CAA2C;",
|
6
|
+
"names": ["default"]
|
7
7
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DSTruncateTextWithTooltipDatatestid = {\n TEXT: 'ds-truncatetextwithtooltip-text',\n};\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,sCAAsC;AAAA,EACjD,MAAM;AACR;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
3
|
+
import { useState, useMemo, useEffect } from "react";
|
3
4
|
import { DSTooltipV3 } from "@elliemae/ds-tooltip";
|
4
5
|
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from "@elliemae/ds-utilities";
|
5
6
|
import { defaultProps } from "./defaultProps";
|
@@ -12,13 +13,16 @@ const DSTruncateTextWithTooltip = (props) => {
|
|
12
13
|
const { text, tooltipProps } = propsWithDefault;
|
13
14
|
const [textWrapperEl, setTextWrapperEl] = useState(null);
|
14
15
|
const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
|
15
|
-
const resizeObserver = useMemo(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
const resizeObserver = useMemo(
|
17
|
+
() => new ResizeObserver((entries) => {
|
18
|
+
if (entries.length) {
|
19
|
+
const [textWrapperEntry] = entries;
|
20
|
+
const el = textWrapperEntry.target;
|
21
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
22
|
+
}
|
23
|
+
}),
|
24
|
+
[]
|
25
|
+
);
|
22
26
|
useEffect(() => {
|
23
27
|
if (textWrapperEl) {
|
24
28
|
setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
|
@@ -31,18 +35,21 @@ const DSTruncateTextWithTooltip = (props) => {
|
|
31
35
|
};
|
32
36
|
}, [resizeObserver, textWrapperEl]);
|
33
37
|
if (isShowingEllipsis)
|
34
|
-
return /* @__PURE__ */
|
38
|
+
return /* @__PURE__ */ jsx(DSTooltipV3, {
|
35
39
|
text,
|
36
|
-
...tooltipProps
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
...tooltipProps,
|
41
|
+
children: /* @__PURE__ */ jsx(Text, {
|
42
|
+
ref: setTextWrapperEl,
|
43
|
+
tabIndex: 0,
|
44
|
+
"data-testid": DSTruncateTextWithTooltipDatatestid.TEXT,
|
45
|
+
children: text
|
46
|
+
})
|
47
|
+
});
|
48
|
+
return /* @__PURE__ */ jsx(Text, {
|
43
49
|
ref: setTextWrapperEl,
|
44
|
-
"data-testid": DSTruncateTextWithTooltipDatatestid.TEXT
|
45
|
-
|
50
|
+
"data-testid": DSTruncateTextWithTooltipDatatestid.TEXT,
|
51
|
+
children: text
|
52
|
+
});
|
46
53
|
};
|
47
54
|
const DSTruncateTextWithTooltipWithSchema = describe(DSTruncateTextWithTooltip);
|
48
55
|
DSTruncateTextWithTooltipWithSchema.propTypes = propTypes;
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/DSTruncateTextWithTooltip.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useMemo, useEffect } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-utilities';\nimport { defaultProps } from './defaultProps';\nimport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid';\nimport { propTypes } from './propTypes';\nimport { Text } from './styles';\nimport type { DSTruncateTextWithTooltipT } from './propTypes';\n\nconst DSTruncateTextWithTooltip = (props: DSTruncateTextWithTooltipT.Props): JSX.Element => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTruncateTextWithTooltipT.Props>(props, defaultProps);\n\n useValidateTypescriptPropTypes(propsWithDefault, propTypes);\n\n const { text, tooltipProps } = propsWithDefault;\n\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement | null>(null);\n const [isShowingEllipsis, setIsShowingEllipsis] = useState<boolean>(false);\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\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.TEXT}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestid.TEXT}>\n {text}\n </Text>\n );\n};\n\nconst DSTruncateTextWithTooltipWithSchema = describe<DSTruncateTextWithTooltipT.Props>(DSTruncateTextWithTooltip);\n\nDSTruncateTextWithTooltipWithSchema.propTypes = propTypes;\n\nexport { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema };\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,SAAgB,UAAU,SAAS,iBAAiB;AACpD,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B,gCAAgC,gBAAgB;AACvF,SAAS,oBAAoB;AAC7B,SAAS,2CAA2C;AACpD,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAGrB,MAAM,4BAA4B,CAAC,UAAyD;AAC1F,QAAM,mBAAmB,6BAA+D,OAAO,YAAY;AAE3G,iCAA+B,kBAAkB,SAAS;AAE1D,QAAM,EAAE,MAAM,aAAa,IAAI;AAE/B,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiC,IAAI;AAC/E,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAkB,KAAK;AAEzE,QAAM,iBAAiB;AAAA,IACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,UAAI,QAAQ,QAAQ;AAClB,cAAM,CAAC,gBAAgB,IAAI;AAC3B,cAAM,KAAK,iBAAiB;AAC5B,6BAAqB,IAAI,cAAc,IAAI,WAAW;AAAA,MACxD;AAAA,IACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,2BAAqB,eAAe,cAAc,eAAe,WAAW;AAC5E,qBAAe,QAAQ,aAAa;AAAA,IACtC;AACA,WAAO,MAAM;AACX,UAAI,eAAe;AACjB,uBAAe,UAAU,aAAa;AAAA,MACxC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,aAAa,CAAC;AAElC,MAAI;AACF,WACE,oBAAC;AAAA,MAAY;AAAA,MAAa,GAAG;AAAA,MAC3B,8BAAC;AAAA,QAAK,KAAK;AAAA,QAAkB,UAAU;AAAA,QAAG,eAAa,oCAAoC;AAAA,QACxF;AAAA,OACH;AAAA,KACF;AAGJ,SACE,oBAAC;AAAA,IAAK,KAAK;AAAA,IAAkB,eAAa,oCAAoC;AAAA,IAC3E;AAAA,GACH;AAEJ;AAEA,MAAM,sCAAsC,SAA2C,yBAAyB;AAEhH,oCAAoC,YAAY;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/defaultProps.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSTruncateTextWithTooltipT } from './propTypes';\n\nexport const defaultProps: DSTruncateTextWithTooltipT.DefaultProps = {\n tooltipProps: {},\n};\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,eAAwD;AAAA,EACnE,cAAc,CAAC;AACjB;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/index.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSTruncateTextWithTooltip';\nexport * from './DSTruncateTextWIthTooltipDatatestid';\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,cAAc;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -2,7 +2,9 @@ import * as React from "react";
|
|
2
2
|
import { PropTypes } from "@elliemae/ds-utilities";
|
3
3
|
const propTypes = {
|
4
4
|
text: PropTypes.string.description("Text to show.").isRequired,
|
5
|
-
tooltipProps: PropTypes.object.description(
|
5
|
+
tooltipProps: PropTypes.object.description(
|
6
|
+
"This component uses DSTooltip component, you can set properties directly to this component with this property."
|
7
|
+
).defaultValue({})
|
6
8
|
};
|
7
9
|
export {
|
8
10
|
propTypes
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/propTypes.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-len */\nimport { PropTypes } from '@elliemae/ds-utilities';\n\nexport declare namespace DSTruncateTextWithTooltipT {\n export interface PropsRequired {\n text: string;\n }\n\n export interface DefaultProps {\n tooltipProps: Record<string, unknown>;\n }\n\n export interface Props extends DefaultProps, PropsRequired {}\n}\n\nexport const propTypes = {\n text: PropTypes.string.description('Text to show.').isRequired,\n tooltipProps: PropTypes.object\n .description(\n 'This component uses DSTooltip component, you can set properties directly to this component with this property.',\n )\n .defaultValue({}),\n};\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,iBAAiB;AAcnB,MAAM,YAAY;AAAA,EACvB,MAAM,UAAU,OAAO,YAAY,eAAe,EAAE;AAAA,EACpD,cAAc,UAAU,OACrB;AAAA,IACC;AAAA,EACF,EACC,aAAa,CAAC,CAAC;AACpB;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/styles.tsx"],
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nexport const 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: ${({ theme }) => theme.colors.brand[200]};\n }\n`;\n"],
|
5
|
-
"mappings": "AAAA;
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,cAAc;AAGhB,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-truncated-tooltip-text",
|
3
|
-
"version": "3.4.
|
3
|
+
"version": "3.4.4-next.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Truncated Tooltip Text",
|
6
6
|
"files": [
|
@@ -51,11 +51,11 @@
|
|
51
51
|
"indent": 4
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@elliemae/ds-popover": "3.4.
|
55
|
-
"@elliemae/ds-popper": "3.4.
|
56
|
-
"@elliemae/ds-system": "3.4.
|
57
|
-
"@elliemae/ds-tooltip": "3.4.
|
58
|
-
"@elliemae/ds-utilities": "3.4.
|
54
|
+
"@elliemae/ds-popover": "3.4.4-next.0",
|
55
|
+
"@elliemae/ds-popper": "3.4.4-next.0",
|
56
|
+
"@elliemae/ds-system": "3.4.4-next.0",
|
57
|
+
"@elliemae/ds-tooltip": "3.4.4-next.0",
|
58
|
+
"@elliemae/ds-utilities": "3.4.4-next.0",
|
59
59
|
"prop-types": "~15.8.1"
|
60
60
|
},
|
61
61
|
"devDependencies": {
|