@cloud-ru/ds-uikit-product-card-predefined 1.0.4 → 2.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 +6 -0
- package/README.md +251 -34
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.js +66 -0
- package/dist/cjs/components/CardServiceInfo/index.d.ts +1 -0
- package/dist/cjs/components/CardServiceInfo/index.js +17 -0
- package/dist/cjs/components/CardServiceInfo/styles.module.css +102 -0
- package/dist/cjs/components/CardServiceLight/CardServiceLight.d.ts +22 -11
- package/dist/cjs/components/CardServiceLight/CardServiceLight.js +98 -31
- package/dist/cjs/components/CardServiceLight/styles.module.css +30 -25
- package/dist/cjs/components/CardServiceSmall/CardServiceSmall.d.ts +7 -6
- package/dist/cjs/components/CardServiceSmall/CardServiceSmall.js +7 -3
- package/dist/cjs/components/CardServiceSmall/styles.module.css +3 -3
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants.d.ts +9 -0
- package/dist/cjs/constants.js +10 -1
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +31 -0
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.js +36 -0
- package/dist/cjs/helperComponents/CardActionsSurface/index.d.ts +2 -0
- package/dist/cjs/helperComponents/CardActionsSurface/index.js +18 -0
- package/dist/cjs/helperComponents/CardActionsSurface/styles.module.css +36 -0
- package/dist/cjs/helperComponents/CardActionsSurface/utils.d.ts +22 -0
- package/dist/cjs/helperComponents/CardActionsSurface/utils.js +43 -0
- package/dist/cjs/helperComponents/CardPromoTag/CardPromoTag.d.ts +16 -0
- package/dist/cjs/helperComponents/CardPromoTag/CardPromoTag.js +24 -0
- package/dist/cjs/helperComponents/CardPromoTag/index.d.ts +1 -0
- package/dist/cjs/helperComponents/CardPromoTag/index.js +17 -0
- package/dist/cjs/helperComponents/index.d.ts +2 -0
- package/dist/cjs/helperComponents/index.js +2 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/locale/index.d.ts +43 -0
- package/dist/cjs/locale/index.js +26 -0
- package/dist/cjs/style.css +166 -23
- package/dist/cjs/types.d.ts +12 -5
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.js +60 -0
- package/dist/esm/components/CardServiceInfo/index.d.ts +1 -0
- package/dist/esm/components/CardServiceInfo/index.js +1 -0
- package/dist/esm/components/CardServiceInfo/styles.module.css +102 -0
- package/dist/esm/components/CardServiceLight/CardServiceLight.d.ts +22 -11
- package/dist/esm/components/CardServiceLight/CardServiceLight.js +101 -34
- package/dist/esm/components/CardServiceLight/styles.module.css +30 -25
- package/dist/esm/components/CardServiceSmall/CardServiceSmall.d.ts +7 -6
- package/dist/esm/components/CardServiceSmall/CardServiceSmall.js +8 -4
- package/dist/esm/components/CardServiceSmall/styles.module.css +3 -3
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/constants.d.ts +9 -0
- package/dist/esm/constants.js +9 -0
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +31 -0
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.js +30 -0
- package/dist/esm/helperComponents/CardActionsSurface/index.d.ts +2 -0
- package/dist/esm/helperComponents/CardActionsSurface/index.js +2 -0
- package/dist/esm/helperComponents/CardActionsSurface/styles.module.css +36 -0
- package/dist/esm/helperComponents/CardActionsSurface/utils.d.ts +22 -0
- package/dist/esm/helperComponents/CardActionsSurface/utils.js +40 -0
- package/dist/esm/helperComponents/CardPromoTag/CardPromoTag.d.ts +16 -0
- package/dist/esm/helperComponents/CardPromoTag/CardPromoTag.js +21 -0
- package/dist/esm/helperComponents/CardPromoTag/index.d.ts +1 -0
- package/dist/esm/helperComponents/CardPromoTag/index.js +1 -0
- package/dist/esm/helperComponents/index.d.ts +2 -0
- package/dist/esm/helperComponents/index.js +2 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/locale/index.d.ts +43 -0
- package/dist/esm/locale/index.js +23 -0
- package/dist/esm/style.css +166 -23
- package/dist/esm/types.d.ts +12 -5
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +21 -11
- package/src/components/CardServiceInfo/CardServiceInfo.tsx +203 -0
- package/src/components/CardServiceInfo/index.ts +1 -0
- package/src/components/CardServiceInfo/styles.module.scss +124 -0
- package/src/components/CardServiceLight/CardServiceLight.tsx +172 -80
- package/src/components/CardServiceLight/styles.module.scss +37 -33
- package/src/components/CardServiceSmall/CardServiceSmall.tsx +14 -6
- package/src/components/CardServiceSmall/styles.module.scss +3 -3
- package/src/components/index.ts +1 -0
- package/src/constants.ts +10 -0
- package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +136 -0
- package/src/helperComponents/CardActionsSurface/index.ts +2 -0
- package/src/helperComponents/CardActionsSurface/styles.module.scss +50 -0
- package/src/helperComponents/CardActionsSurface/utils.ts +76 -0
- package/src/helperComponents/CardPromoTag/CardPromoTag.tsx +46 -0
- package/src/helperComponents/CardPromoTag/index.ts +1 -0
- package/src/helperComponents/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/locale/index.ts +27 -0
- package/src/types.ts +10 -5
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
|
-
import {
|
|
3
|
-
import { ComponentPropsWithoutRef, ElementType,
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
|
|
4
|
+
import { CardActionsSurfaceProps } from '../../helperComponents';
|
|
5
|
+
import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
|
|
6
|
+
type BaseCardServiceLightProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
|
|
6
7
|
/** Иконка сервиса */
|
|
7
8
|
icon?: ReactElement;
|
|
8
9
|
/** Заголовок карточки */
|
|
9
10
|
title: string;
|
|
10
11
|
/** Настройки promo tag. При отсутствии не отображается */
|
|
11
|
-
promoTag?:
|
|
12
|
+
promoTag?: CardPromoTagProps;
|
|
12
13
|
/** Настройки обрезки текста заголовка */
|
|
13
14
|
truncate?: {
|
|
14
15
|
/** Максимальное количество строк заголовка */
|
|
15
16
|
title?: number;
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Формат отображения дополнительных действий: всегда или при наведении и фокусе
|
|
20
|
+
* @default 'hover'
|
|
21
|
+
*/
|
|
22
|
+
actionsVisibility?: VisibilityStrategy;
|
|
23
|
+
/** Подсказка с иконкой «?» рядом с заголовком */
|
|
24
|
+
tooltip?: Omit<TooltipProps, 'trigger' | 'size'>;
|
|
19
25
|
/**
|
|
20
26
|
* Настройки кнопки «Избранное».
|
|
21
|
-
* Keyboard: ArrowRight на карточке →
|
|
27
|
+
* Keyboard: ArrowRight на карточке → tooltip (если есть) → Favorite; ArrowLeft — в обратном порядке.
|
|
22
28
|
*/
|
|
23
29
|
favorite?: FavoriteProps;
|
|
24
|
-
/**
|
|
25
|
-
|
|
30
|
+
/** Неактивное состояние */
|
|
31
|
+
disabled?: boolean;
|
|
26
32
|
/** CSS-класс корневого элемента */
|
|
27
33
|
className?: string;
|
|
28
34
|
/** Support prop для тестов */
|
|
29
35
|
'data-test-id'?: string;
|
|
36
|
+
/** Настройки кнопки раскрытия */
|
|
37
|
+
expandable?: {
|
|
38
|
+
value: boolean;
|
|
39
|
+
onClick(): void;
|
|
40
|
+
};
|
|
30
41
|
};
|
|
31
42
|
export type CardServiceLightProps<T extends ElementType = 'button'> = BaseCardServiceLightProps & {
|
|
32
43
|
/** Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. */
|
|
@@ -34,5 +45,5 @@ export type CardServiceLightProps<T extends ElementType = 'button'> = BaseCardSe
|
|
|
34
45
|
/** Ref на реальный DOM-элемент / инстанс */
|
|
35
46
|
innerRef?: PolymorphicRef<T>;
|
|
36
47
|
} & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardServiceLightProps | 'as' | 'ref'>;
|
|
37
|
-
export declare function CardServiceLight<T extends ElementType = 'button'>({ icon, title, promoTag, truncate,
|
|
48
|
+
export declare function CardServiceLight<T extends ElementType = 'button'>({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
|
|
38
49
|
export {};
|
|
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CardServiceLight = CardServiceLight;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const
|
|
9
|
-
const promo_tag_1 = require("@cloud-ru/ds-promo-tag");
|
|
10
|
-
const toggles_1 = require("@cloud-ru/ds-toggles");
|
|
8
|
+
const theme_1 = require("@cloud-ru/ds-theme");
|
|
11
9
|
const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
|
|
12
10
|
const typography_1 = require("@cloud-ru/ds-typography");
|
|
13
11
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
@@ -15,35 +13,104 @@ const classnames_1 = __importDefault(require("classnames"));
|
|
|
15
13
|
const merge_refs_1 = __importDefault(require("merge-refs"));
|
|
16
14
|
const react_1 = require("react");
|
|
17
15
|
const constants_1 = require("../../constants");
|
|
16
|
+
const helperComponents_1 = require("../../helperComponents");
|
|
18
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const TARGET_BLANK = '_blank';
|
|
19
|
+
function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
|
|
20
|
+
const Component = as ?? 'button';
|
|
21
21
|
const cardRef = (0, react_1.useRef)(null);
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
const tooltipTriggerRef = (0, react_1.useRef)(null);
|
|
23
|
+
const promoTagTooltipTriggerRef = (0, react_1.useRef)(null);
|
|
24
|
+
const favoriteRef = (0, react_1.useRef)(null);
|
|
25
|
+
const expandButtonRef = (0, react_1.useRef)(null);
|
|
26
|
+
const compactThemeClassName = (0, theme_1.useThemeClassnames)({ density: 'compact' });
|
|
27
|
+
const actionsVisibility = actionsVisibilityProp ?? constants_1.VISIBILITY_STRATEGY.hover;
|
|
28
|
+
const [isFavorite, setIsFavorite] = (0, utils_1.useValueControl)({
|
|
29
|
+
value: favorite?.checked,
|
|
30
|
+
defaultValue: false,
|
|
31
|
+
onChange: favorite?.onChange,
|
|
32
|
+
});
|
|
33
|
+
const [isTooltipOpen, setIsTooltipOpen] = (0, react_1.useState)(false);
|
|
34
|
+
const tooltipTrigger = actionsVisibility === constants_1.VISIBILITY_STRATEGY.hover ? 'hoverAndFocusVisible' : 'click';
|
|
35
|
+
const { onKeyDown: onKeyDownProp, ...restWithoutKeyDown } = rest;
|
|
36
|
+
const handleKeyDown = (0, helperComponents_1.createCardActionsKeyDownHandler)({
|
|
37
|
+
disabled,
|
|
38
|
+
cardRef,
|
|
39
|
+
onKeyDown: onKeyDownProp,
|
|
40
|
+
items: [
|
|
41
|
+
promoTag && { ref: promoTagTooltipTriggerRef },
|
|
42
|
+
tooltip && { ref: tooltipTriggerRef },
|
|
43
|
+
favorite?.enabled && {
|
|
44
|
+
ref: favoriteRef,
|
|
45
|
+
onActivate: () => setIsFavorite(!isFavorite),
|
|
46
|
+
},
|
|
47
|
+
expandable && {
|
|
48
|
+
ref: expandButtonRef,
|
|
49
|
+
onActivate: () => expandable.onClick(),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
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') {
|
|
70
|
+
const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
|
|
71
|
+
polymorphicProps = {
|
|
72
|
+
type,
|
|
73
|
+
disabled,
|
|
74
|
+
onClick: disabled ? undefined : onClick,
|
|
75
|
+
...buttonRest,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
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
|
+
};
|
|
90
|
+
}
|
|
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.outlineBorder, "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: (0, classnames_1.default)(styles_module_scss_1.default.promoTag, compactThemeClassName) }))] })] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, tooltip: tooltip
|
|
92
|
+
? {
|
|
93
|
+
...tooltip,
|
|
94
|
+
'data-test-id': constants_1.TEST_IDS.cardServiceLightTooltip,
|
|
95
|
+
buttonRef: tooltipTriggerRef,
|
|
96
|
+
open: isTooltipOpen,
|
|
97
|
+
onOpenChange: setIsTooltipOpen,
|
|
98
|
+
hoverDelayOpen: constants_1.TOOLTIP_HOVER_DELAY_OPEN_MS,
|
|
99
|
+
}
|
|
100
|
+
: undefined, favorite: favorite?.enabled
|
|
101
|
+
? {
|
|
102
|
+
enabled: favorite.enabled,
|
|
103
|
+
checked: isFavorite,
|
|
104
|
+
onChange: setIsFavorite,
|
|
105
|
+
buttonRef: favoriteRef,
|
|
106
|
+
'data-test-id': constants_1.TEST_IDS.cardServiceLightFavorite,
|
|
107
|
+
}
|
|
108
|
+
: undefined, expandable: expandable
|
|
109
|
+
? {
|
|
110
|
+
value: expandable.value,
|
|
111
|
+
onClick: expandable.onClick,
|
|
112
|
+
buttonRef: expandButtonRef,
|
|
113
|
+
}
|
|
114
|
+
: undefined })] }));
|
|
48
115
|
}
|
|
49
116
|
(0, utils_1.withInnerRefSupport)(CardServiceLight);
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
.
|
|
1
|
+
.root{
|
|
2
|
+
cursor:pointer;
|
|
2
3
|
position:relative;
|
|
3
4
|
display:flex;
|
|
4
|
-
flex
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
flex:1 0 0;
|
|
6
|
+
align-items:center;
|
|
7
|
+
width:100%;
|
|
8
|
+
min-width:228px;
|
|
9
|
+
padding:0;
|
|
10
|
+
border:none;
|
|
11
|
+
border-radius:var(--sn-density-radius-3xs, var(--sn-primitive-dimension-2, 2px));
|
|
12
|
+
font:inherit;
|
|
13
|
+
color:inherit;
|
|
14
|
+
text-decoration:none;
|
|
15
|
+
background-color:transparent;
|
|
8
16
|
}
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
transform:translateY(-50%);
|
|
14
|
-
visibility:hidden;
|
|
17
|
+
.root[data-disabled]{
|
|
18
|
+
pointer-events:none;
|
|
19
|
+
cursor:default;
|
|
20
|
+
opacity:var(--sn-theme-effect-opacity-disabled, 0.4);
|
|
15
21
|
}
|
|
16
|
-
.
|
|
17
|
-
|
|
22
|
+
.root:focus-visible{
|
|
23
|
+
outline:var(--sn-theme-color-primary-accent, var(--sn-brand-color-primary-55, var(--sn-brandRole-color-brandA-55, var(--sn-primitive-color-brandA-55, #389f74)))) solid var(--sn-primitive-strokeWeight-strokeSemiBold, 2px);
|
|
24
|
+
outline-offset:0;
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
cursor:pointer;
|
|
22
|
-
box-sizing:border-box;
|
|
23
|
-
text-decoration:none;
|
|
26
|
+
.root:not([data-disabled]):focus-visible{
|
|
27
|
+
background-color:var(--sn-theme-color-material-stateLayer-darkOnAccent-hovered-filled, rgba(0, 0, 0, 0.0588235294));
|
|
24
28
|
}
|
|
25
|
-
.root:hover .
|
|
29
|
+
.root:not([data-disabled]):hover .cardActions, .root:not([data-disabled]):focus-visible .cardActions, .root:not([data-disabled])[data-tooltip-open] .cardActions, .root:not([data-disabled]):has(*:focus-visible) .cardActions{
|
|
30
|
+
position:relative;
|
|
31
|
+
transform:translateX(0);
|
|
26
32
|
visibility:visible;
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
transform:none;
|
|
34
|
+
@media (hover: hover){
|
|
35
|
+
.root:not([data-disabled]):hover{
|
|
36
|
+
background-color:var(--sn-theme-color-material-stateLayer-darkOnAccent-hovered-filled, rgba(0, 0, 0, 0.0588235294));
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
.container{
|
|
36
|
-
position:relative;
|
|
37
41
|
display:flex;
|
|
38
42
|
gap:var(--sn-primitive-dimension-8, 8px);
|
|
39
43
|
align-items:center;
|
|
@@ -41,6 +45,7 @@
|
|
|
41
45
|
width:100%;
|
|
42
46
|
min-width:0;
|
|
43
47
|
padding:var(--sn-primitive-dimension-4, 4px);
|
|
48
|
+
border-radius:inherit;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
.icon{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
2
|
import { PromoTagProps } from '@cloud-ru/ds-promo-tag';
|
|
3
3
|
import { ComponentPropsWithoutRef, ElementType, JSXElementConstructor, ReactElement } from 'react';
|
|
4
|
-
import { FavoriteProps } from '../../types';
|
|
4
|
+
import { FavoriteProps, VisibilityStrategy } from '../../types';
|
|
5
5
|
type BaseCardServiceSmallProps = {
|
|
6
6
|
/** Заголовок карточки */
|
|
7
7
|
title: string;
|
|
@@ -30,12 +30,13 @@ type BaseCardServiceSmallProps = {
|
|
|
30
30
|
* Промо-тег (бейдж). Тип — `PromoTagProps` из `@cloud-ru/ds-promo-tag`.
|
|
31
31
|
*/
|
|
32
32
|
promoBadge?: PromoTagProps;
|
|
33
|
+
/** Настройки кнопки «Избранное» */
|
|
34
|
+
favorite?: FavoriteProps;
|
|
33
35
|
/**
|
|
34
|
-
*
|
|
36
|
+
* Формат отображения кнопки «Избранное»: всегда или при наведении и фокусе
|
|
37
|
+
* @default 'hover'
|
|
35
38
|
*/
|
|
36
|
-
|
|
37
|
-
visibilityStrategy: 'always' | 'hover';
|
|
38
|
-
};
|
|
39
|
+
actionsVisibility?: VisibilityStrategy;
|
|
39
40
|
/** CSS-класс корневого элемента */
|
|
40
41
|
className?: string;
|
|
41
42
|
/** Support prop для тестов */
|
|
@@ -47,5 +48,5 @@ export type CardServiceSmallProps<T extends ElementType = 'div'> = BaseCardServi
|
|
|
47
48
|
/** Ref на реальный DOM-элемент / инстанс */
|
|
48
49
|
innerRef?: PolymorphicRef<T>;
|
|
49
50
|
} & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardServiceSmallProps | 'as' | 'ref'>;
|
|
50
|
-
export declare function CardServiceSmall<T extends ElementType = 'div'>({ title, emblem, truncate, checked, disabled, outline, promoBadge, favorite, className, as, innerRef, 'data-test-id': dataTestId, ...rest }: CardServiceSmallProps<T>): ReactElement | null;
|
|
51
|
+
export declare function CardServiceSmall<T extends ElementType = 'div'>({ title, emblem, truncate, checked, disabled, outline, promoBadge, favorite, actionsVisibility, className, as, innerRef, 'data-test-id': dataTestId, ...rest }: CardServiceSmallProps<T>): ReactElement | null;
|
|
51
52
|
export {};
|
|
@@ -19,8 +19,12 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
|
19
19
|
function isIconEmblem(emblem) {
|
|
20
20
|
return 'icon' in emblem;
|
|
21
21
|
}
|
|
22
|
-
function CardServiceSmall({ title, emblem, truncate, checked, disabled, outline, promoBadge, favorite, className, as, innerRef, 'data-test-id': dataTestId, ...rest }) {
|
|
23
|
-
const [isFavourite, setIsFavourite] = (0, utils_1.
|
|
22
|
+
function CardServiceSmall({ title, emblem, truncate, checked, disabled, outline, promoBadge, favorite, actionsVisibility, className, as, innerRef, 'data-test-id': dataTestId, ...rest }) {
|
|
23
|
+
const [isFavourite, setIsFavourite] = (0, utils_1.useValueControl)({
|
|
24
|
+
value: favorite?.checked,
|
|
25
|
+
defaultValue: false,
|
|
26
|
+
onChange: favorite?.onChange,
|
|
27
|
+
});
|
|
24
28
|
const cardRef = (0, react_1.useRef)(null);
|
|
25
29
|
const favouriteRef = (0, react_1.useRef)(null);
|
|
26
30
|
const handleCardKeyDown = (0, react_1.useCallback)(e => {
|
|
@@ -43,6 +47,6 @@ function CardServiceSmall({ title, emblem, truncate, checked, disabled, outline,
|
|
|
43
47
|
favouriteRef.current?.blur();
|
|
44
48
|
}, []);
|
|
45
49
|
const IconComponent = isIconEmblem(emblem) ? emblem.icon : null;
|
|
46
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), children: [(0, jsx_runtime_1.jsx)(card_1.Card, { as: as, innerRef: (0, merge_refs_1.default)(innerRef, cardRef), disabled: disabled, interactive: true, checked: checked, view: outline ? 'outline' : undefined, className: styles_module_scss_1.default.card, "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceSmall, onKeyDown: handleCardKeyDown, ...rest, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.contentWrapper, children: [IconComponent ? ((0, jsx_runtime_1.jsx)(IconComponent, { className: styles_module_scss_1.default.icon, size: 24 })) : (!isIconEmblem(emblem) && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: emblem })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentLayout, children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'title', size: 's', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceSmallTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }) }), favorite?.enabled && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.favouriteWrapper, "data-visibility
|
|
50
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), children: [(0, jsx_runtime_1.jsx)(card_1.Card, { as: as, innerRef: (0, merge_refs_1.default)(innerRef, cardRef), disabled: disabled, interactive: true, checked: checked, view: outline ? 'outline' : undefined, className: styles_module_scss_1.default.card, "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceSmall, onKeyDown: handleCardKeyDown, ...rest, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.contentWrapper, children: [IconComponent ? ((0, jsx_runtime_1.jsx)(IconComponent, { className: styles_module_scss_1.default.icon, size: 24 })) : (!isIconEmblem(emblem) && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: emblem })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.contentLayout, children: (0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'title', size: 's', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceSmallTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }) }), favorite?.enabled && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.favouriteWrapper, "data-actions-visibility": actionsVisibility ?? constants_1.VISIBILITY_STRATEGY.hover, children: (0, jsx_runtime_1.jsx)(toggles_1.Favourite, { size: 's', checked: isFavourite, inputRef: favouriteRef, onChange: setIsFavourite, tabIndex: -1, onKeyUp: handleFavouriteKeyUp, onClick: handleFavouriteClick, "data-test-id": constants_1.TEST_IDS.cardServiceSmallFavorite, icon: 'star' }) }))] }) }), promoBadge && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.promoTagWrapper, children: (0, jsx_runtime_1.jsx)(promo_tag_1.PromoTag, { ...promoBadge, "data-test-id": constants_1.TEST_IDS.cardServiceSmallPromoBadge }) }))] }));
|
|
47
51
|
}
|
|
48
52
|
(0, utils_1.withInnerRefSupport)(CardServiceSmall);
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
.favouriteWrapper{
|
|
9
9
|
flex-shrink:0;
|
|
10
10
|
}
|
|
11
|
-
.favouriteWrapper[data-visibility
|
|
11
|
+
.favouriteWrapper[data-actions-visibility=hover]{
|
|
12
12
|
display:none;
|
|
13
13
|
}
|
|
14
|
-
.favouriteWrapper[data-visibility
|
|
14
|
+
.favouriteWrapper[data-actions-visibility=always]{
|
|
15
15
|
display:flex;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.wrapper{
|
|
19
19
|
position:relative;
|
|
20
20
|
}
|
|
21
|
-
.wrapper:hover .favouriteWrapper[data-visibility
|
|
21
|
+
.wrapper:hover .favouriteWrapper[data-actions-visibility=hover], .wrapper:focus-within .favouriteWrapper[data-actions-visibility=hover]{
|
|
22
22
|
display:flex;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./CardBanner"), exports);
|
|
18
18
|
__exportStar(require("./CardService"), exports);
|
|
19
19
|
__exportStar(require("./CardServiceLight"), exports);
|
|
20
|
+
__exportStar(require("./CardServiceInfo"), exports);
|
|
20
21
|
__exportStar(require("./CardServiceSmall"), exports);
|
|
21
22
|
__exportStar(require("./CardSuggest"), exports);
|
|
22
23
|
__exportStar(require("./CardCustom"), exports);
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -12,7 +12,15 @@ export declare const TEST_IDS: {
|
|
|
12
12
|
readonly cardServiceLight: "card-service-light";
|
|
13
13
|
readonly cardServiceLightTitle: "card-service-light__title";
|
|
14
14
|
readonly cardServiceLightPromoTag: "card-service-light__promo-tag";
|
|
15
|
+
readonly cardServiceLightPromoTagTooltip: "card-service-light__promo-tag__tooltip";
|
|
15
16
|
readonly cardServiceLightFavorite: "card-service-light__favorite";
|
|
17
|
+
readonly cardServiceLightTooltip: "card-service-light__tooltip";
|
|
18
|
+
readonly cardServiceInfo: "card-service-info";
|
|
19
|
+
readonly cardServiceInfoTitle: "card-service-info__title";
|
|
20
|
+
readonly cardServiceInfoDescription: "card-service-info__description";
|
|
21
|
+
readonly cardServiceInfoPromoTag: "card-service-info__promo-tag";
|
|
22
|
+
readonly cardServiceInfoPromoTagTooltip: "card-service-info__promo-tag__tooltip";
|
|
23
|
+
readonly cardServiceInfoFavorite: "card-service-info__favorite";
|
|
16
24
|
readonly cardSuggest: "card-suggest";
|
|
17
25
|
readonly cardSuggestContent: "card-suggest__content";
|
|
18
26
|
readonly cardSuggestPromoBadge: "card-suggest__promo-badge";
|
|
@@ -29,3 +37,4 @@ export declare const CARD_SIZE: {
|
|
|
29
37
|
readonly S: "s";
|
|
30
38
|
readonly M: "m";
|
|
31
39
|
};
|
|
40
|
+
export declare const TOOLTIP_HOVER_DELAY_OPEN_MS = 300;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CARD_SIZE = exports.CARD_SUGGEST_TRUNCATE_DEFAULTS = exports.VISIBILITY_STRATEGY = exports.TEST_IDS = void 0;
|
|
3
|
+
exports.TOOLTIP_HOVER_DELAY_OPEN_MS = exports.CARD_SIZE = exports.CARD_SUGGEST_TRUNCATE_DEFAULTS = exports.VISIBILITY_STRATEGY = exports.TEST_IDS = void 0;
|
|
4
4
|
exports.TEST_IDS = {
|
|
5
5
|
cardBanner: 'card-banner',
|
|
6
6
|
cardBannerContent: 'card-banner__content',
|
|
@@ -15,7 +15,15 @@ exports.TEST_IDS = {
|
|
|
15
15
|
cardServiceLight: 'card-service-light',
|
|
16
16
|
cardServiceLightTitle: 'card-service-light__title',
|
|
17
17
|
cardServiceLightPromoTag: 'card-service-light__promo-tag',
|
|
18
|
+
cardServiceLightPromoTagTooltip: 'card-service-light__promo-tag__tooltip',
|
|
18
19
|
cardServiceLightFavorite: 'card-service-light__favorite',
|
|
20
|
+
cardServiceLightTooltip: 'card-service-light__tooltip',
|
|
21
|
+
cardServiceInfo: 'card-service-info',
|
|
22
|
+
cardServiceInfoTitle: 'card-service-info__title',
|
|
23
|
+
cardServiceInfoDescription: 'card-service-info__description',
|
|
24
|
+
cardServiceInfoPromoTag: 'card-service-info__promo-tag',
|
|
25
|
+
cardServiceInfoPromoTagTooltip: 'card-service-info__promo-tag__tooltip',
|
|
26
|
+
cardServiceInfoFavorite: 'card-service-info__favorite',
|
|
19
27
|
cardSuggest: 'card-suggest',
|
|
20
28
|
cardSuggestContent: 'card-suggest__content',
|
|
21
29
|
cardSuggestPromoBadge: 'card-suggest__promo-badge',
|
|
@@ -32,3 +40,4 @@ exports.CARD_SIZE = {
|
|
|
32
40
|
S: 's',
|
|
33
41
|
M: 'm',
|
|
34
42
|
};
|
|
43
|
+
exports.TOOLTIP_HOVER_DELAY_OPEN_MS = 300;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
2
|
+
import { ReactElement, RefObject } from 'react';
|
|
3
|
+
import { CardSize, FavoriteProps, VisibilityStrategy } from '../../types';
|
|
4
|
+
export type CardActionsSurfaceProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Формат отображения действий: всегда или при наведении и фокусе
|
|
7
|
+
* @default 'hover'
|
|
8
|
+
*/
|
|
9
|
+
actionsVisibility?: VisibilityStrategy;
|
|
10
|
+
/** Кнопка info с тултипом */
|
|
11
|
+
tooltip?: Omit<TooltipProps, 'children'> & {
|
|
12
|
+
buttonRef?: RefObject<HTMLButtonElement>;
|
|
13
|
+
'data-test-id'?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Кнопка «Избранное» */
|
|
16
|
+
favorite?: FavoriteProps & {
|
|
17
|
+
buttonRef?: RefObject<HTMLButtonElement>;
|
|
18
|
+
'data-test-id'?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Кнопка раскрытия */
|
|
21
|
+
expandable?: {
|
|
22
|
+
value: boolean;
|
|
23
|
+
onClick(): void;
|
|
24
|
+
buttonRef?: RefObject<HTMLButtonElement>;
|
|
25
|
+
};
|
|
26
|
+
/** Размер кнопок действий, для мобильного вида предполагается использовать `s` */
|
|
27
|
+
actionsSize?: CardSize;
|
|
28
|
+
/** CSS-класс корневого элемента */
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function CardActionsSurface({ actionsVisibility, tooltip, favorite, expandable, actionsSize, className, }: CardActionsSurfaceProps): ReactElement | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
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.CardActionsSurface = CardActionsSurface;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const button_1 = require("@cloud-ru/ds-button");
|
|
9
|
+
const product_1 = require("@cloud-ru/ds-icons/interface/product");
|
|
10
|
+
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
11
|
+
const tooltip_1 = require("@cloud-ru/ds-tooltip");
|
|
12
|
+
const utils_1 = require("@cloud-ru/ds-utils");
|
|
13
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const locale_1 = require("../../locale");
|
|
16
|
+
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
|
+
const { t } = locale_1.cardPredefinedLocale.useTranslations();
|
|
19
|
+
if (!tooltip && !favorite && !expandable) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const tooltipTrigger = tooltip?.trigger ??
|
|
23
|
+
(actionsVisibility === constants_1.VISIBILITY_STRATEGY.always ? tooltip_1.TRIGGER.Click : tooltip_1.TRIGGER.HoverAndFocusVisible);
|
|
24
|
+
const handleExpandButtonClick = (e) => {
|
|
25
|
+
(0, utils_1.preventEventDefaultAndPropagation)(e);
|
|
26
|
+
expandable?.onClick();
|
|
27
|
+
};
|
|
28
|
+
const handleFavoriteClick = (e) => {
|
|
29
|
+
(0, utils_1.preventEventDefaultAndPropagation)(e);
|
|
30
|
+
favorite?.onChange?.(!favorite.checked);
|
|
31
|
+
};
|
|
32
|
+
const { buttonRef: tooltipButtonRef, 'data-test-id': tooltipTestId, ...tooltipProps } = tooltip ?? {};
|
|
33
|
+
return (
|
|
34
|
+
// 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, 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)(button_1.Button, { as: 'span', role: 'button', "aria-label": favorite.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd'), "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)(button_1.Button, { as: 'span', role: 'button', "aria-label": expandable.value ? t('actions.collapse') : t('actions.expand'), "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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./CardActionsSurface"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.root{
|
|
2
|
+
display:flex;
|
|
3
|
+
flex-shrink:0;
|
|
4
|
+
align-items:center;
|
|
5
|
+
}
|
|
6
|
+
.root[data-actions-visibility=hover]{
|
|
7
|
+
position:absolute;
|
|
8
|
+
top:var(--card-actions-surface-inset-top, 0);
|
|
9
|
+
right:var(--card-actions-surface-inset-right, 0);
|
|
10
|
+
transform:translateX(10%);
|
|
11
|
+
border-radius:var(--sn-density-radius-3xs, var(--sn-primitive-dimension-2, 2px));
|
|
12
|
+
visibility:hidden;
|
|
13
|
+
background-color:var(--sn-theme-color-neutral-background2Level, var(--sn-brand-color-neutral-99, var(--sn-primitive-color-gray-99, #ffffff)));
|
|
14
|
+
box-shadow:var(--sn-boxShadow-elevation-level2, var(--sn-theme-effect-shadow-level2-layer1-positionX, 0) var(--sn-theme-effect-shadow-level2-layer1-positionY, 0) var(--sn-theme-effect-shadow-level2-layer1-blur, 4px) var(--sn-theme-effect-shadow-level2-layer1-speed, 0) var(--sn-theme-effect-shadow-layer1Color, rgba(0, 0, 0, 0.0784313725)), var(--sn-theme-effect-shadow-level2-layer2-positionX, 0) var(--sn-theme-effect-shadow-level2-layer2-positionY, 4px) var(--sn-theme-effect-shadow-level2-layer2-blur, 8px) var(--sn-theme-effect-shadow-level2-layer2-speed, 2px) var(--sn-theme-effect-shadow-layer2Color, rgba(0, 0, 0, 0.0784313725)));
|
|
15
|
+
transition:visibility 100ms ease-in-out, transform 150ms ease-in-out;
|
|
16
|
+
}
|
|
17
|
+
.root[data-actions-visibility=hover]:has(*:focus-visible){
|
|
18
|
+
transform:translateX(0);
|
|
19
|
+
visibility:visible;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.favorite{
|
|
23
|
+
flex-shrink:0;
|
|
24
|
+
}
|
|
25
|
+
.favorite[data-checked=true] svg{
|
|
26
|
+
color:var(--sn-theme-color-yellow-accent, var(--sn-primitive-color-yellow-55, #f3b917));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.expandButton{
|
|
30
|
+
flex-shrink:0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.tooltipTrigger{
|
|
34
|
+
display:flex;
|
|
35
|
+
flex-shrink:0;
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { KeyboardEventHandler, RefObject } from 'react';
|
|
2
|
+
export type CardActionsKeyboardItem = {
|
|
3
|
+
ref: RefObject<HTMLElement | null>;
|
|
4
|
+
/**
|
|
5
|
+
* Поведение Space/Enter, когда фокус на этом элементе.
|
|
6
|
+
* - `undefined` — ничего не делать (например, trigger тултипа)
|
|
7
|
+
* - функция — вызвать и остановиться
|
|
8
|
+
*/
|
|
9
|
+
onActivate?(): void;
|
|
10
|
+
};
|
|
11
|
+
export type CreateCardActionsKeyDownHandlerOptions = {
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
cardRef: RefObject<HTMLElement | null>;
|
|
14
|
+
/** Упорядоченная цепочка фокуса после карточки: promoTag → tooltip → favorite → expand */
|
|
15
|
+
items: Array<CardActionsKeyboardItem | false | null | undefined>;
|
|
16
|
+
onKeyDown?: KeyboardEventHandler<HTMLElement>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Клавиатура для доп. контролов карточки сервиса:
|
|
20
|
+
* ArrowRight/ArrowLeft — по цепочке card → items; Space/Enter — activate или клик по карточке.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createCardActionsKeyDownHandler({ disabled, cardRef, items: rawItems, onKeyDown, }: CreateCardActionsKeyDownHandlerOptions): KeyboardEventHandler<HTMLElement>;
|