@cloud-ru/ds-truncate-string 1.0.8-preview-65417497.0 → 1.0.8
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/CHANGELOG.md +6 -0
- package/dist/cjs/helperComponents/TruncateStringEnd/TruncateStringEnd.js +16 -8
- package/dist/cjs/helperComponents/TruncateStringMiddle/TruncateStringMiddle.js +12 -4
- package/dist/esm/helperComponents/TruncateStringEnd/TruncateStringEnd.js +16 -8
- package/dist/esm/helperComponents/TruncateStringMiddle/TruncateStringMiddle.js +12 -4
- 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 +19 -8
- package/src/helperComponents/TruncateStringMiddle/TruncateStringMiddle.tsx +14 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.0.8 (2026-09-29)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **FF-9192:** skip resizeObserver init if hideTooltip passed, added RAF for resize measuring ([56d48b2](https://github.com/cloud-ru-tech/snack-v2/commit/56d48b2d5724ffbe5185e7fd1442220c0e477158))
|
|
11
|
+
|
|
6
12
|
## 1.0.7 (2026-09-28)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @ds/truncate-string
|
|
@@ -18,21 +18,29 @@ 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 (textElementRef.current) {
|
|
22
|
-
|
|
21
|
+
if (hideTooltip || !textElementRef.current) {
|
|
22
|
+
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
toggleShowTooltip();
|
|
25
|
+
}, [text, toggleShowTooltip, hideTooltip]);
|
|
25
26
|
(0, react_1.useEffect)(() => {
|
|
27
|
+
if (hideTooltip) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
26
30
|
const throttledToggleShowTooltip = (0, utils_1.throttle)(() => {
|
|
27
31
|
toggleShowTooltip();
|
|
28
32
|
}, 50);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
let observer;
|
|
34
|
+
const rafId = requestAnimationFrame(() => {
|
|
35
|
+
if (!textElementRef.current) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
32
39
|
observer.observe(textElementRef.current);
|
|
33
|
-
}
|
|
40
|
+
});
|
|
34
41
|
return () => {
|
|
35
|
-
|
|
42
|
+
cancelAnimationFrame(rafId);
|
|
43
|
+
observer?.disconnect();
|
|
36
44
|
};
|
|
37
45
|
}, [showTooltip, hideTooltip, toggleShowTooltip]);
|
|
38
46
|
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,6 +18,9 @@ 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
|
+
}
|
|
21
24
|
const setTruncate = (0, utils_1.throttle)(() => {
|
|
22
25
|
setTruncatedString((0, helpers_1.truncateStringMiddle)({
|
|
23
26
|
element: textElementRef.current,
|
|
@@ -27,12 +30,17 @@ function TruncateStringMiddle({ text, className, tooltipClassName, hideTooltip,
|
|
|
27
30
|
setShowTooltip((0, helpers_1.isEllipsisActive)(textElementRef.current));
|
|
28
31
|
}, 50);
|
|
29
32
|
setTruncate();
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
let observer;
|
|
34
|
+
const rafId = requestAnimationFrame(() => {
|
|
35
|
+
if (!textElementRef.current) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
observer = new ResizeObserver(setTruncate);
|
|
32
39
|
observer.observe(textElementRef.current);
|
|
33
|
-
}
|
|
40
|
+
});
|
|
34
41
|
return () => {
|
|
35
|
-
|
|
42
|
+
cancelAnimationFrame(rafId);
|
|
43
|
+
observer?.disconnect();
|
|
36
44
|
};
|
|
37
45
|
}, [showTooltip, text, hideTooltip]);
|
|
38
46
|
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,21 +12,29 @@ export function TruncateStringEnd({ text, className, tooltipClassName, hideToolt
|
|
|
12
12
|
setShowTooltip(isEllipsisActive(textElementRef.current));
|
|
13
13
|
}, []);
|
|
14
14
|
useLayoutEffect(() => {
|
|
15
|
-
if (textElementRef.current) {
|
|
16
|
-
|
|
15
|
+
if (hideTooltip || !textElementRef.current) {
|
|
16
|
+
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
toggleShowTooltip();
|
|
19
|
+
}, [text, toggleShowTooltip, hideTooltip]);
|
|
19
20
|
useEffect(() => {
|
|
21
|
+
if (hideTooltip) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
20
24
|
const throttledToggleShowTooltip = throttle(() => {
|
|
21
25
|
toggleShowTooltip();
|
|
22
26
|
}, 50);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
let observer;
|
|
28
|
+
const rafId = requestAnimationFrame(() => {
|
|
29
|
+
if (!textElementRef.current) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
observer = new ResizeObserver(throttledToggleShowTooltip);
|
|
26
33
|
observer.observe(textElementRef.current);
|
|
27
|
-
}
|
|
34
|
+
});
|
|
28
35
|
return () => {
|
|
29
|
-
|
|
36
|
+
cancelAnimationFrame(rafId);
|
|
37
|
+
observer?.disconnect();
|
|
30
38
|
};
|
|
31
39
|
}, [showTooltip, hideTooltip, toggleShowTooltip]);
|
|
32
40
|
const textElement = (_jsx("span", { ref: textElementRef, className: cn(maxLines > 1 ? styles.text2AndMoreLines : styles.text1Line, className), style: { '--max-lines': maxLines }, ...extractSupportProps(rest), children: text }));
|
|
@@ -12,6 +12,9 @@ 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
|
+
}
|
|
15
18
|
const setTruncate = throttle(() => {
|
|
16
19
|
setTruncatedString(truncateStringMiddle({
|
|
17
20
|
element: textElementRef.current,
|
|
@@ -21,12 +24,17 @@ export function TruncateStringMiddle({ text, className, tooltipClassName, hideTo
|
|
|
21
24
|
setShowTooltip(isEllipsisActive(textElementRef.current));
|
|
22
25
|
}, 50);
|
|
23
26
|
setTruncate();
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
let observer;
|
|
28
|
+
const rafId = requestAnimationFrame(() => {
|
|
29
|
+
if (!textElementRef.current) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
observer = new ResizeObserver(setTruncate);
|
|
26
33
|
observer.observe(textElementRef.current);
|
|
27
|
-
}
|
|
34
|
+
});
|
|
28
35
|
return () => {
|
|
29
|
-
|
|
36
|
+
cancelAnimationFrame(rafId);
|
|
37
|
+
observer?.disconnect();
|
|
30
38
|
};
|
|
31
39
|
}, [showTooltip, text, hideTooltip]);
|
|
32
40
|
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 })] }));
|