@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +251 -34
  3. package/dist/cjs/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
  4. package/dist/cjs/components/CardServiceInfo/CardServiceInfo.js +66 -0
  5. package/dist/cjs/components/CardServiceInfo/index.d.ts +1 -0
  6. package/dist/cjs/components/CardServiceInfo/index.js +17 -0
  7. package/dist/cjs/components/CardServiceInfo/styles.module.css +102 -0
  8. package/dist/cjs/components/CardServiceLight/CardServiceLight.d.ts +22 -11
  9. package/dist/cjs/components/CardServiceLight/CardServiceLight.js +98 -31
  10. package/dist/cjs/components/CardServiceLight/styles.module.css +30 -25
  11. package/dist/cjs/components/CardServiceSmall/CardServiceSmall.d.ts +7 -6
  12. package/dist/cjs/components/CardServiceSmall/CardServiceSmall.js +7 -3
  13. package/dist/cjs/components/CardServiceSmall/styles.module.css +3 -3
  14. package/dist/cjs/components/index.d.ts +1 -0
  15. package/dist/cjs/components/index.js +1 -0
  16. package/dist/cjs/constants.d.ts +9 -0
  17. package/dist/cjs/constants.js +10 -1
  18. package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +31 -0
  19. package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.js +36 -0
  20. package/dist/cjs/helperComponents/CardActionsSurface/index.d.ts +2 -0
  21. package/dist/cjs/helperComponents/CardActionsSurface/index.js +18 -0
  22. package/dist/cjs/helperComponents/CardActionsSurface/styles.module.css +36 -0
  23. package/dist/cjs/helperComponents/CardActionsSurface/utils.d.ts +22 -0
  24. package/dist/cjs/helperComponents/CardActionsSurface/utils.js +43 -0
  25. package/dist/cjs/helperComponents/CardPromoTag/CardPromoTag.d.ts +16 -0
  26. package/dist/cjs/helperComponents/CardPromoTag/CardPromoTag.js +24 -0
  27. package/dist/cjs/helperComponents/CardPromoTag/index.d.ts +1 -0
  28. package/dist/cjs/helperComponents/CardPromoTag/index.js +17 -0
  29. package/dist/cjs/helperComponents/index.d.ts +2 -0
  30. package/dist/cjs/helperComponents/index.js +2 -0
  31. package/dist/cjs/index.d.ts +2 -0
  32. package/dist/cjs/index.js +2 -0
  33. package/dist/cjs/locale/index.d.ts +43 -0
  34. package/dist/cjs/locale/index.js +26 -0
  35. package/dist/cjs/style.css +166 -23
  36. package/dist/cjs/types.d.ts +12 -5
  37. package/dist/esm/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
  38. package/dist/esm/components/CardServiceInfo/CardServiceInfo.js +60 -0
  39. package/dist/esm/components/CardServiceInfo/index.d.ts +1 -0
  40. package/dist/esm/components/CardServiceInfo/index.js +1 -0
  41. package/dist/esm/components/CardServiceInfo/styles.module.css +102 -0
  42. package/dist/esm/components/CardServiceLight/CardServiceLight.d.ts +22 -11
  43. package/dist/esm/components/CardServiceLight/CardServiceLight.js +101 -34
  44. package/dist/esm/components/CardServiceLight/styles.module.css +30 -25
  45. package/dist/esm/components/CardServiceSmall/CardServiceSmall.d.ts +7 -6
  46. package/dist/esm/components/CardServiceSmall/CardServiceSmall.js +8 -4
  47. package/dist/esm/components/CardServiceSmall/styles.module.css +3 -3
  48. package/dist/esm/components/index.d.ts +1 -0
  49. package/dist/esm/components/index.js +1 -0
  50. package/dist/esm/constants.d.ts +9 -0
  51. package/dist/esm/constants.js +9 -0
  52. package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +31 -0
  53. package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.js +30 -0
  54. package/dist/esm/helperComponents/CardActionsSurface/index.d.ts +2 -0
  55. package/dist/esm/helperComponents/CardActionsSurface/index.js +2 -0
  56. package/dist/esm/helperComponents/CardActionsSurface/styles.module.css +36 -0
  57. package/dist/esm/helperComponents/CardActionsSurface/utils.d.ts +22 -0
  58. package/dist/esm/helperComponents/CardActionsSurface/utils.js +40 -0
  59. package/dist/esm/helperComponents/CardPromoTag/CardPromoTag.d.ts +16 -0
  60. package/dist/esm/helperComponents/CardPromoTag/CardPromoTag.js +21 -0
  61. package/dist/esm/helperComponents/CardPromoTag/index.d.ts +1 -0
  62. package/dist/esm/helperComponents/CardPromoTag/index.js +1 -0
  63. package/dist/esm/helperComponents/index.d.ts +2 -0
  64. package/dist/esm/helperComponents/index.js +2 -0
  65. package/dist/esm/index.d.ts +2 -0
  66. package/dist/esm/index.js +2 -0
  67. package/dist/esm/locale/index.d.ts +43 -0
  68. package/dist/esm/locale/index.js +23 -0
  69. package/dist/esm/style.css +166 -23
  70. package/dist/esm/types.d.ts +12 -5
  71. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  72. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  73. package/package.json +21 -11
  74. package/src/components/CardServiceInfo/CardServiceInfo.tsx +203 -0
  75. package/src/components/CardServiceInfo/index.ts +1 -0
  76. package/src/components/CardServiceInfo/styles.module.scss +124 -0
  77. package/src/components/CardServiceLight/CardServiceLight.tsx +172 -80
  78. package/src/components/CardServiceLight/styles.module.scss +37 -33
  79. package/src/components/CardServiceSmall/CardServiceSmall.tsx +14 -6
  80. package/src/components/CardServiceSmall/styles.module.scss +3 -3
  81. package/src/components/index.ts +1 -0
  82. package/src/constants.ts +10 -0
  83. package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +136 -0
  84. package/src/helperComponents/CardActionsSurface/index.ts +2 -0
  85. package/src/helperComponents/CardActionsSurface/styles.module.scss +50 -0
  86. package/src/helperComponents/CardActionsSurface/utils.ts +76 -0
  87. package/src/helperComponents/CardPromoTag/CardPromoTag.tsx +46 -0
  88. package/src/helperComponents/CardPromoTag/index.ts +1 -0
  89. package/src/helperComponents/index.ts +2 -0
  90. package/src/index.ts +2 -0
  91. package/src/locale/index.ts +27 -0
  92. package/src/types.ts +10 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
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
+ # 2.0.0 (2026-08-24)
7
+
8
+ ### BREAKING CHANGES
9
+
10
+ - **FF-8718:** add CardServiceInfo and refactor card actions API ([c710c49](https://github.com/cloud-ru-tech/snack-v2/commit/c710c49b4895409b0537bf8d71f7ef81f0c6cc4a))
11
+
6
12
  ## 1.0.4 (2026-08-20)
7
13
 
8
14
  **Note:** Version bump only for package @ds/uikit-product-card-predefined
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CardPredefined
2
2
 
3
- `@cloud-ru/ds-uikit-product-card-predefined` — Пресеты карточек Product UI Kit — CardBanner, CardService, CardServiceLight, CardServiceSmall, CardSuggest, CardCustom.
3
+ `@cloud-ru/ds-uikit-product-card-predefined` — Пресеты карточек Product UI Kit — CardBanner, CardService, CardServiceLight, CardServiceInfo, CardServiceSmall, CardSuggest, CardCustom.
4
4
 
5
5
  Набор готовых карточек Product UI Kit на базе `@cloud-ru/ds-card`:
6
6
 
@@ -13,7 +13,7 @@ pnpm add @cloud-ru/ds-uikit-product-card-predefined
13
13
  ```
14
14
 
15
15
  ```ts
16
- import { CardBanner, CardService, CardServiceLight, CardSuggest } from '@cloud-ru/ds-uikit-product-card-predefined'
16
+ import { CardBanner, CardService, CardServiceLight, CardServiceInfo, CardSuggest } from '@cloud-ru/ds-uikit-product-card-predefined';
17
17
  ```
18
18
 
19
19
  ## CardBanner
@@ -216,22 +216,10 @@ export function Basic() {
216
216
 
217
217
  ```tsx
218
218
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
219
- import { APPEARANCE, ROLE_APPEARANCE, SIZE } from '@cloud-ru/ds-promo-tag';
220
219
  import { CardServiceLight } from '@cloud-ru/ds-uikit-product-card-predefined';
221
220
 
222
221
  export function WithPromoTag() {
223
- return (
224
- <CardServiceLight
225
- title='Мой сервис'
226
- icon={<PlaceholderSVG size={24} />}
227
- promoTag={{
228
- label: 'New',
229
- appearance: APPEARANCE.Primary,
230
- role: ROLE_APPEARANCE.Accent,
231
- size: SIZE.Xs,
232
- }}
233
- />
234
- );
222
+ return <CardServiceLight title='Мой сервис' icon={<PlaceholderSVG size={24} />} promoTag={{ variant: 'preview' }} />;
235
223
  }
236
224
  ```
237
225
 
@@ -257,7 +245,7 @@ export function WithTruncate() {
257
245
 
258
246
  #### Кнопка «Избранное» (always)
259
247
 
260
- favorite.visibilityStrategy="always" — кнопка видна постоянно; checked и onChange задают controlled-режим.
248
+ actionsVisibility="always" — действия видны постоянно; favorite.checked и onChange задают controlled-режим избранного.
261
249
 
262
250
  ```tsx
263
251
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
@@ -271,9 +259,9 @@ export function WithFavorite() {
271
259
  <CardServiceLight
272
260
  title='Мой сервис'
273
261
  icon={<PlaceholderSVG size={24} />}
262
+ actionsVisibility={VISIBILITY_STRATEGY.always}
274
263
  favorite={{
275
264
  enabled: true,
276
- visibilityStrategy: VISIBILITY_STRATEGY.always,
277
265
  checked: isFavorite,
278
266
  onChange: setIsFavorite,
279
267
  }}
@@ -284,7 +272,7 @@ export function WithFavorite() {
284
272
 
285
273
  #### Кнопка «Избранное» (hover)
286
274
 
287
- favorite.visibilityStrategy="hover" — кнопка появляется при наведении и фокусе на карточке.
275
+ actionsVisibility="hover" — действия появляются при наведении и фокусе на карточке.
288
276
 
289
277
  ```tsx
290
278
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
@@ -295,9 +283,9 @@ export function WithFavoriteHover() {
295
283
  <CardServiceLight
296
284
  title='Мой сервис'
297
285
  icon={<PlaceholderSVG size={24} />}
286
+ actionsVisibility={VISIBILITY_STRATEGY.hover}
298
287
  favorite={{
299
288
  enabled: true,
300
- visibilityStrategy: VISIBILITY_STRATEGY.hover,
301
289
  }}
302
290
  />
303
291
  );
@@ -319,7 +307,7 @@ export function Disabled() {
319
307
 
320
308
  #### Обработка клика
321
309
 
322
- onClick передаётся в корневой Card — карточка интерактивна по умолчанию.
310
+ onClick вызывается при клике по карточке.
323
311
 
324
312
  ```tsx
325
313
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
@@ -369,20 +357,245 @@ export function PolymorphicLink() {
369
357
 
370
358
  | Prop | Type | Default | Description |
371
359
  |------|------|---------|-------------|
360
+ | `actionsSize` | `"m"` \| `"s"` | — | Размер кнопок действий, для мобильного вида предполагается использовать `s` |
361
+ | `actionsVisibility` | `"always"` \| `"hover"` | `'hover'` | Формат отображения дополнительных действий: всегда или при наведении и фокусе |
372
362
  | `as` | `T` | — | Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. |
373
363
  | `className` | `string` | — | CSS-класс корневого элемента |
374
364
  | `data-test-id` | `string` | — | Support prop для тестов |
375
- | `disabled` | `boolean` | — | Неактивное состояние |
376
- | `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное». <br/> Keyboard: ArrowRight на карточке → фокус на Favourite; ArrowLeft на Favourite → фокус на карточку. |
365
+ | `disabled` | `boolean` | `false` | Неактивное состояние |
366
+ | `expandable` | `{ value: boolean; onClick(): void; }` | — | Настройки кнопки раскрытия |
367
+ | `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное». <br/> Keyboard: ArrowRight на карточке → tooltip (если есть) → Favorite; ArrowLeft — в обратном порядке. |
377
368
  | `icon` | `ReactElement<any, string \| JSXElementConstructor<any>>` | — | Иконка сервиса |
378
369
  | `innerRef` | `PolymorphicRef` \| `T` | — | Ref на реальный DOM-элемент / инстанс |
379
- | `onKeyDown` | `KeyboardEventHandler<HTMLElement>` | — | Колбэк нажатия клавиши клавиатуры на карточке |
380
- | `promoTag` | `PromoTagOwnProps` \| `PromoTagProps` | — | Настройки promo tag. При отсутствии не отображается |
370
+ | `promoTag` | `CardPromoTagProps` \| `PromoTagPredefinedBaseProps` | — | Настройки promo tag. При отсутствии не отображается |
381
371
  | `title` | `string` | — | Заголовок карточки |
372
+ | `tooltip` | `TooltipProps` | — | Подсказка с иконкой «?» рядом с заголовком |
382
373
  | `truncate` | `{ title?: number; }` | — | Настройки обрезки текста заголовка |
383
374
 
384
375
  ##### Related types
385
376
 
377
+ - `CardPromoTagProps` = `PromoTagPredefinedProps & { as?: never; innerRef?: never; }`
378
+
379
+ - `CardSize` = `"m"` \| `"s"`
380
+
381
+ **FavoriteProps**
382
+
383
+ | Prop | Type | Default | Description |
384
+ |------|------|---------|-------------|
385
+ | `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
386
+ | `enabled` | `boolean` | — | Включить отображение кнопки избранного |
387
+ | `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
388
+
389
+ - `VisibilityStrategy` = `"always"` \| `"hover"`
390
+
391
+ ### Видимость действий
392
+
393
+ Проп карточки `actionsVisibility` (`'hover'` по умолчанию) управляет всеми
394
+ действиями сразу — тултипом, избранным и кнопкой раскрытия.
395
+
396
+ ## CardServiceInfo
397
+
398
+ Карточка сервиса с описанием — иконка, заголовок, описание, promo tag и кнопка «Избранное».
399
+
400
+ Карточка сервиса с описанием: иконка + заголовок + описание + promo tag + кнопка «Избранное». Подробный вариант рядом с `CardServiceLight`.
401
+
402
+ ### Когда использовать
403
+
404
+ - Подробный режим списка сервисов (заголовок + описание).
405
+ - Когда `CardServiceLight` слишком компактен и нужно показать `description`.
406
+
407
+ ### Примеры использования
408
+
409
+ #### Базовый пример
410
+
411
+ Карточка с иконкой, заголовком и описанием.
412
+
413
+ ```tsx
414
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
415
+ import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
416
+
417
+ export function Basic() {
418
+ return (
419
+ <CardServiceInfo
420
+ title='Мой сервис'
421
+ description='Краткое описание сервиса для подробного режима карточки.'
422
+ icon={<PlaceholderSVG size={24} />}
423
+ />
424
+ );
425
+ }
426
+ ```
427
+
428
+ #### Promo tag
429
+
430
+ Через promoTag рядом с заголовком отображается промо-бейдж.
431
+
432
+ ```tsx
433
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
434
+ import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
435
+
436
+ export function WithPromoTag() {
437
+ return (
438
+ <CardServiceInfo
439
+ title='Мой сервис'
440
+ description='Краткое описание сервиса для подробного режима карточки.'
441
+ icon={<PlaceholderSVG size={24} />}
442
+ promoTag={{
443
+ variant: 'preview',
444
+ }}
445
+ />
446
+ );
447
+ }
448
+ ```
449
+
450
+ #### Кнопка «Избранное» (always)
451
+
452
+ actionsVisibility="always" — действия видны постоянно; favorite.checked и onChange задают controlled-режим избранного.
453
+
454
+ ```tsx
455
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
456
+ import { CardServiceInfo, VISIBILITY_STRATEGY } from '@cloud-ru/ds-uikit-product-card-predefined';
457
+ import { useState } from 'react';
458
+
459
+ export function WithFavorite() {
460
+ const [isFavorite, setIsFavorite] = useState(false);
461
+
462
+ return (
463
+ <CardServiceInfo
464
+ title='Мой сервис'
465
+ description='Краткое описание сервиса для подробного режима карточки.'
466
+ icon={<PlaceholderSVG size={24} />}
467
+ actionsVisibility={VISIBILITY_STRATEGY.always}
468
+ favorite={{
469
+ enabled: true,
470
+ checked: isFavorite,
471
+ onChange: setIsFavorite,
472
+ }}
473
+ />
474
+ );
475
+ }
476
+ ```
477
+
478
+ #### Кнопка «Избранное» (hover)
479
+
480
+ actionsVisibility="hover" — действия появляются при наведении и фокусе на карточке.
481
+
482
+ ```tsx
483
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
484
+ import { CardServiceInfo, VISIBILITY_STRATEGY } from '@cloud-ru/ds-uikit-product-card-predefined';
485
+
486
+ export function WithFavoriteHover() {
487
+ return (
488
+ <CardServiceInfo
489
+ title='Мой сервис'
490
+ description='Краткое описание сервиса для подробного режима карточки.'
491
+ icon={<PlaceholderSVG size={24} />}
492
+ actionsVisibility={VISIBILITY_STRATEGY.hover}
493
+ favorite={{
494
+ enabled: true,
495
+ }}
496
+ />
497
+ );
498
+ }
499
+ ```
500
+
501
+ #### Неактивное состояние
502
+
503
+ disabled блокирует взаимодействие с карточкой.
504
+
505
+ ```tsx
506
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
507
+ import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
508
+
509
+ export function Disabled() {
510
+ return (
511
+ <CardServiceInfo
512
+ title='Мой сервис'
513
+ description='Краткое описание сервиса для подробного режима карточки.'
514
+ icon={<PlaceholderSVG size={24} />}
515
+ disabled
516
+ />
517
+ );
518
+ }
519
+ ```
520
+
521
+ #### Обработка клика
522
+
523
+ onClick вызывается при клике по карточке.
524
+
525
+ ```tsx
526
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
527
+ import { Typography } from '@cloud-ru/ds-typography';
528
+ import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
529
+ import { useState } from 'react';
530
+
531
+ export function WithOnClick() {
532
+ const [clicks, setClicks] = useState(0);
533
+
534
+ return (
535
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
536
+ <CardServiceInfo
537
+ title='Мой сервис'
538
+ description='Краткое описание сервиса для подробного режима карточки.'
539
+ icon={<PlaceholderSVG size={24} />}
540
+ onClick={() => setClicks(c => c + 1)}
541
+ />
542
+
543
+ <Typography variant='body' size='m'>
544
+ Кликов по карточке: {clicks}
545
+ </Typography>
546
+ </div>
547
+ );
548
+ }
549
+ ```
550
+
551
+ #### Ссылка (polymorphic)
552
+
553
+ Через as и href карточка рендерится как якорь.
554
+
555
+ ```tsx
556
+ import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
557
+ import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
558
+
559
+ export function PolymorphicLink() {
560
+ return (
561
+ <CardServiceInfo
562
+ as='a'
563
+ href='https://cloud.ru'
564
+ target='_blank'
565
+ title='Ссылка-сервис'
566
+ description='Карточка рендерится как якорь через as и href.'
567
+ icon={<PlaceholderSVG size={24} />}
568
+ />
569
+ );
570
+ }
571
+ ```
572
+
573
+ ### Props
574
+
575
+ **CardServiceInfoProps**
576
+
577
+ | Prop | Type | Default | Description |
578
+ |------|------|---------|-------------|
579
+ | `actionsSize` | `"m"` \| `"s"` | `m` | Размер кнопок действий, для мобильного вида предполагается использовать `s` |
580
+ | `actionsVisibility` | `"always"` \| `"hover"` | `'hover'` | Формат отображения дополнительных действий: всегда или при наведении и фокусе |
581
+ | `as` | `T` | — | Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. |
582
+ | `className` | `string` | — | CSS-класс корневого элемента |
583
+ | `data-test-id` | `string` | — | Support prop для тестов |
584
+ | `description` | `string` | — | Описание сервиса |
585
+ | `disabled` | `boolean` | — | Неактивное состояние |
586
+ | `expandable` | `{ value: boolean; onClick(): void; }` | — | Настройки кнопки раскрытия |
587
+ | `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное». <br/> Keyboard: ArrowRight на карточке → Favorite → expand; ArrowLeft — в обратном порядке. |
588
+ | `icon` | `ReactElement<any, string \| JSXElementConstructor<any>>` | — | Иконка сервиса |
589
+ | `innerRef` | `PolymorphicRef` \| `T` | — | Ref на реальный DOM-элемент / инстанс |
590
+ | `promoTag` | `CardPromoTagProps` \| `PromoTagPredefinedBaseProps` | — | Настройки promo tag. При отсутствии не отображается |
591
+ | `title` | `string` | — | Заголовок карточки |
592
+
593
+ ##### Related types
594
+
595
+ - `CardPromoTagProps` = `PromoTagPredefinedProps & { as?: never; innerRef?: never; }`
596
+
597
+ - `CardSize` = `"m"` \| `"s"`
598
+
386
599
  **FavoriteProps**
387
600
 
388
601
  | Prop | Type | Default | Description |
@@ -390,7 +603,6 @@ export function PolymorphicLink() {
390
603
  | `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
391
604
  | `enabled` | `boolean` | — | Включить отображение кнопки избранного |
392
605
  | `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
393
- | `visibilityStrategy` | `"always"` \| `"hover"` | — | Формат отображения: всегда или при наведении и фокусе |
394
606
 
395
607
  - `VisibilityStrategy` = `"always"` \| `"hover"`
396
608
 
@@ -488,7 +700,7 @@ export function WithOutline() {
488
700
 
489
701
  #### Кнопка «Избранное» (always)
490
702
 
491
- favorite.visibilityStrategy="always" — кнопка видна постоянно; checked и onChange задают controlled-режим.
703
+ actionsVisibility="always" — кнопка видна постоянно; checked и onChange задают controlled-режим.
492
704
 
493
705
  ```tsx
494
706
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
@@ -502,9 +714,9 @@ export function WithFavorite() {
502
714
  <CardServiceSmall
503
715
  title='Название сервиса'
504
716
  emblem={{ icon: PlaceholderSVG }}
717
+ actionsVisibility={VISIBILITY_STRATEGY.always}
505
718
  favorite={{
506
719
  enabled: true,
507
- visibilityStrategy: VISIBILITY_STRATEGY.always,
508
720
  checked: isFavorite,
509
721
  onChange: setIsFavorite,
510
722
  }}
@@ -515,7 +727,7 @@ export function WithFavorite() {
515
727
 
516
728
  #### Кнопка «Избранное» (hover)
517
729
 
518
- favorite.visibilityStrategy="hover" — кнопка появляется при наведении и фокусе на карточке.
730
+ actionsVisibility="hover" — кнопка появляется при наведении и фокусе на карточке.
519
731
 
520
732
  ```tsx
521
733
  import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
@@ -526,10 +738,8 @@ export function WithFavoriteHover() {
526
738
  <CardServiceSmall
527
739
  title='Название сервиса'
528
740
  emblem={{ icon: PlaceholderSVG }}
529
- favorite={{
530
- enabled: true,
531
- visibilityStrategy: VISIBILITY_STRATEGY.hover,
532
- }}
741
+ actionsVisibility={VISIBILITY_STRATEGY.hover}
742
+ favorite={{ enabled: true }}
533
743
  />
534
744
  );
535
745
  }
@@ -604,13 +814,14 @@ export function PolymorphicLink() {
604
814
 
605
815
  | Prop | Type | Default | Description |
606
816
  |------|------|---------|-------------|
817
+ | `actionsVisibility` | `"always"` \| `"hover"` | `'hover'` | Формат отображения кнопки «Избранное»: всегда или при наведении и фокусе |
607
818
  | `as` | `T` | — | Полиморфный элемент: `'div'`, `'a'`, `{Link}` и т.д. |
608
819
  | `checked` | `boolean` | — | Выбранное состояние |
609
820
  | `className` | `string` | — | CSS-класс корневого элемента |
610
821
  | `data-test-id` | `string` | — | Support prop для тестов |
611
822
  | `disabled` | `boolean` | — | Неактивное состояние |
612
823
  | `emblem` | `ReactElement<any, string \| JSXElementConstructor<any>> \| { icon: JSXElementConstructor<{ className?: string \| undefined; size?: number \| undefined; }>; }` | — | Эмблема: объект с иконкой-компонентом. <br/> Принимает `{ icon: JSXElementConstructor }` или произвольный ReactElement. |
613
- | `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное». `visibilityStrategy` обязателен. |
824
+ | `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное» |
614
825
  | `innerRef` | `PolymorphicRef` \| `T` | — | Ref на реальный DOM-элемент / инстанс |
615
826
  | `outline` | `boolean` | — | Рамка вокруг карточки |
616
827
  | `promoBadge` | `PromoTagOwnProps` \| `PromoTagProps` | — | Промо-тег (бейдж). Тип — `PromoTagProps` из `@cloud-ru/ds-promo-tag`. |
@@ -626,10 +837,16 @@ export function PolymorphicLink() {
626
837
  | `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
627
838
  | `enabled` | `boolean` | — | Включить отображение кнопки избранного |
628
839
  | `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
629
- | `visibilityStrategy` | `"always"` \| `"hover"` | — | Формат отображения: всегда или при наведении и фокусе |
630
840
 
631
841
  - `VisibilityStrategy` = `"always"` \| `"hover"`
632
842
 
843
+ ### Видимость действий
844
+
845
+ Проп карточки `actionsVisibility` (`'hover'` по умолчанию) управляет всеми
846
+ действиями сразу — тултипом, избранным и кнопкой раскрытия.
847
+ пакета. `favorite.visibilityStrategy` устарел и оставлен для совместимости: если `actionsVisibility`
848
+ не задан, значение берётся из него.
849
+
633
850
  ## CardSuggest
634
851
 
635
852
  Карточка-подсказка с двумя размерами (m/s), управляющими типографикой и отступами.
@@ -0,0 +1,43 @@
1
+ import { PolymorphicRef } from '@cloud-ru/ds-card';
2
+ import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
3
+ import { CardActionsSurfaceProps } from '../../helperComponents';
4
+ import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
5
+ type BaseCardServiceInfoProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
6
+ /** Иконка сервиса */
7
+ icon?: ReactElement;
8
+ /** Заголовок карточки */
9
+ title: string;
10
+ /** Описание сервиса */
11
+ description: string;
12
+ /** Настройки promo tag. При отсутствии не отображается */
13
+ promoTag?: CardPromoTagProps;
14
+ /**
15
+ * Формат отображения дополнительных действий: всегда или при наведении и фокусе
16
+ * @default 'hover'
17
+ */
18
+ actionsVisibility?: VisibilityStrategy;
19
+ /**
20
+ * Настройки кнопки «Избранное».
21
+ * Keyboard: ArrowRight на карточке → Favorite → expand; ArrowLeft — в обратном порядке.
22
+ */
23
+ favorite?: FavoriteProps;
24
+ /** Неактивное состояние */
25
+ disabled?: boolean;
26
+ /** CSS-класс корневого элемента */
27
+ className?: string;
28
+ /** Support prop для тестов */
29
+ 'data-test-id'?: string;
30
+ /** Настройки кнопки раскрытия */
31
+ expandable?: {
32
+ value: boolean;
33
+ onClick(): void;
34
+ };
35
+ };
36
+ export type CardServiceInfoProps<T extends ElementType = 'button'> = BaseCardServiceInfoProps & {
37
+ /** Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. */
38
+ as?: T;
39
+ /** Ref на реальный DOM-элемент / инстанс */
40
+ innerRef?: PolymorphicRef<T>;
41
+ } & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardServiceInfoProps | 'as' | 'ref'>;
42
+ export declare function CardServiceInfo<T extends ElementType = 'button'>({ as, innerRef, icon, title, description, promoTag, actionsVisibility: actionsVisibilityProp, favorite, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceInfoProps<T>): ReactElement | null;
43
+ export {};
@@ -0,0 +1,66 @@
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.CardServiceInfo = CardServiceInfo;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const card_1 = require("@cloud-ru/ds-card");
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
+ function CardServiceInfo({ as, innerRef, icon, title, description, promoTag, actionsVisibility: actionsVisibilityProp, favorite, actionsSize = 'm', className, disabled, expandable, 'data-test-id': dataTestId, ...rest }) {
20
+ const cardRef = (0, react_1.useRef)(null);
21
+ const favoriteRef = (0, react_1.useRef)(null);
22
+ const expandButtonRef = (0, react_1.useRef)(null);
23
+ const promoTagTooltipTriggerRef = (0, react_1.useRef)(null);
24
+ const compactThemeClassName = (0, theme_1.useThemeClassnames)({ density: 'compact' });
25
+ const actionsVisibility = actionsVisibilityProp ?? constants_1.VISIBILITY_STRATEGY.hover;
26
+ const visibleActions = [favorite?.enabled, expandable].filter(Boolean);
27
+ const [isFavorite, setIsFavorite] = (0, utils_1.useValueControl)({
28
+ value: favorite?.checked,
29
+ defaultValue: false,
30
+ onChange: favorite?.onChange,
31
+ });
32
+ const tooltipTrigger = actionsVisibility === constants_1.VISIBILITY_STRATEGY.hover ? 'hoverAndFocusVisible' : 'click';
33
+ const { onKeyDown: onKeyDownProp, ...restWithoutKeyDown } = rest;
34
+ const handleKeyDown = (0, helperComponents_1.createCardActionsKeyDownHandler)({
35
+ disabled,
36
+ cardRef,
37
+ onKeyDown: onKeyDownProp,
38
+ items: [
39
+ promoTag && { ref: promoTagTooltipTriggerRef },
40
+ favorite?.enabled && {
41
+ ref: favoriteRef,
42
+ onActivate: () => setIsFavorite(!isFavorite),
43
+ },
44
+ expandable && {
45
+ ref: expandButtonRef,
46
+ onActivate: () => expandable.onClick(),
47
+ },
48
+ ],
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: (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.actions, favorite: favorite?.enabled
51
+ ? {
52
+ enabled: favorite.enabled,
53
+ checked: isFavorite,
54
+ onChange: setIsFavorite,
55
+ buttonRef: favoriteRef,
56
+ 'data-test-id': constants_1.TEST_IDS.cardServiceInfoFavorite,
57
+ }
58
+ : undefined, expandable: expandable
59
+ ? {
60
+ value: expandable.value,
61
+ onClick: expandable.onClick,
62
+ buttonRef: expandButtonRef,
63
+ }
64
+ : undefined })] }), (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.cardServiceInfoDescription, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: description, maxLines: 2, variant: 'end' }) })] })] }) }));
65
+ }
66
+ (0, utils_1.withInnerRefSupport)(CardServiceInfo);
@@ -0,0 +1 @@
1
+ export * from './CardServiceInfo';
@@ -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("./CardServiceInfo"), exports);
@@ -0,0 +1,102 @@
1
+ .actions{
2
+ --card-actions-surface-inset-top:var(--sn-primitive-dimension-4, 4px);
3
+ --card-actions-surface-inset-right:var(--sn-primitive-dimension-4, 4px);
4
+ }
5
+
6
+ .titleContainer{
7
+ display:flex;
8
+ gap:var(--sn-primitive-dimension-4, 4px);
9
+ align-items:center;
10
+ width:100%;
11
+ min-width:0;
12
+ }
13
+ .titleContainer[data-actions-visibility=always][data-actions-size=s][data-visible-actions="1"]{
14
+ padding-right:calc(1 * var(--sn-button-anatomy-size-s-container-iconOnly-minWidth, var(--sn-density-size-s, var(--sn-primitive-dimension-48, 48px))));
15
+ }
16
+ .titleContainer[data-actions-visibility=always][data-actions-size=s][data-visible-actions="2"]{
17
+ padding-right:calc(2 * var(--sn-button-anatomy-size-s-container-iconOnly-minWidth, var(--sn-density-size-s, var(--sn-primitive-dimension-48, 48px))));
18
+ }
19
+ .titleContainer[data-actions-visibility=always][data-actions-size=m][data-visible-actions="1"]{
20
+ padding-right:calc(1 * var(--sn-button-anatomy-size-m-container-iconOnly-minWidth, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px))));
21
+ }
22
+ .titleContainer[data-actions-visibility=always][data-actions-size=m][data-visible-actions="2"]{
23
+ padding-right:calc(2 * var(--sn-button-anatomy-size-m-container-iconOnly-minWidth, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px))));
24
+ }
25
+
26
+ .root{
27
+ cursor:pointer;
28
+ position:relative;
29
+ box-sizing:border-box;
30
+ width:100%;
31
+ padding:0;
32
+ border:none;
33
+ font:inherit;
34
+ color:inherit;
35
+ text-decoration:none;
36
+ background-color:transparent;
37
+ outline:none;
38
+ }
39
+ .root:hover .actions, .root:focus-visible .actions, .root:has(*:focus-visible) .actions{
40
+ transform:translateX(0);
41
+ visibility:visible;
42
+ }
43
+ .root:hover .titleContainer[data-actions-size=s][data-visible-actions="1"], .root:focus-visible .titleContainer[data-actions-size=s][data-visible-actions="1"], .root:has(*:focus-visible) .titleContainer[data-actions-size=s][data-visible-actions="1"]{
44
+ padding-right:calc(1 * var(--sn-button-anatomy-size-s-container-iconOnly-minWidth, var(--sn-density-size-s, var(--sn-primitive-dimension-48, 48px))));
45
+ }
46
+ .root:hover .titleContainer[data-actions-size=s][data-visible-actions="2"], .root:focus-visible .titleContainer[data-actions-size=s][data-visible-actions="2"], .root:has(*:focus-visible) .titleContainer[data-actions-size=s][data-visible-actions="2"]{
47
+ padding-right:calc(2 * var(--sn-button-anatomy-size-s-container-iconOnly-minWidth, var(--sn-density-size-s, var(--sn-primitive-dimension-48, 48px))));
48
+ }
49
+ .root:hover .titleContainer[data-actions-size=m][data-visible-actions="1"], .root:focus-visible .titleContainer[data-actions-size=m][data-visible-actions="1"], .root:has(*:focus-visible) .titleContainer[data-actions-size=m][data-visible-actions="1"]{
50
+ padding-right:calc(1 * var(--sn-button-anatomy-size-m-container-iconOnly-minWidth, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px))));
51
+ }
52
+ .root:hover .titleContainer[data-actions-size=m][data-visible-actions="2"], .root:focus-visible .titleContainer[data-actions-size=m][data-visible-actions="2"], .root:has(*:focus-visible) .titleContainer[data-actions-size=m][data-visible-actions="2"]{
53
+ padding-right:calc(2 * var(--sn-button-anatomy-size-m-container-iconOnly-minWidth, var(--sn-density-size-m, var(--sn-primitive-dimension-56, 56px))));
54
+ }
55
+
56
+ .container{
57
+ display:flex;
58
+ gap:var(--sn-primitive-dimension-4, 4px);
59
+ align-items:flex-start;
60
+ box-sizing:border-box;
61
+ width:100%;
62
+ min-width:0;
63
+ padding:var(--sn-density-spacing-interval-s, var(--sn-primitive-dimension-8, 8px));
64
+ }
65
+
66
+ .icon{
67
+ flex-shrink:0;
68
+ width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
69
+ height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
70
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
71
+ }
72
+
73
+ .textContent{
74
+ display:flex;
75
+ flex:1;
76
+ flex-direction:column;
77
+ align-items:flex-start;
78
+ min-width:0;
79
+ text-align:left;
80
+ }
81
+
82
+ .titleRow{
83
+ display:flex;
84
+ gap:var(--sn-primitive-dimension-4, 4px);
85
+ align-items:center;
86
+ justify-content:space-between;
87
+ width:100%;
88
+ min-height:var(--sn-primitive-dimension-24, 24px);
89
+ }
90
+
91
+ .title{
92
+ overflow:hidden;
93
+ display:block;
94
+ flex-shrink:1;
95
+ min-width:0;
96
+ color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
97
+ }
98
+
99
+ .description{
100
+ width:100%;
101
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
102
+ }