@elliemae/ds-truncated-tooltip-text 2.3.0-next.0 → 3.0.0-alpha.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.
Files changed (37) hide show
  1. package/dist/cjs/DSTruncateTextWithTooltip.js +86 -0
  2. package/dist/cjs/DSTruncateTextWithTooltip.js.map +7 -0
  3. package/dist/cjs/DSTruncatedTooltipText.js +119 -0
  4. package/dist/cjs/DSTruncatedTooltipText.js.map +7 -0
  5. package/dist/cjs/SimpleTruncatedTooltipText.js +137 -0
  6. package/dist/cjs/SimpleTruncatedTooltipText.js.map +7 -0
  7. package/dist/cjs/TooltipTextProvider.js +74 -0
  8. package/dist/cjs/TooltipTextProvider.js.map +7 -0
  9. package/dist/cjs/index.js +45 -0
  10. package/dist/cjs/index.js.map +7 -0
  11. package/dist/esm/DSTruncateTextWithTooltip.js +57 -0
  12. package/dist/esm/DSTruncateTextWithTooltip.js.map +7 -0
  13. package/dist/esm/DSTruncatedTooltipText.js +90 -0
  14. package/dist/esm/DSTruncatedTooltipText.js.map +7 -0
  15. package/dist/esm/SimpleTruncatedTooltipText.js +108 -0
  16. package/dist/esm/SimpleTruncatedTooltipText.js.map +7 -0
  17. package/dist/esm/TooltipTextProvider.js +45 -0
  18. package/dist/esm/TooltipTextProvider.js.map +7 -0
  19. package/dist/esm/index.js +16 -0
  20. package/dist/esm/index.js.map +7 -0
  21. package/{types → dist/types}/DSTruncateTextWithTooltip.d.ts +0 -0
  22. package/{types → dist/types}/DSTruncatedTooltipText.d.ts +0 -0
  23. package/{types → dist/types}/SimpleTruncatedTooltipText.d.ts +0 -0
  24. package/{types → dist/types}/TooltipTextProvider.d.ts +0 -0
  25. package/dist/types/index.d.ts +4 -0
  26. package/package.json +35 -27
  27. package/cjs/DSTruncateTextWithTooltip.js +0 -75
  28. package/cjs/DSTruncatedTooltipText.js +0 -112
  29. package/cjs/SimpleTruncatedTooltipText.js +0 -148
  30. package/cjs/TooltipTextProvider.js +0 -78
  31. package/cjs/index.js +0 -19
  32. package/esm/DSTruncateTextWithTooltip.js +0 -65
  33. package/esm/DSTruncatedTooltipText.js +0 -100
  34. package/esm/SimpleTruncatedTooltipText.js +0 -136
  35. package/esm/TooltipTextProvider.js +0 -64
  36. package/esm/index.js +0 -4
  37. package/types/index.d.ts +0 -5
@@ -0,0 +1,90 @@
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
+ }) => {
21
+ const tooltipContext = useContext(TruncatedTooltipContext);
22
+ useEffect(() => {
23
+ if (zIndex && tooltipContext)
24
+ tooltipContext.setZIndex(zIndex);
25
+ }, [zIndex]);
26
+ if (!tooltipContext)
27
+ return value;
28
+ const { showTooltip, hideTooltip } = tooltipContext;
29
+ const handleMouseEnter = (e) => {
30
+ const { target } = e;
31
+ if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
32
+ showTooltip({
33
+ value,
34
+ reference: target
35
+ }, e);
36
+ }
37
+ };
38
+ const handleMouseLeave = (e) => {
39
+ hideTooltip({ reference: e.target });
40
+ };
41
+ const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
42
+ return /* @__PURE__ */ React2.createElement(Text, {
43
+ ...containerProps,
44
+ ...otherTextProps,
45
+ ...handlers
46
+ }, value);
47
+ };
48
+ DSTruncatedTooltipText.defaultProps = {
49
+ value: "",
50
+ zIndex: 110
51
+ };
52
+ const truncatedTooltipTextProps = {
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)
74
+ };
75
+ DSTruncatedTooltipText.defaultProps = {
76
+ containerProps: {},
77
+ value: "",
78
+ tooltipPlacement: void 0,
79
+ tooltipDelay: void 0
80
+ };
81
+ DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
82
+ const TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);
83
+ TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
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
+ }
@@ -0,0 +1,108 @@
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;
24
+ const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
25
+ const show = useCallback((newState) => {
26
+ setTooltipState({ ...tooltipState, ...newState, visible: true });
27
+ }, [tooltipState]);
28
+ const hideTooltip = useCallback((newState) => {
29
+ setTooltipState({ ...tooltipState, ...newState, visible: false });
30
+ }, [tooltipState]);
31
+ const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
32
+ const handleMouseEnter = useCallback((e) => {
33
+ const { target } = e;
34
+ const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
35
+ if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
36
+ showTooltip({ value, reference: SimpleTruncatedTextEl });
37
+ }
38
+ }, [showTooltip, value]);
39
+ const handleMouseLeave = useCallback(() => {
40
+ cancelShowTooltip();
41
+ hideTooltip({ reference: null });
42
+ }, [hideTooltip, cancelShowTooltip]);
43
+ const handlers = useMemo(() => {
44
+ if (!showTooltip)
45
+ return {};
46
+ return {
47
+ onMouseEnter: handleMouseEnter,
48
+ onMouseLeave: handleMouseLeave
49
+ };
50
+ }, [showTooltip, handleMouseEnter, handleMouseLeave]);
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]);
67
+ return PureSimpleTruncatedTooltipText;
68
+ };
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
+ };
94
+ SimpleTruncatedTooltipText.defaultProps = {
95
+ containerProps: {},
96
+ tooltipOptions: {},
97
+ textOptions: {},
98
+ value: "",
99
+ placement: positions.TOP,
100
+ tooltipDelay: 200,
101
+ zIndex: 110
102
+ };
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
+ }
@@ -0,0 +1,45 @@
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
+ }) {
12
+ const {
13
+ show: showTooltip,
14
+ hide: hideTooltip,
15
+ state: tooltipState
16
+ } = usePopoverProviderState({ delay: tooltipDelay });
17
+ const [zIndex, setZIndex] = useState(110);
18
+ const value = useMemo(() => ({
19
+ showTooltip,
20
+ hideTooltip,
21
+ setZIndex
22
+ }), []);
23
+ return /* @__PURE__ */ React2.createElement(Provider, {
24
+ value
25
+ }, children, tooltipState.visible ? /* @__PURE__ */ React2.createElement(DSPopover, {
26
+ boundaries: "window",
27
+ placement,
28
+ showArrow: true,
29
+ ...tooltipOptions,
30
+ ...tooltipState.options || {},
31
+ content: tooltipState.value,
32
+ referenceEl: tooltipState.reference,
33
+ style: { pointerEvents: "none", zIndex },
34
+ visible: tooltipState.visible
35
+ }) : null);
36
+ }
37
+ TooltipTextProvider.propTypes = {};
38
+ TooltipTextProvider.defaultProps = {};
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
+ }
@@ -0,0 +1,16 @@
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
@@ -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
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';
2
+ export { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';
3
+ export { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';
4
+ export { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from './DSTruncateTextWithTooltip';
package/package.json CHANGED
@@ -1,31 +1,34 @@
1
1
  {
2
2
  "name": "@elliemae/ds-truncated-tooltip-text",
3
- "version": "2.3.0-next.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Truncated Tooltip Text",
6
- "module": "./esm/index.js",
7
- "main": "./cjs/index.js",
8
- "types": "./types/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "module": "./dist/esm/index.js",
10
+ "main": "./dist/cjs/index.js",
11
+ "types": "./dist/types/index.d.ts",
9
12
  "exports": {
10
13
  ".": {
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
14
+ "import": "./dist/esm/index.js",
15
+ "require": "./dist/cjs/index.js"
13
16
  },
14
17
  "./TooltipTextProvider": {
15
- "import": "./esm/TooltipTextProvider.js",
16
- "require": "./cjs/TooltipTextProvider.js"
18
+ "import": "./dist/esm/TooltipTextProvider.js",
19
+ "require": "./dist/cjs/TooltipTextProvider.js"
17
20
  },
18
21
  "./SimpleTruncatedTooltipText": {
19
- "import": "./esm/SimpleTruncatedTooltipText.js",
20
- "require": "./cjs/SimpleTruncatedTooltipText.js"
22
+ "import": "./dist/esm/SimpleTruncatedTooltipText.js",
23
+ "require": "./dist/cjs/SimpleTruncatedTooltipText.js"
21
24
  },
22
25
  "./DSTruncateTextWithTooltip": {
23
- "import": "./esm/DSTruncateTextWithTooltip.js",
24
- "require": "./cjs/DSTruncateTextWithTooltip.js"
26
+ "import": "./dist/esm/DSTruncateTextWithTooltip.js",
27
+ "require": "./dist/cjs/DSTruncateTextWithTooltip.js"
25
28
  },
26
29
  "./DSTruncatedTooltipText": {
27
- "import": "./esm/DSTruncatedTooltipText.js",
28
- "require": "./cjs/DSTruncatedTooltipText.js"
30
+ "import": "./dist/esm/DSTruncatedTooltipText.js",
31
+ "require": "./dist/cjs/DSTruncatedTooltipText.js"
29
32
  }
30
33
  },
31
34
  "sideEffects": [
@@ -37,21 +40,21 @@
37
40
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
38
41
  },
39
42
  "engines": {
40
- "npm": ">=7",
41
- "node": ">=14"
43
+ "pnpm": ">=6",
44
+ "node": ">=16"
42
45
  },
43
46
  "author": "ICE MT",
44
- "scripts": {
45
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
46
- "prebuild": "exit 0",
47
- "predev": "exit 0",
48
- "build": "node ../../scripts/build/build.js"
47
+ "jestSonar": {
48
+ "sonar56x": true,
49
+ "reportPath": "reports",
50
+ "reportFile": "tests.xml",
51
+ "indent": 4
49
52
  },
50
53
  "dependencies": {
51
- "@elliemae/ds-popover": "2.3.0-next.0",
52
- "@elliemae/ds-popper": "2.3.0-next.0",
53
- "@elliemae/ds-tooltip": "2.3.0-next.0",
54
- "@elliemae/ds-utilities": "2.3.0-next.0",
54
+ "@elliemae/ds-popover": "3.0.0-alpha.0",
55
+ "@elliemae/ds-popper": "3.0.0-alpha.0",
56
+ "@elliemae/ds-tooltip": "3.0.0-alpha.0",
57
+ "@elliemae/ds-utilities": "3.0.0-alpha.0",
55
58
  "prop-types": "~15.7.2",
56
59
  "react-desc": "~4.1.3"
57
60
  },
@@ -65,7 +68,12 @@
65
68
  },
66
69
  "publishConfig": {
67
70
  "access": "public",
68
- "directory": "dist",
69
- "generateSubmodules": true
71
+ "typeSafety": false
72
+ },
73
+ "scripts": {
74
+ "dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
75
+ "test": "node ../../scripts/testing/test.mjs",
76
+ "lint": "node ../../scripts/lint.mjs",
77
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
70
78
  }
71
79
  }
@@ -1,75 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- require('core-js/modules/web.dom-collections.iterator.js');
7
- require('core-js/modules/esnext.async-iterator.filter.js');
8
- require('core-js/modules/esnext.iterator.constructor.js');
9
- require('core-js/modules/esnext.iterator.filter.js');
10
- require('core-js/modules/esnext.async-iterator.for-each.js');
11
- require('core-js/modules/esnext.iterator.for-each.js');
12
- var React = require('react');
13
- var dsTooltip = require('@elliemae/ds-tooltip');
14
- var styled = require('styled-components');
15
- var jsxRuntime = require('react/jsx-runtime');
16
-
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
20
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
21
-
22
- 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; }
23
-
24
- 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__default["default"](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; }
25
- const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
26
- componentId: "sc-1w57q5j-0"
27
- })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;:focus{border:none;outline:none;background:", ";}"], props => props.theme.colors.brand['200']);
28
- const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';
29
- const DSTruncateTextWithTooltip = _ref => {
30
- let {
31
- text,
32
- tooltipProps = {}
33
- } = _ref;
34
- const [textWrapperEl, setTextWrapperEl] = React.useState(); // const textWrapperEl = useRef<HTMLSpanElement>();
35
-
36
- const [isShowingEllipsis, setIsShowingEllipsis] = React.useState(false); // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;
37
-
38
- const resizeObserver = React.useMemo(() => new ResizeObserver(entries => {
39
- if (entries.length) {
40
- const [textWrapperEntry] = entries;
41
- const el = textWrapperEntry.target;
42
- setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
43
- }
44
- }), []);
45
- React.useEffect(() => {
46
- if (textWrapperEl) {
47
- setIsShowingEllipsis((textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.scrollWidth) > (textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.clientWidth));
48
- resizeObserver.observe(textWrapperEl);
49
- }
50
-
51
- return () => {
52
- if (textWrapperEl) {
53
- resizeObserver.unobserve(textWrapperEl);
54
- }
55
- };
56
- }, [resizeObserver, textWrapperEl]);
57
- if (isShowingEllipsis) return /*#__PURE__*/jsxRuntime.jsx(dsTooltip.DSTooltipV3, _objectSpread(_objectSpread({
58
- text: text
59
- }, tooltipProps), {}, {
60
- children: /*#__PURE__*/jsxRuntime.jsx(Text, {
61
- ref: setTextWrapperEl,
62
- tabIndex: 0,
63
- "data-testid": DSTruncateTextWithTooltipDatatestId,
64
- children: text
65
- })
66
- }));
67
- return /*#__PURE__*/jsxRuntime.jsx(Text, {
68
- ref: setTextWrapperEl,
69
- "data-testid": DSTruncateTextWithTooltipDatatestId,
70
- children: text
71
- });
72
- };
73
-
74
- exports.DSTruncateTextWithTooltip = DSTruncateTextWithTooltip;
75
- exports.DSTruncateTextWithTooltipDatatestId = DSTruncateTextWithTooltipDatatestId;
@@ -1,112 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.filter.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.filter.js');
8
- require('core-js/modules/esnext.async-iterator.for-each.js');
9
- require('core-js/modules/esnext.iterator.for-each.js');
10
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
11
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
12
- var React = require('react');
13
- var reactDesc = require('react-desc');
14
- var styled = require('styled-components');
15
- var dsPopper = require('@elliemae/ds-popper');
16
- var TooltipTextProvider = require('./TooltipTextProvider.js');
17
- var jsxRuntime = require('react/jsx-runtime');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
22
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
23
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
24
-
25
- const _excluded = ["containerProps", "value", "zIndex"];
26
-
27
- 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; }
28
-
29
- 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__default["default"](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; }
30
-
31
- const isEllipsisActive = _ref => {
32
- let {
33
- offsetWidth,
34
- scrollWidth
35
- } = _ref;
36
- return offsetWidth < scrollWidth;
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__default["default"].span.withConfig({
41
- componentId: "sc-1olo1o7-0"
42
- })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
43
-
44
- const DSTruncatedTooltipText = _ref2 => {
45
- let {
46
- containerProps = {},
47
- value = '',
48
- zIndex = 110
49
- } = _ref2,
50
- otherTextProps = _objectWithoutProperties__default["default"](_ref2, _excluded);
51
-
52
- const tooltipContext = React.useContext(TooltipTextProvider.TruncatedTooltipContext);
53
- React.useEffect(() => {
54
- if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);
55
- }, [zIndex]);
56
- if (!tooltipContext) return value;
57
- const {
58
- showTooltip,
59
- hideTooltip
60
- } = tooltipContext;
61
-
62
- const handleMouseEnter = e => {
63
- const {
64
- target
65
- } = e;
66
-
67
- if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
68
- showTooltip({
69
- value,
70
- reference: target
71
- }, e);
72
- }
73
- };
74
-
75
- const handleMouseLeave = e => {
76
- hideTooltip({
77
- reference: e.target
78
- });
79
- };
80
-
81
- const handlers = showTooltip ? {
82
- onMouseEnter: handleMouseEnter,
83
- onMouseLeave: handleMouseLeave
84
- } : {};
85
- return /*#__PURE__*/jsxRuntime.jsx(Text, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, containerProps), otherTextProps), handlers), {}, {
86
- children: value
87
- }));
88
- };
89
-
90
- DSTruncatedTooltipText.defaultProps = {
91
- value: '',
92
- zIndex: 110
93
- };
94
- const truncatedTooltipTextProps = {
95
- containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
96
- value: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('Text that when truncated will trigger the tooltip interaction'),
97
- tooltipPlacement: reactDesc.PropTypes.oneOf([dsPopper.PopperPositions.AUTO_START, dsPopper.PopperPositions.AUTO_END, dsPopper.PopperPositions.AUTO, dsPopper.PopperPositions.TOP_START, dsPopper.PopperPositions.TOP, dsPopper.PopperPositions.TOP_END, dsPopper.PopperPositions.RIGHT_START, dsPopper.PopperPositions.RIGHT, dsPopper.PopperPositions.RIGHT_END, dsPopper.PopperPositions.BOTTOM_START, dsPopper.PopperPositions.BOTTOM, dsPopper.PopperPositions.BOTTOM_END, dsPopper.PopperPositions.LEFT_START, dsPopper.PopperPositions.LEFT, dsPopper.PopperPositions.LEFT_END]).description('Position of the tooltip'),
98
- tooltipDelay: reactDesc.PropTypes.number.description('Delay to show the tooltip'),
99
- zIndex: reactDesc.PropTypes.number.description('override default zIndex').defaultValue(110)
100
- };
101
- DSTruncatedTooltipText.defaultProps = {
102
- containerProps: {},
103
- value: '',
104
- tooltipPlacement: undefined,
105
- tooltipDelay: undefined
106
- };
107
- const TruncatedTooltipTextWithSchema = reactDesc.describe(DSTruncatedTooltipText);
108
- TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
109
-
110
- exports.DSTruncatedTooltipText = DSTruncatedTooltipText;
111
- exports.TruncatedTooltipTextWithSchema = TruncatedTooltipTextWithSchema;
112
- exports["default"] = DSTruncatedTooltipText;