@cloud-ru/ds-uikit-product-card-predefined 4.3.2 → 4.3.3-preview-7f0ca3f7.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.
@@ -16,7 +16,6 @@ const react_1 = require("react");
16
16
  const constants_1 = require("../../constants");
17
17
  const helperComponents_1 = require("../../helperComponents");
18
18
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
19
- const TARGET_BLANK = '_blank';
20
19
  const { appearance: ACRYLIC_APPEARANCE, level: ACRYLIC_LEVEL } = (0, materials_1.backgroundPredefinedFillToAcrylic)(materials_1.BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
21
20
  /**
22
21
  * Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
@@ -73,22 +72,7 @@ function CardNavigation({ as, innerRef, icon, title, description, promoTag, trun
73
72
  ],
74
73
  }), [disabled, onKeyDownProp, promoTag, cardTooltip, favorite?.enabled, expandable, isFavorite, setIsFavorite]);
75
74
  let polymorphicProps;
76
- if (Component === 'a') {
77
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown;
78
- polymorphicProps = {
79
- ...anchorRest,
80
- href: href ?? '#',
81
- target,
82
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
83
- onClick: disabled
84
- ? (e) => {
85
- e.preventDefault();
86
- onClick?.(e);
87
- }
88
- : onClick,
89
- };
90
- }
91
- else if (Component === 'button') {
75
+ if (Component === 'button') {
92
76
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
93
77
  polymorphicProps = {
94
78
  type,
@@ -98,19 +82,9 @@ function CardNavigation({ as, innerRef, icon, title, description, promoTag, trun
98
82
  };
99
83
  }
100
84
  else {
101
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
102
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
103
- const { onClick, ...componentRest } = restWithoutKeyDown;
104
- polymorphicProps = {
105
- ...componentRest,
106
- onClick: disabled
107
- ? (e) => {
108
- e.preventDefault();
109
- }
110
- : onClick,
111
- };
85
+ polymorphicProps = (0, utils_1.getLinkElementProps)(Component, restWithoutKeyDown, disabled);
112
86
  }
113
- return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardNavigation, "data-detailed": isDetailed || undefined, "data-disabled": disabled || undefined, "data-actions-visibility": actionsVisibility, "data-visible-actions": visibleActionsCount, "data-acrylic-appearance": ACRYLIC_APPEARANCE, "data-acrylic-level": ACRYLIC_LEVEL, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, onPointerEnter: handlePointerEnter, onFocus: handleFocus, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [isDetailed && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.acrylic, "aria-hidden": true, "data-acrylic-background": true }), (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.textContent, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.titleRow, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardNavigationTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: isDetailed ? 1 : truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardNavigationPromoTag, className: compactThemeClassName }))] }), isDetailed && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'p', variant: 'body', size: 's', className: styles_module_scss_1.default.description, "data-test-id": constants_1.TEST_IDS.cardNavigationDescription, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: description, maxLines: 2, variant: 'end' }) }))] })] }), shouldRenderActions && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: cardTooltip
87
+ return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardNavigation, "data-detailed": isDetailed || undefined, "data-disabled": disabled || undefined, "data-actions-visibility": actionsVisibility, "data-visible-actions": visibleActionsCount, "data-acrylic-appearance": ACRYLIC_APPEARANCE, "data-acrylic-level": ACRYLIC_LEVEL, onKeyDown: handleKeyDown, onPointerEnter: handlePointerEnter, onFocus: handleFocus, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [isDetailed && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.acrylic, "aria-hidden": true, "data-acrylic-background": true }), (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.textContent, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.titleRow, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardNavigationTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: isDetailed ? 1 : truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardNavigationPromoTag, className: compactThemeClassName }))] }), isDetailed && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'p', variant: 'body', size: 's', className: styles_module_scss_1.default.description, "data-test-id": constants_1.TEST_IDS.cardNavigationDescription, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: description, maxLines: 2, variant: 'end' }) }))] })] }), shouldRenderActions && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: cardTooltip
114
88
  ? {
115
89
  ...cardTooltip,
116
90
  'data-test-id': constants_1.TEST_IDS.cardNavigationTooltip,
@@ -15,7 +15,6 @@ const react_1 = require("react");
15
15
  const constants_1 = require("../../constants");
16
16
  const helperComponents_1 = require("../../helperComponents");
17
17
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
18
- const TARGET_BLANK = '_blank';
19
18
  function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
20
19
  const Component = as ?? 'button';
21
20
  const cardRef = (0, react_1.useRef)(null);
@@ -51,22 +50,7 @@ function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actio
51
50
  ],
52
51
  });
53
52
  let polymorphicProps;
54
- if (Component === 'a') {
55
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown;
56
- polymorphicProps = {
57
- ...anchorRest,
58
- href: href ?? '#',
59
- target,
60
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
61
- onClick: disabled
62
- ? (e) => {
63
- e.preventDefault();
64
- onClick?.(e);
65
- }
66
- : onClick,
67
- };
68
- }
69
- else if (Component === 'button') {
53
+ if (Component === 'button') {
70
54
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
71
55
  polymorphicProps = {
72
56
  type,
@@ -76,19 +60,9 @@ function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actio
76
60
  };
77
61
  }
78
62
  else {
79
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
80
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
81
- const { onClick, ...componentRest } = restWithoutKeyDown;
82
- polymorphicProps = {
83
- ...componentRest,
84
- onClick: disabled
85
- ? (e) => {
86
- e.preventDefault();
87
- }
88
- : onClick,
89
- };
63
+ polymorphicProps = (0, utils_1.getLinkElementProps)(Component, restWithoutKeyDown, disabled);
90
64
  }
91
- return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceLightTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceLightPromoTag, className: compactThemeClassName }))] })] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
65
+ return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceLightTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceLightPromoTag, className: compactThemeClassName }))] })] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
92
66
  ? {
93
67
  ...tooltip,
94
68
  'data-test-id': constants_1.TEST_IDS.cardServiceLightTooltip,
@@ -3,14 +3,13 @@ import { BACKGROUND_PREDEFINED_FILL, backgroundPredefinedFillToAcrylic } from '@
3
3
  import { useThemeClassnames } from '@cloud-ru/ds-theme';
4
4
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
5
5
  import { Typography } from '@cloud-ru/ds-typography';
6
- import { useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
6
+ import { getLinkElementProps, useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
7
7
  import cn from 'classnames';
8
8
  import mergeRefs from 'merge-refs';
9
9
  import { useMemo, useRef, useState, } from 'react';
10
10
  import { TEST_IDS, VISIBILITY_STRATEGY } from '../../constants.js';
11
11
  import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler } from '../../helperComponents/index.js';
12
12
  import styles from './styles.module.css';
13
- const TARGET_BLANK = '_blank';
14
13
  const { appearance: ACRYLIC_APPEARANCE, level: ACRYLIC_LEVEL } = backgroundPredefinedFillToAcrylic(BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
15
14
  /**
16
15
  * Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
@@ -67,22 +66,7 @@ export function CardNavigation({ as, innerRef, icon, title, description, promoTa
67
66
  ],
68
67
  }), [disabled, onKeyDownProp, promoTag, cardTooltip, favorite?.enabled, expandable, isFavorite, setIsFavorite]);
69
68
  let polymorphicProps;
70
- if (Component === 'a') {
71
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown;
72
- polymorphicProps = {
73
- ...anchorRest,
74
- href: href ?? '#',
75
- target,
76
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
77
- onClick: disabled
78
- ? (e) => {
79
- e.preventDefault();
80
- onClick?.(e);
81
- }
82
- : onClick,
83
- };
84
- }
85
- else if (Component === 'button') {
69
+ if (Component === 'button') {
86
70
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
87
71
  polymorphicProps = {
88
72
  type,
@@ -92,19 +76,9 @@ export function CardNavigation({ as, innerRef, icon, title, description, promoTa
92
76
  };
93
77
  }
94
78
  else {
95
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
96
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
97
- const { onClick, ...componentRest } = restWithoutKeyDown;
98
- polymorphicProps = {
99
- ...componentRest,
100
- onClick: disabled
101
- ? (e) => {
102
- e.preventDefault();
103
- }
104
- : onClick,
105
- };
79
+ polymorphicProps = getLinkElementProps(Component, restWithoutKeyDown, disabled);
106
80
  }
107
- return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardNavigation, "data-detailed": isDetailed || undefined, "data-disabled": disabled || undefined, "data-actions-visibility": actionsVisibility, "data-visible-actions": visibleActionsCount, "data-acrylic-appearance": ACRYLIC_APPEARANCE, "data-acrylic-level": ACRYLIC_LEVEL, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, onPointerEnter: handlePointerEnter, onFocus: handleFocus, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [isDetailed && _jsx("span", { className: styles.acrylic, "aria-hidden": true, "data-acrylic-background": true }), _jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), _jsxs("div", { className: styles.container, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.textContent, children: [_jsxs("div", { className: styles.titleRow, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardNavigationTitle, children: _jsx(TruncateString, { text: title, maxLines: isDetailed ? 1 : truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardNavigationPromoTag, className: compactThemeClassName }))] }), isDetailed && (_jsx(Typography, { as: 'p', variant: 'body', size: 's', className: styles.description, "data-test-id": TEST_IDS.cardNavigationDescription, children: _jsx(TruncateString, { text: description, maxLines: 2, variant: 'end' }) }))] })] }), shouldRenderActions && (_jsx(CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: cardTooltip
81
+ return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardNavigation, "data-detailed": isDetailed || undefined, "data-disabled": disabled || undefined, "data-actions-visibility": actionsVisibility, "data-visible-actions": visibleActionsCount, "data-acrylic-appearance": ACRYLIC_APPEARANCE, "data-acrylic-level": ACRYLIC_LEVEL, onKeyDown: handleKeyDown, onPointerEnter: handlePointerEnter, onFocus: handleFocus, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [isDetailed && _jsx("span", { className: styles.acrylic, "aria-hidden": true, "data-acrylic-background": true }), _jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), _jsxs("div", { className: styles.container, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.textContent, children: [_jsxs("div", { className: styles.titleRow, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardNavigationTitle, children: _jsx(TruncateString, { text: title, maxLines: isDetailed ? 1 : truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardNavigationPromoTag, className: compactThemeClassName }))] }), isDetailed && (_jsx(Typography, { as: 'p', variant: 'body', size: 's', className: styles.description, "data-test-id": TEST_IDS.cardNavigationDescription, children: _jsx(TruncateString, { text: description, maxLines: 2, variant: 'end' }) }))] })] }), shouldRenderActions && (_jsx(CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: cardTooltip
108
82
  ? {
109
83
  ...cardTooltip,
110
84
  'data-test-id': TEST_IDS.cardNavigationTooltip,
@@ -2,14 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useThemeClassnames } from '@cloud-ru/ds-theme';
3
3
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
4
4
  import { Typography } from '@cloud-ru/ds-typography';
5
- import { useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
5
+ import { getLinkElementProps, useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
6
6
  import cn from 'classnames';
7
7
  import mergeRefs from 'merge-refs';
8
- import { useRef, useState, } from 'react';
8
+ import { useRef, useState } from 'react';
9
9
  import { TEST_IDS, VISIBILITY_STRATEGY } from '../../constants.js';
10
10
  import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler } from '../../helperComponents/index.js';
11
11
  import styles from './styles.module.css';
12
- const TARGET_BLANK = '_blank';
13
12
  export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
14
13
  const Component = as ?? 'button';
15
14
  const cardRef = useRef(null);
@@ -45,22 +44,7 @@ export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate
45
44
  ],
46
45
  });
47
46
  let polymorphicProps;
48
- if (Component === 'a') {
49
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown;
50
- polymorphicProps = {
51
- ...anchorRest,
52
- href: href ?? '#',
53
- target,
54
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
55
- onClick: disabled
56
- ? (e) => {
57
- e.preventDefault();
58
- onClick?.(e);
59
- }
60
- : onClick,
61
- };
62
- }
63
- else if (Component === 'button') {
47
+ if (Component === 'button') {
64
48
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
65
49
  polymorphicProps = {
66
50
  type,
@@ -70,19 +54,9 @@ export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate
70
54
  };
71
55
  }
72
56
  else {
73
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
74
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
75
- const { onClick, ...componentRest } = restWithoutKeyDown;
76
- polymorphicProps = {
77
- ...componentRest,
78
- onClick: disabled
79
- ? (e) => {
80
- e.preventDefault();
81
- }
82
- : onClick,
83
- };
57
+ polymorphicProps = getLinkElementProps(Component, restWithoutKeyDown, disabled);
84
58
  }
85
- return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [_jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), _jsxs("div", { className: styles.container, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceLightTitle, children: _jsx(TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceLightPromoTag, className: compactThemeClassName }))] })] }), _jsx(CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
59
+ return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [_jsx("span", { className: styles.stateLayer, "data-state": 'emptyNeutralOnBackground', "aria-hidden": true }), _jsxs("div", { className: styles.container, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceLightTitle, children: _jsx(TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceLightPromoTag, className: compactThemeClassName }))] })] }), _jsx(CardActionsSurface, { actionsVisibility: actionsVisibility, className: styles.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
86
60
  ? {
87
61
  ...tooltip,
88
62
  'data-test-id': TEST_IDS.cardServiceLightTooltip,