@cloud-ru/ds-truncate-string 1.0.7-preview-494c465d.0 → 1.0.7

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 CHANGED
@@ -3,6 +3,10 @@
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.7 (2026-09-28)
7
+
8
+ **Note:** Version bump only for package @ds/truncate-string
9
+
6
10
  ## 1.0.6 (2026-09-25)
7
11
 
8
12
  **Note:** Version bump only for package @ds/truncate-string
@@ -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 (hideTooltip || !textElementRef.current) {
22
- return;
21
+ if (textElementRef.current) {
22
+ toggleShowTooltip();
23
23
  }
24
- toggleShowTooltip();
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
- let observer;
34
- const rafId = requestAnimationFrame(() => {
35
- if (!textElementRef.current) {
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
- cancelAnimationFrame(rafId);
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
- let observer;
34
- const rafId = requestAnimationFrame(() => {
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
- cancelAnimationFrame(rafId);
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 (hideTooltip || !textElementRef.current) {
16
- return;
15
+ if (textElementRef.current) {
16
+ toggleShowTooltip();
17
17
  }
18
- toggleShowTooltip();
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
- let observer;
28
- const rafId = requestAnimationFrame(() => {
29
- if (!textElementRef.current) {
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
- cancelAnimationFrame(rafId);
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
- let observer;
28
- const rafId = requestAnimationFrame(() => {
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
- cancelAnimationFrame(rafId);
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 })] }));