@cloud-ru/ds-truncate-string 1.0.24-preview-ee843611.0 → 1.0.24-preview-2df639a4.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/README.md CHANGED
@@ -77,7 +77,7 @@ export function TruncateMultiline() {
77
77
  | Prop | Type | Default | Description |
78
78
  |------|------|---------|-------------|
79
79
  | `className` | `string` | — | |
80
- | `data-test-id` | `string` | — | |
80
+ | `data-test-id` | `string` | — | Идентификатор элемента для поиска в автоматизированных тестах. |
81
81
  | `hideTooltip` | `boolean` | — | Скрывать ли тултип с полным текстом |
82
82
  | `maxLines` | `number` | — | Максимальное кол-во строк, до которого может сворачиваться текст. |
83
83
  | `placement` | `"bottom"` \| `"bottom-end"` \| `"bottom-start"` \| `"left"` \| `"left-end"` \| `"left-start"` \| `"right"` \| `"right-end"` \| `"right-start"` \| `"top"` \| `"top-end"` \| `"top-start"` | — | Положение тултипа относительно обрезанного текста. |
@@ -3,6 +3,8 @@ export declare const VARIANT: {
3
3
  readonly End: "end";
4
4
  };
5
5
  export declare const TEST_IDS: {
6
+ readonly truncateStringEndTooltip: "truncate-string-end__tooltip";
7
+ readonly truncateStringMiddleTooltip: "truncate-string-middle__tooltip";
6
8
  readonly root: "truncate-string";
7
9
  readonly fullText: "truncate-string__full-text";
8
10
  readonly truncatedText: "truncate-string__truncated-text";
@@ -6,6 +6,8 @@ exports.VARIANT = {
6
6
  End: 'end',
7
7
  };
8
8
  exports.TEST_IDS = {
9
+ truncateStringEndTooltip: 'truncate-string-end__tooltip',
10
+ truncateStringMiddleTooltip: 'truncate-string-middle__tooltip',
9
11
  root: 'truncate-string',
10
12
  fullText: 'truncate-string__full-text',
11
13
  truncatedText: 'truncate-string__truncated-text',
@@ -9,6 +9,7 @@ const tooltip_1 = require("@cloud-ru/ds-tooltip");
9
9
  const utils_1 = require("@cloud-ru/ds-utils");
10
10
  const classnames_1 = __importDefault(require("classnames"));
11
11
  const react_1 = require("react");
12
+ const constants_1 = require("../../constants");
12
13
  const helpers_1 = require("../../helpers");
13
14
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
14
15
  function TruncateStringEnd({ text, className, tooltipClassName, hideTooltip, maxLines = 1, placement = 'top', trigger = 'hoverAndFocusVisible', ...rest }) {
@@ -38,7 +39,7 @@ function TruncateStringEnd({ text, className, tooltipClassName, hideTooltip, max
38
39
  }, [text, maxLines, showTooltip, hideTooltip]);
39
40
  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 }));
40
41
  if (showTooltip && !hideTooltip) {
41
- return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: text, placement: placement, hoverDelayOpen: 500, className: tooltipClassName, triggerClassName: styles_module_scss_1.default.tooltipTrigger, trigger: trigger, children: textElement }));
42
+ return ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { "data-test-id": constants_1.TEST_IDS.truncateStringEndTooltip, tip: text, placement: placement, hoverDelayOpen: 500, className: tooltipClassName, triggerClassName: styles_module_scss_1.default.tooltipTrigger, trigger: trigger, children: textElement }));
42
43
  }
43
44
  return textElement;
44
45
  }
@@ -44,5 +44,5 @@ function TruncateStringMiddle({ text, className, tooltipClassName, hideTooltip,
44
44
  };
45
45
  }, [showTooltip, text, hideTooltip]);
46
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 })] }));
47
- return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), ...(0, utils_1.extractSupportProps)(rest), children: showTooltip && !hideTooltip ? ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: text, placement: placement, hoverDelayOpen: 500, triggerClassName: styles_module_scss_1.default.textContainer, className: tooltipClassName, trigger: trigger, children: textElement })) : (textElement) }));
47
+ return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), ...(0, utils_1.extractSupportProps)(rest), children: showTooltip && !hideTooltip ? ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { "data-test-id": constants_1.TEST_IDS.truncateStringMiddleTooltip, tip: text, placement: placement, hoverDelayOpen: 500, triggerClassName: styles_module_scss_1.default.textContainer, className: tooltipClassName, trigger: trigger, children: textElement })) : (textElement) }));
48
48
  }
@@ -3,6 +3,8 @@ export declare const VARIANT: {
3
3
  readonly End: "end";
4
4
  };
5
5
  export declare const TEST_IDS: {
6
+ readonly truncateStringEndTooltip: "truncate-string-end__tooltip";
7
+ readonly truncateStringMiddleTooltip: "truncate-string-middle__tooltip";
6
8
  readonly root: "truncate-string";
7
9
  readonly fullText: "truncate-string__full-text";
8
10
  readonly truncatedText: "truncate-string__truncated-text";
@@ -3,6 +3,8 @@ export const VARIANT = {
3
3
  End: 'end',
4
4
  };
5
5
  export const TEST_IDS = {
6
+ truncateStringEndTooltip: 'truncate-string-end__tooltip',
7
+ truncateStringMiddleTooltip: 'truncate-string-middle__tooltip',
6
8
  root: 'truncate-string',
7
9
  fullText: 'truncate-string__full-text',
8
10
  truncatedText: 'truncate-string__truncated-text',
@@ -3,6 +3,7 @@ import { Tooltip } from '@cloud-ru/ds-tooltip';
3
3
  import { extractSupportProps, throttle } from '@cloud-ru/ds-utils';
4
4
  import cn from 'classnames';
5
5
  import { useEffect, useRef, useState } from 'react';
6
+ import { TEST_IDS } from '../../constants.js';
6
7
  import { isEllipsisActive } from '../../helpers/index.js';
7
8
  import styles from './styles.module.css';
8
9
  export function TruncateStringEnd({ text, className, tooltipClassName, hideTooltip, maxLines = 1, placement = 'top', trigger = 'hoverAndFocusVisible', ...rest }) {
@@ -32,7 +33,7 @@ export function TruncateStringEnd({ text, className, tooltipClassName, hideToolt
32
33
  }, [text, maxLines, showTooltip, hideTooltip]);
33
34
  const textElement = (_jsx("span", { ref: textElementRef, className: cn(maxLines > 1 ? styles.text2AndMoreLines : styles.text1Line, className), style: { '--max-lines': maxLines }, ...extractSupportProps(rest), children: text }));
34
35
  if (showTooltip && !hideTooltip) {
35
- return (_jsx(Tooltip, { tip: text, placement: placement, hoverDelayOpen: 500, className: tooltipClassName, triggerClassName: styles.tooltipTrigger, trigger: trigger, children: textElement }));
36
+ return (_jsx(Tooltip, { "data-test-id": TEST_IDS.truncateStringEndTooltip, tip: text, placement: placement, hoverDelayOpen: 500, className: tooltipClassName, triggerClassName: styles.tooltipTrigger, trigger: trigger, children: textElement }));
36
37
  }
37
38
  return textElement;
38
39
  }
@@ -38,5 +38,5 @@ export function TruncateStringMiddle({ text, className, tooltipClassName, hideTo
38
38
  };
39
39
  }, [showTooltip, text, hideTooltip]);
40
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 })] }));
41
- return (_jsx("span", { className: cn(styles.wrapper, className), ...extractSupportProps(rest), children: showTooltip && !hideTooltip ? (_jsx(Tooltip, { tip: text, placement: placement, hoverDelayOpen: 500, triggerClassName: styles.textContainer, className: tooltipClassName, trigger: trigger, children: textElement })) : (textElement) }));
41
+ return (_jsx("span", { className: cn(styles.wrapper, className), ...extractSupportProps(rest), children: showTooltip && !hideTooltip ? (_jsx(Tooltip, { "data-test-id": TEST_IDS.truncateStringMiddleTooltip, tip: text, placement: placement, hoverDelayOpen: 500, triggerClassName: styles.textContainer, className: tooltipClassName, trigger: trigger, children: textElement })) : (textElement) }));
42
42
  }