@elliemae/ds-truncated-tooltip-text 3.32.1-rc.7 → 3.33.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DSTruncatedTooltipText.js +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 +37 -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 +5 -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,43 @@
|
|
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 truncateTextWithTooltip_exports = {};
|
30
|
+
__export(truncateTextWithTooltip_exports, {
|
31
|
+
DSTruncateTextWithTooltip: () => import_DSTruncateTextWithTooltip.DSTruncateTextWithTooltip,
|
32
|
+
DSTruncateTextWithTooltipDatatestid: () => import_DSTruncateTextWIthTooltipDatatestid.DSTruncateTextWithTooltipDatatestid,
|
33
|
+
DSTruncateTextWithTooltipPropTypes: () => import_react_desc_prop_types.DSTruncateTextWithTooltipPropTypes,
|
34
|
+
DSTruncateTextWithTooltipPropTypesSchema: () => import_react_desc_prop_types.DSTruncateTextWithTooltipPropTypesSchema,
|
35
|
+
DSTruncateTextWithTooltipWithSchema: () => import_DSTruncateTextWithTooltip.DSTruncateTextWithTooltipWithSchema,
|
36
|
+
defaultProps: () => import_react_desc_prop_types.defaultProps
|
37
|
+
});
|
38
|
+
module.exports = __toCommonJS(truncateTextWithTooltip_exports);
|
39
|
+
var React = __toESM(require("react"));
|
40
|
+
var import_DSTruncateTextWithTooltip = require("./DSTruncateTextWithTooltip.js");
|
41
|
+
var import_DSTruncateTextWIthTooltipDatatestid = require("./DSTruncateTextWIthTooltipDatatestid.js");
|
42
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
43
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/truncateTextWithTooltip/index.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["export { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema } from './DSTruncateTextWithTooltip.js';\nexport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid.js';\nexport {\n type DSTruncateTextWithTooltipT,\n defaultProps,\n DSTruncateTextWithTooltipPropTypes,\n DSTruncateTextWithTooltipPropTypesSchema,\n} from './react-desc-prop-types.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uCAA+E;AAC/E,iDAAoD;AACpD,mCAKO;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,48 @@
|
|
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 react_desc_prop_types_exports = {};
|
30
|
+
__export(react_desc_prop_types_exports, {
|
31
|
+
DSTruncateTextWithTooltipPropTypes: () => DSTruncateTextWithTooltipPropTypes,
|
32
|
+
DSTruncateTextWithTooltipPropTypesSchema: () => DSTruncateTextWithTooltipPropTypesSchema,
|
33
|
+
defaultProps: () => defaultProps
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
36
|
+
var React = __toESM(require("react"));
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
38
|
+
const defaultProps = {
|
39
|
+
tooltipProps: {}
|
40
|
+
};
|
41
|
+
const DSTruncateTextWithTooltipPropTypes = {
|
42
|
+
text: import_ds_props_helpers.PropTypes.string.description("Text to show.").isRequired,
|
43
|
+
tooltipProps: import_ds_props_helpers.PropTypes.object.description(
|
44
|
+
"This component uses DSTooltip component, you can set properties directly to this component with this property."
|
45
|
+
).defaultValue({})
|
46
|
+
};
|
47
|
+
const DSTruncateTextWithTooltipPropTypesSchema = DSTruncateTextWithTooltipPropTypes;
|
48
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/truncateTextWithTooltip/react-desc-prop-types.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type { WeakValidationMap } from 'react';\nimport type { DSPropTypesSchema } from '@elliemae/ds-utilities';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n// import type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSTruncateTextWithTooltipT {\n export interface DefaultProps {\n tooltipProps: Record<string, unknown>;\n }\n export interface OptionalProps {}\n export interface RequiredProps {\n text: string;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n OptionalProps,\n // Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n // XstyledProps,\n RequiredProps {}\n\n export interface InternalProps\n extends DefaultProps,\n OptionalProps,\n // Omit<GlobalAttributesT<HTMLButtonElement>, keyof DefaultProps | keyof OptionalProps | keyof RequiredProps>,\n // XstyledProps,\n RequiredProps {}\n}\n\nexport const defaultProps: DSTruncateTextWithTooltipT.DefaultProps = {\n tooltipProps: {},\n};\n\nexport const DSTruncateTextWithTooltipPropTypes: DSPropTypesSchema<DSTruncateTextWithTooltipT.Props> = {\n text: PropTypes.string.description('Text to show.').isRequired,\n tooltipProps: PropTypes.object\n .description(\n 'This component uses DSTooltip component, you can set properties directly to this component with this property.',\n )\n .defaultValue({}),\n};\n\nexport const DSTruncateTextWithTooltipPropTypesSchema =\n DSTruncateTextWithTooltipPropTypes as unknown as WeakValidationMap<DSTruncateTextWithTooltipT.Props>;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAA0B;AA2BnB,MAAM,eAAwD;AAAA,EACnE,cAAc,CAAC;AACjB;AAEO,MAAM,qCAA0F;AAAA,EACrG,MAAM,kCAAU,OAAO,YAAY,eAAe,EAAE;AAAA,EACpD,cAAc,kCAAU,OACrB;AAAA,IACC;AAAA,EACF,EACC,aAAa,CAAC,CAAC;AACpB;AAEO,MAAM,2CACX;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,48 @@
|
|
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 styles_exports = {};
|
30
|
+
__export(styles_exports, {
|
31
|
+
Text: () => Text
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(styles_exports);
|
34
|
+
var React = __toESM(require("react"));
|
35
|
+
var import_ds_system = require("@elliemae/ds-system");
|
36
|
+
const Text = import_ds_system.styled.span`
|
37
|
+
text-overflow: ellipsis;
|
38
|
+
white-space: nowrap;
|
39
|
+
overflow: hidden;
|
40
|
+
display: inline-block;
|
41
|
+
max-width: 100%;
|
42
|
+
&:focus {
|
43
|
+
border: none;
|
44
|
+
outline: none;
|
45
|
+
background: ${({ theme }) => theme.colors.brand[200]};
|
46
|
+
}
|
47
|
+
`;
|
48
|
+
//# sourceMappingURL=styles.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/truncateTextWithTooltip/styles.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
4
|
+
"sourcesContent": ["import { styled } from '@elliemae/ds-system';\n\n// reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755\nexport const Text = styled.span`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n display: inline-block;\n max-width: 100%;\n &:focus {\n border: none;\n outline: none;\n background: ${({ theme }) => theme.colors.brand[200]};\n }\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAuB;AAGhB,MAAM,OAAO,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,MAAM,MAAM,MAAM,OAAO,MAAM,GAAG;AAAA;AAAA;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,72 @@
|
|
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 __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
}
|
14
|
+
return to;
|
15
|
+
};
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
var React = __toESM(require("react"));
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
26
|
+
var import__ = require("../index.js");
|
27
|
+
const testRequiredProps = {
|
28
|
+
text: "This is defined as just as string so this is fine for testing"
|
29
|
+
};
|
30
|
+
const testOptionalProps = {};
|
31
|
+
const testPartialDefaults = {
|
32
|
+
tooltipProps: {}
|
33
|
+
};
|
34
|
+
const testProps = {
|
35
|
+
...testRequiredProps,
|
36
|
+
...testOptionalProps,
|
37
|
+
...testPartialDefaults
|
38
|
+
};
|
39
|
+
const testPropsAsSyntax = {
|
40
|
+
...testRequiredProps,
|
41
|
+
...testOptionalProps,
|
42
|
+
...testPartialDefaults
|
43
|
+
};
|
44
|
+
const testCompleteDefaults = {
|
45
|
+
tooltipProps: {}
|
46
|
+
};
|
47
|
+
const testInternalProps = {
|
48
|
+
...testRequiredProps,
|
49
|
+
...testOptionalProps,
|
50
|
+
...testCompleteDefaults
|
51
|
+
};
|
52
|
+
const testInternalPropsAsSyntax = {
|
53
|
+
...testRequiredProps,
|
54
|
+
...testOptionalProps,
|
55
|
+
...testCompleteDefaults
|
56
|
+
};
|
57
|
+
const testExplicitDefinition = {
|
58
|
+
text: "This is defined as just as string so this is fine for testing"
|
59
|
+
};
|
60
|
+
const testInferedTypeCompatibility = {
|
61
|
+
text: "This is defined as just as string so this is fine for testing"
|
62
|
+
};
|
63
|
+
const testDefinitionAsConst = {
|
64
|
+
text: "This is defined as just as string so this is fine for testing"
|
65
|
+
};
|
66
|
+
const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSTruncateTextWithTooltip, { ...testExplicitDefinition }),
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSTruncateTextWithTooltip, { ...testInferedTypeCompatibility }),
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSTruncateTextWithTooltip, { ...testDefinitionAsConst }),
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.DSTruncateTextWithTooltip, { text: "System Message" })
|
71
|
+
] });
|
72
|
+
//# sourceMappingURL=typescript-truncate-text-with-tooltip-valid.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/truncateTextWithTooltip/typescript-testing/typescript-truncate-text-with-tooltip-valid.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSTruncateTextWithTooltip } from '../index.js';\nimport type { DSTruncateTextWithTooltipT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSTruncateTextWithTooltipT.Props;\ntype ComponentPropsInternals = DSTruncateTextWithTooltipT.InternalProps;\ntype ComponentPropsDefaultProps = DSTruncateTextWithTooltipT.DefaultProps;\ntype ComponentPropsOptionalProps = DSTruncateTextWithTooltipT.OptionalProps;\ntype ComponentPropsRequiredProps = DSTruncateTextWithTooltipT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n text: 'This is defined as just as string so this is fine for testing',\n};\nconst testOptionalProps: ComponentPropsOptionalProps = {};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n tooltipProps: {},\n};\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n tooltipProps: {},\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testOptionalProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n text: 'This is defined as just as string so this is fine for testing',\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n text: 'This is defined as just as string so this is fine for testing',\n} as ComponentPropsForApp;\n\nconst testDefinitionAsConst = {\n text: 'This is defined as just as string so this is fine for testing',\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSTruncateTextWithTooltip {...testExplicitDefinition} />\n <DSTruncateTextWithTooltip {...testInferedTypeCompatibility} />\n <DSTruncateTextWithTooltip {...testDefinitionAsConst} />\n {/* works with inline values */}\n <DSTruncateTextWithTooltip text=\"System Message\" />\n </>\n);\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;AC6DrB;AA5DF,eAA0C;AAU1C,MAAM,oBAAiD;AAAA,EACrD,MAAM;AACR;AACA,MAAM,oBAAiD,CAAC;AAIxD,MAAM,sBAA2D;AAAA,EAC/D,cAAc,CAAC;AACjB;AACA,MAAM,YAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,uBAA6D;AAAA,EACjE,cAAc,CAAC;AACjB;AACA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,MAAM;AACR;AAGA,MAAM,+BAA+B;AAAA,EACnC,MAAM;AACR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AACR;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,sCAA2B,GAAG,wBAAwB;AAAA,EACvD,4CAAC,sCAA2B,GAAG,8BAA8B;AAAA,EAC7D,4CAAC,sCAA2B,GAAG,uBAAuB;AAAA,EAEtD,4CAAC,sCAA0B,MAAK,kBAAiB;AAAA,GACnD;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
3
|
+
import { useContext, useEffect } from "react";
|
4
|
+
import { describe, PropTypes } from "@elliemae/ds-props-helpers";
|
5
|
+
import { styled } from "@elliemae/ds-system";
|
6
|
+
import { PopperPositions as positions } from "@elliemae/ds-popper";
|
7
|
+
import { TruncatedTooltipContext } from "./TooltipTextProvider.js";
|
8
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
9
|
+
const Text = styled.span`
|
10
|
+
text-overflow: ellipsis;
|
11
|
+
white-space: nowrap;
|
12
|
+
overflow: hidden;
|
13
|
+
display: inline-block;
|
14
|
+
max-width: 100%;
|
15
|
+
`;
|
16
|
+
const DSTruncatedTooltipText = ({
|
17
|
+
containerProps = {},
|
18
|
+
value = "",
|
19
|
+
zIndex = 3e3,
|
20
|
+
// https://jira.elliemae.io/browse/PUI-1755 https://jira.elliemae.io/browse/PUI-8732
|
21
|
+
...otherTextProps
|
22
|
+
}) => {
|
23
|
+
const tooltipContext = useContext(TruncatedTooltipContext);
|
24
|
+
useEffect(() => {
|
25
|
+
if (zIndex && tooltipContext)
|
26
|
+
tooltipContext.setZIndex(zIndex);
|
27
|
+
}, [zIndex]);
|
28
|
+
if (!tooltipContext)
|
29
|
+
return value;
|
30
|
+
const { showTooltip, hideTooltip } = tooltipContext;
|
31
|
+
const handleMouseEnter = (e) => {
|
32
|
+
const { target } = e;
|
33
|
+
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
34
|
+
showTooltip(
|
35
|
+
{
|
36
|
+
value,
|
37
|
+
reference: target
|
38
|
+
},
|
39
|
+
e
|
40
|
+
);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
const handleMouseLeave = (e) => {
|
44
|
+
hideTooltip({ reference: e.target });
|
45
|
+
};
|
46
|
+
const handlers = showTooltip ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave } : {};
|
47
|
+
return /* @__PURE__ */ jsx(Text, { ...containerProps, ...otherTextProps, ...handlers, children: value });
|
48
|
+
};
|
49
|
+
DSTruncatedTooltipText.defaultProps = {
|
50
|
+
value: "",
|
51
|
+
zIndex: 110
|
52
|
+
};
|
53
|
+
const truncatedTooltipTextProps = {
|
54
|
+
containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
|
55
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).description(
|
56
|
+
"Text that when truncated will trigger the tooltip interaction"
|
57
|
+
),
|
58
|
+
tooltipPlacement: PropTypes.oneOf([
|
59
|
+
positions.AUTO_START,
|
60
|
+
positions.AUTO_END,
|
61
|
+
positions.AUTO,
|
62
|
+
positions.TOP_START,
|
63
|
+
positions.TOP,
|
64
|
+
positions.TOP_END,
|
65
|
+
positions.RIGHT_START,
|
66
|
+
positions.RIGHT,
|
67
|
+
positions.RIGHT_END,
|
68
|
+
positions.BOTTOM_START,
|
69
|
+
positions.BOTTOM,
|
70
|
+
positions.BOTTOM_END,
|
71
|
+
positions.LEFT_START,
|
72
|
+
positions.LEFT,
|
73
|
+
positions.LEFT_END
|
74
|
+
]).description("Position of the tooltip"),
|
75
|
+
tooltipDelay: PropTypes.number.description("Delay to show the tooltip"),
|
76
|
+
zIndex: PropTypes.number.description("override default zIndex").defaultValue(110)
|
77
|
+
};
|
78
|
+
DSTruncatedTooltipText.defaultProps = {
|
79
|
+
containerProps: {},
|
80
|
+
value: "",
|
81
|
+
tooltipPlacement: void 0,
|
82
|
+
tooltipDelay: void 0
|
83
|
+
};
|
84
|
+
DSTruncatedTooltipText.propTypes = truncatedTooltipTextProps;
|
85
|
+
DSTruncatedTooltipText.displayName = "DSTruncatedTooltipText";
|
86
|
+
const TruncatedTooltipTextWithSchema = describe(DSTruncatedTooltipText);
|
87
|
+
TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
|
88
|
+
var DSTruncatedTooltipText_default = DSTruncatedTooltipText;
|
89
|
+
export {
|
90
|
+
DSTruncatedTooltipText,
|
91
|
+
TruncatedTooltipTextWithSchema,
|
92
|
+
DSTruncatedTooltipText_default as default
|
93
|
+
};
|
94
|
+
//# sourceMappingURL=DSTruncatedTooltipText.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSTruncatedTooltipText.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useEffect } from 'react';\nimport { describe, PropTypes } from '@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"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACmDnB;AAnDJ,SAAgB,YAAY,iBAAiB;AAC7C,SAAS,UAAU,iBAAiB;AACpC,SAAS,cAAc;AACvB,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,+BAA+B;AAExC,MAAM,mBAAmB,CAAC,E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V,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC,EAAE,YAAY,yBAAyB;AAAA,EACxC,cAAc,UAAU,OAAO,YAAY,2BAA2B;AAAA,EACtE,QAAQ,UAAU,OAAO,YAAY,yBAAyB,EAAE,aAAa,GAAG;AAClF;AAEA,uBAAuB,eAAe;AAAA,EACpC,gBAAgB,CAAC;AAAA,EACjB,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,cAAc;AAChB;AAEA,uBAAuB,YAAY;AACnC,uBAAuB,cAAc;AACrC,MAAM,iCAAiC,SAAS,sBAAsB;AACtE,+BAA+B,YAAY;AAG3C,IAAO,iCAAQ;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import { useCallback, useContext, useMemo, useState } from "react";
|
4
|
+
import { useCancellableDelayedCallback } from "@elliemae/ds-utilities";
|
5
|
+
import PropTypes from "prop-types";
|
6
|
+
import { styled, ThemeContext } from "@elliemae/ds-system";
|
7
|
+
import { DSPopover, PopperPositions as positions } from "@elliemae/ds-popover";
|
8
|
+
const dsTestId = "DS-SimpleTruncateText";
|
9
|
+
const isEllipsisActive = ({ offsetWidth, scrollWidth }) => offsetWidth < scrollWidth;
|
10
|
+
const initialTooltipState = (value = "", options = {}) => ({
|
11
|
+
reference: null,
|
12
|
+
visible: false,
|
13
|
+
value,
|
14
|
+
options
|
15
|
+
});
|
16
|
+
const Text = styled.span`
|
17
|
+
text-overflow: ellipsis;
|
18
|
+
white-space: nowrap;
|
19
|
+
overflow: hidden;
|
20
|
+
display: inline-block;
|
21
|
+
max-width: 100%;
|
22
|
+
`;
|
23
|
+
const SimpleTruncatedTooltipText = (props) => {
|
24
|
+
const { containerProps, tooltipDelay, placement, value, zIndex, tooltipOptions, textOptions } = props;
|
25
|
+
const [tooltipState, setTooltipState] = useState(initialTooltipState(value, tooltipOptions));
|
26
|
+
const show = useCallback(
|
27
|
+
(newState) => {
|
28
|
+
setTooltipState({ ...tooltipState, ...newState, visible: true });
|
29
|
+
},
|
30
|
+
[tooltipState]
|
31
|
+
);
|
32
|
+
const hideTooltip = useCallback(
|
33
|
+
(newState) => {
|
34
|
+
setTooltipState({ ...tooltipState, ...newState, visible: false });
|
35
|
+
},
|
36
|
+
[tooltipState]
|
37
|
+
);
|
38
|
+
const [showTooltip, cancelShowTooltip] = useCancellableDelayedCallback(show, tooltipDelay);
|
39
|
+
const handleMouseEnter = useCallback(
|
40
|
+
(e) => {
|
41
|
+
const { target } = e;
|
42
|
+
const SimpleTruncatedTextEl = target.closest(`[data-testid="${dsTestId}"]`);
|
43
|
+
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
44
|
+
showTooltip({ value, reference: SimpleTruncatedTextEl });
|
45
|
+
}
|
46
|
+
},
|
47
|
+
[showTooltip, value]
|
48
|
+
);
|
49
|
+
const handleMouseLeave = useCallback(() => {
|
50
|
+
cancelShowTooltip();
|
51
|
+
hideTooltip({ reference: null });
|
52
|
+
}, [hideTooltip, cancelShowTooltip]);
|
53
|
+
const handlers = useMemo(() => {
|
54
|
+
if (!showTooltip)
|
55
|
+
return {};
|
56
|
+
return {
|
57
|
+
onMouseEnter: handleMouseEnter,
|
58
|
+
onMouseLeave: handleMouseLeave
|
59
|
+
};
|
60
|
+
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
61
|
+
const theme = useContext(ThemeContext);
|
62
|
+
const PurePopover = useMemo(
|
63
|
+
() => /* @__PURE__ */ jsx(Fragment, { children: tooltipState.visible ? /* @__PURE__ */ jsx(
|
64
|
+
DSPopover,
|
65
|
+
{
|
66
|
+
boundaries: "window",
|
67
|
+
style: { pointerEvents: "none", zIndex: zIndex ?? theme.zIndex.tooltip },
|
68
|
+
placement,
|
69
|
+
content: tooltipState.value,
|
70
|
+
referenceEl: tooltipState.reference,
|
71
|
+
visible: tooltipState.visible,
|
72
|
+
showArrow: true
|
73
|
+
}
|
74
|
+
) : null }),
|
75
|
+
[tooltipState, placement, zIndex]
|
76
|
+
);
|
77
|
+
const PureText = useMemo(
|
78
|
+
() => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
79
|
+
Text,
|
80
|
+
{
|
81
|
+
...containerProps && { ...containerProps },
|
82
|
+
...textOptions && { ...textOptions },
|
83
|
+
...handlers && { ...handlers },
|
84
|
+
"data-testid": dsTestId,
|
85
|
+
children: value
|
86
|
+
}
|
87
|
+
) }),
|
88
|
+
[containerProps, textOptions, handlers, value]
|
89
|
+
);
|
90
|
+
const PureSimpleTruncatedTooltipText = useMemo(
|
91
|
+
() => /* @__PURE__ */ jsxs(Fragment, { children: [
|
92
|
+
PureText,
|
93
|
+
PurePopover
|
94
|
+
] }),
|
95
|
+
[PureText, PurePopover]
|
96
|
+
);
|
97
|
+
return PureSimpleTruncatedTooltipText;
|
98
|
+
};
|
99
|
+
SimpleTruncatedTooltipText.propTypes = {
|
100
|
+
containerProps: PropTypes.object,
|
101
|
+
tooltipOptions: PropTypes.object,
|
102
|
+
textOptions: PropTypes.object,
|
103
|
+
/** Text that when truncated will trigger the tooltip interaction */
|
104
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.node]),
|
105
|
+
/** Position of the tooltip */
|
106
|
+
placement: PropTypes.oneOf([
|
107
|
+
positions.AUTO_START,
|
108
|
+
positions.AUTO_END,
|
109
|
+
positions.AUTO,
|
110
|
+
positions.TOP_START,
|
111
|
+
positions.TOP,
|
112
|
+
positions.TOP_END,
|
113
|
+
positions.RIGHT_START,
|
114
|
+
positions.RIGHT,
|
115
|
+
positions.RIGHT_END,
|
116
|
+
positions.BOTTOM_START,
|
117
|
+
positions.BOTTOM,
|
118
|
+
positions.BOTTOM_END,
|
119
|
+
positions.LEFT_START,
|
120
|
+
positions.LEFT,
|
121
|
+
positions.LEFT_END
|
122
|
+
]),
|
123
|
+
/** Delay to show the tooltip */
|
124
|
+
tooltipDelay: PropTypes.number,
|
125
|
+
/** override default zIndex */
|
126
|
+
zIndex: PropTypes.number
|
127
|
+
};
|
128
|
+
SimpleTruncatedTooltipText.defaultProps = {
|
129
|
+
containerProps: {},
|
130
|
+
tooltipOptions: {},
|
131
|
+
textOptions: {},
|
132
|
+
value: "",
|
133
|
+
placement: positions.TOP,
|
134
|
+
tooltipDelay: 200
|
135
|
+
};
|
136
|
+
var SimpleTruncatedTooltipText_default = SimpleTruncatedTooltipText;
|
137
|
+
export {
|
138
|
+
SimpleTruncatedTooltipText,
|
139
|
+
SimpleTruncatedTooltipText_default as default
|
140
|
+
};
|
141
|
+
//# sourceMappingURL=SimpleTruncatedTooltipText.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/SimpleTruncatedTooltipText.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React, { useCallback, 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"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwFjB,mBAEI,KAgCJ,YAlCA;AAvFN,SAAgB,aAAa,YAAY,SAAS,gBAAgB;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AAAA;AAAA,EAE/E,WAAW,UAAU,MAAM;AAAA,IACzB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC;AAAA;AAAA,EAED,cAAc,UAAU;AAAA;AAAA,EAExB,QAAQ,UAAU;AACpB;AAEA,2BAA2B,eAAe;AAAA,EACxC,gBAAgB,CAAC;AAAA,EACjB,gBAAgB,CAAC;AAAA,EACjB,aAAa,CAAC;AAAA,EACd,OAAO;AAAA,EACP,WAAW,UAAU;AAAA,EACrB,cAAc;AAChB;AAGA,IAAO,qCAAQ;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
3
|
+
import React2, { useMemo, useState } from "react";
|
4
|
+
import { DSPopover, usePopoverProviderState } from "@elliemae/ds-popover";
|
5
|
+
const TruncatedTooltipContext = React2.createContext();
|
6
|
+
const { Provider } = TruncatedTooltipContext;
|
7
|
+
const TooltipTextProvider = ({ children, tooltipDelay = 200, placement = "top", ...tooltipOptions }) => {
|
8
|
+
const {
|
9
|
+
show: showTooltip,
|
10
|
+
hide: hideTooltip,
|
11
|
+
state: tooltipState
|
12
|
+
} = usePopoverProviderState({ delay: tooltipDelay });
|
13
|
+
const [zIndex, setZIndex] = useState(110);
|
14
|
+
const value = useMemo(
|
15
|
+
() => ({
|
16
|
+
showTooltip,
|
17
|
+
hideTooltip,
|
18
|
+
setZIndex
|
19
|
+
}),
|
20
|
+
[]
|
21
|
+
);
|
22
|
+
return /* @__PURE__ */ jsxs(Provider, { value, children: [
|
23
|
+
children,
|
24
|
+
tooltipState.visible ? /* @__PURE__ */ jsx(
|
25
|
+
DSPopover,
|
26
|
+
{
|
27
|
+
boundaries: "window",
|
28
|
+
placement,
|
29
|
+
showArrow: true,
|
30
|
+
...tooltipOptions,
|
31
|
+
...tooltipState.options || {},
|
32
|
+
content: tooltipState.value,
|
33
|
+
referenceEl: tooltipState.reference,
|
34
|
+
style: { pointerEvents: "none", zIndex },
|
35
|
+
visible: tooltipState.visible
|
36
|
+
}
|
37
|
+
) : null
|
38
|
+
] });
|
39
|
+
};
|
40
|
+
TooltipTextProvider.propTypes = {};
|
41
|
+
TooltipTextProvider.defaultProps = {};
|
42
|
+
var TooltipTextProvider_default = TooltipTextProvider;
|
43
|
+
export {
|
44
|
+
TooltipTextProvider,
|
45
|
+
TruncatedTooltipContext,
|
46
|
+
TooltipTextProvider_default as default
|
47
|
+
};
|
48
|
+
//# sourceMappingURL=TooltipTextProvider.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/TooltipTextProvider.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useMemo, useState } from 'react';\nimport { DSPopover, usePopoverProviderState } from '@elliemae/ds-popover';\n\nconst TruncatedTooltipContext = React.createContext();\n\nconst { Provider } = TruncatedTooltipContext;\n\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"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0BnB,SAGI,KAHJ;AAzBJ,OAAOA,UAAS,SAAS,gBAAgB;AACzC,SAAS,WAAW,+BAA+B;AAEnD,MAAM,0BAA0BA,OAAM,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,IAAI,wBAAwB,EAAE,OAAO,aAAa,CAAC;AACnD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,GAAG;AAExC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SACE,qBAAC,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/esm/index.js
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
|
3
|
-
import {
|
2
|
+
import { TooltipTextProvider, TruncatedTooltipContext } from "./TooltipTextProvider.js";
|
3
|
+
import { SimpleTruncatedTooltipText } from "./SimpleTruncatedTooltipText.js";
|
4
|
+
import { DSTruncatedTooltipText, TruncatedTooltipTextWithSchema, default as default2 } from "./DSTruncatedTooltipText.js";
|
5
|
+
import {
|
6
|
+
DSTruncateTextWithTooltipDatatestid,
|
7
|
+
DSTruncateTextWithTooltip,
|
8
|
+
DSTruncateTextWithTooltipWithSchema
|
9
|
+
} from "./truncateTextWithTooltip/index.js";
|
4
10
|
export {
|
11
|
+
DSTruncateTextWithTooltip,
|
12
|
+
DSTruncateTextWithTooltipDatatestid,
|
13
|
+
DSTruncateTextWithTooltipWithSchema,
|
14
|
+
DSTruncatedTooltipText,
|
15
|
+
SimpleTruncatedTooltipText,
|
16
|
+
TooltipTextProvider,
|
17
|
+
TruncatedTooltipContext,
|
18
|
+
TruncatedTooltipTextWithSchema,
|
5
19
|
default2 as default
|
6
20
|
};
|
7
21
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB,+BAA+B;AAC7D,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB,gCAAgC,WAAAA,gBAAe;AAChF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
6
6
|
"names": ["default"]
|
7
7
|
}
|