@cloud-ru/ds-uikit-product-card-predefined 3.1.0 → 3.1.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 +7 -0
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.js +1 -1
- package/dist/cjs/components/CardServiceLight/CardServiceLight.js +1 -3
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +3 -1
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.js +8 -2
- package/dist/cjs/helperComponents/CardPromoTag/CardPromoTag.js +6 -2
- package/dist/cjs/helperComponents/CardPromoTag/styles.module.css +3 -0
- package/dist/cjs/style.css +3 -0
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.js +1 -1
- package/dist/esm/components/CardServiceLight/CardServiceLight.js +1 -3
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +3 -1
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.js +8 -2
- package/dist/esm/helperComponents/CardPromoTag/CardPromoTag.js +3 -2
- package/dist/esm/helperComponents/CardPromoTag/styles.module.css +3 -0
- package/dist/esm/style.css +3 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/CardServiceInfo/CardServiceInfo.tsx +1 -1
- package/src/components/CardServiceLight/CardServiceLight.tsx +2 -3
- package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +22 -1
- package/src/helperComponents/CardPromoTag/CardPromoTag.tsx +3 -2
- package/src/helperComponents/CardPromoTag/styles.module.scss +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
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
|
+
## 3.1.1 (2026-09-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **FF-9146:** disable hover on CardPromoTag, removed unused classname ([efbf49e](https://github.com/cloud-ru-tech/snack-v2/commit/efbf49ec55507ef4779bbce3fc813e0c1c19faeb))
|
|
11
|
+
- **FF-9146:** handle CardActionsSurface tooltips overlapping ([f3f684d](https://github.com/cloud-ru-tech/snack-v2/commit/f3f684de6498dacfb815ea962b6f22462fad5499))
|
|
12
|
+
|
|
6
13
|
# 3.1.0 (2026-09-16)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
|
@@ -47,7 +47,7 @@ function CardServiceInfo({ as, innerRef, icon, title, description, promoTag, act
|
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
});
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(card_1.Card, { as: (as ?? 'button'), innerRef: (0, merge_refs_1.default)(innerRef, cardRef), disabled: disabled, interactive: true, radius: 's', view: 'outline', backgroundPredefined: 'neutralBackground1Level', className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceInfo, onKeyDown: handleKeyDown, ...restWithoutKeyDown, children: (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.jsxs)("div", { className: styles_module_scss_1.default.titleContainer, "data-actions-visibility": actionsVisibility, "data-actions-size": actionsSize, "data-visible-actions": visibleActions.length, 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.cardServiceInfoTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: 1, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceInfoPromoTag, className:
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(card_1.Card, { as: (as ?? 'button'), innerRef: (0, merge_refs_1.default)(innerRef, cardRef), disabled: disabled, interactive: true, radius: 's', view: 'outline', backgroundPredefined: 'neutralBackground1Level', className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceInfo, onKeyDown: handleKeyDown, ...restWithoutKeyDown, children: (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.jsxs)("div", { className: styles_module_scss_1.default.titleContainer, "data-actions-visibility": actionsVisibility, "data-actions-size": actionsSize, "data-visible-actions": visibleActions.length, 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.cardServiceInfoTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: 1, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceInfoPromoTag, className: compactThemeClassName }))] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.actions, favorite: favorite?.enabled
|
|
51
51
|
? {
|
|
52
52
|
enabled: favorite.enabled,
|
|
53
53
|
checked: isFavorite,
|
|
@@ -91,13 +91,11 @@ function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actio
|
|
|
91
91
|
: onClick,
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
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, "data-mobile": isMobile || undefined, 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:
|
|
94
|
+
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, "data-mobile": isMobile || undefined, 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, { actionsSize: isMobile ? 's' : 'm', actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
|
|
95
95
|
? {
|
|
96
96
|
...tooltip,
|
|
97
97
|
'data-test-id': constants_1.TEST_IDS.cardServiceLightTooltip,
|
|
98
98
|
buttonRef: tooltipTriggerRef,
|
|
99
|
-
open: isTooltipOpen,
|
|
100
|
-
onOpenChange: setIsTooltipOpen,
|
|
101
99
|
}
|
|
102
100
|
: undefined, favorite: favorite?.enabled
|
|
103
101
|
? {
|
|
@@ -27,5 +27,7 @@ export type CardActionsSurfaceProps = {
|
|
|
27
27
|
actionsSize?: CardSize;
|
|
28
28
|
/** CSS-класс корневого элемента */
|
|
29
29
|
className?: string;
|
|
30
|
+
/** Callback, вызываемый при открытии тултипа */
|
|
31
|
+
onTooltipOpenChange?(isOpen: boolean): void;
|
|
30
32
|
};
|
|
31
|
-
export declare function CardActionsSurface({ actionsVisibility, tooltip, favorite, expandable, actionsSize, className, }: CardActionsSurfaceProps): ReactElement | null;
|
|
33
|
+
export declare function CardActionsSurface({ actionsVisibility, tooltip, favorite, expandable, actionsSize, className, onTooltipOpenChange, }: CardActionsSurfaceProps): ReactElement | null;
|
|
@@ -11,11 +11,17 @@ const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
|
11
11
|
const tooltip_1 = require("@cloud-ru/ds-tooltip");
|
|
12
12
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
13
13
|
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const react_1 = require("react");
|
|
14
15
|
const constants_1 = require("../../constants");
|
|
15
16
|
const locale_1 = require("../../locale");
|
|
16
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
17
|
-
function CardActionsSurface({ actionsVisibility = constants_1.VISIBILITY_STRATEGY.hover, tooltip, favorite, expandable, actionsSize = 'm', className, }) {
|
|
18
|
+
function CardActionsSurface({ actionsVisibility = constants_1.VISIBILITY_STRATEGY.hover, tooltip, favorite, expandable, actionsSize = 'm', className, onTooltipOpenChange, }) {
|
|
18
19
|
const { t } = locale_1.cardPredefinedLocale.useTranslations();
|
|
20
|
+
const [visibleTooltip, setVisibleTooltip] = (0, react_1.useState)(undefined);
|
|
21
|
+
const getHandleTooltipOpenChange = (0, react_1.useCallback)((tooltipType) => (isOpen) => {
|
|
22
|
+
setVisibleTooltip(isOpen ? tooltipType : undefined);
|
|
23
|
+
onTooltipOpenChange?.(isOpen);
|
|
24
|
+
}, [onTooltipOpenChange]);
|
|
19
25
|
if (!tooltip && !favorite && !expandable) {
|
|
20
26
|
return null;
|
|
21
27
|
}
|
|
@@ -32,5 +38,5 @@ function CardActionsSurface({ actionsVisibility = constants_1.VISIBILITY_STRATEG
|
|
|
32
38
|
const { buttonRef: tooltipButtonRef, 'data-test-id': tooltipTestId, ...tooltipProps } = tooltip ?? {};
|
|
33
39
|
return (
|
|
34
40
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
35
|
-
(0, jsx_runtime_1.jsxs)("div", { onClick: utils_1.preventEventDefaultAndPropagation, className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-actions-visibility": actionsVisibility, children: [tooltip && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { ...tooltipProps, tip: tooltip.tip, trigger: tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, triggerClassName: styles_module_scss_1.default.tooltipTrigger, children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-label": t('actions.info'), size: actionsSize, appearance: 'neutral', view: 'simple', icon: (0, jsx_runtime_1.jsx)(product_1.InfoOutlineSVG, {}), tabIndex: -1, onClick: utils_1.preventEventDefault, innerRef: tooltipButtonRef, "data-test-id": tooltipTestId }) })), favorite?.enabled && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: favorite.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd'), trigger: tooltipTrigger, triggerClassName: styles_module_scss_1.default.tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-pressed": Boolean(favorite.checked), size: actionsSize, appearance: 'neutral', view: 'simple', icon: favorite.checked ? (0, jsx_runtime_1.jsx)(system_1.StarFilledSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.StarSVG, {}), onClick: handleFavoriteClick, className: styles_module_scss_1.default.favorite, innerRef: favorite.buttonRef, tabIndex: -1, "data-test-id": favorite['data-test-id'], "data-checked": favorite.checked || undefined }) })), expandable && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: expandable.value ? t('actions.collapse') : t('actions.expand'), trigger: tooltipTrigger, triggerClassName: styles_module_scss_1.default.tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-expanded": expandable.value, size: actionsSize, appearance: 'neutral', view: 'simple', icon: expandable.value ? (0, jsx_runtime_1.jsx)(system_1.CollapseVerticalSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.ExpandVerticalSVG, {}), onClick: handleExpandButtonClick, className: styles_module_scss_1.default.expandButton, innerRef: expandable.buttonRef, tabIndex: -1 }) }))] }));
|
|
41
|
+
(0, jsx_runtime_1.jsxs)("div", { onClick: utils_1.preventEventDefaultAndPropagation, className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-actions-visibility": actionsVisibility, children: [tooltip && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { ...tooltipProps, open: visibleTooltip === 'info', onOpenChange: getHandleTooltipOpenChange('info'), tip: tooltip.tip, trigger: tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, triggerClassName: styles_module_scss_1.default.tooltipTrigger, children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-label": t('actions.info'), size: actionsSize, appearance: 'neutral', view: 'simple', icon: (0, jsx_runtime_1.jsx)(product_1.InfoOutlineSVG, {}), tabIndex: -1, onClick: utils_1.preventEventDefault, innerRef: tooltipButtonRef, "data-test-id": tooltipTestId }) })), favorite?.enabled && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: favorite.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd'), trigger: tooltipTrigger, triggerClassName: styles_module_scss_1.default.tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, open: visibleTooltip === 'favorite', onOpenChange: getHandleTooltipOpenChange('favorite'), children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-pressed": Boolean(favorite.checked), size: actionsSize, appearance: 'neutral', view: 'simple', icon: favorite.checked ? (0, jsx_runtime_1.jsx)(system_1.StarFilledSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.StarSVG, {}), onClick: handleFavoriteClick, className: styles_module_scss_1.default.favorite, innerRef: favorite.buttonRef, tabIndex: -1, "data-test-id": favorite['data-test-id'], "data-checked": favorite.checked || undefined }) })), expandable && ((0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { tip: expandable.value ? t('actions.collapse') : t('actions.expand'), trigger: tooltipTrigger, triggerClassName: styles_module_scss_1.default.tooltipTrigger, hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS, open: visibleTooltip === 'expandable', onOpenChange: getHandleTooltipOpenChange('expandable'), children: (0, jsx_runtime_1.jsx)(button_1.Button, { as: 'span', role: 'button', "aria-expanded": expandable.value, size: actionsSize, appearance: 'neutral', view: 'simple', icon: expandable.value ? (0, jsx_runtime_1.jsx)(system_1.CollapseVerticalSVG, {}) : (0, jsx_runtime_1.jsx)(system_1.ExpandVerticalSVG, {}), onClick: handleExpandButtonClick, className: styles_module_scss_1.default.expandButton, innerRef: expandable.buttonRef, tabIndex: -1 }) }))] }));
|
|
36
42
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CardPromoTag = CardPromoTag;
|
|
4
7
|
const uikit_product_promo_tag_predefined_1 = require("@cloud-ru/ds-uikit-product-promo-tag-predefined");
|
|
5
8
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
9
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
6
10
|
const react_1 = require("react");
|
|
11
|
+
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
7
12
|
function CardPromoTag({ promoTag, tooltipTrigger, innerRef, className, 'data-test-id': dataTestId, }) {
|
|
8
13
|
// `PromoTagPredefinedProps` — union, дискриминированный по `variant`, и `tooltip` у каждого
|
|
9
14
|
// варианта свой. При спреде TS union сплющивает, связь `variant` ↔ `tooltip` теряется, поэтому
|
|
@@ -12,11 +17,10 @@ function CardPromoTag({ promoTag, tooltipTrigger, innerRef, className, 'data-tes
|
|
|
12
17
|
// JSX-спред union-типа TS сплющил бы заново.
|
|
13
18
|
const props = {
|
|
14
19
|
...promoTag,
|
|
15
|
-
as: 'span',
|
|
16
20
|
tabIndex: -1,
|
|
17
21
|
tooltip: { ...promoTag.tooltip, trigger: tooltipTrigger },
|
|
18
22
|
innerRef,
|
|
19
|
-
className,
|
|
23
|
+
className: (0, classnames_1.default)(styles_module_scss_1.default.promoTag, className),
|
|
20
24
|
'data-test-id': dataTestId,
|
|
21
25
|
};
|
|
22
26
|
return (0, react_1.createElement)(uikit_product_promo_tag_predefined_1.PromoTagPredefined, props);
|
package/dist/cjs/style.css
CHANGED
|
@@ -41,7 +41,7 @@ export function CardServiceInfo({ as, innerRef, icon, title, description, promoT
|
|
|
41
41
|
},
|
|
42
42
|
],
|
|
43
43
|
});
|
|
44
|
-
return (_jsx(Card, { as: (as ?? 'button'), innerRef: mergeRefs(innerRef, cardRef), disabled: disabled, interactive: true, radius: 's', view: 'outline', backgroundPredefined: 'neutralBackground1Level', className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceInfo, onKeyDown: handleKeyDown, ...restWithoutKeyDown, children: _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: [_jsxs("div", { className: styles.titleContainer, "data-actions-visibility": actionsVisibility, "data-actions-size": actionsSize, "data-visible-actions": visibleActions.length, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceInfoTitle, children: _jsx(TruncateString, { text: title, maxLines: 1, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceInfoPromoTag, className:
|
|
44
|
+
return (_jsx(Card, { as: (as ?? 'button'), innerRef: mergeRefs(innerRef, cardRef), disabled: disabled, interactive: true, radius: 's', view: 'outline', backgroundPredefined: 'neutralBackground1Level', className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceInfo, onKeyDown: handleKeyDown, ...restWithoutKeyDown, children: _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: [_jsxs("div", { className: styles.titleContainer, "data-actions-visibility": actionsVisibility, "data-actions-size": actionsSize, "data-visible-actions": visibleActions.length, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceInfoTitle, children: _jsx(TruncateString, { text: title, maxLines: 1, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceInfoPromoTag, className: compactThemeClassName }))] }), _jsx(CardActionsSurface, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles.actions, favorite: favorite?.enabled
|
|
45
45
|
? {
|
|
46
46
|
enabled: favorite.enabled,
|
|
47
47
|
checked: isFavorite,
|
|
@@ -85,13 +85,11 @@ export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate
|
|
|
85
85
|
: onClick,
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
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, "data-mobile": isMobile || undefined, 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:
|
|
88
|
+
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, "data-mobile": isMobile || undefined, 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, { actionsSize: isMobile ? 's' : 'm', actionsVisibility: actionsVisibility, className: styles.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: tooltip
|
|
89
89
|
? {
|
|
90
90
|
...tooltip,
|
|
91
91
|
'data-test-id': TEST_IDS.cardServiceLightTooltip,
|
|
92
92
|
buttonRef: tooltipTriggerRef,
|
|
93
|
-
open: isTooltipOpen,
|
|
94
|
-
onOpenChange: setIsTooltipOpen,
|
|
95
93
|
}
|
|
96
94
|
: undefined, favorite: favorite?.enabled
|
|
97
95
|
? {
|
|
@@ -27,5 +27,7 @@ export type CardActionsSurfaceProps = {
|
|
|
27
27
|
actionsSize?: CardSize;
|
|
28
28
|
/** CSS-класс корневого элемента */
|
|
29
29
|
className?: string;
|
|
30
|
+
/** Callback, вызываемый при открытии тултипа */
|
|
31
|
+
onTooltipOpenChange?(isOpen: boolean): void;
|
|
30
32
|
};
|
|
31
|
-
export declare function CardActionsSurface({ actionsVisibility, tooltip, favorite, expandable, actionsSize, className, }: CardActionsSurfaceProps): ReactElement | null;
|
|
33
|
+
export declare function CardActionsSurface({ actionsVisibility, tooltip, favorite, expandable, actionsSize, className, onTooltipOpenChange, }: CardActionsSurfaceProps): ReactElement | null;
|
|
@@ -5,11 +5,17 @@ import { CollapseVerticalSVG, ExpandVerticalSVG, StarFilledSVG, StarSVG } from '
|
|
|
5
5
|
import { Tooltip, TRIGGER } from '@cloud-ru/ds-tooltip';
|
|
6
6
|
import { preventEventDefault, preventEventDefaultAndPropagation } from '@cloud-ru/ds-utils';
|
|
7
7
|
import cn from 'classnames';
|
|
8
|
+
import { useCallback, useState } from 'react';
|
|
8
9
|
import { TOOLTIP_HOVER_DELAY_OPEN_MS, VISIBILITY_STRATEGY } from '../../constants.js';
|
|
9
10
|
import { cardPredefinedLocale } from '../../locale/index.js';
|
|
10
11
|
import styles from './styles.module.css';
|
|
11
|
-
export function CardActionsSurface({ actionsVisibility = VISIBILITY_STRATEGY.hover, tooltip, favorite, expandable, actionsSize = 'm', className, }) {
|
|
12
|
+
export function CardActionsSurface({ actionsVisibility = VISIBILITY_STRATEGY.hover, tooltip, favorite, expandable, actionsSize = 'm', className, onTooltipOpenChange, }) {
|
|
12
13
|
const { t } = cardPredefinedLocale.useTranslations();
|
|
14
|
+
const [visibleTooltip, setVisibleTooltip] = useState(undefined);
|
|
15
|
+
const getHandleTooltipOpenChange = useCallback((tooltipType) => (isOpen) => {
|
|
16
|
+
setVisibleTooltip(isOpen ? tooltipType : undefined);
|
|
17
|
+
onTooltipOpenChange?.(isOpen);
|
|
18
|
+
}, [onTooltipOpenChange]);
|
|
13
19
|
if (!tooltip && !favorite && !expandable) {
|
|
14
20
|
return null;
|
|
15
21
|
}
|
|
@@ -26,5 +32,5 @@ export function CardActionsSurface({ actionsVisibility = VISIBILITY_STRATEGY.hov
|
|
|
26
32
|
const { buttonRef: tooltipButtonRef, 'data-test-id': tooltipTestId, ...tooltipProps } = tooltip ?? {};
|
|
27
33
|
return (
|
|
28
34
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
29
|
-
_jsxs("div", { onClick: preventEventDefaultAndPropagation, className: cn(styles.root, className), "data-actions-visibility": actionsVisibility, children: [tooltip && (_jsx(Tooltip, { ...tooltipProps, tip: tooltip.tip, trigger: tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, triggerClassName: styles.tooltipTrigger, children: _jsx(Button, { as: 'span', role: 'button', "aria-label": t('actions.info'), size: actionsSize, appearance: 'neutral', view: 'simple', icon: _jsx(InfoOutlineSVG, {}), tabIndex: -1, onClick: preventEventDefault, innerRef: tooltipButtonRef, "data-test-id": tooltipTestId }) })), favorite?.enabled && (_jsx(Tooltip, { tip: favorite.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd'), trigger: tooltipTrigger, triggerClassName: styles.tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, children: _jsx(Button, { as: 'span', role: 'button', "aria-pressed": Boolean(favorite.checked), size: actionsSize, appearance: 'neutral', view: 'simple', icon: favorite.checked ? _jsx(StarFilledSVG, {}) : _jsx(StarSVG, {}), onClick: handleFavoriteClick, className: styles.favorite, innerRef: favorite.buttonRef, tabIndex: -1, "data-test-id": favorite['data-test-id'], "data-checked": favorite.checked || undefined }) })), expandable && (_jsx(Tooltip, { tip: expandable.value ? t('actions.collapse') : t('actions.expand'), trigger: tooltipTrigger, triggerClassName: styles.tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, children: _jsx(Button, { as: 'span', role: 'button', "aria-expanded": expandable.value, size: actionsSize, appearance: 'neutral', view: 'simple', icon: expandable.value ? _jsx(CollapseVerticalSVG, {}) : _jsx(ExpandVerticalSVG, {}), onClick: handleExpandButtonClick, className: styles.expandButton, innerRef: expandable.buttonRef, tabIndex: -1 }) }))] }));
|
|
35
|
+
_jsxs("div", { onClick: preventEventDefaultAndPropagation, className: cn(styles.root, className), "data-actions-visibility": actionsVisibility, children: [tooltip && (_jsx(Tooltip, { ...tooltipProps, open: visibleTooltip === 'info', onOpenChange: getHandleTooltipOpenChange('info'), tip: tooltip.tip, trigger: tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, triggerClassName: styles.tooltipTrigger, children: _jsx(Button, { as: 'span', role: 'button', "aria-label": t('actions.info'), size: actionsSize, appearance: 'neutral', view: 'simple', icon: _jsx(InfoOutlineSVG, {}), tabIndex: -1, onClick: preventEventDefault, innerRef: tooltipButtonRef, "data-test-id": tooltipTestId }) })), favorite?.enabled && (_jsx(Tooltip, { tip: favorite.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd'), trigger: tooltipTrigger, triggerClassName: styles.tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, open: visibleTooltip === 'favorite', onOpenChange: getHandleTooltipOpenChange('favorite'), children: _jsx(Button, { as: 'span', role: 'button', "aria-pressed": Boolean(favorite.checked), size: actionsSize, appearance: 'neutral', view: 'simple', icon: favorite.checked ? _jsx(StarFilledSVG, {}) : _jsx(StarSVG, {}), onClick: handleFavoriteClick, className: styles.favorite, innerRef: favorite.buttonRef, tabIndex: -1, "data-test-id": favorite['data-test-id'], "data-checked": favorite.checked || undefined }) })), expandable && (_jsx(Tooltip, { tip: expandable.value ? t('actions.collapse') : t('actions.expand'), trigger: tooltipTrigger, triggerClassName: styles.tooltipTrigger, hoverDelayOpen: TOOLTIP_HOVER_DELAY_OPEN_MS, open: visibleTooltip === 'expandable', onOpenChange: getHandleTooltipOpenChange('expandable'), children: _jsx(Button, { as: 'span', role: 'button', "aria-expanded": expandable.value, size: actionsSize, appearance: 'neutral', view: 'simple', icon: expandable.value ? _jsx(CollapseVerticalSVG, {}) : _jsx(ExpandVerticalSVG, {}), onClick: handleExpandButtonClick, className: styles.expandButton, innerRef: expandable.buttonRef, tabIndex: -1 }) }))] }));
|
|
30
36
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PromoTagPredefined } from '@cloud-ru/ds-uikit-product-promo-tag-predefined';
|
|
2
2
|
import { withInnerRefSupport } from '@cloud-ru/ds-utils';
|
|
3
|
+
import cn from 'classnames';
|
|
3
4
|
import { createElement } from 'react';
|
|
5
|
+
import styles from './styles.module.css';
|
|
4
6
|
export function CardPromoTag({ promoTag, tooltipTrigger, innerRef, className, 'data-test-id': dataTestId, }) {
|
|
5
7
|
// `PromoTagPredefinedProps` — union, дискриминированный по `variant`, и `tooltip` у каждого
|
|
6
8
|
// варианта свой. При спреде TS union сплющивает, связь `variant` ↔ `tooltip` теряется, поэтому
|
|
@@ -9,11 +11,10 @@ export function CardPromoTag({ promoTag, tooltipTrigger, innerRef, className, 'd
|
|
|
9
11
|
// JSX-спред union-типа TS сплющил бы заново.
|
|
10
12
|
const props = {
|
|
11
13
|
...promoTag,
|
|
12
|
-
as: 'span',
|
|
13
14
|
tabIndex: -1,
|
|
14
15
|
tooltip: { ...promoTag.tooltip, trigger: tooltipTrigger },
|
|
15
16
|
innerRef,
|
|
16
|
-
className,
|
|
17
|
+
className: cn(styles.promoTag, className),
|
|
17
18
|
'data-test-id': dataTestId,
|
|
18
19
|
};
|
|
19
20
|
return createElement(PromoTagPredefined, props);
|