@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,86 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var DSTruncateTextWithTooltip_exports = {};
29
+ __export(DSTruncateTextWithTooltip_exports, {
30
+ DSTruncateTextWithTooltip: () => DSTruncateTextWithTooltip,
31
+ DSTruncateTextWithTooltipDatatestId: () => DSTruncateTextWithTooltipDatatestId
32
+ });
33
+ var React = __toESM(require("react"));
34
+ var import_react = __toESM(require("react"));
35
+ var import_ds_tooltip = require("@elliemae/ds-tooltip");
36
+ var import_styled_components = __toESM(require("styled-components"));
37
+ const Text = import_styled_components.default.span`
38
+ text-overflow: ellipsis;
39
+ white-space: nowrap;
40
+ overflow: hidden;
41
+ display: inline-block;
42
+ max-width: 100%;
43
+ :focus {
44
+ border: none;
45
+ outline: none;
46
+ background: ${(props) => props.theme.colors.brand["200"]};
47
+ }
48
+ `;
49
+ const DSTruncateTextWithTooltipDatatestId = "DS-TruncateTextWithTooltip";
50
+ const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }) => {
51
+ const [textWrapperEl, setTextWrapperEl] = (0, import_react.useState)();
52
+ const [isShowingEllipsis, setIsShowingEllipsis] = (0, import_react.useState)(false);
53
+ const resizeObserver = (0, import_react.useMemo)(() => new ResizeObserver((entries) => {
54
+ if (entries.length) {
55
+ const [textWrapperEntry] = entries;
56
+ const el = textWrapperEntry.target;
57
+ setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
58
+ }
59
+ }), []);
60
+ (0, import_react.useEffect)(() => {
61
+ if (textWrapperEl) {
62
+ setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
63
+ resizeObserver.observe(textWrapperEl);
64
+ }
65
+ return () => {
66
+ if (textWrapperEl) {
67
+ resizeObserver.unobserve(textWrapperEl);
68
+ }
69
+ };
70
+ }, [resizeObserver, textWrapperEl]);
71
+ if (isShowingEllipsis)
72
+ return /* @__PURE__ */ import_react.default.createElement(import_ds_tooltip.DSTooltipV3, {
73
+ text,
74
+ ...tooltipProps
75
+ }, /* @__PURE__ */ import_react.default.createElement(Text, {
76
+ ref: setTextWrapperEl,
77
+ tabIndex: 0,
78
+ "data-testid": DSTruncateTextWithTooltipDatatestId
79
+ }, text));
80
+ return /* @__PURE__ */ import_react.default.createElement(Text, {
81
+ ref: setTextWrapperEl,
82
+ "data-testid": DSTruncateTextWithTooltipDatatestId
83
+ }, text);
84
+ };
85
+ module.exports = __toCommonJS(DSTruncateTextWithTooltip_exports);
86
+ //# sourceMappingURL=DSTruncateTextWithTooltip.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/DSTruncateTextWithTooltip.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React, { useState, useMemo, useEffect, useRef } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport styled from 'styled-components';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n :focus {\n border: none;\n outline: none;\n background: ${(props) => props.theme.colors.brand['200']};\n }\n`;\ninterface PropsT {\n text: string;\n tooltipProps?: Record<string, unknown>;\n}\nexport const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';\nexport const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }: PropsT): JSX.Element => {\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement>();\n // const textWrapperEl = useRef<HTMLSpanElement>();\n const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);\n // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n useEffect(() => {\n if (textWrapperEl) {\n setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);\n resizeObserver.observe(textWrapperEl);\n }\n return () => {\n if (textWrapperEl) {\n resizeObserver.unobserve(textWrapperEl);\n }\n };\n }, [resizeObserver, textWrapperEl]);\n\n if (isShowingEllipsis)\n return (\n <DSTooltipV3 text={text} {...tooltipProps}>\n <Text ref={setTextWrapperEl} tabIndex={0} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestId}>\n {text}\n </Text>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA4D;AAC5D,wBAA4B;AAC5B,+BAAmB;AAGnB,MAAM,OAAO,iCAAO;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,2BAAS;AAG3D,QAAM,iBAAiB,0BACrB,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,8BAAU,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,mDAAC,+BAAD;AAAA,MAAa;AAAA,SAAgB;AAAA,OAC3B,mDAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa;AAAA,OACpD;AAKT,SACE,mDAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa;AAAA,KACvC;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,119 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var DSTruncatedTooltipText_exports = {};
29
+ __export(DSTruncatedTooltipText_exports, {
30
+ DSTruncatedTooltipText: () => DSTruncatedTooltipText,
31
+ TruncatedTooltipTextWithSchema: () => TruncatedTooltipTextWithSchema,
32
+ default: () => DSTruncatedTooltipText_default
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_react_desc = require("react-desc");
37
+ var import_styled_components = __toESM(require("styled-components"));
38
+ var import_ds_popper = require("@elliemae/ds-popper");
39
+ var import_TooltipTextProvider = require("./TooltipTextProvider");
40
+ const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
41
+ const Text = import_styled_components.default.span`
42
+ text-overflow: ellipsis;
43
+ white-space: nowrap;
44
+ overflow: hidden;
45
+ display: inline-block;
46
+ max-width: 100%;
47
+ `;
48
+ const DSTruncatedTooltipText = ({
49
+ containerProps = {},
50
+ value = "",
51
+ zIndex = 110,
52
+ ...otherTextProps
53
+ }) => {
54
+ const tooltipContext = (0, import_react.useContext)(import_TooltipTextProvider.TruncatedTooltipContext);
55
+ (0, import_react.useEffect)(() => {
56
+ if (zIndex && tooltipContext)
57
+ tooltipContext.setZIndex(zIndex);
58
+ }, [zIndex]);
59
+ if (!tooltipContext)
60
+ return value;
61
+ const { showTooltip, hideTooltip } = tooltipContext;
62
+ const handleMouseEnter = (e) => {
63
+ const { target } = e;
64
+ if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
65
+ showTooltip({
66
+ value,
67
+ reference: target
68
+ }, e);
69
+ }
70
+ };
71
+ const handleMouseLeave = (e) => {
72
+ hideTooltip({ reference: e.target });
73
+ };
74
+ const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
75
+ return /* @__PURE__ */ import_react.default.createElement(Text, {
76
+ ...containerProps,
77
+ ...otherTextProps,
78
+ ...handlers
79
+ }, value);
80
+ };
81
+ DSTruncatedTooltipText.defaultProps = {
82
+ value: "",
83
+ zIndex: 110
84
+ };
85
+ const truncatedTooltipTextProps = {
86
+ containerProps: import_react_desc.PropTypes.object.description("Set of Properties attached to the main container"),
87
+ value: import_react_desc.PropTypes.oneOfType([import_react_desc.PropTypes.string, import_react_desc.PropTypes.number]).description("Text that when truncated will trigger the tooltip interaction"),
88
+ tooltipPlacement: import_react_desc.PropTypes.oneOf([
89
+ import_ds_popper.PopperPositions.AUTO_START,
90
+ import_ds_popper.PopperPositions.AUTO_END,
91
+ import_ds_popper.PopperPositions.AUTO,
92
+ import_ds_popper.PopperPositions.TOP_START,
93
+ import_ds_popper.PopperPositions.TOP,
94
+ import_ds_popper.PopperPositions.TOP_END,
95
+ import_ds_popper.PopperPositions.RIGHT_START,
96
+ import_ds_popper.PopperPositions.RIGHT,
97
+ import_ds_popper.PopperPositions.RIGHT_END,
98
+ import_ds_popper.PopperPositions.BOTTOM_START,
99
+ import_ds_popper.PopperPositions.BOTTOM,
100
+ import_ds_popper.PopperPositions.BOTTOM_END,
101
+ import_ds_popper.PopperPositions.LEFT_START,
102
+ import_ds_popper.PopperPositions.LEFT,
103
+ import_ds_popper.PopperPositions.LEFT_END
104
+ ]).description("Position of the tooltip"),
105
+ tooltipDelay: import_react_desc.PropTypes.number.description("Delay to show the tooltip"),
106
+ zIndex: import_react_desc.PropTypes.number.description("override default zIndex").defaultValue(110)
107
+ };
108
+ DSTruncatedTooltipText.defaultProps = {
109
+ containerProps: {},
110
+ value: "",
111
+ tooltipPlacement: void 0,
112
+ tooltipDelay: void 0
113
+ };
114
+ DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
115
+ const TruncatedTooltipTextWithSchema = (0, import_react_desc.describe)(DSTruncatedTooltipText);
116
+ TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
117
+ var DSTruncatedTooltipText_default = DSTruncatedTooltipText;
118
+ module.exports = __toCommonJS(DSTruncatedTooltipText_exports);
119
+ //# sourceMappingURL=DSTruncatedTooltipText.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/DSTruncatedTooltipText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from 'react-desc';\nimport styled from 'styled-components';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) =>\n offsetWidth < scrollWidth;\n\n// reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n`;\n\nconst DSTruncatedTooltipText = ({\n containerProps = {},\n value = '',\n zIndex = 110, // https://jira.elliemae.io/browse/PUI-1755\n ...otherTextProps\n}) => {\n const tooltipContext = useContext(TruncatedTooltipContext);\n useEffect(() => {\n if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);\n }, [zIndex]);\n\n if (!tooltipContext) return value;\n\n const { showTooltip, hideTooltip } = tooltipContext;\n\n const handleMouseEnter = (e) => {\n const { target } = e;\n if (target && isEllipsisActive(target, target.getBoundingClientRect())) {\n showTooltip(\n {\n value,\n reference: target,\n },\n e,\n );\n }\n };\n\n const handleMouseLeave = (e) => {\n hideTooltip({ reference: e.target });\n };\n\n const handlers = showTooltip\n ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }\n : {};\n return (\n <Text {...containerProps} {...otherTextProps} {...handlers}>\n {value}\n </Text>\n );\n};\n\nDSTruncatedTooltipText.defaultProps = {\n value: '',\n zIndex: 110,\n};\n\nconst truncatedTooltipTextProps = {\n containerProps: PropTypes.object.description(\n 'Set of Properties attached to the main container',\n ),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n tooltipPlacement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]).description('Position of the tooltip'),\n tooltipDelay: PropTypes.number.description('Delay to show the tooltip'),\n zIndex: PropTypes.number\n .description('override default zIndex')\n .defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\n\nconst TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);\nTruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;\n\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };\nexport default DSTruncatedTooltipText;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA6C;AAC7C,wBAAoC;AACpC,+BAAmB;AACnB,uBAA6C;AAC7C,iCAAwC;AAExC,MAAM,mBAAmB,CAAC,EAAE,aAAa,kBACvC,cAAc;AAGhB,MAAM,OAAO,iCAAO;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,6BAAW;AAClC,8BAAU,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,mDAAC,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,4BAAU,OAAO,YAC/B;AAAA,EAEF,OAAO,4BAAU,UAAU,CAAC,4BAAU,QAAQ,4BAAU,SAAS,YAC/D;AAAA,EAEF,kBAAkB,4BAAU,MAAM;AAAA,IAChC,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,IACV,iCAAU;AAAA,KACT,YAAY;AAAA,EACf,cAAc,4BAAU,OAAO,YAAY;AAAA,EAC3C,QAAQ,4BAAU,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,gCAAS;AAChD,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,137 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var SimpleTruncatedTooltipText_exports = {};
29
+ __export(SimpleTruncatedTooltipText_exports, {
30
+ SimpleTruncatedTooltipText: () => SimpleTruncatedTooltipText,
31
+ default: () => SimpleTruncatedTooltipText_default
32
+ });
33
+ var React = __toESM(require("react"));
34
+ var import_react = __toESM(require("react"));
35
+ var import_ds_utilities = require("@elliemae/ds-utilities");
36
+ var import_prop_types = __toESM(require("prop-types"));
37
+ var import_styled_components = __toESM(require("styled-components"));
38
+ var import_ds_popover = require("@elliemae/ds-popover");
39
+ const dsTestId = "DS-SimpleTruncateText";
40
+ const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
41
+ const initialTooltipState = (value = "", options = {}) => ({
42
+ reference: null,
43
+ visible: false,
44
+ value,
45
+ options
46
+ });
47
+ const Text = import_styled_components.default.span`
48
+ text-overflow: ellipsis;
49
+ white-space: nowrap;
50
+ overflow: hidden;
51
+ display: inline-block;
52
+ max-width: 100%;
53
+ `;
54
+ const SimpleTruncatedTooltipText = (props) => {
55
+ const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
56
+ const [tooltipState, setTooltipState] = (0, import_react.useState)(initialTooltipState(value, tooltipOptions));
57
+ const show = (0, import_react.useCallback)((newState) => {
58
+ setTooltipState({ ...tooltipState, ...newState, visible: true });
59
+ }, [tooltipState]);
60
+ const hideTooltip = (0, import_react.useCallback)((newState) => {
61
+ setTooltipState({ ...tooltipState, ...newState, visible: false });
62
+ }, [tooltipState]);
63
+ const [showTooltip, cancelShowTooltip] = (0, import_ds_utilities.useCancellableDelayedCallback)(show, tooltipDelay);
64
+ const handleMouseEnter = (0, import_react.useCallback)((e) => {
65
+ const { target } = e;
66
+ const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
67
+ if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
68
+ showTooltip({ value, reference: SimpleTruncatedTextEl });
69
+ }
70
+ }, [showTooltip, value]);
71
+ const handleMouseLeave = (0, import_react.useCallback)(() => {
72
+ cancelShowTooltip();
73
+ hideTooltip({ reference: null });
74
+ }, [hideTooltip, cancelShowTooltip]);
75
+ const handlers = (0, import_react.useMemo)(() => {
76
+ if (!showTooltip)
77
+ return {};
78
+ return {
79
+ onMouseEnter: handleMouseEnter,
80
+ onMouseLeave: handleMouseLeave
81
+ };
82
+ }, [showTooltip, handleMouseEnter, handleMouseLeave]);
83
+ const PurePopover = (0, import_react.useMemo)(() => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, tooltipState.visible ? /* @__PURE__ */ import_react.default.createElement(import_ds_popover.DSPopover, {
84
+ boundaries: "window",
85
+ style: { pointerEvents: "none", zIndex },
86
+ placement,
87
+ content: tooltipState.value,
88
+ referenceEl: tooltipState.reference,
89
+ visible: tooltipState.visible,
90
+ showArrow: true
91
+ }) : null), [tooltipState, placement, zIndex]);
92
+ const PureText = (0, import_react.useMemo)(() => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(Text, {
93
+ ...containerProps && { ...containerProps },
94
+ ...textOptions && { ...textOptions },
95
+ ...handlers && { ...handlers },
96
+ "data-testid": dsTestId
97
+ }, value)), [containerProps, textOptions, handlers, value]);
98
+ const PureSimpleTruncatedTooltipText = (0, import_react.useMemo)(() => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, PureText, PurePopover), [PureText, PurePopover]);
99
+ return PureSimpleTruncatedTooltipText;
100
+ };
101
+ SimpleTruncatedTooltipText.propTypes = {
102
+ containerProps: import_prop_types.default.object,
103
+ tooltipOptions: import_prop_types.default.object,
104
+ textOptions: import_prop_types.default.object,
105
+ value: import_prop_types.default.oneOfType([import_prop_types.default.string, import_prop_types.default.number, import_prop_types.default.node]),
106
+ placement: import_prop_types.default.oneOf([
107
+ import_ds_popover.PopperPositions.AUTO_START,
108
+ import_ds_popover.PopperPositions.AUTO_END,
109
+ import_ds_popover.PopperPositions.AUTO,
110
+ import_ds_popover.PopperPositions.TOP_START,
111
+ import_ds_popover.PopperPositions.TOP,
112
+ import_ds_popover.PopperPositions.TOP_END,
113
+ import_ds_popover.PopperPositions.RIGHT_START,
114
+ import_ds_popover.PopperPositions.RIGHT,
115
+ import_ds_popover.PopperPositions.RIGHT_END,
116
+ import_ds_popover.PopperPositions.BOTTOM_START,
117
+ import_ds_popover.PopperPositions.BOTTOM,
118
+ import_ds_popover.PopperPositions.BOTTOM_END,
119
+ import_ds_popover.PopperPositions.LEFT_START,
120
+ import_ds_popover.PopperPositions.LEFT,
121
+ import_ds_popover.PopperPositions.LEFT_END
122
+ ]),
123
+ tooltipDelay: import_prop_types.default.number,
124
+ zIndex: import_prop_types.default.number
125
+ };
126
+ SimpleTruncatedTooltipText.defaultProps = {
127
+ containerProps: {},
128
+ tooltipOptions: {},
129
+ textOptions: {},
130
+ value: "",
131
+ placement: import_ds_popover.PopperPositions.TOP,
132
+ tooltipDelay: 200,
133
+ zIndex: 110
134
+ };
135
+ var SimpleTruncatedTooltipText_default = SimpleTruncatedTooltipText;
136
+ module.exports = __toCommonJS(SimpleTruncatedTooltipText_exports);
137
+ //# sourceMappingURL=SimpleTruncatedTooltipText.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/SimpleTruncatedTooltipText.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,74 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var TooltipTextProvider_exports = {};
29
+ __export(TooltipTextProvider_exports, {
30
+ TooltipTextProvider: () => TooltipTextProvider,
31
+ TruncatedTooltipContext: () => TruncatedTooltipContext,
32
+ default: () => TooltipTextProvider_default
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_ds_popover = require("@elliemae/ds-popover");
37
+ const TruncatedTooltipContext = import_react.default.createContext();
38
+ const { Provider } = TruncatedTooltipContext;
39
+ function TooltipTextProvider({
40
+ children,
41
+ tooltipDelay = 200,
42
+ placement = "top",
43
+ ...tooltipOptions
44
+ }) {
45
+ const {
46
+ show: showTooltip,
47
+ hide: hideTooltip,
48
+ state: tooltipState
49
+ } = (0, import_ds_popover.usePopoverProviderState)({ delay: tooltipDelay });
50
+ const [zIndex, setZIndex] = (0, import_react.useState)(110);
51
+ const value = (0, import_react.useMemo)(() => ({
52
+ showTooltip,
53
+ hideTooltip,
54
+ setZIndex
55
+ }), []);
56
+ return /* @__PURE__ */ import_react.default.createElement(Provider, {
57
+ value
58
+ }, children, tooltipState.visible ? /* @__PURE__ */ import_react.default.createElement(import_ds_popover.DSPopover, {
59
+ boundaries: "window",
60
+ placement,
61
+ showArrow: true,
62
+ ...tooltipOptions,
63
+ ...tooltipState.options || {},
64
+ content: tooltipState.value,
65
+ referenceEl: tooltipState.reference,
66
+ style: { pointerEvents: "none", zIndex },
67
+ visible: tooltipState.visible
68
+ }) : null);
69
+ }
70
+ TooltipTextProvider.propTypes = {};
71
+ TooltipTextProvider.defaultProps = {};
72
+ var TooltipTextProvider_default = TooltipTextProvider;
73
+ module.exports = __toCommonJS(TooltipTextProvider_exports);
74
+ //# sourceMappingURL=TooltipTextProvider.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/TooltipTextProvider.tsx", "../../../../scripts/build/transpile/react-shim.js"],
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({\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", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAyC;AACzC,wBAAmD;AAEnD,MAAM,0BAA0B,qBAAM;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,+CAAwB,EAAE,OAAO;AACrC,QAAM,CAAC,QAAQ,aAAa,2BAAS;AAErC,QAAM,QAAQ,0BACZ,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,MAEF;AAGF,SACE,mDAAC,UAAD;AAAA,IAAU;AAAA,KACP,UACA,aAAa,UACZ,mDAAC,6BAAD;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,45 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ DSTruncateTextWithTooltip: () => import_DSTruncateTextWithTooltip.DSTruncateTextWithTooltip,
31
+ DSTruncateTextWithTooltipDatatestId: () => import_DSTruncateTextWithTooltip.DSTruncateTextWithTooltipDatatestId,
32
+ DSTruncatedTooltipText: () => import_DSTruncatedTooltipText.DSTruncatedTooltipText,
33
+ SimpleTruncatedTooltipText: () => import_SimpleTruncatedTooltipText.SimpleTruncatedTooltipText,
34
+ TooltipTextProvider: () => import_TooltipTextProvider.TooltipTextProvider,
35
+ TruncatedTooltipContext: () => import_TooltipTextProvider.TruncatedTooltipContext,
36
+ TruncatedTooltipTextWithSchema: () => import_DSTruncatedTooltipText.TruncatedTooltipTextWithSchema,
37
+ default: () => import_DSTruncatedTooltipText.default
38
+ });
39
+ var React = __toESM(require("react"));
40
+ var import_TooltipTextProvider = require("./TooltipTextProvider");
41
+ var import_SimpleTruncatedTooltipText = require("./SimpleTruncatedTooltipText");
42
+ var import_DSTruncatedTooltipText = __toESM(require("./DSTruncatedTooltipText"));
43
+ var import_DSTruncateTextWithTooltip = require("./DSTruncateTextWithTooltip");
44
+ module.exports = __toCommonJS(src_exports);
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText';\nexport { DSTruncateTextWithTooltipDatatestId, DSTruncateTextWithTooltip } from './DSTruncateTextWithTooltip';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAA6D;AAC7D,wCAA2C;AAC3C,oCAAgF;AAChF,uCAA+E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,57 @@
1
+ import * as React from "react";
2
+ import React2, { useState, useMemo, useEffect } from "react";
3
+ import { DSTooltipV3 } from "@elliemae/ds-tooltip";
4
+ import styled from "styled-components";
5
+ const Text = styled.span`
6
+ text-overflow: ellipsis;
7
+ white-space: nowrap;
8
+ overflow: hidden;
9
+ display: inline-block;
10
+ max-width: 100%;
11
+ :focus {
12
+ border: none;
13
+ outline: none;
14
+ background: ${(props) => props.theme.colors.brand["200"]};
15
+ }
16
+ `;
17
+ const DSTruncateTextWithTooltipDatatestId = "DS-TruncateTextWithTooltip";
18
+ const DSTruncateTextWithTooltip = ({ text, tooltipProps = {} }) => {
19
+ const [textWrapperEl, setTextWrapperEl] = useState();
20
+ const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
21
+ const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
22
+ if (entries.length) {
23
+ const [textWrapperEntry] = entries;
24
+ const el = textWrapperEntry.target;
25
+ setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
26
+ }
27
+ }), []);
28
+ useEffect(() => {
29
+ if (textWrapperEl) {
30
+ setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
31
+ resizeObserver.observe(textWrapperEl);
32
+ }
33
+ return () => {
34
+ if (textWrapperEl) {
35
+ resizeObserver.unobserve(textWrapperEl);
36
+ }
37
+ };
38
+ }, [resizeObserver, textWrapperEl]);
39
+ if (isShowingEllipsis)
40
+ return /* @__PURE__ */ React2.createElement(DSTooltipV3, {
41
+ text,
42
+ ...tooltipProps
43
+ }, /* @__PURE__ */ React2.createElement(Text, {
44
+ ref: setTextWrapperEl,
45
+ tabIndex: 0,
46
+ "data-testid": DSTruncateTextWithTooltipDatatestId
47
+ }, text));
48
+ return /* @__PURE__ */ React2.createElement(Text, {
49
+ ref: setTextWrapperEl,
50
+ "data-testid": DSTruncateTextWithTooltipDatatestId
51
+ }, text);
52
+ };
53
+ export {
54
+ DSTruncateTextWithTooltip,
55
+ DSTruncateTextWithTooltipDatatestId
56
+ };
57
+ //# sourceMappingURL=DSTruncateTextWithTooltip.js.map
@@ -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
+ }