@elliemae/ds-truncated-tooltip-text 2.2.0 → 2.3.0-alpha.3
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/index.d.ts +4 -5
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncateTextWithTooltip.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAGA,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBASF,CAAC,UAAU,MAAM,MAAM,OAAO,MAAM;AAAA;AAAA;AAO/C,MAAM,sCAAsC;AAC5C,MAAM,4BAA4B,CAAC,EAAE,MAAM,eAAe,SAA8B;AAC7F,QAAM,CAAC,eAAe,oBAAoB;AAE1C,QAAM,CAAC,mBAAmB,wBAAwB,SAAS;AAG3D,QAAM,iBAAiB,QACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,QAAI,QAAQ,QAAQ;AAClB,YAAM,CAAC,oBAAoB;AAC3B,YAAM,KAAK,iBAAiB;AAC5B,2BAAqB,IAAI,cAAc,IAAI;AAAA;AAAA,MAGjD;AAEF,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,2BAAqB,eAAe,cAAc,eAAe;AACjE,qBAAe,QAAQ;AAAA;AAEzB,WAAO,MAAM;AACX,UAAI,eAAe;AACjB,uBAAe,UAAU;AAAA;AAAA;AAAA,KAG5B,CAAC,gBAAgB;AAEpB,MAAI;AACF,WACE,qCAAC,aAAD;AAAA,MAAa;AAAA,SAAgB;AAAA,OAC3B,qCAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa;AAAA,OACpD;AAKT,SACE,qCAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa;AAAA,KACvC;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,59 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const isEllipsisActive = _ref => {
|
|
22
|
-
let {
|
|
23
|
-
offsetWidth,
|
|
24
|
-
scrollWidth
|
|
25
|
-
} = _ref;
|
|
26
|
-
return offsetWidth < scrollWidth;
|
|
27
|
-
}; // reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const Text = /*#__PURE__*/styled.span.withConfig({
|
|
31
|
-
componentId: "sc-1olo1o7-0"
|
|
32
|
-
})(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
|
|
33
|
-
|
|
34
|
-
const DSTruncatedTooltipText = _ref2 => {
|
|
35
|
-
let {
|
|
36
|
-
containerProps = {},
|
|
37
|
-
value = '',
|
|
38
|
-
zIndex = 110
|
|
39
|
-
} = _ref2,
|
|
40
|
-
otherTextProps = _objectWithoutProperties(_ref2, _excluded);
|
|
41
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useContext, useEffect } from "react";
|
|
3
|
+
import { describe, PropTypes } from "react-desc";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { PopperPositions as positions } from "@elliemae/ds-popper";
|
|
6
|
+
import { TruncatedTooltipContext } from "./TooltipTextProvider";
|
|
7
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
|
8
|
+
const Text = styled.span`
|
|
9
|
+
text-overflow: ellipsis;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
`;
|
|
15
|
+
const DSTruncatedTooltipText = ({
|
|
16
|
+
containerProps = {},
|
|
17
|
+
value = "",
|
|
18
|
+
zIndex = 110,
|
|
19
|
+
...otherTextProps
|
|
20
|
+
}) => {
|
|
42
21
|
const tooltipContext = useContext(TruncatedTooltipContext);
|
|
43
22
|
useEffect(() => {
|
|
44
|
-
if (zIndex && tooltipContext)
|
|
23
|
+
if (zIndex && tooltipContext)
|
|
24
|
+
tooltipContext.setZIndex(zIndex);
|
|
45
25
|
}, [zIndex]);
|
|
46
|
-
if (!tooltipContext)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const handleMouseEnter = e => {
|
|
53
|
-
const {
|
|
54
|
-
target
|
|
55
|
-
} = e;
|
|
56
|
-
|
|
26
|
+
if (!tooltipContext)
|
|
27
|
+
return value;
|
|
28
|
+
const { showTooltip, hideTooltip } = tooltipContext;
|
|
29
|
+
const handleMouseEnter = (e) => {
|
|
30
|
+
const { target } = e;
|
|
57
31
|
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
|
58
32
|
showTooltip({
|
|
59
33
|
value,
|
|
@@ -61,40 +35,56 @@ const DSTruncatedTooltipText = _ref2 => {
|
|
|
61
35
|
}, e);
|
|
62
36
|
}
|
|
63
37
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
hideTooltip({
|
|
67
|
-
reference: e.target
|
|
68
|
-
});
|
|
38
|
+
const handleMouseLeave = (e) => {
|
|
39
|
+
hideTooltip({ reference: e.target });
|
|
69
40
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
children: value
|
|
77
|
-
}));
|
|
41
|
+
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
|
42
|
+
return /* @__PURE__ */ React2.createElement(Text, {
|
|
43
|
+
...containerProps,
|
|
44
|
+
...otherTextProps,
|
|
45
|
+
...handlers
|
|
46
|
+
}, value);
|
|
78
47
|
};
|
|
79
|
-
|
|
80
48
|
DSTruncatedTooltipText.defaultProps = {
|
|
81
|
-
value:
|
|
49
|
+
value: "",
|
|
82
50
|
zIndex: 110
|
|
83
51
|
};
|
|
84
52
|
const truncatedTooltipTextProps = {
|
|
85
|
-
containerProps: PropTypes.object.description(
|
|
86
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(
|
|
87
|
-
tooltipPlacement: PropTypes.oneOf([
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
|
54
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description("Text that when truncated will trigger the tooltip interaction"),
|
|
55
|
+
tooltipPlacement: PropTypes.oneOf([
|
|
56
|
+
positions.AUTO_START,
|
|
57
|
+
positions.AUTO_END,
|
|
58
|
+
positions.AUTO,
|
|
59
|
+
positions.TOP_START,
|
|
60
|
+
positions.TOP,
|
|
61
|
+
positions.TOP_END,
|
|
62
|
+
positions.RIGHT_START,
|
|
63
|
+
positions.RIGHT,
|
|
64
|
+
positions.RIGHT_END,
|
|
65
|
+
positions.BOTTOM_START,
|
|
66
|
+
positions.BOTTOM,
|
|
67
|
+
positions.BOTTOM_END,
|
|
68
|
+
positions.LEFT_START,
|
|
69
|
+
positions.LEFT,
|
|
70
|
+
positions.LEFT_END
|
|
71
|
+
]).description("Position of the tooltip"),
|
|
72
|
+
tooltipDelay: PropTypes.number.description("Delay to show the tooltip"),
|
|
73
|
+
zIndex: PropTypes.number.description("override default zIndex").defaultValue(110)
|
|
90
74
|
};
|
|
91
75
|
DSTruncatedTooltipText.defaultProps = {
|
|
92
76
|
containerProps: {},
|
|
93
|
-
value:
|
|
94
|
-
tooltipPlacement:
|
|
95
|
-
tooltipDelay:
|
|
77
|
+
value: "",
|
|
78
|
+
tooltipPlacement: void 0,
|
|
79
|
+
tooltipDelay: void 0
|
|
96
80
|
};
|
|
81
|
+
DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
|
|
97
82
|
const TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);
|
|
98
83
|
TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
|
|
99
|
-
|
|
100
|
-
export {
|
|
84
|
+
var DSTruncatedTooltipText_default = DSTruncatedTooltipText;
|
|
85
|
+
export {
|
|
86
|
+
DSTruncatedTooltipText,
|
|
87
|
+
TruncatedTooltipTextWithSchema,
|
|
88
|
+
DSTruncatedTooltipText_default as default
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=DSTruncatedTooltipText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncatedTooltipText.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAEA,MAAM,mBAAmB,CAAC,EAAE,aAAa,kBACvC,cAAc;AAGhB,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,yBAAyB,CAAC;AAAA,EAC9B,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,SAAS;AAAA,KACN;AAAA,MACC;AACJ,QAAM,iBAAiB,WAAW;AAClC,YAAU,MAAM;AACd,QAAI,UAAU;AAAgB,qBAAe,UAAU;AAAA,KACtD,CAAC;AAEJ,MAAI,CAAC;AAAgB,WAAO;AAE5B,QAAM,EAAE,aAAa,gBAAgB;AAErC,QAAM,mBAAmB,CAAC,MAAM;AAC9B,UAAM,EAAE,WAAW;AACnB,QAAI,UAAU,iBAAiB,QAAQ,OAAO,0BAA0B;AACtE,kBACE;AAAA,QACE;AAAA,QACA,WAAW;AAAA,SAEb;AAAA;AAAA;AAKN,QAAM,mBAAmB,CAAC,MAAM;AAC9B,gBAAY,EAAE,WAAW,EAAE;AAAA;AAG7B,QAAM,WAAW,cACb,EAAE,cAAc,kBAAkB,cAAc,qBAChD;AACJ,SACE,qCAAC,MAAD;AAAA,OAAU;AAAA,OAAoB;AAAA,OAAoB;AAAA,KAC/C;AAAA;AAKP,uBAAuB,eAAe;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ;AAAA;AAGV,MAAM,4BAA4B;AAAA,EAChC,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAEF,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,SAAS,YAC/D;AAAA,EAEF,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,KACT,YAAY;AAAA,EACf,cAAc,UAAU,OAAO,YAAY;AAAA,EAC3C,QAAQ,UAAU,OACf,YAAY,2BACZ,aAAa;AAAA;AAGlB,uBAAuB,eAAe;AAAA,EACpC,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAAA;AAGhB,uBAAuB,YAAY;AAEnC,MAAM,iCAAiC,SAAS;AAChD,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,136 +1,108 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} = _ref;
|
|
25
|
-
return offsetWidth < scrollWidth;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const initialTooltipState = function () {
|
|
29
|
-
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
30
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31
|
-
return {
|
|
32
|
-
reference: null,
|
|
33
|
-
visible: false,
|
|
34
|
-
value,
|
|
35
|
-
options
|
|
36
|
-
};
|
|
37
|
-
}; // reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const Text = /*#__PURE__*/styled.span.withConfig({
|
|
41
|
-
componentId: "sc-2f4vtq-0"
|
|
42
|
-
})(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
|
|
43
|
-
|
|
44
|
-
const SimpleTruncatedTooltipText = props => {
|
|
45
|
-
const {
|
|
46
|
-
containerProps,
|
|
47
|
-
tooltipDelay,
|
|
48
|
-
placement,
|
|
49
|
-
value,
|
|
50
|
-
zIndex,
|
|
51
|
-
tooltipOptions,
|
|
52
|
-
textOptions
|
|
53
|
-
} = props; // not using "usePopoverProviderState" because usePopoverState has memory leak issues
|
|
54
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { useCancellableDelayedCallback } from "@elliemae/ds-utilities";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { DSPopover, PopperPositions as positions } from "@elliemae/ds-popover";
|
|
7
|
+
const dsTestId = "DS-SimpleTruncateText";
|
|
8
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
|
9
|
+
const initialTooltipState = (value = "", options = {}) => ({
|
|
10
|
+
reference: null,
|
|
11
|
+
visible: false,
|
|
12
|
+
value,
|
|
13
|
+
options
|
|
14
|
+
});
|
|
15
|
+
const Text = styled.span`
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
display: inline-block;
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
`;
|
|
22
|
+
const SimpleTruncatedTooltipText = (props) => {
|
|
23
|
+
const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
|
|
55
24
|
const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
|
|
56
|
-
const show = useCallback(newState => {
|
|
57
|
-
setTooltipState(
|
|
58
|
-
visible: true
|
|
59
|
-
}));
|
|
25
|
+
const show = useCallback((newState) => {
|
|
26
|
+
setTooltipState({ ...tooltipState, ...newState, visible: true });
|
|
60
27
|
}, [tooltipState]);
|
|
61
|
-
const hideTooltip = useCallback(newState => {
|
|
62
|
-
setTooltipState(
|
|
63
|
-
visible: false
|
|
64
|
-
}));
|
|
28
|
+
const hideTooltip = useCallback((newState) => {
|
|
29
|
+
setTooltipState({ ...tooltipState, ...newState, visible: false });
|
|
65
30
|
}, [tooltipState]);
|
|
66
31
|
const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
|
|
67
|
-
const handleMouseEnter = useCallback(e => {
|
|
68
|
-
const {
|
|
69
|
-
|
|
70
|
-
} = e; // we search for the closest parent with data-testid matching this component
|
|
71
|
-
// this is required because the target may not be this component itself
|
|
72
|
-
// when the user gives JSX as a value.
|
|
73
|
-
// JSX as a value is required for features like text highlight during research
|
|
74
|
-
// wich would still allow the truncation behaviour (see tree view for example)
|
|
75
|
-
// when the target has the test-id itself target===SimpleTruncatedTextEl
|
|
76
|
-
|
|
77
|
-
const SimpleTruncatedTextEl = target.closest("[data-testid=\"".concat(dsTestId, "\"]"));
|
|
78
|
-
|
|
32
|
+
const handleMouseEnter = useCallback((e) => {
|
|
33
|
+
const { target } = e;
|
|
34
|
+
const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
|
|
79
35
|
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
|
80
|
-
showTooltip({
|
|
81
|
-
value,
|
|
82
|
-
reference: SimpleTruncatedTextEl
|
|
83
|
-
});
|
|
36
|
+
showTooltip({ value, reference: SimpleTruncatedTextEl });
|
|
84
37
|
}
|
|
85
38
|
}, [showTooltip, value]);
|
|
86
39
|
const handleMouseLeave = useCallback(() => {
|
|
87
40
|
cancelShowTooltip();
|
|
88
|
-
hideTooltip({
|
|
89
|
-
reference: null
|
|
90
|
-
});
|
|
41
|
+
hideTooltip({ reference: null });
|
|
91
42
|
}, [hideTooltip, cancelShowTooltip]);
|
|
92
43
|
const handlers = useMemo(() => {
|
|
93
|
-
if (!showTooltip)
|
|
44
|
+
if (!showTooltip)
|
|
45
|
+
return {};
|
|
94
46
|
return {
|
|
95
47
|
onMouseEnter: handleMouseEnter,
|
|
96
48
|
onMouseLeave: handleMouseLeave
|
|
97
49
|
};
|
|
98
50
|
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
|
99
|
-
const PurePopover = useMemo(() =>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"data-testid": dsTestId // this is used by mouse enter too. required to support value as JSX
|
|
116
|
-
,
|
|
117
|
-
children: value
|
|
118
|
-
}))
|
|
119
|
-
}), [containerProps, textOptions, handlers, value]);
|
|
120
|
-
const PureSimpleTruncatedTooltipText = useMemo(() => /*#__PURE__*/jsxs(Fragment, {
|
|
121
|
-
children: [PureText, PurePopover]
|
|
122
|
-
}), [PureText, PurePopover]);
|
|
51
|
+
const PurePopover = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, tooltipState.visible ? /* @__PURE__ */ React2.createElement(DSPopover, {
|
|
52
|
+
boundaries: "window",
|
|
53
|
+
style: { pointerEvents: "none", zIndex },
|
|
54
|
+
placement,
|
|
55
|
+
content: tooltipState.value,
|
|
56
|
+
referenceEl: tooltipState.reference,
|
|
57
|
+
visible: tooltipState.visible,
|
|
58
|
+
showArrow: true
|
|
59
|
+
}) : null), [tooltipState, placement, zIndex]);
|
|
60
|
+
const PureText = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Text, {
|
|
61
|
+
...containerProps && { ...containerProps },
|
|
62
|
+
...textOptions && { ...textOptions },
|
|
63
|
+
...handlers && { ...handlers },
|
|
64
|
+
"data-testid": dsTestId
|
|
65
|
+
}, value)), [containerProps, textOptions, handlers, value]);
|
|
66
|
+
const PureSimpleTruncatedTooltipText = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, PureText, PurePopover), [PureText, PurePopover]);
|
|
123
67
|
return PureSimpleTruncatedTooltipText;
|
|
124
68
|
};
|
|
125
|
-
|
|
69
|
+
SimpleTruncatedTooltipText.propTypes = {
|
|
70
|
+
containerProps: PropTypes.object,
|
|
71
|
+
tooltipOptions: PropTypes.object,
|
|
72
|
+
textOptions: PropTypes.object,
|
|
73
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),
|
|
74
|
+
placement: PropTypes.oneOf([
|
|
75
|
+
positions.AUTO_START,
|
|
76
|
+
positions.AUTO_END,
|
|
77
|
+
positions.AUTO,
|
|
78
|
+
positions.TOP_START,
|
|
79
|
+
positions.TOP,
|
|
80
|
+
positions.TOP_END,
|
|
81
|
+
positions.RIGHT_START,
|
|
82
|
+
positions.RIGHT,
|
|
83
|
+
positions.RIGHT_END,
|
|
84
|
+
positions.BOTTOM_START,
|
|
85
|
+
positions.BOTTOM,
|
|
86
|
+
positions.BOTTOM_END,
|
|
87
|
+
positions.LEFT_START,
|
|
88
|
+
positions.LEFT,
|
|
89
|
+
positions.LEFT_END
|
|
90
|
+
]),
|
|
91
|
+
tooltipDelay: PropTypes.number,
|
|
92
|
+
zIndex: PropTypes.number
|
|
93
|
+
};
|
|
126
94
|
SimpleTruncatedTooltipText.defaultProps = {
|
|
127
95
|
containerProps: {},
|
|
128
96
|
tooltipOptions: {},
|
|
129
97
|
textOptions: {},
|
|
130
|
-
value:
|
|
131
|
-
placement:
|
|
98
|
+
value: "",
|
|
99
|
+
placement: positions.TOP,
|
|
132
100
|
tooltipDelay: 200,
|
|
133
101
|
zIndex: 110
|
|
134
102
|
};
|
|
135
|
-
|
|
136
|
-
export {
|
|
103
|
+
var SimpleTruncatedTooltipText_default = SimpleTruncatedTooltipText;
|
|
104
|
+
export {
|
|
105
|
+
SimpleTruncatedTooltipText,
|
|
106
|
+
SimpleTruncatedTooltipText_default as default
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=SimpleTruncatedTooltipText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/SimpleTruncatedTooltipText.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { useCancellableDelayedCallback } from '@elliemae/ds-utilities';\nimport PropTypes from 'prop-types';\nimport styled from 'styled-components';\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\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 PurePopover = useMemo(\n () => (\n <>\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n style={{ pointerEvents: 'none', zIndex }}\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 zIndex: 110,\n};\n\nexport { SimpleTruncatedTooltipText };\nexport default SimpleTruncatedTooltipText;\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AAEA,MAAM,WAAW;AAEjB,MAAM,mBAAmB,CAAC,EAAE,aAAa,kBAAkB,cAAc;AAEzE,MAAM,sBAAsB,CAAC,QAAQ,IAAI,UAAU,OAAQ;AAAA,EACzD,WAAW;AAAA,EACX,SAAS;AAAA,EACT;AAAA,EACA;AAAA;AAGF,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQpB,MAAM,6BAA6B,CAAC,UAAU;AAC5C,QAAM,EAAE,gBAAgB,cAAc,WAAW,OAAO,QAAQ,gBAAgB,gBAAgB;AAGhG,QAAM,CAAC,cAAc,mBAAmB,SAAS,oBAAoB,OAAO;AAC5E,QAAM,OAAO,YACX,CAAC,aAAa;AACZ,oBAAgB,KAAK,iBAAiB,UAAU,SAAS;AAAA,KAE3D,CAAC;AAEH,QAAM,cAAc,YAClB,CAAC,aAAa;AACZ,oBAAgB,KAAK,iBAAiB,UAAU,SAAS;AAAA,KAE3D,CAAC;AAEH,QAAM,CAAC,aAAa,qBAAqB,8BAA8B,MAAM;AAE7E,QAAM,mBAAmB,YACvB,CAAC,MAAM;AACL,UAAM,EAAE,WAAW;AAOnB,UAAM,wBAAwB,OAAO,QAAQ,iBAAiB;AAC9D,QAAI,yBAAyB,iBAAiB,wBAAwB;AACpE,kBAAY,EAAE,OAAO,WAAW;AAAA;AAAA,KAGpC,CAAC,aAAa;AAGhB,QAAM,mBAAmB,YAAY,MAAM;AACzC;AACA,gBAAY,EAAE,WAAW;AAAA,KACxB,CAAC,aAAa;AAEjB,QAAM,WAAW,QAAQ,MAAM;AAC7B,QAAI,CAAC;AAAa,aAAO;AACzB,WAAO;AAAA,MACL,cAAc;AAAA,MACd,cAAc;AAAA;AAAA,KAEf,CAAC,aAAa,kBAAkB;AAEnC,QAAM,cAAc,QAClB,MACE,4DACG,aAAa,UACZ,qCAAC,WAAD;AAAA,IACE,YAAW;AAAA,IACX,OAAO,EAAE,eAAe,QAAQ;AAAA,IAChC;AAAA,IACA,SAAS,aAAa;AAAA,IACtB,aAAa,aAAa;AAAA,IAC1B,SAAS,aAAa;AAAA,IACtB,WAAS;AAAA,OAET,OAGR,CAAC,cAAc,WAAW;AAE5B,QAAM,WAAW,QACf,MACE,4DACE,qCAAC,MAAD;AAAA,OACO,kBAAkB,KAAK;AAAA,OACvB,eAAe,KAAK;AAAA,OACpB,YAAY,KAAK;AAAA,IACtB,eAAa;AAAA,KAEZ,SAIP,CAAC,gBAAgB,aAAa,UAAU;AAG1C,QAAM,iCAAiC,QACrC,MACE,4DACG,UACA,cAGL,CAAC,UAAU;AAGb,SAAO;AAAA;AAGT,2BAA2B,YAAY;AAAA,EACrC,gBAAgB,UAAU;AAAA,EAC1B,gBAAgB,UAAU;AAAA,EAC1B,aAAa,UAAU;AAAA,EAEvB,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,QAAQ,UAAU;AAAA,EAE1E,WAAW,UAAU,MAAM;AAAA,IACzB,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;AAAA,EAGZ,cAAc,UAAU;AAAA,EAExB,QAAQ,UAAU;AAAA;AAGpB,2BAA2B,eAAe;AAAA,EACxC,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,OAAO;AAAA,EACP,WAAW,UAAU;AAAA,EACrB,cAAc;AAAA,EACd,QAAQ;AAAA;AAIV,IAAO,qCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,64 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { jsx } from 'react/jsx-runtime';
|
|
13
|
-
|
|
14
|
-
const _excluded = ["children", "tooltipDelay", "placement"];
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
const TruncatedTooltipContext = /*#__PURE__*/React.createContext();
|
|
20
|
-
const {
|
|
21
|
-
Provider
|
|
22
|
-
} = TruncatedTooltipContext;
|
|
23
|
-
|
|
24
|
-
function TooltipTextProvider(_ref) {
|
|
25
|
-
let {
|
|
26
|
-
children,
|
|
27
|
-
tooltipDelay = 200,
|
|
28
|
-
placement = 'top'
|
|
29
|
-
} = _ref,
|
|
30
|
-
tooltipOptions = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useMemo, useState } from "react";
|
|
3
|
+
import { DSPopover, usePopoverProviderState } from "@elliemae/ds-popover";
|
|
4
|
+
const TruncatedTooltipContext = React2.createContext();
|
|
5
|
+
const { Provider } = TruncatedTooltipContext;
|
|
6
|
+
function TooltipTextProvider({
|
|
7
|
+
children,
|
|
8
|
+
tooltipDelay = 200,
|
|
9
|
+
placement = "top",
|
|
10
|
+
...tooltipOptions
|
|
11
|
+
}) {
|
|
32
12
|
const {
|
|
33
13
|
show: showTooltip,
|
|
34
14
|
hide: hideTooltip,
|
|
35
15
|
state: tooltipState
|
|
36
|
-
} = usePopoverProviderState({
|
|
37
|
-
delay: tooltipDelay
|
|
38
|
-
});
|
|
16
|
+
} = usePopoverProviderState({ delay: tooltipDelay });
|
|
39
17
|
const [zIndex, setZIndex] = useState(110);
|
|
40
18
|
const value = useMemo(() => ({
|
|
41
19
|
showTooltip,
|
|
42
20
|
hideTooltip,
|
|
43
21
|
setZIndex
|
|
44
22
|
}), []);
|
|
45
|
-
return
|
|
46
|
-
value
|
|
47
|
-
},
|
|
23
|
+
return /* @__PURE__ */ React2.createElement(Provider, {
|
|
24
|
+
value
|
|
25
|
+
}, children, tooltipState.visible ? /* @__PURE__ */ React2.createElement(DSPopover, {
|
|
48
26
|
boundaries: "window",
|
|
49
|
-
placement
|
|
50
|
-
showArrow: true
|
|
51
|
-
|
|
27
|
+
placement,
|
|
28
|
+
showArrow: true,
|
|
29
|
+
...tooltipOptions,
|
|
30
|
+
...tooltipState.options || {},
|
|
52
31
|
content: tooltipState.value,
|
|
53
32
|
referenceEl: tooltipState.reference,
|
|
54
|
-
style: {
|
|
55
|
-
pointerEvents: 'none',
|
|
56
|
-
zIndex
|
|
57
|
-
},
|
|
33
|
+
style: { pointerEvents: "none", zIndex },
|
|
58
34
|
visible: tooltipState.visible
|
|
59
|
-
})
|
|
35
|
+
}) : null);
|
|
60
36
|
}
|
|
61
|
-
|
|
37
|
+
TooltipTextProvider.propTypes = {};
|
|
62
38
|
TooltipTextProvider.defaultProps = {};
|
|
63
|
-
|
|
64
|
-
export {
|
|
39
|
+
var TooltipTextProvider_default = TooltipTextProvider;
|
|
40
|
+
export {
|
|
41
|
+
TooltipTextProvider,
|
|
42
|
+
TruncatedTooltipContext,
|
|
43
|
+
TooltipTextProvider_default as default
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=TooltipTextProvider.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/TooltipTextProvider.tsx"],
|
|
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({\n children,\n tooltipDelay = 200,\n placement = 'top',\n ...tooltipOptions\n}) {\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;ACCA;AACA;AAEA,MAAM,0BAA0B,OAAM;AAEtC,MAAM,EAAE,aAAa;AAErB,6BAA6B;AAAA,EAC3B;AAAA,EACA,eAAe;AAAA,EACf,YAAY;AAAA,KACT;AAAA,GACF;AACD,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACL,wBAAwB,EAAE,OAAO;AACrC,QAAM,CAAC,QAAQ,aAAa,SAAS;AAErC,QAAM,QAAQ,QACZ,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAGF,SACE,qCAAC,UAAD;AAAA,IAAU;AAAA,KACP,UACA,aAAa,UACZ,qCAAC,WAAD;AAAA,IACE,YAAW;AAAA,IACX;AAAA,IACA,WAAS;AAAA,OACL;AAAA,OACC,aAAa,WAAW;AAAA,IAC7B,SAAS,aAAa;AAAA,IACtB,aAAa,aAAa;AAAA,IAC1B,OAAO,EAAE,eAAe,QAAQ;AAAA,IAChC,SAAS,aAAa;AAAA,OAEtB;AAAA;AAKV,oBAAoB,YAAY;AAChC,oBAAoB,eAAe;AAGnC,IAAO,8BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { TooltipTextProvider, TruncatedTooltipContext } from "./TooltipTextProvider";
|
|
3
|
+
import { SimpleTruncatedTooltipText } from "./SimpleTruncatedTooltipText";
|
|
4
|
+
import { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default as default2 } from "./DSTruncatedTooltipText";
|
|
5
|
+
import { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from "./DSTruncateTextWithTooltip";
|
|
6
|
+
export {
|
|
7
|
+
DSTruncateTextWithTooltip,
|
|
8
|
+
DSTruncateTextWithTooltipDatatestId,
|
|
9
|
+
DSTruncatedTooltipText,
|
|
10
|
+
SimpleTruncatedTooltipText,
|
|
11
|
+
TooltipTextProvider,
|
|
12
|
+
TruncatedTooltipContext,
|
|
13
|
+
TruncatedTooltipTextWithSchema,
|
|
14
|
+
default2 as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
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 } from './DSTruncateTextWithTooltip';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-truncated-tooltip-text",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Truncated Tooltip Text",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"build": "node ../../scripts/build/build.js"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@elliemae/ds-popover": "2.
|
|
52
|
-
"@elliemae/ds-popper": "2.
|
|
53
|
-
"@elliemae/ds-tooltip": "2.
|
|
54
|
-
"@elliemae/ds-utilities": "2.
|
|
51
|
+
"@elliemae/ds-popover": "2.3.0-alpha.3",
|
|
52
|
+
"@elliemae/ds-popper": "2.3.0-alpha.3",
|
|
53
|
+
"@elliemae/ds-tooltip": "2.3.0-alpha.3",
|
|
54
|
+
"@elliemae/ds-utilities": "2.3.0-alpha.3",
|
|
55
55
|
"prop-types": "~15.7.2",
|
|
56
56
|
"react-desc": "~4.1.3"
|
|
57
57
|
},
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export * from './DSTruncateTextWithTooltip';
|
|
1
|
+
export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';
|
|
2
|
+
export { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';
|
|
3
|
+
export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';
|
|
4
|
+
export { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from './DSTruncateTextWithTooltip';
|