@cloud-ru/ds-uikit-product-card-predefined 3.1.4-preview-d90ac2be.0 → 3.1.4

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/components/CardCustom/Footer/components/CallToAction/styles.module.css +4 -4
  3. package/dist/cjs/components/CardCustom/FunctionBadge/styles.module.css +4 -3
  4. package/dist/cjs/components/CardCustom/Header/styles.module.css +1 -7
  5. package/dist/cjs/components/CardCustom/Image/styles.module.css +3 -3
  6. package/dist/cjs/components/CardServiceInfo/styles.module.css +11 -11
  7. package/dist/cjs/components/CardServiceLight/styles.module.css +7 -7
  8. package/dist/cjs/components/CardServiceSmall/CardServiceSmall.js +1 -1
  9. package/dist/cjs/components/CardServiceSmall/styles.module.css +6 -0
  10. package/dist/cjs/components/index.d.ts +0 -1
  11. package/dist/cjs/components/index.js +0 -1
  12. package/dist/cjs/constants.d.ts +0 -7
  13. package/dist/cjs/constants.js +0 -7
  14. package/dist/cjs/helperComponents/CardAction/CardAction.js +1 -1
  15. package/dist/cjs/helperComponents/CardAction/styles.module.css +8 -1
  16. package/dist/cjs/helperComponents/CardActionsSurface/styles.module.css +5 -4
  17. package/dist/cjs/helperComponents/FunctionBadgeWrapper/styles.module.css +4 -3
  18. package/dist/cjs/style.css +53 -503
  19. package/dist/esm/components/CardCustom/Footer/components/CallToAction/styles.module.css +4 -4
  20. package/dist/esm/components/CardCustom/FunctionBadge/styles.module.css +4 -3
  21. package/dist/esm/components/CardCustom/Header/styles.module.css +1 -7
  22. package/dist/esm/components/CardCustom/Image/styles.module.css +3 -3
  23. package/dist/esm/components/CardServiceInfo/styles.module.css +11 -11
  24. package/dist/esm/components/CardServiceLight/styles.module.css +7 -7
  25. package/dist/esm/components/CardServiceSmall/CardServiceSmall.js +1 -1
  26. package/dist/esm/components/CardServiceSmall/styles.module.css +6 -0
  27. package/dist/esm/components/index.d.ts +0 -1
  28. package/dist/esm/components/index.js +0 -1
  29. package/dist/esm/constants.d.ts +0 -7
  30. package/dist/esm/constants.js +0 -7
  31. package/dist/esm/helperComponents/CardAction/CardAction.js +1 -1
  32. package/dist/esm/helperComponents/CardAction/styles.module.css +8 -1
  33. package/dist/esm/helperComponents/CardActionsSurface/styles.module.css +5 -4
  34. package/dist/esm/helperComponents/FunctionBadgeWrapper/styles.module.css +4 -3
  35. package/dist/esm/style.css +53 -503
  36. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  37. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  38. package/package.json +18 -18
  39. package/src/components/CardCustom/Footer/components/CallToAction/styles.module.scss +2 -2
  40. package/src/components/CardCustom/FunctionBadge/styles.module.scss +2 -1
  41. package/src/components/CardCustom/Header/styles.module.scss +2 -6
  42. package/src/components/CardCustom/Image/styles.module.scss +2 -3
  43. package/src/components/CardServiceInfo/styles.module.scss +2 -2
  44. package/src/components/CardServiceLight/styles.module.scss +2 -2
  45. package/src/components/CardServiceSmall/CardServiceSmall.tsx +2 -1
  46. package/src/components/CardServiceSmall/styles.module.scss +6 -0
  47. package/src/components/CardSuggest/styles.module.scss +18 -11
  48. package/src/components/index.ts +0 -1
  49. package/src/constants.ts +0 -7
  50. package/src/helperComponents/CardAction/CardAction.tsx +2 -2
  51. package/src/helperComponents/CardAction/styles.module.scss +7 -0
  52. package/src/helperComponents/CardActionsSurface/styles.module.scss +1 -0
  53. package/src/helperComponents/FunctionBadgeWrapper/styles.module.scss +1 -0
  54. package/dist/cjs/components/CardNavigation/CardNavigation.d.ts +0 -61
  55. package/dist/cjs/components/CardNavigation/CardNavigation.js +0 -139
  56. package/dist/cjs/components/CardNavigation/index.d.ts +0 -1
  57. package/dist/cjs/components/CardNavigation/index.js +0 -17
  58. package/dist/cjs/components/CardNavigation/styles.module.css +0 -460
  59. package/dist/esm/components/CardNavigation/CardNavigation.d.ts +0 -61
  60. package/dist/esm/components/CardNavigation/CardNavigation.js +0 -133
  61. package/dist/esm/components/CardNavigation/index.d.ts +0 -1
  62. package/dist/esm/components/CardNavigation/index.js +0 -1
  63. package/dist/esm/components/CardNavigation/styles.module.css +0 -460
  64. package/src/components/CardNavigation/CardNavigation.tsx +0 -331
  65. package/src/components/CardNavigation/index.ts +0 -1
  66. package/src/components/CardNavigation/styles.module.scss +0 -246
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-uikit-product-card-predefined",
3
- "version": "3.1.4-preview-d90ac2be.0",
3
+ "version": "3.1.4",
4
4
  "description": "Пресеты карточек Product UI Kit — CardBanner, CardService, CardServiceLight, CardServiceSmall, CardSuggest, CardCustom.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,23 +41,23 @@
41
41
  "dependencies": {
42
42
  "classnames": "^2.5.1",
43
43
  "merge-refs": "^2.0.0",
44
- "@cloud-ru/ds-adaptive": "1.0.1",
45
- "@cloud-ru/ds-button": "1.0.2",
46
- "@cloud-ru/ds-icon-predefined": "1.0.1",
47
- "@cloud-ru/ds-list": "2.2.1-preview-d90ac2be.0",
48
- "@cloud-ru/ds-promo-tag": "1.0.1",
49
- "@cloud-ru/ds-icons": "1.2.0",
50
- "@cloud-ru/ds-locale": "1.0.0",
51
- "@cloud-ru/ds-materials": "1.0.1",
52
- "@cloud-ru/ds-tag": "1.1.3-preview-d90ac2be.0",
53
- "@cloud-ru/ds-card": "1.0.14-preview-d90ac2be.0",
54
- "@cloud-ru/ds-theme": "1.1.0",
55
- "@cloud-ru/ds-tooltip": "1.0.5",
56
- "@cloud-ru/ds-toggles": "1.1.5-preview-d90ac2be.0",
57
- "@cloud-ru/ds-uikit-product-promo-tag-predefined": "1.0.6-preview-d90ac2be.0",
58
- "@cloud-ru/ds-truncate-string": "1.0.6-preview-d90ac2be.0",
59
- "@cloud-ru/ds-typography": "1.0.0",
60
- "@cloud-ru/ds-utils": "1.1.0"
44
+ "@cloud-ru/ds-adaptive": "^1.0.1",
45
+ "@cloud-ru/ds-button": "^1.0.3",
46
+ "@cloud-ru/ds-card": "^1.0.14",
47
+ "@cloud-ru/ds-icon-predefined": "^1.0.2",
48
+ "@cloud-ru/ds-icons": "^1.2.1",
49
+ "@cloud-ru/ds-list": "^2.2.1",
50
+ "@cloud-ru/ds-locale": "^1.0.0",
51
+ "@cloud-ru/ds-materials": "^2.0.0",
52
+ "@cloud-ru/ds-promo-tag": "^1.0.2",
53
+ "@cloud-ru/ds-tag": "^1.1.3",
54
+ "@cloud-ru/ds-theme": "^2.0.0",
55
+ "@cloud-ru/ds-toggles": "^1.1.5",
56
+ "@cloud-ru/ds-tooltip": "^1.0.6",
57
+ "@cloud-ru/ds-truncate-string": "^1.0.6",
58
+ "@cloud-ru/ds-typography": "^1.0.0",
59
+ "@cloud-ru/ds-uikit-product-promo-tag-predefined": "^1.0.6",
60
+ "@cloud-ru/ds-utils": "^1.1.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
@@ -26,8 +26,8 @@
26
26
  color: base.$sn-theme-color-primary-text;
27
27
 
28
28
  svg {
29
- width: base.$sn-density-size-icon-s !important; /* stylelint-disable-line declaration-no-important */
30
- height: base.$sn-density-size-icon-s !important; /* stylelint-disable-line declaration-no-important */
29
+ width: base.$sn-density-icon-s !important; /* stylelint-disable-line declaration-no-important */
30
+ height: base.$sn-density-icon-s !important; /* stylelint-disable-line declaration-no-important */
31
31
  }
32
32
  }
33
33
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  $function-badge-size: base.$sn-primitive-dimension-32;
4
4
  $function-badge-border-radius: base.$sn-brand-anatomy-radius-card-toggles-xs;
5
- $icon-size: base.$sn-density-size-icon-s;
5
+ $icon-size: base.$sn-density-icon-s;
6
6
 
7
7
  .button {
8
8
  cursor: pointer;
@@ -13,6 +13,7 @@ $icon-size: base.$sn-density-size-icon-s;
13
13
  align-items: center;
14
14
  justify-content: center;
15
15
 
16
+ box-sizing: border-box;
16
17
  width: $function-badge-size;
17
18
  height: $function-badge-size;
18
19
  border: 0;
@@ -23,12 +23,8 @@
23
23
  }
24
24
  }
25
25
 
26
- [data-card-custom-image] + .titleLayout {
27
- @each $size in shared.$sizes {
28
- &[data-size='#{$size}'] {
29
- padding-top: 0;
30
- }
31
- }
26
+ [data-card-custom-image] + .titleLayout[data-size] {
27
+ padding-top: 0;
32
28
  }
33
29
 
34
30
  .contentLayout {
@@ -3,9 +3,8 @@
3
3
 
4
4
  $modes: 'little', 'middle', 'background';
5
5
 
6
- // Высоты little/middle-режимов заданы в Figma-мастере фиксированными px; в наборе
7
- // `@cloud-ru/ds-figma-variables` нет dimension-токена под 144/240 (максимум — 136).
8
- $image-little-height: 144px;
6
+ $image-little-height: base.$sn-primitive-dimension-144;
7
+ // Нет токена: шкала primitive-dimension заканчивается на 152.
9
8
  $image-middle-height: 240px;
10
9
 
11
10
  // mask-image использует только альфа-канал стопов: RGB роли не играет, важна
@@ -81,8 +81,8 @@ $actions-counts: 1, 2;
81
81
 
82
82
  .icon {
83
83
  flex-shrink: 0;
84
- width: base.$sn-density-size-icon-s;
85
- height: base.$sn-density-size-icon-s;
84
+ width: base.$sn-density-icon-s;
85
+ height: base.$sn-density-icon-s;
86
86
  color: base.$sn-theme-color-available-version-textTertiary;
87
87
  }
88
88
 
@@ -84,8 +84,8 @@
84
84
 
85
85
  .icon {
86
86
  flex-shrink: 0;
87
- width: base.$sn-density-size-icon-s;
88
- height: base.$sn-density-size-icon-s;
87
+ width: base.$sn-density-icon-s;
88
+ height: base.$sn-density-icon-s;
89
89
  color: base.$sn-theme-color-available-version-textTertiary;
90
90
  }
91
91
 
@@ -128,6 +128,7 @@ export function CardServiceSmall<T extends ElementType = 'div'>({
128
128
  innerRef={mergeRefs(innerRef, cardRef)}
129
129
  disabled={disabled}
130
130
  interactive
131
+ radius='s'
131
132
  checked={checked}
132
133
  view={outline ? 'outline' : undefined}
133
134
  className={styles.card}
@@ -137,7 +138,7 @@ export function CardServiceSmall<T extends ElementType = 'div'>({
137
138
  >
138
139
  <div className={styles.contentWrapper}>
139
140
  {IconComponent ? (
140
- <IconComponent className={styles.icon} size={24} />
141
+ <IconComponent className={cn(styles.icon, styles.iconSvg)} />
141
142
  ) : (
142
143
  !isIconEmblem(emblem) && <div className={styles.icon}>{emblem}</div>
143
144
  )}
@@ -21,6 +21,7 @@
21
21
 
22
22
  .wrapper {
23
23
  position: relative;
24
+ box-sizing: border-box;
24
25
 
25
26
  &:hover,
26
27
  &:focus-within {
@@ -53,6 +54,11 @@
53
54
  color: base.$sn-theme-color-available-version-textMain;
54
55
  }
55
56
 
57
+ .iconSvg {
58
+ width: base.$sn-density-icon-s;
59
+ height: base.$sn-density-icon-s;
60
+ }
61
+
56
62
  .contentLayout {
57
63
  overflow: hidden;
58
64
  display: block;
@@ -1,5 +1,17 @@
1
+ @use 'sass:map';
1
2
  @use '@cloud-ru/ds-figma-variables/build/scss/styles/styles.module' as base;
2
3
 
4
+ $content-spacing: (
5
+ 'm': (
6
+ 'gap': base.$sn-primitive-dimension-8,
7
+ 'padding': base.$sn-primitive-dimension-16,
8
+ ),
9
+ 's': (
10
+ 'gap': base.$sn-primitive-dimension-4,
11
+ 'padding': base.$sn-primitive-dimension-8,
12
+ ),
13
+ );
14
+
3
15
  .content {
4
16
  position: relative;
5
17
 
@@ -29,17 +41,12 @@
29
41
  box-sizing: border-box;
30
42
  text-decoration: none;
31
43
 
32
- &[data-size='m'] {
33
- .content {
34
- gap: base.$sn-primitive-dimension-8;
35
- padding: base.$sn-primitive-dimension-16;
36
- }
37
- }
38
-
39
- &[data-size='s'] {
40
- .content {
41
- gap: base.$sn-primitive-dimension-4;
42
- padding: base.$sn-primitive-dimension-8;
44
+ @each $size, $spacing in $content-spacing {
45
+ &[data-size='#{$size}'] {
46
+ .content {
47
+ gap: map.get($spacing, 'gap');
48
+ padding: map.get($spacing, 'padding');
49
+ }
43
50
  }
44
51
  }
45
52
  }
@@ -5,4 +5,3 @@ export * from './CardServiceInfo';
5
5
  export * from './CardServiceSmall';
6
6
  export * from './CardSuggest';
7
7
  export * from './CardCustom';
8
- export * from './CardNavigation';
package/src/constants.ts CHANGED
@@ -28,13 +28,6 @@ export const TEST_IDS = {
28
28
  cardServiceInfoPromoTag: 'card-service-info__promo-tag',
29
29
  cardServiceInfoPromoTagTooltip: 'card-service-info__promo-tag__tooltip',
30
30
  cardServiceInfoFavorite: 'card-service-info__favorite',
31
- cardNavigation: 'card-navigation',
32
- cardNavigationTitle: 'card-navigation__title',
33
- cardNavigationDescription: 'card-navigation__description',
34
- cardNavigationPromoTag: 'card-navigation__promo-tag',
35
- cardNavigationPromoTagTooltip: 'card-navigation__promo-tag__tooltip',
36
- cardNavigationFavorite: 'card-navigation__favorite',
37
- cardNavigationTooltip: 'card-navigation__tooltip',
38
31
  cardSuggest: 'card-suggest',
39
32
  cardSuggestContent: 'card-suggest__content',
40
33
  cardSuggestPromoBadge: 'card-suggest__promo-badge',
@@ -15,11 +15,11 @@ type CardActionProps = {
15
15
  export function CardAction({ actionLabel, className }: CardActionProps): ReactElement {
16
16
  return (
17
17
  <div className={cn(styles.root, className)}>
18
- <Typography as='span' variant='label' size='l'>
18
+ <Typography as='span' variant='label' size='m'>
19
19
  {actionLabel}
20
20
  </Typography>
21
21
 
22
- <ArrowRightSVG size={24} />
22
+ <ArrowRightSVG className={styles.icon} />
23
23
  </div>
24
24
  );
25
25
  }
@@ -5,7 +5,14 @@
5
5
  gap: base.$sn-primitive-dimension-4;
6
6
  align-items: center;
7
7
 
8
+ box-sizing: border-box;
8
9
  height: base.$sn-primitive-dimension-32;
9
10
 
10
11
  color: base.$sn-theme-color-primary-text;
11
12
  }
13
+
14
+ .icon {
15
+ flex-shrink: 0;
16
+ width: base.$sn-density-icon-s;
17
+ height: base.$sn-density-icon-s;
18
+ }
@@ -4,6 +4,7 @@
4
4
  display: flex;
5
5
  flex-shrink: 0;
6
6
  align-items: center;
7
+ box-sizing: border-box;
7
8
 
8
9
  // Позиционирование hover-поверхности живёт только здесь; карточка-потребитель задаёт отступы
9
10
  // от своего угла через `--card-actions-surface-inset-*`.
@@ -12,6 +12,7 @@ $function-badge-border-radius: base.$sn-brand-anatomy-radius-card-toggles-xs;
12
12
 
13
13
  display: none;
14
14
 
15
+ box-sizing: border-box;
15
16
  padding-top: $function-badge-padding;
16
17
  padding-right: $function-badge-padding;
17
18
 
@@ -1,61 +0,0 @@
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, CardSize, 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
- /** Размер кнопок действий. По умолчанию — по раскладке (`s` на mobile, `m` на desktop) */
30
- actionsSize?: CardSize;
31
- /** Подсказка с иконкой «?» рядом с заголовком. Показывается только в компактном виде */
32
- tooltip?: Omit<TooltipProps, 'trigger' | 'size'>;
33
- /**
34
- * Настройки кнопки «Избранное».
35
- * Keyboard: ArrowRight на карточке → promo tag → tooltip (если есть) → Favorite → expand; ArrowLeft — в обратном порядке.
36
- */
37
- favorite?: FavoriteProps;
38
- /** Неактивное состояние */
39
- disabled?: boolean;
40
- /** CSS-класс корневого элемента */
41
- className?: string;
42
- /** Support prop для тестов */
43
- 'data-test-id'?: string;
44
- /** Настройки кнопки раскрытия */
45
- expandable?: {
46
- value: boolean;
47
- onClick(): void;
48
- };
49
- };
50
- export type CardNavigationProps<T extends ElementType = 'button'> = BaseCardNavigationProps & {
51
- /** Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. */
52
- as?: T;
53
- /** Ref на реальный DOM-элемент / инстанс */
54
- innerRef?: PolymorphicRef<T>;
55
- } & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardNavigationProps | 'as' | 'ref'>;
56
- /**
57
- * Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
58
- * (вид с описанием) в один компонент с одним деревом DOM.
59
- */
60
- export declare function CardNavigation<T extends ElementType = 'button'>({ as, innerRef, icon, title, description, promoTag, truncate, actionsVisibility: actionsVisibilityProp, actionsSize: actionsSizeProp, favorite, tooltip, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardNavigationProps<T>): ReactElement | null;
61
- export {};
@@ -1,139 +0,0 @@
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 adaptive_1 = require("@cloud-ru/ds-adaptive");
9
- const materials_1 = require("@cloud-ru/ds-materials");
10
- const theme_1 = require("@cloud-ru/ds-theme");
11
- const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
12
- const typography_1 = require("@cloud-ru/ds-typography");
13
- const utils_1 = require("@cloud-ru/ds-utils");
14
- const classnames_1 = __importDefault(require("classnames"));
15
- const merge_refs_1 = __importDefault(require("merge-refs"));
16
- const react_1 = require("react");
17
- const constants_1 = require("../../constants");
18
- const helperComponents_1 = require("../../helperComponents");
19
- const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
20
- const TARGET_BLANK = '_blank';
21
- const { appearance: ACRYLIC_APPEARANCE, level: ACRYLIC_LEVEL } = (0, materials_1.backgroundPredefinedFillToAcrylic)(materials_1.BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
22
- /**
23
- * Карточка навигации к сервису: объединяет `CardServiceLight` (компактный вид) и `CardServiceInfo`
24
- * (вид с описанием) в один компонент с одним деревом DOM.
25
- */
26
- function CardNavigation({ as, innerRef, icon, title, description, promoTag, truncate, actionsVisibility: actionsVisibilityProp, actionsSize: actionsSizeProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
27
- const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
28
- const isMobile = (0, adaptive_1.isMobileLayout)(layoutType);
29
- const Component = as ?? 'button';
30
- const cardRef = (0, react_1.useRef)(null);
31
- const tooltipTriggerRef = (0, react_1.useRef)(null);
32
- const promoTagTooltipTriggerRef = (0, react_1.useRef)(null);
33
- const favoriteRef = (0, react_1.useRef)(null);
34
- const expandButtonRef = (0, react_1.useRef)(null);
35
- const compactThemeClassName = (0, theme_1.useThemeClassnames)({ density: 'compact' });
36
- const isDetailed = description !== undefined;
37
- const actionsVisibility = actionsVisibilityProp ?? constants_1.VISIBILITY_STRATEGY.hover;
38
- const actionsSize = actionsSizeProp ?? (isMobile ? 's' : 'm');
39
- // Подсказка «?» есть только у компактного вида: в подробном её роль играет описание.
40
- const cardTooltip = isDetailed ? undefined : tooltip;
41
- const visibleActionsCount = Number(Boolean(favorite?.enabled)) + Number(Boolean(expandable));
42
- const [isFavorite, setIsFavorite] = (0, utils_1.useValueControl)({
43
- value: favorite?.checked,
44
- defaultValue: false,
45
- onChange: favorite?.onChange,
46
- });
47
- const [isTooltipOpen, setIsTooltipOpen] = (0, react_1.useState)(false);
48
- // Панель действий (`Tooltip` на floating-ui + кнопки) в режиме `hover` скрыта до наведения, `always` показывает панель сразу.
49
- // При рендере большого количества карточек на одном экране может вызывать лаги, поэтому монтируем её при первом наведении или фокусе.
50
- const [isActionsRequested, setIsActionsRequested] = (0, react_1.useState)(false);
51
- const shouldRenderActions = isActionsRequested || actionsVisibility === constants_1.VISIBILITY_STRATEGY.always;
52
- const tooltipTrigger = actionsVisibility === constants_1.VISIBILITY_STRATEGY.hover ? 'hoverAndFocusVisible' : 'click';
53
- const { onKeyDown: onKeyDownProp, onPointerEnter: onPointerEnterProp, onFocus: onFocusProp, ...restWithoutKeyDown } = rest;
54
- const handlePointerEnter = (event) => {
55
- setIsActionsRequested(true);
56
- onPointerEnterProp?.(event);
57
- };
58
- const handleFocus = (event) => {
59
- setIsActionsRequested(true);
60
- onFocusProp?.(event);
61
- };
62
- const handleKeyDown = (0, react_1.useMemo)(() => (0, helperComponents_1.createCardActionsKeyDownHandler)({
63
- disabled,
64
- cardRef,
65
- onKeyDown: onKeyDownProp,
66
- items: [
67
- promoTag && { ref: promoTagTooltipTriggerRef },
68
- cardTooltip && { ref: tooltipTriggerRef },
69
- favorite?.enabled && {
70
- ref: favoriteRef,
71
- onActivate: () => setIsFavorite(!isFavorite),
72
- },
73
- expandable && {
74
- ref: expandButtonRef,
75
- onActivate: () => expandable.onClick(),
76
- },
77
- ],
78
- }), [disabled, onKeyDownProp, promoTag, cardTooltip, favorite?.enabled, expandable, isFavorite, setIsFavorite]);
79
- let polymorphicProps;
80
- if (Component === 'a') {
81
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown;
82
- polymorphicProps = {
83
- ...anchorRest,
84
- href: href ?? '#',
85
- target,
86
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
87
- onClick: disabled
88
- ? (e) => {
89
- e.preventDefault();
90
- onClick?.(e);
91
- }
92
- : onClick,
93
- };
94
- }
95
- else if (Component === 'button') {
96
- const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown;
97
- polymorphicProps = {
98
- type,
99
- disabled,
100
- onClick: disabled ? undefined : onClick,
101
- ...buttonRest,
102
- };
103
- }
104
- else {
105
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
106
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
107
- const { onClick, ...componentRest } = restWithoutKeyDown;
108
- polymorphicProps = {
109
- ...componentRest,
110
- onClick: disabled
111
- ? (e) => {
112
- e.preventDefault();
113
- }
114
- : onClick,
115
- };
116
- }
117
- 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-mobile": isMobile || undefined, "data-actions-size": actionsSize, "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, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, onTooltipOpenChange: setIsTooltipOpen, tooltip: cardTooltip
118
- ? {
119
- ...cardTooltip,
120
- 'data-test-id': constants_1.TEST_IDS.cardNavigationTooltip,
121
- buttonRef: tooltipTriggerRef,
122
- }
123
- : undefined, favorite: favorite?.enabled
124
- ? {
125
- enabled: favorite.enabled,
126
- checked: isFavorite,
127
- onChange: setIsFavorite,
128
- buttonRef: favoriteRef,
129
- 'data-test-id': constants_1.TEST_IDS.cardNavigationFavorite,
130
- }
131
- : undefined, expandable: expandable
132
- ? {
133
- value: expandable.value,
134
- onClick: expandable.onClick,
135
- buttonRef: expandButtonRef,
136
- }
137
- : undefined })), isDetailed && (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.outlineBorder, "aria-hidden": true })] }));
138
- }
139
- (0, utils_1.withInnerRefSupport)(CardNavigation);
@@ -1 +0,0 @@
1
- export * from './CardNavigation';
@@ -1,17 +0,0 @@
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);