@elliemae/ds-truncated-tooltip-text 3.32.2-next.1 → 3.33.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DSTruncatedTooltipText.js +124 -0
- package/dist/cjs/DSTruncatedTooltipText.js.map +7 -0
- package/dist/cjs/SimpleTruncatedTooltipText.js +171 -0
- package/dist/cjs/SimpleTruncatedTooltipText.js.map +7 -0
- package/dist/cjs/TooltipTextProvider.js +78 -0
- package/dist/cjs/TooltipTextProvider.js.map +7 -0
- package/dist/cjs/index.js +13 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +38 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +80 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/index.js +43 -0
- package/dist/cjs/truncateTextWithTooltip/index.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/react-desc-prop-types.js +48 -0
- package/dist/cjs/truncateTextWithTooltip/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/styles.js +48 -0
- package/dist/cjs/truncateTextWithTooltip/styles.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.js +72 -0
- package/dist/cjs/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.js.map +7 -0
- package/dist/esm/DSTruncatedTooltipText.js +94 -0
- package/dist/esm/DSTruncatedTooltipText.js.map +7 -0
- package/dist/esm/SimpleTruncatedTooltipText.js +141 -0
- package/dist/esm/SimpleTruncatedTooltipText.js.map +7 -0
- package/dist/esm/TooltipTextProvider.js +48 -0
- package/dist/esm/TooltipTextProvider.js.map +7 -0
- package/dist/esm/index.js +16 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +8 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +53 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/index.js +17 -0
- package/dist/esm/truncateTextWithTooltip/index.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/react-desc-prop-types.js +18 -0
- package/dist/esm/truncateTextWithTooltip/react-desc-prop-types.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/styles.js +18 -0
- package/dist/esm/truncateTextWithTooltip/styles.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.js +49 -0
- package/dist/esm/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.js.map +7 -0
- package/dist/types/DSTruncatedTooltipText.d.ts +37 -0
- package/dist/types/SimpleTruncatedTooltipText.d.ts +36 -0
- package/dist/types/TooltipTextProvider.d.ts +14 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.d.ts +3 -0
- package/dist/types/truncateTextWithTooltip/DSTruncateTextWithTooltip.d.ts +4 -0
- package/dist/types/truncateTextWithTooltip/index.d.ts +3 -0
- package/dist/types/truncateTextWithTooltip/react-desc-prop-types.d.ts +19 -0
- package/dist/types/truncateTextWithTooltip/styles.d.ts +1 -0
- package/dist/types/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.d.ts +1 -0
- package/package.json +9 -3
@@ -0,0 +1,124 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var DSTruncatedTooltipText_exports = {};
|
30
|
+
__export(DSTruncatedTooltipText_exports, {
|
31
|
+
DSTruncatedTooltipText: () => DSTruncatedTooltipText,
|
32
|
+
TruncatedTooltipTextWithSchema: () => TruncatedTooltipTextWithSchema,
|
33
|
+
default: () => DSTruncatedTooltipText_default
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(DSTruncatedTooltipText_exports);
|
36
|
+
var React = __toESM(require("react"));
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
38
|
+
var import_react = require("react");
|
39
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
40
|
+
var import_ds_system = require("@elliemae/ds-system");
|
41
|
+
var import_ds_popper = require("@elliemae/ds-popper");
|
42
|
+
var import_TooltipTextProvider = require("./TooltipTextProvider.js");
|
43
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
44
|
+
const Text = import_ds_system.styled.span`
|
45
|
+
text-overflow: ellipsis;
|
46
|
+
white-space: nowrap;
|
47
|
+
overflow: hidden;
|
48
|
+
display: inline-block;
|
49
|
+
max-width: 100%;
|
50
|
+
`;
|
51
|
+
const DSTruncatedTooltipText = ({
|
52
|
+
containerProps = {},
|
53
|
+
value = "",
|
54
|
+
zIndex = 3e3,
|
55
|
+
// https://jira.elliemae.io/browse/PUI-1755 https://jira.elliemae.io/browse/PUI-8732
|
56
|
+
...otherTextProps
|
57
|
+
}) => {
|
58
|
+
const tooltipContext = (0, import_react.useContext)(import_TooltipTextProvider.TruncatedTooltipContext);
|
59
|
+
(0, import_react.useEffect)(() => {
|
60
|
+
if (zIndex && tooltipContext)
|
61
|
+
tooltipContext.setZIndex(zIndex);
|
62
|
+
}, [zIndex]);
|
63
|
+
if (!tooltipContext)
|
64
|
+
return value;
|
65
|
+
const { showTooltip, hideTooltip } = tooltipContext;
|
66
|
+
const handleMouseEnter = (e) => {
|
67
|
+
const { target } = e;
|
68
|
+
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
69
|
+
showTooltip(
|
70
|
+
{
|
71
|
+
value,
|
72
|
+
reference: target
|
73
|
+
},
|
74
|
+
e
|
75
|
+
);
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const handleMouseLeave = (e) => {
|
79
|
+
hideTooltip({ reference: e.target });
|
80
|
+
};
|
81
|
+
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { ...containerProps, ...otherTextProps, ...handlers, children: value });
|
83
|
+
};
|
84
|
+
DSTruncatedTooltipText.defaultProps = {
|
85
|
+
value: "",
|
86
|
+
zIndex: 110
|
87
|
+
};
|
88
|
+
const truncatedTooltipTextProps = {
|
89
|
+
containerProps: import_ds_props_helpers.PropTypes.object.description("Set of Properties attached to the main container"),
|
90
|
+
value: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.string, import_ds_props_helpers.PropTypes.number]).description(
|
91
|
+
"Text that when truncated will trigger the tooltip interaction"
|
92
|
+
),
|
93
|
+
tooltipPlacement: import_ds_props_helpers.PropTypes.oneOf([
|
94
|
+
import_ds_popper.PopperPositions.AUTO_START,
|
95
|
+
import_ds_popper.PopperPositions.AUTO_END,
|
96
|
+
import_ds_popper.PopperPositions.AUTO,
|
97
|
+
import_ds_popper.PopperPositions.TOP_START,
|
98
|
+
import_ds_popper.PopperPositions.TOP,
|
99
|
+
import_ds_popper.PopperPositions.TOP_END,
|
100
|
+
import_ds_popper.PopperPositions.RIGHT_START,
|
101
|
+
import_ds_popper.PopperPositions.RIGHT,
|
102
|
+
import_ds_popper.PopperPositions.RIGHT_END,
|
103
|
+
import_ds_popper.PopperPositions.BOTTOM_START,
|
104
|
+
import_ds_popper.PopperPositions.BOTTOM,
|
105
|
+
import_ds_popper.PopperPositions.BOTTOM_END,
|
106
|
+
import_ds_popper.PopperPositions.LEFT_START,
|
107
|
+
import_ds_popper.PopperPositions.LEFT,
|
108
|
+
import_ds_popper.PopperPositions.LEFT_END
|
109
|
+
]).description("Position of the tooltip"),
|
110
|
+
tooltipDelay: import_ds_props_helpers.PropTypes.number.description("Delay to show the tooltip"),
|
111
|
+
zIndex: import_ds_props_helpers.PropTypes.number.description("override default zIndex").defaultValue(110)
|
112
|
+
};
|
113
|
+
DSTruncatedTooltipText.defaultProps = {
|
114
|
+
containerProps: {},
|
115
|
+
value: "",
|
116
|
+
tooltipPlacement: void 0,
|
117
|
+
tooltipDelay: void 0
|
118
|
+
};
|
119
|
+
DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
|
120
|
+
DSTruncatedTooltipText.displayName = "DSTruncatedTooltipText";
|
121
|
+
const TruncatedTooltipTextWithSchema = (0, import_ds_props_helpers.describe)(DSTruncatedTooltipText);
|
122
|
+
TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
|
123
|
+
var DSTruncatedTooltipText_default = DSTruncatedTooltipText;
|
124
|
+
//# 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 '@elliemae/ds-props-helpers';\nimport { styled } from '@elliemae/ds-system';\nimport { PopperPositions as positions } from '@elliemae/ds-popper';\nimport { TruncatedTooltipContext } from './TooltipTextProvider.js';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;\n\n// reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n`;\n\nconst DSTruncatedTooltipText = ({\n containerProps = {},\n value = '',\n zIndex = 3000, // https://jira.elliemae.io/browse/PUI-1755 https://jira.elliemae.io/browse/PUI-8732\n ...otherTextProps\n}) => {\n const tooltipContext = useContext(TruncatedTooltipContext);\n useEffect(() => {\n if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);\n }, [zIndex]);\n\n if (!tooltipContext) return value;\n\n const { showTooltip, hideTooltip } = tooltipContext;\n\n const handleMouseEnter = (e) => {\n const { target } = e;\n if (target && isEllipsisActive(target, target.getBoundingClientRect())) {\n showTooltip(\n {\n value,\n reference: target,\n },\n e,\n );\n }\n };\n\n const handleMouseLeave = (e) => {\n hideTooltip({ reference: e.target });\n };\n\n const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};\n return (\n <Text {...containerProps} {...otherTextProps} {...handlers}>\n {value}\n </Text>\n );\n};\n\nDSTruncatedTooltipText.defaultProps = {\n value: '',\n zIndex: 110,\n};\n\nconst truncatedTooltipTextProps = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(\n 'Text that when truncated will trigger the tooltip interaction',\n ),\n tooltipPlacement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]).description('Position of the tooltip'),\n tooltipDelay: PropTypes.number.description('Delay to show the tooltip'),\n zIndex: PropTypes.number.description('override default zIndex').defaultValue(110),\n};\n\nDSTruncatedTooltipText.defaultProps = {\n containerProps: {},\n value: '',\n tooltipPlacement: undefined,\n tooltipDelay: undefined,\n};\n\nDSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;\nDSTruncatedTooltipText.displayName = 'DSTruncatedTooltipText';\nconst TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);\nTruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;\n\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema };\nexport default DSTruncatedTooltipText;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADmDnB;AAnDJ,mBAA6C;AAC7C,8BAAoC;AACpC,uBAAuB;AACvB,uBAA6C;AAC7C,iCAAwC;AAExC,MAAM,mBAA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gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,IACV,iBAAAA,gBAAU;AAAA,EACZ,CAAC,EAAE,YAAY,yBAAyB;AAAA,EACxC,cAAc,kCAAU,OAAO,YAAY,2BAA2B;AAAA,EACtE,QAAQ,kCAAU,OAAO,YAAY,yBAAyB,EAAE,aAAa,GAAG;AAClF;AAEA,uBAAuB,eAAe;AAAA,EACpC,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAChB;AAEA,uBAAuB,YAAY;AACnC,uBAAuB,cAAc;AACrC,MAAM,qCAAiC,kCAAS,sBAAsB;AACtE,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
|
6
|
+
"names": ["positions"]
|
7
|
+
}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var SimpleTruncatedTooltipText_exports = {};
|
30
|
+
__export(SimpleTruncatedTooltipText_exports, {
|
31
|
+
SimpleTruncatedTooltipText: () => SimpleTruncatedTooltipText,
|
32
|
+
default: () => SimpleTruncatedTooltipText_default
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(SimpleTruncatedTooltipText_exports);
|
35
|
+
var React = __toESM(require("react"));
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
37
|
+
var import_react = require("react");
|
38
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
39
|
+
var import_prop_types = __toESM(require("prop-types"));
|
40
|
+
var import_ds_system = require("@elliemae/ds-system");
|
41
|
+
var import_ds_popover = require("@elliemae/ds-popover");
|
42
|
+
const dsTestId = "DS-SimpleTruncateText";
|
43
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
44
|
+
const initialTooltipState = (value = "", options = {}) => ({
|
45
|
+
reference: null,
|
46
|
+
visible: false,
|
47
|
+
value,
|
48
|
+
options
|
49
|
+
});
|
50
|
+
const Text = import_ds_system.styled.span`
|
51
|
+
text-overflow: ellipsis;
|
52
|
+
white-space: nowrap;
|
53
|
+
overflow: hidden;
|
54
|
+
display: inline-block;
|
55
|
+
max-width: 100%;
|
56
|
+
`;
|
57
|
+
const SimpleTruncatedTooltipText = (props) => {
|
58
|
+
const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
|
59
|
+
const [tooltipState, setTooltipState] = (0, import_react.useState)(initialTooltipState(value, tooltipOptions));
|
60
|
+
const show = (0, import_react.useCallback)(
|
61
|
+
(newState) => {
|
62
|
+
setTooltipState({ ...tooltipState, ...newState, visible: true });
|
63
|
+
},
|
64
|
+
[tooltipState]
|
65
|
+
);
|
66
|
+
const hideTooltip = (0, import_react.useCallback)(
|
67
|
+
(newState) => {
|
68
|
+
setTooltipState({ ...tooltipState, ...newState, visible: false });
|
69
|
+
},
|
70
|
+
[tooltipState]
|
71
|
+
);
|
72
|
+
const [showTooltip, cancelShowTooltip] = (0, import_ds_utilities.useCancellableDelayedCallback)(show, tooltipDelay);
|
73
|
+
const handleMouseEnter = (0, import_react.useCallback)(
|
74
|
+
(e) => {
|
75
|
+
const { target } = e;
|
76
|
+
const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
|
77
|
+
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
78
|
+
showTooltip({ value, reference: SimpleTruncatedTextEl });
|
79
|
+
}
|
80
|
+
},
|
81
|
+
[showTooltip, value]
|
82
|
+
);
|
83
|
+
const handleMouseLeave = (0, import_react.useCallback)(() => {
|
84
|
+
cancelShowTooltip();
|
85
|
+
hideTooltip({ reference: null });
|
86
|
+
}, [hideTooltip, cancelShowTooltip]);
|
87
|
+
const handlers = (0, import_react.useMemo)(() => {
|
88
|
+
if (!showTooltip)
|
89
|
+
return {};
|
90
|
+
return {
|
91
|
+
onMouseEnter: handleMouseEnter,
|
92
|
+
onMouseLeave: handleMouseLeave
|
93
|
+
};
|
94
|
+
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
95
|
+
const theme = (0, import_react.useContext)(import_ds_system.ThemeContext);
|
96
|
+
const PurePopover = (0, import_react.useMemo)(
|
97
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: tooltipState.visible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
98
|
+
import_ds_popover.DSPopover,
|
99
|
+
{
|
100
|
+
boundaries: "window",
|
101
|
+
style: { pointerEvents: "none", zIndex: zIndex ?? theme.zIndex.tooltip },
|
102
|
+
placement,
|
103
|
+
content: tooltipState.value,
|
104
|
+
referenceEl: tooltipState.reference,
|
105
|
+
visible: tooltipState.visible,
|
106
|
+
showArrow: true
|
107
|
+
}
|
108
|
+
) : null }),
|
109
|
+
[tooltipState, placement, zIndex]
|
110
|
+
);
|
111
|
+
const PureText = (0, import_react.useMemo)(
|
112
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
113
|
+
Text,
|
114
|
+
{
|
115
|
+
...containerProps && { ...containerProps },
|
116
|
+
...textOptions && { ...textOptions },
|
117
|
+
...handlers && { ...handlers },
|
118
|
+
"data-testid": dsTestId,
|
119
|
+
children: value
|
120
|
+
}
|
121
|
+
) }),
|
122
|
+
[containerProps, textOptions, handlers, value]
|
123
|
+
);
|
124
|
+
const PureSimpleTruncatedTooltipText = (0, import_react.useMemo)(
|
125
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
126
|
+
PureText,
|
127
|
+
PurePopover
|
128
|
+
] }),
|
129
|
+
[PureText, PurePopover]
|
130
|
+
);
|
131
|
+
return PureSimpleTruncatedTooltipText;
|
132
|
+
};
|
133
|
+
SimpleTruncatedTooltipText.propTypes = {
|
134
|
+
containerProps: import_prop_types.default.object,
|
135
|
+
tooltipOptions: import_prop_types.default.object,
|
136
|
+
textOptions: import_prop_types.default.object,
|
137
|
+
/** Text that when truncated will trigger the tooltip interaction */
|
138
|
+
value: import_prop_types.default.oneOfType([import_prop_types.default.string, import_prop_types.default.number, import_prop_types.default.node]),
|
139
|
+
/** Position of the tooltip */
|
140
|
+
placement: import_prop_types.default.oneOf([
|
141
|
+
import_ds_popover.PopperPositions.AUTO_START,
|
142
|
+
import_ds_popover.PopperPositions.AUTO_END,
|
143
|
+
import_ds_popover.PopperPositions.AUTO,
|
144
|
+
import_ds_popover.PopperPositions.TOP_START,
|
145
|
+
import_ds_popover.PopperPositions.TOP,
|
146
|
+
import_ds_popover.PopperPositions.TOP_END,
|
147
|
+
import_ds_popover.PopperPositions.RIGHT_START,
|
148
|
+
import_ds_popover.PopperPositions.RIGHT,
|
149
|
+
import_ds_popover.PopperPositions.RIGHT_END,
|
150
|
+
import_ds_popover.PopperPositions.BOTTOM_START,
|
151
|
+
import_ds_popover.PopperPositions.BOTTOM,
|
152
|
+
import_ds_popover.PopperPositions.BOTTOM_END,
|
153
|
+
import_ds_popover.PopperPositions.LEFT_START,
|
154
|
+
import_ds_popover.PopperPositions.LEFT,
|
155
|
+
import_ds_popover.PopperPositions.LEFT_END
|
156
|
+
]),
|
157
|
+
/** Delay to show the tooltip */
|
158
|
+
tooltipDelay: import_prop_types.default.number,
|
159
|
+
/** override default zIndex */
|
160
|
+
zIndex: import_prop_types.default.number
|
161
|
+
};
|
162
|
+
SimpleTruncatedTooltipText.defaultProps = {
|
163
|
+
containerProps: {},
|
164
|
+
tooltipOptions: {},
|
165
|
+
textOptions: {},
|
166
|
+
value: "",
|
167
|
+
placement: import_ds_popover.PopperPositions.TOP,
|
168
|
+
tooltipDelay: 200
|
169
|
+
};
|
170
|
+
var SimpleTruncatedTooltipText_default = SimpleTruncatedTooltipText;
|
171
|
+
//# 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, useContext, useMemo, useState } from 'react';\nimport { useCancellableDelayedCallback } from '@elliemae/ds-utilities';\nimport PropTypes from 'prop-types';\nimport { styled, ThemeContext } from '@elliemae/ds-system';\nimport { DSPopover, PopperPositions as positions } from '@elliemae/ds-popover';\n\nconst dsTestId = 'DS-SimpleTruncateText';\n\nconst isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;\n\nconst initialTooltipState = (value = '', options = {}) => ({\n reference: null,\n visible: false,\n value,\n options,\n});\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nconst Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n`;\n\ninterface SimpleTruncatedTooltipTextProps {\n containerProps?: Record<string, unknown>;\n tooltipDelay?: number;\n placement?: string;\n value?: string | JSX.Element;\n zIndex?: number;\n tooltipOptions?: Record<string, unknown>;\n textOptions?: Record<string, unknown>;\n}\n\nconst SimpleTruncatedTooltipText = (props: SimpleTruncatedTooltipTextProps) => {\n const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;\n // not using \"usePopoverProviderState\" because usePopoverState has memory leak issues\n const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));\n const show = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: true });\n },\n [tooltipState],\n );\n const hideTooltip = useCallback(\n (newState) => {\n setTooltipState({ ...tooltipState, ...newState, visible: false });\n },\n [tooltipState],\n );\n const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);\n\n const handleMouseEnter = useCallback(\n (e) => {\n const { target } = e;\n // we search for the closest parent with data-testid matching this component\n // this is required because the target may not be this component itself\n // when the user gives JSX as a value.\n // JSX as a value is required for features like text highlight during research\n // wich would still allow the truncation behaviour (see tree view for example)\n // when the target has the test-id itself target===SimpleTruncatedTextEl\n const SimpleTruncatedTextEl = target.closest(`[data-testid=\"${dsTestId}\"]`);\n if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {\n showTooltip({ value, reference: SimpleTruncatedTextEl });\n }\n },\n [showTooltip, value],\n );\n\n const handleMouseLeave = useCallback(() => {\n cancelShowTooltip();\n hideTooltip({ reference: null });\n }, [hideTooltip, cancelShowTooltip]);\n\n const handlers = useMemo(() => {\n if (!showTooltip) return {};\n return {\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n };\n }, [showTooltip, handleMouseEnter, handleMouseLeave]);\n\n const theme = useContext(ThemeContext);\n\n const PurePopover = useMemo(\n () => (\n <>\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n style={{ pointerEvents: 'none', zIndex: zIndex ?? theme.zIndex.tooltip }}\n placement={placement}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n visible={tooltipState.visible}\n showArrow\n />\n ) : null}\n </>\n ),\n [tooltipState, placement, zIndex],\n );\n const PureText = useMemo(\n () => (\n <>\n <Text\n {...(containerProps && { ...containerProps })}\n {...(textOptions && { ...textOptions })}\n {...(handlers && { ...handlers })}\n data-testid={dsTestId} // this is used by mouse enter too. required to support value as JSX\n >\n {value}\n </Text>\n </>\n ),\n [containerProps, textOptions, handlers, value],\n );\n\n const PureSimpleTruncatedTooltipText = useMemo(\n () => (\n <>\n {PureText}\n {PurePopover}\n </>\n ),\n [PureText, PurePopover],\n );\n\n return PureSimpleTruncatedTooltipText;\n};\n\nSimpleTruncatedTooltipText.propTypes = {\n containerProps: PropTypes.object,\n tooltipOptions: PropTypes.object,\n textOptions: PropTypes.object,\n /** Text that when truncated will trigger the tooltip interaction */\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),\n /** Position of the tooltip */\n placement: PropTypes.oneOf([\n positions.AUTO_START,\n positions.AUTO_END,\n positions.AUTO,\n positions.TOP_START,\n positions.TOP,\n positions.TOP_END,\n positions.RIGHT_START,\n positions.RIGHT,\n positions.RIGHT_END,\n positions.BOTTOM_START,\n positions.BOTTOM,\n positions.BOTTOM_END,\n positions.LEFT_START,\n positions.LEFT,\n positions.LEFT_END,\n ]),\n /** Delay to show the tooltip */\n tooltipDelay: PropTypes.number,\n /** override default zIndex */\n zIndex: PropTypes.number,\n};\n\nSimpleTruncatedTooltipText.defaultProps = {\n containerProps: {},\n tooltipOptions: {},\n textOptions: {},\n value: '',\n placement: positions.TOP,\n tooltipDelay: 200,\n};\n\nexport { SimpleTruncatedTooltipText };\nexport default SimpleTruncatedTooltipText;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADwFjB;AAvFN,mBAAkE;AAClE,0BAA8C;AAC9C,wBAAsB;AACtB,uBAAqC;AACrC,wBAAwD;AAExD,MAAM,WAAW;AAEjB,MAAM,mBAAmB,CAAC,EAAE,aAAa,YAAY,MAAM,cAAc;AAEzE,MAAM,sBAAsB,CAAC,QAAQ,IAAI,UAAU,CAAC,OAAO;AAAA,EACzD,WAAW;AAAA,EACX,SAAS;AAAA,EACT;AAAA,EACA;AACF;AAEA,MAAM,OAAO,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBpB,MAAM,6BAA6B,CAAC,UAA2C;AAC7E,QAAM,EAAE,gBAAgB,cAAc,WAAW,OAAO,QAAQ,gBAAgB,YAAY,IAAI;AAEhG,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAS,oBAAoB,OAAO,cAAc,CAAC;AAC3F,QAAM,WAAO;AAAA,IACX,CAAC,aAAa;AACZ,sBAAgB,EAAE,GAAG,cAAc,GAAG,UAAU,SAAS,KAAK,CAAC;AAAA,IACjE;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AACA,QAAM,kBAAc;AAAA,IAClB,CA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AAO;AAAA,EACP,WAAW,kBAAAC,gBAAU;AAAA,EACrB,cAAc;AAChB;AAGA,IAAO,qCAAQ;",
|
6
|
+
"names": ["PropTypes", "positions"]
|
7
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var TooltipTextProvider_exports = {};
|
30
|
+
__export(TooltipTextProvider_exports, {
|
31
|
+
TooltipTextProvider: () => TooltipTextProvider,
|
32
|
+
TruncatedTooltipContext: () => TruncatedTooltipContext,
|
33
|
+
default: () => TooltipTextProvider_default
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(TooltipTextProvider_exports);
|
36
|
+
var React = __toESM(require("react"));
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
38
|
+
var import_react = __toESM(require("react"));
|
39
|
+
var import_ds_popover = require("@elliemae/ds-popover");
|
40
|
+
const TruncatedTooltipContext = import_react.default.createContext();
|
41
|
+
const { Provider } = TruncatedTooltipContext;
|
42
|
+
const TooltipTextProvider = ({ children, tooltipDelay = 200, placement = "top", ...tooltipOptions }) => {
|
43
|
+
const {
|
44
|
+
show: showTooltip,
|
45
|
+
hide: hideTooltip,
|
46
|
+
state: tooltipState
|
47
|
+
} = (0, import_ds_popover.usePopoverProviderState)({ delay: tooltipDelay });
|
48
|
+
const [zIndex, setZIndex] = (0, import_react.useState)(110);
|
49
|
+
const value = (0, import_react.useMemo)(
|
50
|
+
() => ({
|
51
|
+
showTooltip,
|
52
|
+
hideTooltip,
|
53
|
+
setZIndex
|
54
|
+
}),
|
55
|
+
[]
|
56
|
+
);
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Provider, { value, children: [
|
58
|
+
children,
|
59
|
+
tooltipState.visible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
60
|
+
import_ds_popover.DSPopover,
|
61
|
+
{
|
62
|
+
boundaries: "window",
|
63
|
+
placement,
|
64
|
+
showArrow: true,
|
65
|
+
...tooltipOptions,
|
66
|
+
...tooltipState.options || {},
|
67
|
+
content: tooltipState.value,
|
68
|
+
referenceEl: tooltipState.reference,
|
69
|
+
style: { pointerEvents: "none", zIndex },
|
70
|
+
visible: tooltipState.visible
|
71
|
+
}
|
72
|
+
) : null
|
73
|
+
] });
|
74
|
+
};
|
75
|
+
TooltipTextProvider.propTypes = {};
|
76
|
+
TooltipTextProvider.defaultProps = {};
|
77
|
+
var TooltipTextProvider_default = TooltipTextProvider;
|
78
|
+
//# 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\nconst TooltipTextProvider = ({ children, tooltipDelay = 200, placement = 'top', ...tooltipOptions }) => {\n const {\n show: showTooltip,\n hide: hideTooltip,\n state: tooltipState,\n } = usePopoverProviderState({ delay: tooltipDelay });\n const [zIndex, setZIndex] = useState(110);\n\n const value = useMemo(\n () => ({\n showTooltip,\n hideTooltip,\n setZIndex,\n }),\n [],\n );\n\n return (\n <Provider value={value}>\n {children}\n {tooltipState.visible ? (\n <DSPopover\n boundaries=\"window\"\n placement={placement}\n showArrow\n {...tooltipOptions}\n {...(tooltipState.options || {})}\n content={tooltipState.value}\n referenceEl={tooltipState.reference}\n style={{ pointerEvents: 'none', zIndex }}\n visible={tooltipState.visible}\n />\n ) : null}\n </Provider>\n );\n};\n\nTooltipTextProvider.propTypes = {};\nTooltipTextProvider.defaultProps = {};\n\nexport { TooltipTextProvider, TruncatedTooltipContext };\nexport default TooltipTextProvider;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD0BnB;AAzBJ,mBAAyC;AACzC,wBAAmD;AAEnD,MAAM,0BAA0B,aAAAA,QAAM,cAAc;AAEpD,MAAM,EAAE,SAAS,IAAI;AAErB,MAAM,sBAAsB,CAAC,EAAE,UAAU,eAAe,KAAK,YAAY,OAAO,GAAG,eAAe,MAAM;AACtG,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT,QAAI,2CAAwB,EAAE,OAAO,aAAa,CAAC;AACnD,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,GAAG;AAExC,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SACE,6CAAC,YAAS,OACP;AAAA;AAAA,IACA,aAAa,UACZ;AAAA,MAAC;AAAA;AAAA,QACC,YAAW;AAAA,QACX;AAAA,QACA,WAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAI,aAAa,WAAW,CAAC;AAAA,QAC9B,SAAS,aAAa;AAAA,QACtB,aAAa,aAAa;AAAA,QAC1B,OAAO,EAAE,eAAe,QAAQ,OAAO;AAAA,QACvC,SAAS,aAAa;AAAA;AAAA,IACxB,IACE;AAAA,KACN;AAEJ;AAEA,oBAAoB,YAAY,CAAC;AACjC,oBAAoB,eAAe,CAAC;AAGpC,IAAO,8BAAQ;",
|
6
|
+
"names": ["React"]
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
}
|
18
18
|
return to;
|
19
19
|
};
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
21
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
23
22
|
// file that has been converted to a CommonJS file using a Babel-
|
@@ -29,10 +28,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
29
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
29
|
var src_exports = {};
|
31
30
|
__export(src_exports, {
|
32
|
-
|
31
|
+
DSTruncateTextWithTooltip: () => import_truncateTextWithTooltip.DSTruncateTextWithTooltip,
|
32
|
+
DSTruncateTextWithTooltipDatatestid: () => import_truncateTextWithTooltip.DSTruncateTextWithTooltipDatatestid,
|
33
|
+
DSTruncateTextWithTooltipWithSchema: () => import_truncateTextWithTooltip.DSTruncateTextWithTooltipWithSchema,
|
34
|
+
DSTruncatedTooltipText: () => import_DSTruncatedTooltipText.DSTruncatedTooltipText,
|
35
|
+
SimpleTruncatedTooltipText: () => import_SimpleTruncatedTooltipText.SimpleTruncatedTooltipText,
|
36
|
+
TooltipTextProvider: () => import_TooltipTextProvider.TooltipTextProvider,
|
37
|
+
TruncatedTooltipContext: () => import_TooltipTextProvider.TruncatedTooltipContext,
|
38
|
+
TruncatedTooltipTextWithSchema: () => import_DSTruncatedTooltipText.TruncatedTooltipTextWithSchema,
|
39
|
+
default: () => import_DSTruncatedTooltipText.default
|
33
40
|
});
|
34
41
|
module.exports = __toCommonJS(src_exports);
|
35
42
|
var React = __toESM(require("react"));
|
36
|
-
|
37
|
-
var
|
43
|
+
var import_TooltipTextProvider = require("./TooltipTextProvider.js");
|
44
|
+
var import_SimpleTruncatedTooltipText = require("./SimpleTruncatedTooltipText.js");
|
45
|
+
var import_DSTruncatedTooltipText = __toESM(require("./DSTruncatedTooltipText.js"));
|
46
|
+
var import_truncateTextWithTooltip = require("./truncateTextWithTooltip/index.js");
|
38
47
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
-
"sourcesContent": ["export
|
5
|
-
"mappings": "
|
4
|
+
"sourcesContent": ["export { TooltipTextProvider, TruncatedTooltipContext } from './TooltipTextProvider.js';\nexport { SimpleTruncatedTooltipText } from './SimpleTruncatedTooltipText.js';\nexport { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default } from './DSTruncatedTooltipText.js';\nexport {\n DSTruncateTextWithTooltipDatatestid,\n DSTruncateTextWithTooltip,\n DSTruncateTextWithTooltipWithSchema,\n} from './truncateTextWithTooltip/index.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAA6D;AAC7D,wCAA2C;AAC3C,oCAAgF;AAChF,qCAIO;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var DSTruncateTextWIthTooltipDatatestid_exports = {};
|
30
|
+
__export(DSTruncateTextWIthTooltipDatatestid_exports, {
|
31
|
+
DSTruncateTextWithTooltipDatatestid: () => DSTruncateTextWithTooltipDatatestid
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(DSTruncateTextWIthTooltipDatatestid_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
const DSTruncateTextWithTooltipDatatestid = {
|
36
|
+
TEXT: "ds-truncatetextwithtooltip-text"
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=DSTruncateTextWIthTooltipDatatestid.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["export const DSTruncateTextWithTooltipDatatestid = {\n TEXT: 'ds-truncatetextwithtooltip-text',\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,sCAAsC;AAAA,EACjD,MAAM;AACR;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var DSTruncateTextWithTooltip_exports = {};
|
30
|
+
__export(DSTruncateTextWithTooltip_exports, {
|
31
|
+
DSTruncateTextWithTooltip: () => DSTruncateTextWithTooltip,
|
32
|
+
DSTruncateTextWithTooltipWithSchema: () => DSTruncateTextWithTooltipWithSchema
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(DSTruncateTextWithTooltip_exports);
|
35
|
+
var React = __toESM(require("react"));
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
37
|
+
var import_react = require("react");
|
38
|
+
var import_ds_tooltip = require("@elliemae/ds-tooltip");
|
39
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
40
|
+
var import_DSTruncateTextWIthTooltipDatatestid = require("./DSTruncateTextWIthTooltipDatatestid.js");
|
41
|
+
var import_styles = require("./styles.js");
|
42
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
43
|
+
const DSTruncateTextWithTooltip = (props) => {
|
44
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_react_desc_prop_types.defaultProps);
|
45
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(
|
46
|
+
propsWithDefault,
|
47
|
+
import_react_desc_prop_types.DSTruncateTextWithTooltipPropTypesSchema,
|
48
|
+
"DSTruncateTextWithTooltip"
|
49
|
+
);
|
50
|
+
const { text, tooltipProps } = propsWithDefault;
|
51
|
+
const [textWrapperEl, setTextWrapperEl] = (0, import_react.useState)(null);
|
52
|
+
const [isShowingEllipsis, setIsShowingEllipsis] = (0, import_react.useState)(false);
|
53
|
+
const resizeObserver = (0, import_react.useMemo)(
|
54
|
+
() => new ResizeObserver((entries) => {
|
55
|
+
if (entries.length) {
|
56
|
+
const [textWrapperEntry] = entries;
|
57
|
+
const el = textWrapperEntry.target;
|
58
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
59
|
+
}
|
60
|
+
}),
|
61
|
+
[]
|
62
|
+
);
|
63
|
+
(0, import_react.useEffect)(() => {
|
64
|
+
if (textWrapperEl) {
|
65
|
+
setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
|
66
|
+
resizeObserver.observe(textWrapperEl);
|
67
|
+
}
|
68
|
+
return () => {
|
69
|
+
if (textWrapperEl) {
|
70
|
+
resizeObserver.unobserve(textWrapperEl);
|
71
|
+
}
|
72
|
+
};
|
73
|
+
}, [resizeObserver, textWrapperEl]);
|
74
|
+
if (isShowingEllipsis)
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_tooltip.DSTooltipV3, { text, ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Text, { ref: setTextWrapperEl, tabIndex: 0, "data-testid": import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid.TEXT, children: text }) });
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Text, { ref: setTextWrapperEl, "data-testid": import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid.TEXT, children: text });
|
77
|
+
};
|
78
|
+
const DSTruncateTextWithTooltipWithSchema = (0, import_ds_props_helpers.describe)(DSTruncateTextWithTooltip);
|
79
|
+
DSTruncateTextWithTooltipWithSchema.propTypes = import_react_desc_prop_types.DSTruncateTextWithTooltipPropTypesSchema;
|
80
|
+
//# sourceMappingURL=DSTruncateTextWithTooltip.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/truncateTextWithTooltip/DSTruncateTextWithTooltip.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import React, { useState, useMemo, useEffect } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-props-helpers';\nimport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid.js';\nimport { Text } from './styles.js';\nimport {\n type DSTruncateTextWithTooltipT,\n DSTruncateTextWithTooltipPropTypesSchema,\n defaultProps,\n} from './react-desc-prop-types.js';\n\nconst DSTruncateTextWithTooltip = (props: DSTruncateTextWithTooltipT.Props): JSX.Element => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTruncateTextWithTooltipT.InternalProps>(props, defaultProps);\n\n useValidateTypescriptPropTypes(\n propsWithDefault,\n DSTruncateTextWithTooltipPropTypesSchema,\n 'DSTruncateTextWithTooltip',\n );\n\n const { text, tooltipProps } = propsWithDefault;\n\n const [textWrapperEl, setTextWrapperEl] = useState<HTMLSpanElement | null>(null);\n const [isShowingEllipsis, setIsShowingEllipsis] = useState<boolean>(false);\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n\n useEffect(() => {\n if (textWrapperEl) {\n setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);\n resizeObserver.observe(textWrapperEl);\n }\n return () => {\n if (textWrapperEl) {\n resizeObserver.unobserve(textWrapperEl);\n }\n };\n }, [resizeObserver, textWrapperEl]);\n\n if (isShowingEllipsis)\n return (\n <DSTooltipV3 text={text} {...tooltipProps}>\n <Text ref={setTextWrapperEl} tabIndex={0} data-testid={DSTruncateTextWithTooltipDatatestid.TEXT}>\n {text}\n </Text>\n </DSTooltipV3>\n );\n\n return (\n <Text ref={setTextWrapperEl} data-testid={DSTruncateTextWithTooltipDatatestid.TEXT}>\n {text}\n </Text>\n );\n};\n\nconst DSTruncateTextWithTooltipWithSchema = describe(DSTruncateTextWithTooltip);\n\nDSTruncateTextWithTooltipWithSchema.propTypes = DSTruncateTextWithTooltipPropTypesSchema;\n\nexport { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoDf;AApDR,mBAAoD;AACpD,wBAA4B;AAC5B,8BAAuF;AACvF,iDAAoD;AACpD,oBAAqB;AACrB,mCAIO;AAEP,MAAM,4BAA4B,CAAC,UAAyD;AAC1F,QAAM,uBAAmB,sDAAuE,OAAO,yCAAY;AAEnH;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,aAAa,IAAI;AAE/B,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAiC,IAAI;AAC/E,QAAM,CAAC,mBAAmB,oBAAoB,QAAI,uBAAkB,KAAK;AAEzE,QAAM,qBAAiB;AAA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