@cloud-ru/ds-tag 1.1.21 → 1.2.1

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,16 @@
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.2.1 (2026-11-04)
7
+
8
+ **Note:** Version bump only for package @ds/tag
9
+
10
+ # 1.2.0 (2026-11-04)
11
+
12
+ ### Features
13
+
14
+ - **FF-9112:** add tooltips for tagrow ([9c36e5e](https://github.com/cloud-ru-tech/snack-v2/commit/9c36e5e863c3ee8b1e485e4236e63867e32ef1e3))
15
+
6
16
  ## 1.1.21 (2026-11-03)
7
17
 
8
18
  **Note:** Version bump only for package @ds/tag
package/README.md CHANGED
@@ -77,6 +77,7 @@ export function Removable() {
77
77
  | `onDelete` | `MouseEventHandler<HTMLButtonElement>` | — | Обработчик удаления тега. Если задан — отображается крестик-remove |
78
78
  | `size` | `"m"` \| `"s"` \| `"xs"` | — | |
79
79
  | `tabIndex` | `number` | — | |
80
+ | `tooltip` | `TooltipProps` | — | Тултип над тегом |
80
81
  | `truncateVariant` | `"end"` \| `"middle"` | — | Вариант обрезания подписи, не поместившейся в тег. |
81
82
 
82
83
  ##### Related types
@@ -1,3 +1,3 @@
1
1
  import { TagLinkProps, TagProps } from '../../types';
2
2
  export declare function isTagLinkProps(props: TagProps): props is TagLinkProps;
3
- export declare function Tag(props: TagProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Tag({ tooltip, ...props }: TagProps): import("react/jsx-runtime").JSX.Element;
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isTagLinkProps = isTagLinkProps;
4
4
  exports.Tag = Tag;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const tooltip_1 = require("@cloud-ru/ds-tooltip");
6
7
  const utils_1 = require("@cloud-ru/ds-utils");
8
+ const react_1 = require("react");
7
9
  const TagBase_1 = require("../TagBase");
8
10
  const TagLink_1 = require("../TagLink");
9
11
  function isTagLinkProps(props) {
10
12
  return 'href' in props && props.href !== undefined;
11
13
  }
12
- function Tag(props) {
13
- return isTagLinkProps(props) ? (0, jsx_runtime_1.jsx)(TagLink_1.TagLink, { ...props }) : (0, jsx_runtime_1.jsx)(TagBase_1.TagBase, { ...props });
14
+ function Tag({ tooltip, ...props }) {
15
+ const [restrictOpenTooltip, setRestrictOpenTooltip] = (0, react_1.useState)(false);
16
+ return ((0, jsx_runtime_1.jsx)(tooltip_1.WithTooltip, { tooltip: tooltip && { ...tooltip, open: restrictOpenTooltip ? false : tooltip.open }, children: isTagLinkProps(props) ? ((0, jsx_runtime_1.jsx)(TagLink_1.TagLink, { ...props })) : ((0, jsx_runtime_1.jsx)(TagBase_1.TagBase, { ...props, changeRestrictTooltipState: tooltip ? setRestrictOpenTooltip : undefined, hideTruncateTooltip: Boolean(tooltip) })) }));
14
17
  }
15
18
  (0, utils_1.withInnerRefSupport)(Tag);
@@ -1,2 +1,5 @@
1
1
  import { TagBaseProps } from '../../types';
2
- export declare function TagBase({ label, truncateVariant, size, appearance, onDelete, className, tabIndex, innerRef, ...rest }: TagBaseProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function TagBase({ label, truncateVariant, size, appearance, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }: TagBaseProps & {
3
+ changeRestrictTooltipState?: (state: boolean) => void;
4
+ hideTruncateTooltip: boolean;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -12,8 +12,8 @@ const classnames_1 = __importDefault(require("classnames"));
12
12
  const constants_1 = require("../../constants");
13
13
  const constants_2 = require("./constants");
14
14
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
15
- function TagBase({ label, truncateVariant, size = constants_1.SIZE.S, appearance = constants_1.APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, ...rest }) {
15
+ function TagBase({ label, truncateVariant, size = constants_1.SIZE.S, appearance = constants_1.APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }) {
16
16
  const isRemovable = Boolean(onDelete);
17
- return ((0, jsx_runtime_1.jsxs)("span", { ref: innerRef, ...(0, utils_1.extractSupportProps)(rest), className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.textWrapper, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { className: styles_module_scss_1.default.label, text: label, variant: truncateVariant }) }), isRemovable && ((0, jsx_runtime_1.jsx)("button", { type: 'button', className: styles_module_scss_1.default.tagButton, onClick: onDelete, "data-test-id": constants_1.TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.icon, children: (0, jsx_runtime_1.jsx)(system_1.CrossSVG, { size: constants_2.ICON_SIZE[size] }) }) }))] }));
17
+ return ((0, jsx_runtime_1.jsxs)("span", { ref: innerRef, ...(0, utils_1.extractSupportProps)(rest), className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.textWrapper, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { className: styles_module_scss_1.default.label, text: label, variant: truncateVariant, hideTooltip: hideTruncateTooltip }) }), isRemovable && ((0, jsx_runtime_1.jsx)("button", { type: 'button', className: styles_module_scss_1.default.tagButton, onClick: onDelete, onMouseEnter: () => changeRestrictTooltipState?.(true), onMouseLeave: () => changeRestrictTooltipState?.(false), "data-test-id": constants_1.TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.icon, children: (0, jsx_runtime_1.jsx)(system_1.CrossSVG, { size: constants_2.ICON_SIZE[size] }) }) }))] }));
18
18
  }
19
19
  (0, utils_1.withInnerRefSupport)(TagBase);
@@ -1,3 +1,4 @@
1
+ import { TooltipProps } from '@cloud-ru/ds-tooltip';
1
2
  import { TruncateStringProps } from '@cloud-ru/ds-truncate-string';
2
3
  import { PolymorphicRef, ValueOf, WithSupportProps } from '@cloud-ru/ds-utils';
3
4
  import { ComponentPropsWithoutRef, ElementType, MouseEvent, MouseEventHandler, Ref } from 'react';
@@ -9,11 +10,15 @@ export type LinkProps = {
9
10
  onClick?(e: MouseEvent<HTMLAnchorElement>): void;
10
11
  target?: HTMLAnchorElement['target'];
11
12
  };
13
+ export type TagTooltipProps = {
14
+ /** Тултип над тегом */
15
+ tooltip?: TooltipProps;
16
+ };
12
17
  export type TagRowItem = {
13
18
  id?: string;
14
19
  label: string;
15
20
  appearance?: Appearance;
16
- } & Partial<LinkProps>;
21
+ } & Partial<LinkProps> & TagTooltipProps;
17
22
  export type TagRowItemInner = Omit<TagRowItem, 'appearance'> & {
18
23
  appearance: Appearance;
19
24
  };
@@ -49,7 +54,8 @@ export type TagLinkProps<T extends ElementType = 'a'> = WithSupportProps<Omit<Co
49
54
  */
50
55
  innerRef?: PolymorphicRef<T>;
51
56
  } & Omit<ComponentPropsWithoutRef<T>, keyof CommonTagProps | 'as' | 'ref'>>;
52
- export type TagProps = TagBaseProps | TagLinkProps;
57
+ export type TagWithTooltipProps = (TagBaseProps | TagLinkProps) & TagTooltipProps;
58
+ export type TagProps = TagWithTooltipProps;
53
59
  export type TagRowProps = WithSupportProps<{
54
60
  items: TagRowItem[];
55
61
  rowLimit?: number;
@@ -1,3 +1,3 @@
1
1
  import { TagLinkProps, TagProps } from '../../types.js';
2
2
  export declare function isTagLinkProps(props: TagProps): props is TagLinkProps;
3
- export declare function Tag(props: TagProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Tag({ tooltip, ...props }: TagProps): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { WithTooltip } from '@cloud-ru/ds-tooltip';
2
3
  import { withInnerRefSupport } from '@cloud-ru/ds-utils';
4
+ import { useState } from 'react';
3
5
  import { TagBase } from '../TagBase/index.js';
4
6
  import { TagLink } from '../TagLink/index.js';
5
7
  export function isTagLinkProps(props) {
6
8
  return 'href' in props && props.href !== undefined;
7
9
  }
8
- export function Tag(props) {
9
- return isTagLinkProps(props) ? _jsx(TagLink, { ...props }) : _jsx(TagBase, { ...props });
10
+ export function Tag({ tooltip, ...props }) {
11
+ const [restrictOpenTooltip, setRestrictOpenTooltip] = useState(false);
12
+ return (_jsx(WithTooltip, { tooltip: tooltip && { ...tooltip, open: restrictOpenTooltip ? false : tooltip.open }, children: isTagLinkProps(props) ? (_jsx(TagLink, { ...props })) : (_jsx(TagBase, { ...props, changeRestrictTooltipState: tooltip ? setRestrictOpenTooltip : undefined, hideTruncateTooltip: Boolean(tooltip) })) }));
10
13
  }
11
14
  withInnerRefSupport(Tag);
@@ -1,2 +1,5 @@
1
1
  import { TagBaseProps } from '../../types.js';
2
- export declare function TagBase({ label, truncateVariant, size, appearance, onDelete, className, tabIndex, innerRef, ...rest }: TagBaseProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function TagBase({ label, truncateVariant, size, appearance, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }: TagBaseProps & {
3
+ changeRestrictTooltipState?: (state: boolean) => void;
4
+ hideTruncateTooltip: boolean;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -6,8 +6,8 @@ import cn from 'classnames';
6
6
  import { APPEARANCE, SIZE, TEST_IDS } from '../../constants.js';
7
7
  import { ICON_SIZE } from './constants.js';
8
8
  import styles from './styles.module.css';
9
- export function TagBase({ label, truncateVariant, size = SIZE.S, appearance = APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, ...rest }) {
9
+ export function TagBase({ label, truncateVariant, size = SIZE.S, appearance = APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }) {
10
10
  const isRemovable = Boolean(onDelete);
11
- return (_jsxs("span", { ref: innerRef, ...extractSupportProps(rest), className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [_jsx("span", { className: styles.textWrapper, children: _jsx(TruncateString, { className: styles.label, text: label, variant: truncateVariant }) }), isRemovable && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, "data-test-id": TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: _jsx("span", { className: styles.icon, children: _jsx(CrossSVG, { size: ICON_SIZE[size] }) }) }))] }));
11
+ return (_jsxs("span", { ref: innerRef, ...extractSupportProps(rest), className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [_jsx("span", { className: styles.textWrapper, children: _jsx(TruncateString, { className: styles.label, text: label, variant: truncateVariant, hideTooltip: hideTruncateTooltip }) }), isRemovable && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, onMouseEnter: () => changeRestrictTooltipState?.(true), onMouseLeave: () => changeRestrictTooltipState?.(false), "data-test-id": TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: _jsx("span", { className: styles.icon, children: _jsx(CrossSVG, { size: ICON_SIZE[size] }) }) }))] }));
12
12
  }
13
13
  withInnerRefSupport(TagBase);
@@ -1,3 +1,4 @@
1
+ import { TooltipProps } from '@cloud-ru/ds-tooltip';
1
2
  import { TruncateStringProps } from '@cloud-ru/ds-truncate-string';
2
3
  import { PolymorphicRef, ValueOf, WithSupportProps } from '@cloud-ru/ds-utils';
3
4
  import { ComponentPropsWithoutRef, ElementType, MouseEvent, MouseEventHandler, Ref } from 'react';
@@ -9,11 +10,15 @@ export type LinkProps = {
9
10
  onClick?(e: MouseEvent<HTMLAnchorElement>): void;
10
11
  target?: HTMLAnchorElement['target'];
11
12
  };
13
+ export type TagTooltipProps = {
14
+ /** Тултип над тегом */
15
+ tooltip?: TooltipProps;
16
+ };
12
17
  export type TagRowItem = {
13
18
  id?: string;
14
19
  label: string;
15
20
  appearance?: Appearance;
16
- } & Partial<LinkProps>;
21
+ } & Partial<LinkProps> & TagTooltipProps;
17
22
  export type TagRowItemInner = Omit<TagRowItem, 'appearance'> & {
18
23
  appearance: Appearance;
19
24
  };
@@ -49,7 +54,8 @@ export type TagLinkProps<T extends ElementType = 'a'> = WithSupportProps<Omit<Co
49
54
  */
50
55
  innerRef?: PolymorphicRef<T>;
51
56
  } & Omit<ComponentPropsWithoutRef<T>, keyof CommonTagProps | 'as' | 'ref'>>;
52
- export type TagProps = TagBaseProps | TagLinkProps;
57
+ export type TagWithTooltipProps = (TagBaseProps | TagLinkProps) & TagTooltipProps;
58
+ export type TagProps = TagWithTooltipProps;
53
59
  export type TagRowProps = WithSupportProps<{
54
60
  items: TagRowItem[];
55
61
  rowLimit?: number;