@elliemae/ds-truncated-tooltip-text 3.0.0-next.1 → 3.0.0-next.5
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 +145 -0
- package/dist/cjs/DSTruncatedTooltipText.js.map +7 -0
- package/dist/cjs/SimpleTruncatedTooltipText.js +151 -0
- package/dist/cjs/SimpleTruncatedTooltipText.js.map +7 -0
- package/dist/cjs/TooltipTextProvider.js +106 -0
- package/dist/cjs/TooltipTextProvider.js.map +7 -0
- package/dist/cjs/index.js +45 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +37 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +95 -0
- package/dist/cjs/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/defaultProps.js +37 -0
- package/dist/cjs/truncateTextWithTooltip/defaultProps.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/index.js +29 -0
- package/dist/cjs/truncateTextWithTooltip/index.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/propTypes.js +39 -0
- package/dist/cjs/truncateTextWithTooltip/propTypes.js.map +7 -0
- package/dist/cjs/truncateTextWithTooltip/styles.js +47 -0
- package/dist/cjs/truncateTextWithTooltip/styles.js.map +7 -0
- package/dist/esm/DSTruncatedTooltipText.js +118 -0
- package/dist/esm/DSTruncatedTooltipText.js.map +7 -0
- package/dist/esm/SimpleTruncatedTooltipText.js +124 -0
- package/dist/esm/SimpleTruncatedTooltipText.js.map +7 -0
- package/dist/esm/TooltipTextProvider.js +79 -0
- package/dist/esm/TooltipTextProvider.js.map +7 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js +8 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWIthTooltipDatatestid.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js +68 -0
- package/dist/esm/truncateTextWithTooltip/DSTruncateTextWithTooltip.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/defaultProps.js +8 -0
- package/dist/esm/truncateTextWithTooltip/defaultProps.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/index.js +4 -0
- package/dist/esm/truncateTextWithTooltip/index.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/propTypes.js +10 -0
- package/dist/esm/truncateTextWithTooltip/propTypes.js.map +7 -0
- package/dist/esm/truncateTextWithTooltip/styles.js +18 -0
- package/dist/esm/truncateTextWithTooltip/styles.js.map +7 -0
- package/package.json +37 -27
- package/cjs/DSTruncateTextWithTooltip.js +0 -75
- package/cjs/DSTruncatedTooltipText.js +0 -112
- package/cjs/SimpleTruncatedTooltipText.js +0 -148
- package/cjs/TooltipTextProvider.js +0 -78
- package/cjs/index.js +0 -19
- package/esm/DSTruncateTextWithTooltip.js +0 -65
- package/esm/DSTruncatedTooltipText.js +0 -100
- package/esm/SimpleTruncatedTooltipText.js +0 -136
- package/esm/TooltipTextProvider.js +0 -64
- package/esm/index.js +0 -4
- package/types/DSTruncateTextWithTooltip.d.ts +0 -8
- package/types/DSTruncatedTooltipText.d.ts +0 -64
- package/types/SimpleTruncatedTooltipText.d.ts +0 -29
- package/types/TooltipTextProvider.d.ts +0 -14
- package/types/index.d.ts +0 -5
@@ -0,0 +1,68 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6
|
+
var __spreadValues = (a, b) => {
|
7
|
+
for (var prop in b || (b = {}))
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
10
|
+
if (__getOwnPropSymbols)
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
12
|
+
if (__propIsEnum.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
}
|
15
|
+
return a;
|
16
|
+
};
|
17
|
+
import * as React from "react";
|
18
|
+
import React2, { useState, useMemo, useEffect } from "react";
|
19
|
+
import { DSTooltipV3 } from "@elliemae/ds-tooltip";
|
20
|
+
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from "@elliemae/ds-props-helpers";
|
21
|
+
import { defaultProps } from "./defaultProps";
|
22
|
+
import { DSTruncateTextWithTooltipDatatestid } from "./DSTruncateTextWIthTooltipDatatestid";
|
23
|
+
import { propTypes } from "./propTypes";
|
24
|
+
import { Text } from "./styles";
|
25
|
+
const DSTruncateTextWithTooltip = (props) => {
|
26
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
27
|
+
useValidateTypescriptPropTypes(propsWithDefault, propTypes);
|
28
|
+
const { text, tooltipProps } = propsWithDefault;
|
29
|
+
const [textWrapperEl, setTextWrapperEl] = useState(null);
|
30
|
+
const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
|
31
|
+
const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
|
32
|
+
if (entries.length) {
|
33
|
+
const [textWrapperEntry] = entries;
|
34
|
+
const el = textWrapperEntry.target;
|
35
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
36
|
+
}
|
37
|
+
}), []);
|
38
|
+
useEffect(() => {
|
39
|
+
if (textWrapperEl) {
|
40
|
+
setIsShowingEllipsis(textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth);
|
41
|
+
resizeObserver.observe(textWrapperEl);
|
42
|
+
}
|
43
|
+
return () => {
|
44
|
+
if (textWrapperEl) {
|
45
|
+
resizeObserver.unobserve(textWrapperEl);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
}, [resizeObserver, textWrapperEl]);
|
49
|
+
if (isShowingEllipsis)
|
50
|
+
return /* @__PURE__ */ React2.createElement(DSTooltipV3, __spreadValues({
|
51
|
+
text
|
52
|
+
}, tooltipProps), /* @__PURE__ */ React2.createElement(Text, {
|
53
|
+
ref: setTextWrapperEl,
|
54
|
+
tabIndex: 0,
|
55
|
+
"data-testid": DSTruncateTextWithTooltipDatatestid.TEXT
|
56
|
+
}, text));
|
57
|
+
return /* @__PURE__ */ React2.createElement(Text, {
|
58
|
+
ref: setTextWrapperEl,
|
59
|
+
"data-testid": DSTruncateTextWithTooltipDatatestid.TEXT
|
60
|
+
}, text);
|
61
|
+
};
|
62
|
+
const DSTruncateTextWithTooltipWithSchema = describe(DSTruncateTextWithTooltip);
|
63
|
+
DSTruncateTextWithTooltipWithSchema.propTypes = propTypes;
|
64
|
+
export {
|
65
|
+
DSTruncateTextWithTooltip,
|
66
|
+
DSTruncateTextWithTooltipWithSchema
|
67
|
+
};
|
68
|
+
//# sourceMappingURL=DSTruncateTextWithTooltip.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/DSTruncateTextWithTooltip.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useMemo, useEffect } from 'react';\nimport { DSTooltipV3 } from '@elliemae/ds-tooltip';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, describe } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from './defaultProps';\nimport { DSTruncateTextWithTooltipDatatestid } from './DSTruncateTextWIthTooltipDatatestid';\nimport { propTypes } from './propTypes';\nimport { Text } from './styles';\nimport type { DSTruncateTextWithTooltipT } from './propTypes';\n\nconst DSTruncateTextWithTooltip = (props: DSTruncateTextWithTooltipT.Props): JSX.Element => {\n const propsWithDefault = useMemoMergePropsWithDefault<DSTruncateTextWithTooltipT.Props>(props, defaultProps);\n\n useValidateTypescriptPropTypes(propsWithDefault, propTypes);\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<DSTruncateTextWithTooltipT.Props>(DSTruncateTextWithTooltip);\n\nDSTruncateTextWithTooltipWithSchema.propTypes = propTypes;\n\nexport { DSTruncateTextWithTooltip, DSTruncateTextWithTooltipWithSchema };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,4BAA4B,CAAC,UAAyD;AAC1F,QAAM,mBAAmB,6BAA+D,OAAO;AAE/F,iCAA+B,kBAAkB;AAEjD,QAAM,EAAE,MAAM,iBAAiB;AAE/B,QAAM,CAAC,eAAe,oBAAoB,SAAiC;AAC3E,QAAM,CAAC,mBAAmB,wBAAwB,SAAkB;AAEpE,QAAM,iBAAiB,QACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,QAAI,QAAQ,QAAQ;AAClB,YAAM,CAAC,oBAAoB;AAC3B,YAAM,KAAK,iBAAiB;AAC5B,2BAAqB,IAAI,cAAc,IAAI;AAAA;AAAA,MAGjD;AAGF,YAAU,MAAM;AACd,QAAI,eAAe;AACjB,2BAAqB,eAAe,cAAc,eAAe;AACjE,qBAAe,QAAQ;AAAA;AAEzB,WAAO,MAAM;AACX,UAAI,eAAe;AACjB,uBAAe,UAAU;AAAA;AAAA;AAAA,KAG5B,CAAC,gBAAgB;AAEpB,MAAI;AACF,WACE,qCAAC,aAAD;AAAA,MAAa;AAAA,OAAgB,eAC3B,qCAAC,MAAD;AAAA,MAAM,KAAK;AAAA,MAAkB,UAAU;AAAA,MAAG,eAAa,oCAAoC;AAAA,OACxF;AAKT,SACE,qCAAC,MAAD;AAAA,IAAM,KAAK;AAAA,IAAkB,eAAa,oCAAoC;AAAA,KAC3E;AAAA;AAKP,MAAM,sCAAsC,SAA2C;AAEvF,oCAAoC,YAAY;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/defaultProps.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSTruncateTextWithTooltipT } from './propTypes';\n\nexport const defaultProps: DSTruncateTextWithTooltipT.DefaultProps = {\n tooltipProps: {},\n};\n"],
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,eAAwD;AAAA,EACnE,cAAc;AAAA;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/index.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSTruncateTextWithTooltip';\nexport * from './DSTruncateTextWIthTooltipDatatestid';\n"],
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { PropTypes } from "@elliemae/ds-props-helpers";
|
3
|
+
const propTypes = {
|
4
|
+
text: PropTypes.string.description("Text to show.").isRequired,
|
5
|
+
tooltipProps: PropTypes.object.description("This component uses DSTooltip component, you can set properties directly to this component with this property.").defaultValue({})
|
6
|
+
};
|
7
|
+
export {
|
8
|
+
propTypes
|
9
|
+
};
|
10
|
+
//# sourceMappingURL=propTypes.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/propTypes.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-len */\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSTruncateTextWithTooltipT {\n export interface PropsRequired {\n text: string;\n }\n\n export interface DefaultProps {\n tooltipProps: Record<string, unknown>;\n }\n\n export interface Props extends DefaultProps, PropsRequired {}\n}\n\nexport const propTypes = {\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"],
|
5
|
+
"mappings": "AAAA;ACCA;AAcO,MAAM,YAAY;AAAA,EACvB,MAAM,UAAU,OAAO,YAAY,iBAAiB;AAAA,EACpD,cAAc,UAAU,OACrB,YACC,kHAED,aAAa;AAAA;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import styled from "styled-components";
|
3
|
+
const Text = styled.span`
|
4
|
+
text-overflow: ellipsis;
|
5
|
+
white-space: nowrap;
|
6
|
+
overflow: hidden;
|
7
|
+
display: inline-block;
|
8
|
+
max-width: 100%;
|
9
|
+
&:focus {
|
10
|
+
border: none;
|
11
|
+
outline: none;
|
12
|
+
background: ${({ theme }) => theme.colors.brand[200]};
|
13
|
+
}
|
14
|
+
`;
|
15
|
+
export {
|
16
|
+
Text
|
17
|
+
};
|
18
|
+
//# sourceMappingURL=styles.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/truncateTextWithTooltip/styles.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\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"],
|
5
|
+
"mappings": "AAAA;ACAA;AAGO,MAAM,OAAO,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAST,CAAC,EAAE,YAAY,MAAM,OAAO,MAAM;AAAA;AAAA;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/package.json
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
{
|
2
2
|
"name": "@elliemae/ds-truncated-tooltip-text",
|
3
|
-
"version": "3.0.0-next.
|
3
|
+
"version": "3.0.0-next.5",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "ICE MT - Dimsum - Truncated Tooltip Text",
|
6
|
-
"
|
7
|
-
|
8
|
-
|
6
|
+
"files": [
|
7
|
+
"dist"
|
8
|
+
],
|
9
|
+
"module": "./dist/esm/index.js",
|
10
|
+
"main": "./dist/cjs/index.js",
|
11
|
+
"types": "./dist/types/index.d.ts",
|
9
12
|
"exports": {
|
10
13
|
".": {
|
11
|
-
"import": "./esm/index.js",
|
12
|
-
"require": "./cjs/index.js"
|
14
|
+
"import": "./dist/esm/index.js",
|
15
|
+
"require": "./dist/cjs/index.js"
|
13
16
|
},
|
14
17
|
"./TooltipTextProvider": {
|
15
|
-
"import": "./esm/TooltipTextProvider.js",
|
16
|
-
"require": "./cjs/TooltipTextProvider.js"
|
18
|
+
"import": "./dist/esm/TooltipTextProvider.js",
|
19
|
+
"require": "./dist/cjs/TooltipTextProvider.js"
|
17
20
|
},
|
18
21
|
"./SimpleTruncatedTooltipText": {
|
19
|
-
"import": "./esm/SimpleTruncatedTooltipText.js",
|
20
|
-
"require": "./cjs/SimpleTruncatedTooltipText.js"
|
22
|
+
"import": "./dist/esm/SimpleTruncatedTooltipText.js",
|
23
|
+
"require": "./dist/cjs/SimpleTruncatedTooltipText.js"
|
21
24
|
},
|
22
25
|
"./DSTruncateTextWithTooltip": {
|
23
|
-
"import": "./esm/DSTruncateTextWithTooltip.js",
|
24
|
-
"require": "./cjs/DSTruncateTextWithTooltip.js"
|
26
|
+
"import": "./dist/esm/DSTruncateTextWithTooltip.js",
|
27
|
+
"require": "./dist/cjs/DSTruncateTextWithTooltip.js"
|
25
28
|
},
|
26
29
|
"./DSTruncatedTooltipText": {
|
27
|
-
"import": "./esm/DSTruncatedTooltipText.js",
|
28
|
-
"require": "./cjs/DSTruncatedTooltipText.js"
|
30
|
+
"import": "./dist/esm/DSTruncatedTooltipText.js",
|
31
|
+
"require": "./dist/cjs/DSTruncatedTooltipText.js"
|
29
32
|
}
|
30
33
|
},
|
31
34
|
"sideEffects": [
|
@@ -37,21 +40,22 @@
|
|
37
40
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
38
41
|
},
|
39
42
|
"engines": {
|
40
|
-
"
|
41
|
-
"node": ">=
|
43
|
+
"pnpm": ">=6",
|
44
|
+
"node": ">=16"
|
42
45
|
},
|
43
46
|
"author": "ICE MT",
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
47
|
+
"jestSonar": {
|
48
|
+
"sonar56x": true,
|
49
|
+
"reportPath": "reports",
|
50
|
+
"reportFile": "tests.xml",
|
51
|
+
"indent": 4
|
49
52
|
},
|
50
53
|
"dependencies": {
|
51
|
-
"@elliemae/ds-popover": "3.0.0-next.
|
52
|
-
"@elliemae/ds-popper": "3.0.0-next.
|
53
|
-
"@elliemae/ds-
|
54
|
-
"@elliemae/ds-
|
54
|
+
"@elliemae/ds-popover": "3.0.0-next.5",
|
55
|
+
"@elliemae/ds-popper": "3.0.0-next.5",
|
56
|
+
"@elliemae/ds-props-helpers": "3.0.0-next.5",
|
57
|
+
"@elliemae/ds-tooltip": "3.0.0-next.5",
|
58
|
+
"@elliemae/ds-utilities": "3.0.0-next.5",
|
55
59
|
"prop-types": "~15.7.2",
|
56
60
|
"react-desc": "~4.1.3"
|
57
61
|
},
|
@@ -65,7 +69,13 @@
|
|
65
69
|
},
|
66
70
|
"publishConfig": {
|
67
71
|
"access": "public",
|
68
|
-
"
|
69
|
-
|
72
|
+
"typeSafety": false
|
73
|
+
},
|
74
|
+
"scripts": {
|
75
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
76
|
+
"test": "node ../../scripts/testing/test.mjs",
|
77
|
+
"lint": "node ../../scripts/lint.mjs",
|
78
|
+
"dts": "node ../../scripts/dts.mjs",
|
79
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
70
80
|
}
|
71
81
|
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
7
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
9
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
10
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
11
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
12
|
-
var React = require('react');
|
13
|
-
var dsTooltip = require('@elliemae/ds-tooltip');
|
14
|
-
var styled = require('styled-components');
|
15
|
-
var jsxRuntime = require('react/jsx-runtime');
|
16
|
-
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
18
|
-
|
19
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
20
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
21
|
-
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
23
|
-
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
25
|
-
const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
|
26
|
-
componentId: "sc-1w57q5j-0"
|
27
|
-
})(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;:focus{border:none;outline:none;background:", ";}"], props => props.theme.colors.brand['200']);
|
28
|
-
const DSTruncateTextWithTooltipDatatestId = 'DS-TruncateTextWithTooltip';
|
29
|
-
const DSTruncateTextWithTooltip = _ref => {
|
30
|
-
let {
|
31
|
-
text,
|
32
|
-
tooltipProps = {}
|
33
|
-
} = _ref;
|
34
|
-
const [textWrapperEl, setTextWrapperEl] = React.useState(); // const textWrapperEl = useRef<HTMLSpanElement>();
|
35
|
-
|
36
|
-
const [isShowingEllipsis, setIsShowingEllipsis] = React.useState(false); // const isShowingEllipsis = textWrapperEl?.scrollWidth > textWrapperEl?.clientWidth;
|
37
|
-
|
38
|
-
const resizeObserver = React.useMemo(() => new ResizeObserver(entries => {
|
39
|
-
if (entries.length) {
|
40
|
-
const [textWrapperEntry] = entries;
|
41
|
-
const el = textWrapperEntry.target;
|
42
|
-
setIsShowingEllipsis((el === null || el === void 0 ? void 0 : el.scrollWidth) > (el === null || el === void 0 ? void 0 : el.clientWidth));
|
43
|
-
}
|
44
|
-
}), []);
|
45
|
-
React.useEffect(() => {
|
46
|
-
if (textWrapperEl) {
|
47
|
-
setIsShowingEllipsis((textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.scrollWidth) > (textWrapperEl === null || textWrapperEl === void 0 ? void 0 : textWrapperEl.clientWidth));
|
48
|
-
resizeObserver.observe(textWrapperEl);
|
49
|
-
}
|
50
|
-
|
51
|
-
return () => {
|
52
|
-
if (textWrapperEl) {
|
53
|
-
resizeObserver.unobserve(textWrapperEl);
|
54
|
-
}
|
55
|
-
};
|
56
|
-
}, [resizeObserver, textWrapperEl]);
|
57
|
-
if (isShowingEllipsis) return /*#__PURE__*/jsxRuntime.jsx(dsTooltip.DSTooltipV3, _objectSpread(_objectSpread({
|
58
|
-
text: text
|
59
|
-
}, tooltipProps), {}, {
|
60
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Text, {
|
61
|
-
ref: setTextWrapperEl,
|
62
|
-
tabIndex: 0,
|
63
|
-
"data-testid": DSTruncateTextWithTooltipDatatestId,
|
64
|
-
children: text
|
65
|
-
})
|
66
|
-
}));
|
67
|
-
return /*#__PURE__*/jsxRuntime.jsx(Text, {
|
68
|
-
ref: setTextWrapperEl,
|
69
|
-
"data-testid": DSTruncateTextWithTooltipDatatestId,
|
70
|
-
children: text
|
71
|
-
});
|
72
|
-
};
|
73
|
-
|
74
|
-
exports.DSTruncateTextWithTooltip = DSTruncateTextWithTooltip;
|
75
|
-
exports.DSTruncateTextWithTooltipDatatestId = DSTruncateTextWithTooltipDatatestId;
|
@@ -1,112 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
7
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
8
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
9
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
10
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
11
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
12
|
-
var React = require('react');
|
13
|
-
var reactDesc = require('react-desc');
|
14
|
-
var styled = require('styled-components');
|
15
|
-
var dsPopper = require('@elliemae/ds-popper');
|
16
|
-
var TooltipTextProvider = require('./TooltipTextProvider.js');
|
17
|
-
var jsxRuntime = require('react/jsx-runtime');
|
18
|
-
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
|
-
|
21
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
22
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
23
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
24
|
-
|
25
|
-
const _excluded = ["containerProps", "value", "zIndex"];
|
26
|
-
|
27
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
28
|
-
|
29
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
30
|
-
|
31
|
-
const isEllipsisActive = _ref => {
|
32
|
-
let {
|
33
|
-
offsetWidth,
|
34
|
-
scrollWidth
|
35
|
-
} = _ref;
|
36
|
-
return offsetWidth < scrollWidth;
|
37
|
-
}; // reduce the possibility of error showing the tooltip (text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
|
38
|
-
|
39
|
-
|
40
|
-
const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
|
41
|
-
componentId: "sc-1olo1o7-0"
|
42
|
-
})(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
|
43
|
-
|
44
|
-
const DSTruncatedTooltipText = _ref2 => {
|
45
|
-
let {
|
46
|
-
containerProps = {},
|
47
|
-
value = '',
|
48
|
-
zIndex = 110
|
49
|
-
} = _ref2,
|
50
|
-
otherTextProps = _objectWithoutProperties__default["default"](_ref2, _excluded);
|
51
|
-
|
52
|
-
const tooltipContext = React.useContext(TooltipTextProvider.TruncatedTooltipContext);
|
53
|
-
React.useEffect(() => {
|
54
|
-
if (zIndex && tooltipContext) tooltipContext.setZIndex(zIndex);
|
55
|
-
}, [zIndex]);
|
56
|
-
if (!tooltipContext) return value;
|
57
|
-
const {
|
58
|
-
showTooltip,
|
59
|
-
hideTooltip
|
60
|
-
} = tooltipContext;
|
61
|
-
|
62
|
-
const handleMouseEnter = e => {
|
63
|
-
const {
|
64
|
-
target
|
65
|
-
} = e;
|
66
|
-
|
67
|
-
if (target && isEllipsisActive(target, target.getBoundingClientRect())) {
|
68
|
-
showTooltip({
|
69
|
-
value,
|
70
|
-
reference: target
|
71
|
-
}, e);
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
const handleMouseLeave = e => {
|
76
|
-
hideTooltip({
|
77
|
-
reference: e.target
|
78
|
-
});
|
79
|
-
};
|
80
|
-
|
81
|
-
const handlers = showTooltip ? {
|
82
|
-
onMouseEnter: handleMouseEnter,
|
83
|
-
onMouseLeave: handleMouseLeave
|
84
|
-
} : {};
|
85
|
-
return /*#__PURE__*/jsxRuntime.jsx(Text, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, containerProps), otherTextProps), handlers), {}, {
|
86
|
-
children: value
|
87
|
-
}));
|
88
|
-
};
|
89
|
-
|
90
|
-
DSTruncatedTooltipText.defaultProps = {
|
91
|
-
value: '',
|
92
|
-
zIndex: 110
|
93
|
-
};
|
94
|
-
const truncatedTooltipTextProps = {
|
95
|
-
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
96
|
-
value: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.string, reactDesc.PropTypes.number]).description('Text that when truncated will trigger the tooltip interaction'),
|
97
|
-
tooltipPlacement: reactDesc.PropTypes.oneOf([dsPopper.PopperPositions.AUTO_START, dsPopper.PopperPositions.AUTO_END, dsPopper.PopperPositions.AUTO, dsPopper.PopperPositions.TOP_START, dsPopper.PopperPositions.TOP, dsPopper.PopperPositions.TOP_END, dsPopper.PopperPositions.RIGHT_START, dsPopper.PopperPositions.RIGHT, dsPopper.PopperPositions.RIGHT_END, dsPopper.PopperPositions.BOTTOM_START, dsPopper.PopperPositions.BOTTOM, dsPopper.PopperPositions.BOTTOM_END, dsPopper.PopperPositions.LEFT_START, dsPopper.PopperPositions.LEFT, dsPopper.PopperPositions.LEFT_END]).description('Position of the tooltip'),
|
98
|
-
tooltipDelay: reactDesc.PropTypes.number.description('Delay to show the tooltip'),
|
99
|
-
zIndex: reactDesc.PropTypes.number.description('override default zIndex').defaultValue(110)
|
100
|
-
};
|
101
|
-
DSTruncatedTooltipText.defaultProps = {
|
102
|
-
containerProps: {},
|
103
|
-
value: '',
|
104
|
-
tooltipPlacement: undefined,
|
105
|
-
tooltipDelay: undefined
|
106
|
-
};
|
107
|
-
const TruncatedTooltipTextWithSchema = reactDesc.describe(DSTruncatedTooltipText);
|
108
|
-
TruncatedTooltipTextWithSchema.propTypes = truncatedTooltipTextProps;
|
109
|
-
|
110
|
-
exports.DSTruncatedTooltipText = DSTruncatedTooltipText;
|
111
|
-
exports.TruncatedTooltipTextWithSchema = TruncatedTooltipTextWithSchema;
|
112
|
-
exports["default"] = DSTruncatedTooltipText;
|
@@ -1,148 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
6
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
7
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
8
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
9
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
10
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
11
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
12
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
13
|
-
var React = require('react');
|
14
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
15
|
-
var styled = require('styled-components');
|
16
|
-
var DSPopover = require('@elliemae/ds-popover');
|
17
|
-
var jsxRuntime = require('react/jsx-runtime');
|
18
|
-
|
19
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
20
|
-
|
21
|
-
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
22
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
23
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
24
|
-
var DSPopover__default = /*#__PURE__*/_interopDefaultLegacy(DSPopover);
|
25
|
-
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
27
|
-
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
29
|
-
const dsTestId = 'DS-SimpleTruncateText';
|
30
|
-
|
31
|
-
const isEllipsisActive = _ref => {
|
32
|
-
let {
|
33
|
-
offsetWidth,
|
34
|
-
scrollWidth
|
35
|
-
} = _ref;
|
36
|
-
return offsetWidth < scrollWidth;
|
37
|
-
};
|
38
|
-
|
39
|
-
const initialTooltipState = function () {
|
40
|
-
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
41
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
42
|
-
return {
|
43
|
-
reference: null,
|
44
|
-
visible: false,
|
45
|
-
value,
|
46
|
-
options
|
47
|
-
};
|
48
|
-
}; // reduce the possibility of error showing the tooltip(text-overflow: ellipsis) https://jira.elliemae.io/browse/PUI-1755
|
49
|
-
|
50
|
-
|
51
|
-
const Text = /*#__PURE__*/styled__default["default"].span.withConfig({
|
52
|
-
componentId: "sc-2f4vtq-0"
|
53
|
-
})(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:inline-block;max-width:100%;"]);
|
54
|
-
|
55
|
-
const SimpleTruncatedTooltipText = props => {
|
56
|
-
const {
|
57
|
-
containerProps,
|
58
|
-
tooltipDelay,
|
59
|
-
placement,
|
60
|
-
value,
|
61
|
-
zIndex,
|
62
|
-
tooltipOptions,
|
63
|
-
textOptions
|
64
|
-
} = props; // not using "usePopoverProviderState" because usePopoverState has memory leak issues
|
65
|
-
|
66
|
-
const [tooltipState, setTooltipState] = React.useState(initialTooltipState(value, tooltipOptions));
|
67
|
-
const show = React.useCallback(newState => {
|
68
|
-
setTooltipState(_objectSpread(_objectSpread(_objectSpread({}, tooltipState), newState), {}, {
|
69
|
-
visible: true
|
70
|
-
}));
|
71
|
-
}, [tooltipState]);
|
72
|
-
const hideTooltip = React.useCallback(newState => {
|
73
|
-
setTooltipState(_objectSpread(_objectSpread(_objectSpread({}, tooltipState), newState), {}, {
|
74
|
-
visible: false
|
75
|
-
}));
|
76
|
-
}, [tooltipState]);
|
77
|
-
const [showTooltip, cancelShowTooltip] = dsUtilities.useCancellableDelayedCallback(show, tooltipDelay);
|
78
|
-
const handleMouseEnter = React.useCallback(e => {
|
79
|
-
const {
|
80
|
-
target
|
81
|
-
} = e; // we search for the closest parent with data-testid matching this component
|
82
|
-
// this is required because the target may not be this component itself
|
83
|
-
// when the user gives JSX as a value.
|
84
|
-
// JSX as a value is required for features like text highlight during research
|
85
|
-
// wich would still allow the truncation behaviour (see tree view for example)
|
86
|
-
// when the target has the test-id itself target===SimpleTruncatedTextEl
|
87
|
-
|
88
|
-
const SimpleTruncatedTextEl = target.closest("[data-testid=\"".concat(dsTestId, "\"]"));
|
89
|
-
|
90
|
-
if (SimpleTruncatedTextEl && isEllipsisActive(SimpleTruncatedTextEl)) {
|
91
|
-
showTooltip({
|
92
|
-
value,
|
93
|
-
reference: SimpleTruncatedTextEl
|
94
|
-
});
|
95
|
-
}
|
96
|
-
}, [showTooltip, value]);
|
97
|
-
const handleMouseLeave = React.useCallback(() => {
|
98
|
-
cancelShowTooltip();
|
99
|
-
hideTooltip({
|
100
|
-
reference: null
|
101
|
-
});
|
102
|
-
}, [hideTooltip, cancelShowTooltip]);
|
103
|
-
const handlers = React.useMemo(() => {
|
104
|
-
if (!showTooltip) return {};
|
105
|
-
return {
|
106
|
-
onMouseEnter: handleMouseEnter,
|
107
|
-
onMouseLeave: handleMouseLeave
|
108
|
-
};
|
109
|
-
}, [showTooltip, handleMouseEnter, handleMouseLeave]);
|
110
|
-
const PurePopover = React.useMemo(() => /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
111
|
-
children: tooltipState.visible ? /*#__PURE__*/_jsx2__default["default"](DSPopover__default["default"], {
|
112
|
-
boundaries: "window",
|
113
|
-
style: {
|
114
|
-
pointerEvents: 'none',
|
115
|
-
zIndex
|
116
|
-
},
|
117
|
-
placement: placement,
|
118
|
-
content: tooltipState.value,
|
119
|
-
referenceEl: tooltipState.reference,
|
120
|
-
visible: tooltipState.visible,
|
121
|
-
showArrow: true
|
122
|
-
}) : null
|
123
|
-
}), [tooltipState, placement, zIndex]);
|
124
|
-
const PureText = React.useMemo(() => /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
125
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Text, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, containerProps && _objectSpread({}, containerProps)), textOptions && _objectSpread({}, textOptions)), handlers && _objectSpread({}, handlers)), {}, {
|
126
|
-
"data-testid": dsTestId // this is used by mouse enter too. required to support value as JSX
|
127
|
-
,
|
128
|
-
children: value
|
129
|
-
}))
|
130
|
-
}), [containerProps, textOptions, handlers, value]);
|
131
|
-
const PureSimpleTruncatedTooltipText = React.useMemo(() => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
132
|
-
children: [PureText, PurePopover]
|
133
|
-
}), [PureText, PurePopover]);
|
134
|
-
return PureSimpleTruncatedTooltipText;
|
135
|
-
};
|
136
|
-
|
137
|
-
SimpleTruncatedTooltipText.defaultProps = {
|
138
|
-
containerProps: {},
|
139
|
-
tooltipOptions: {},
|
140
|
-
textOptions: {},
|
141
|
-
value: '',
|
142
|
-
placement: DSPopover.PopperPositions.TOP,
|
143
|
-
tooltipDelay: 200,
|
144
|
-
zIndex: 110
|
145
|
-
};
|
146
|
-
|
147
|
-
exports.SimpleTruncatedTooltipText = SimpleTruncatedTooltipText;
|
148
|
-
exports["default"] = SimpleTruncatedTooltipText;
|