@cloud-ru/ds-uikit-product-card-predefined 3.1.7-preview-65417497.0 → 4.0.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/CHANGELOG.md +15 -0
- package/README.md +0 -3
- package/dist/cjs/components/CardNavigation/CardNavigation.d.ts +59 -0
- package/dist/cjs/components/CardNavigation/CardNavigation.js +135 -0
- package/dist/cjs/components/CardNavigation/index.d.ts +1 -0
- package/dist/cjs/components/CardNavigation/index.js +17 -0
- package/dist/cjs/components/CardNavigation/styles.module.css +460 -0
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.d.ts +2 -3
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.js +2 -2
- package/dist/cjs/components/CardServiceInfo/styles.module.css +4 -16
- package/dist/cjs/components/CardServiceLight/CardServiceLight.js +1 -1
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants.d.ts +7 -0
- package/dist/cjs/constants.js +7 -0
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +2 -4
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.js +18 -5
- package/dist/cjs/style.css +464 -16
- package/dist/esm/components/CardNavigation/CardNavigation.d.ts +59 -0
- package/dist/esm/components/CardNavigation/CardNavigation.js +129 -0
- package/dist/esm/components/CardNavigation/index.d.ts +1 -0
- package/dist/esm/components/CardNavigation/index.js +1 -0
- package/dist/esm/components/CardNavigation/styles.module.css +460 -0
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.d.ts +2 -3
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.js +2 -2
- package/dist/esm/components/CardServiceInfo/styles.module.css +4 -16
- package/dist/esm/components/CardServiceLight/CardServiceLight.js +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/constants.d.ts +7 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +2 -4
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.js +19 -6
- package/dist/esm/style.css +464 -16
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/components/CardNavigation/CardNavigation.tsx +321 -0
- package/src/components/CardNavigation/index.ts +1 -0
- package/src/components/CardNavigation/styles.module.scss +247 -0
- package/src/components/CardServiceInfo/CardServiceInfo.tsx +1 -5
- package/src/components/CardServiceInfo/styles.module.scss +6 -12
- package/src/components/CardServiceLight/CardServiceLight.tsx +0 -1
- package/src/components/index.ts +1 -0
- package/src/constants.ts +7 -0
- package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +28 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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
|
+
# 4.0.0 (2026-09-29)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **FF-9088:** align header and service cards with compact density ([e1248e8](https://github.com/cloud-ru-tech/snack-v2/commit/e1248e8ca5d1462df2a5a46b080cc19bb51cf59d))
|
|
11
|
+
- **FF-9088:** close card action tooltip when pointer leaves actions ([c62d55c](https://github.com/cloud-ru-tech/snack-v2/commit/c62d55cc43a3d703df4faec350083174fddee389))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **FF-9192:** add CardNavigation ([8315509](https://github.com/cloud-ru-tech/snack-v2/commit/8315509d5aae9666466ab7bde03b30b2cc7ac8dc))
|
|
16
|
+
|
|
17
|
+
### BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
- **FF-9088:** remove actionsSize from card actions ([bfad613](https://github.com/cloud-ru-tech/snack-v2/commit/bfad613905acd6e7ac0b78db4b62eb4e45d96c29))
|
|
20
|
+
|
|
6
21
|
## 3.1.6 (2026-09-28)
|
|
7
22
|
|
|
8
23
|
**Note:** Version bump only for package @ds/uikit-product-card-predefined
|
package/README.md
CHANGED
|
@@ -583,7 +583,6 @@ export function PolymorphicLink() {
|
|
|
583
583
|
|
|
584
584
|
| Prop | Type | Default | Description |
|
|
585
585
|
|------|------|---------|-------------|
|
|
586
|
-
| `actionsSize` | `"m"` \| `"s"` | `m` | Размер кнопок действий, для мобильного вида предполагается использовать `s` |
|
|
587
586
|
| `actionsVisibility` | `"always"` \| `"hover"` | `'hover'` | Формат отображения дополнительных действий: всегда или при наведении и фокусе |
|
|
588
587
|
| `as` | `ElementType` | — | Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. |
|
|
589
588
|
| `className` | `string` | — | CSS-класс корневого элемента |
|
|
@@ -601,8 +600,6 @@ export function PolymorphicLink() {
|
|
|
601
600
|
|
|
602
601
|
- `CardPromoTagProps` = `PromoTagPredefinedProps & { as?: never; innerRef?: never; }`
|
|
603
602
|
|
|
604
|
-
- `CardSize` = `"m"` \| `"s"`
|
|
605
|
-
|
|
606
603
|
**FavoriteProps**
|
|
607
604
|
|
|
608
605
|
| Prop | Type | Default | Description |
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
|
+
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
|
|
4
|
+
import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
|
|
5
|
+
type BaseCardNavigationProps = {
|
|
6
|
+
/** Иконка сервиса */
|
|
7
|
+
icon?: ReactElement;
|
|
8
|
+
/** Заголовок карточки */
|
|
9
|
+
title: string;
|
|
10
|
+
/**
|
|
11
|
+
* Описание сервиса. Передано (в том числе пустой строкой) — карточка в подробном виде: с рамкой
|
|
12
|
+
* и описанием под заголовком. Не передано — компактный вид в одну строку.
|
|
13
|
+
*
|
|
14
|
+
* Вид меняется без пересоздания DOM: переключение описания — обновление пропа, а не перемонтирование.
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/** Настройки promo tag. При отсутствии не отображается */
|
|
18
|
+
promoTag?: CardPromoTagProps;
|
|
19
|
+
/** Настройки обрезки текста заголовка. В подробном виде заголовок всегда в одну строку */
|
|
20
|
+
truncate?: {
|
|
21
|
+
/** Максимальное количество строк заголовка */
|
|
22
|
+
title?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Формат отображения дополнительных действий: всегда или при наведении и фокусе
|
|
26
|
+
* @default 'hover'
|
|
27
|
+
*/
|
|
28
|
+
actionsVisibility?: VisibilityStrategy;
|
|
29
|
+
/** Подсказка с иконкой «?» рядом с заголовком. Показывается только в компактном виде */
|
|
30
|
+
tooltip?: Omit<TooltipProps, 'trigger' | 'size'>;
|
|
31
|
+
/**
|
|
32
|
+
* Настройки кнопки «Избранное».
|
|
33
|
+
* Keyboard: ArrowRight на карточке → promo tag → tooltip (если есть) → Favorite → expand; ArrowLeft — в обратном порядке.
|
|
34
|
+
*/
|
|
35
|
+
favorite?: FavoriteProps;
|
|
36
|
+
/** Неактивное состояние */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/** CSS-класс корневого элемента */
|
|
39
|
+
className?: string;
|
|
40
|
+
/** Support prop для тестов */
|
|
41
|
+
'data-test-id'?: string;
|
|
42
|
+
/** Настройки кнопки раскрытия */
|
|
43
|
+
expandable?: {
|
|
44
|
+
value: boolean;
|
|
45
|
+
onClick(): void;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type CardNavigationProps<T extends ElementType = 'button'> = BaseCardNavigationProps & {
|
|
49
|
+
/** Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. */
|
|
50
|
+
as?: T;
|
|
51
|
+
/** Ref на реальный DOM-элемент / инстанс */
|
|
52
|
+
innerRef?: PolymorphicRef<T>;
|
|
53
|
+
} & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardNavigationProps | 'as' | 'ref'>;
|
|
54
|
+
/**
|
|
55
|
+
* Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
|
|
56
|
+
* (вид с описанием) в один компонент с одним деревом DOM.
|
|
57
|
+
*/
|
|
58
|
+
export declare function CardNavigation<T extends ElementType = 'button'>({ as, innerRef, icon, title, description, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardNavigationProps<T>): ReactElement | null;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CardNavigation = CardNavigation;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const materials_1 = require("@cloud-ru/ds-materials");
|
|
9
|
+
const theme_1 = require("@cloud-ru/ds-theme");
|
|
10
|
+
const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
|
|
11
|
+
const typography_1 = require("@cloud-ru/ds-typography");
|
|
12
|
+
const utils_1 = require("@cloud-ru/ds-utils");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const merge_refs_1 = __importDefault(require("merge-refs"));
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
17
|
+
const helperComponents_1 = require("../../helperComponents");
|
|
18
|
+
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
19
|
+
const TARGET_BLANK = '_blank';
|
|
20
|
+
const { appearance: ACRYLIC_APPEARANCE, level: ACRYLIC_LEVEL } = (0, materials_1.backgroundPredefinedFillToAcrylic)(materials_1.BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
|
|
21
|
+
/**
|
|
22
|
+
* Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
|
|
23
|
+
* (вид с описанием) в один компонент с одним деревом DOM.
|
|
24
|
+
*/
|
|
25
|
+
function CardNavigation({ as, innerRef, icon, title, description, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
|
|
26
|
+
const Component = as ?? 'button';
|
|
27
|
+
const cardRef = (0, react_1.useRef)(null);
|
|
28
|
+
const tooltipTriggerRef = (0, react_1.useRef)(null);
|
|
29
|
+
const promoTagTooltipTriggerRef = (0, react_1.useRef)(null);
|
|
30
|
+
const favoriteRef = (0, react_1.useRef)(null);
|
|
31
|
+
const expandButtonRef = (0, react_1.useRef)(null);
|
|
32
|
+
const compactThemeClassName = (0, theme_1.useThemeClassnames)({ density: 'compact' });
|
|
33
|
+
const isDetailed = description !== undefined;
|
|
34
|
+
const actionsVisibility = actionsVisibilityProp ?? constants_1.VISIBILITY_STRATEGY.hover;
|
|
35
|
+
// Подсказка «?» есть только у компактного вида: в подробном её роль играет описание.
|
|
36
|
+
const cardTooltip = isDetailed ? undefined : tooltip;
|
|
37
|
+
const visibleActionsCount = Number(Boolean(favorite?.enabled)) + Number(Boolean(expandable));
|
|
38
|
+
const [isFavorite, setIsFavorite] = (0, utils_1.useValueControl)({
|
|
39
|
+
value: favorite?.checked,
|
|
40
|
+
defaultValue: false,
|
|
41
|
+
onChange: favorite?.onChange,
|
|
42
|
+
});
|
|
43
|
+
const [isTooltipOpen, setIsTooltipOpen] = (0, react_1.useState)(false);
|
|
44
|
+
// Панель действий (`Tooltip` на floating-ui + кнопки) в режиме `hover` скрыта до наведения, `always` показывает панель сразу.
|
|
45
|
+
// При рендере большого количества карточек на одном экране может вызывать лаги, поэтому монтируем её при первом наведении или фокусе.
|
|
46
|
+
const [isActionsRequested, setIsActionsRequested] = (0, react_1.useState)(false);
|
|
47
|
+
const shouldRenderActions = isActionsRequested || actionsVisibility === constants_1.VISIBILITY_STRATEGY.always;
|
|
48
|
+
const tooltipTrigger = actionsVisibility === constants_1.VISIBILITY_STRATEGY.hover ? 'hoverAndFocusVisible' : 'click';
|
|
49
|
+
const { onKeyDown: onKeyDownProp, onPointerEnter: onPointerEnterProp, onFocus: onFocusProp, ...restWithoutKeyDown } = rest;
|
|
50
|
+
const handlePointerEnter = (event) => {
|
|
51
|
+
setIsActionsRequested(true);
|
|
52
|
+
onPointerEnterProp?.(event);
|
|
53
|
+
};
|
|
54
|
+
const handleFocus = (event) => {
|
|
55
|
+
setIsActionsRequested(true);
|
|
56
|
+
onFocusProp?.(event);
|
|
57
|
+
};
|
|
58
|
+
const handleKeyDown = (0, react_1.useMemo)(() => (0, helperComponents_1.createCardActionsKeyDownHandler)({
|
|
59
|
+
disabled,
|
|
60
|
+
cardRef,
|
|
61
|
+
onKeyDown: onKeyDownProp,
|
|
62
|
+
items: [
|
|
63
|
+
promoTag && { ref: promoTagTooltipTriggerRef },
|
|
64
|
+
cardTooltip && { ref: tooltipTriggerRef },
|
|
65
|
+
favorite?.enabled && {
|
|
66
|
+
ref: favoriteRef,
|
|
67
|
+
onActivate: () => setIsFavorite(!isFavorite),
|
|
68
|
+
},
|
|
69
|
+
expandable && {
|
|
70
|
+
ref: expandButtonRef,
|
|
71
|
+
onActivate: () => expandable.onClick(),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
}), [disabled, onKeyDownProp, promoTag, cardTooltip, favorite?.enabled, expandable, isFavorite, setIsFavorite]);
|
|
75
|
+
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') {
|
|
92
|
+
const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
|
|
93
|
+
polymorphicProps = {
|
|
94
|
+
type,
|
|
95
|
+
disabled,
|
|
96
|
+
onClick: disabled ? undefined : onClick,
|
|
97
|
+
...buttonRest,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
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
|
+
};
|
|
112
|
+
}
|
|
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
|
|
114
|
+
? {
|
|
115
|
+
...cardTooltip,
|
|
116
|
+
'data-test-id': constants_1.TEST_IDS.cardNavigationTooltip,
|
|
117
|
+
buttonRef: tooltipTriggerRef,
|
|
118
|
+
}
|
|
119
|
+
: undefined, favorite: favorite?.enabled
|
|
120
|
+
? {
|
|
121
|
+
enabled: favorite.enabled,
|
|
122
|
+
checked: isFavorite,
|
|
123
|
+
onChange: setIsFavorite,
|
|
124
|
+
buttonRef: favoriteRef,
|
|
125
|
+
'data-test-id': constants_1.TEST_IDS.cardNavigationFavorite,
|
|
126
|
+
}
|
|
127
|
+
: undefined, expandable: expandable
|
|
128
|
+
? {
|
|
129
|
+
value: expandable.value,
|
|
130
|
+
onClick: expandable.onClick,
|
|
131
|
+
buttonRef: expandButtonRef,
|
|
132
|
+
}
|
|
133
|
+
: undefined })), isDetailed && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.outlineBorder, "aria-hidden": true })] }));
|
|
134
|
+
}
|
|
135
|
+
(0, utils_1.withInnerRefSupport)(CardNavigation);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CardNavigation';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CardNavigation"), exports);
|