@cloud-ru/ds-truncate-string 1.0.6-preview-c228f409.0 → 1.0.6-preview-d50a3da1.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/helperComponents/TruncateStringEnd/TruncateStringEnd.js +8 -16
- package/dist/cjs/helperComponents/TruncateStringMiddle/TruncateStringMiddle.js +4 -12
- package/dist/esm/helperComponents/TruncateStringEnd/TruncateStringEnd.js +8 -16
- package/dist/esm/helperComponents/TruncateStringMiddle/TruncateStringMiddle.js +4 -12
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/helperComponents/TruncateStringEnd/TruncateStringEnd.tsx +8 -19
- package/src/helperComponents/TruncateStringMiddle/TruncateStringMiddle.tsx +4 -14
|
@@ -18,29 +18,21 @@ function TruncateStringEnd({ text, className, tooltipClassName, hideTooltip, max
|
|
|
18
18
|
setShowTooltip((0, helpers_1.isEllipsisActive)(textElementRef.current));
|
|
19
19
|
}, []);
|
|
20
20
|
(0, utils_1.useLayoutEffect)(() => {
|
|
21
|
-
if (
|
|
22
|
-
|
|
21
|
+
if (textElementRef.current) {
|
|
22
|
+
toggleShowTooltip();
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
}, [text, toggleShowTooltip, hideTooltip]);
|
|
24
|
+
}, [text, toggleShowTooltip]);
|
|
26
25
|
(0, react_1.useEffect)(() => {
|
|
27
|
-
if (hideTooltip) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
26
|
const throttledToggleShowTooltip = (0, utils_1.throttle)(() => {
|
|
31
27
|
toggleShowTooltip();
|
|
32
28
|
}, 50);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
29
|
+
const observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
30
|
+
if (textElementRef.current) {
|
|
31
|
+
toggleShowTooltip();
|
|
39
32
|
observer.observe(textElementRef.current);
|
|
40
|
-
}
|
|
33
|
+
}
|
|
41
34
|
return () => {
|
|
42
|
-
|
|
43
|
-
observer?.disconnect();
|
|
35
|
+
observer.disconnect();
|
|
44
36
|
};
|
|
45
37
|
}, [showTooltip, hideTooltip, toggleShowTooltip]);
|
|
46
38
|
const textElement = ((0, jsx_runtime_1.jsx)("span", { ref: textElementRef, className: (0, classnames_1.default)(maxLines > 1 ? styles_module_scss_1.default.text2AndMoreLines : styles_module_scss_1.default.text1Line, className), style: { '--max-lines': maxLines }, ...(0, utils_1.extractSupportProps)(rest), children: text }));
|
|
@@ -18,9 +18,6 @@ function TruncateStringMiddle({ text, className, tooltipClassName, hideTooltip,
|
|
|
18
18
|
const textElementRef = (0, react_1.useRef)(null);
|
|
19
19
|
const truncatedTextElementRef = (0, react_1.useRef)(null);
|
|
20
20
|
(0, react_1.useEffect)(() => {
|
|
21
|
-
if (hideTooltip) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
21
|
const setTruncate = (0, utils_1.throttle)(() => {
|
|
25
22
|
setTruncatedString((0, helpers_1.truncateStringMiddle)({
|
|
26
23
|
element: textElementRef.current,
|
|
@@ -30,17 +27,12 @@ function TruncateStringMiddle({ text, className, tooltipClassName, hideTooltip,
|
|
|
30
27
|
setShowTooltip((0, helpers_1.isEllipsisActive)(textElementRef.current));
|
|
31
28
|
}, 50);
|
|
32
29
|
setTruncate();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!textElementRef.current) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
observer = new ResizeObserver(setTruncate);
|
|
30
|
+
const observer = new ResizeObserver(setTruncate);
|
|
31
|
+
if (textElementRef.current) {
|
|
39
32
|
observer.observe(textElementRef.current);
|
|
40
|
-
}
|
|
33
|
+
}
|
|
41
34
|
return () => {
|
|
42
|
-
|
|
43
|
-
observer?.disconnect();
|
|
35
|
+
observer.disconnect();
|
|
44
36
|
};
|
|
45
37
|
}, [showTooltip, text, hideTooltip]);
|
|
46
38
|
const textElement = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { ref: textElementRef, className: styles_module_scss_1.default.fullText, "data-test-id": constants_1.TEST_IDS.fullText, children: text }), (0, jsx_runtime_1.jsx)("span", { ref: truncatedTextElementRef, className: styles_module_scss_1.default.truncatedText, "data-test-id": constants_1.TEST_IDS.truncatedText, children: truncatedString })] }));
|
|
@@ -12,29 +12,21 @@ export function TruncateStringEnd({ text, className, tooltipClassName, hideToolt
|
|
|
12
12
|
setShowTooltip(isEllipsisActive(textElementRef.current));
|
|
13
13
|
}, []);
|
|
14
14
|
useLayoutEffect(() => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
15
|
+
if (textElementRef.current) {
|
|
16
|
+
toggleShowTooltip();
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
}, [text, toggleShowTooltip, hideTooltip]);
|
|
18
|
+
}, [text, toggleShowTooltip]);
|
|
20
19
|
useEffect(() => {
|
|
21
|
-
if (hideTooltip) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
20
|
const throttledToggleShowTooltip = throttle(() => {
|
|
25
21
|
toggleShowTooltip();
|
|
26
22
|
}, 50);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
23
|
+
const observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
24
|
+
if (textElementRef.current) {
|
|
25
|
+
toggleShowTooltip();
|
|
33
26
|
observer.observe(textElementRef.current);
|
|
34
|
-
}
|
|
27
|
+
}
|
|
35
28
|
return () => {
|
|
36
|
-
|
|
37
|
-
observer?.disconnect();
|
|
29
|
+
observer.disconnect();
|
|
38
30
|
};
|
|
39
31
|
}, [showTooltip, hideTooltip, toggleShowTooltip]);
|
|
40
32
|
const textElement = (_jsx("span", { ref: textElementRef, className: cn(maxLines > 1 ? styles.text2AndMoreLines : styles.text1Line, className), style: { '--max-lines': maxLines }, ...extractSupportProps(rest), children: text }));
|
|
@@ -12,9 +12,6 @@ export function TruncateStringMiddle({ text, className, tooltipClassName, hideTo
|
|
|
12
12
|
const textElementRef = useRef(null);
|
|
13
13
|
const truncatedTextElementRef = useRef(null);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
if (hideTooltip) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
15
|
const setTruncate = throttle(() => {
|
|
19
16
|
setTruncatedString(truncateStringMiddle({
|
|
20
17
|
element: textElementRef.current,
|
|
@@ -24,17 +21,12 @@ export function TruncateStringMiddle({ text, className, tooltipClassName, hideTo
|
|
|
24
21
|
setShowTooltip(isEllipsisActive(textElementRef.current));
|
|
25
22
|
}, 50);
|
|
26
23
|
setTruncate();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!textElementRef.current) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
observer = new ResizeObserver(setTruncate);
|
|
24
|
+
const observer = new ResizeObserver(setTruncate);
|
|
25
|
+
if (textElementRef.current) {
|
|
33
26
|
observer.observe(textElementRef.current);
|
|
34
|
-
}
|
|
27
|
+
}
|
|
35
28
|
return () => {
|
|
36
|
-
|
|
37
|
-
observer?.disconnect();
|
|
29
|
+
observer.disconnect();
|
|
38
30
|
};
|
|
39
31
|
}, [showTooltip, text, hideTooltip]);
|
|
40
32
|
const textElement = (_jsxs(_Fragment, { children: [_jsx("span", { ref: textElementRef, className: styles.fullText, "data-test-id": TEST_IDS.fullText, children: text }), _jsx("span", { ref: truncatedTextElementRef, className: styles.truncatedText, "data-test-id": TEST_IDS.truncatedText, children: truncatedString })] }));
|