@cloud-ru/ds-uikit-product-card-predefined 1.0.1 → 1.0.2-preview-7665e9c3.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/README.md +224 -28
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
- package/dist/cjs/components/CardServiceInfo/CardServiceInfo.js +70 -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 +95 -0
- package/dist/cjs/components/CardServiceLight/CardServiceLight.d.ts +22 -11
- package/dist/cjs/components/CardServiceLight/CardServiceLight.js +92 -31
- package/dist/cjs/components/CardServiceLight/styles.module.css +30 -25
- package/dist/cjs/components/CardServiceSmall/CardServiceSmall.js +5 -1
- 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 +34 -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 +23 -0
- package/dist/cjs/helperComponents/CardActionsSurface/utils.js +45 -0
- package/dist/cjs/helperComponents/index.d.ts +1 -0
- package/dist/cjs/helperComponents/index.js +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/style.css +156 -20
- package/dist/cjs/types.d.ts +0 -5
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.d.ts +43 -0
- package/dist/esm/components/CardServiceInfo/CardServiceInfo.js +64 -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 +95 -0
- package/dist/esm/components/CardServiceLight/CardServiceLight.d.ts +22 -11
- package/dist/esm/components/CardServiceLight/CardServiceLight.js +95 -34
- package/dist/esm/components/CardServiceLight/styles.module.css +30 -25
- package/dist/esm/components/CardServiceSmall/CardServiceSmall.js +6 -2
- 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 +28 -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 +23 -0
- package/dist/esm/helperComponents/CardActionsSurface/utils.js +42 -0
- package/dist/esm/helperComponents/index.d.ts +1 -0
- package/dist/esm/helperComponents/index.js +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/style.css +156 -20
- package/dist/esm/types.d.ts +0 -5
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +15 -12
- package/src/components/CardServiceInfo/CardServiceInfo.tsx +202 -0
- package/src/components/CardServiceInfo/index.ts +1 -0
- package/src/components/CardServiceInfo/styles.module.scss +122 -0
- package/src/components/CardServiceLight/CardServiceLight.tsx +161 -80
- package/src/components/CardServiceLight/styles.module.scss +37 -33
- package/src/components/CardServiceSmall/CardServiceSmall.tsx +6 -2
- package/src/components/index.ts +1 -0
- package/src/constants.ts +10 -0
- package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +123 -0
- package/src/helperComponents/CardActionsSurface/index.ts +2 -0
- package/src/helperComponents/CardActionsSurface/styles.module.scss +48 -0
- package/src/helperComponents/CardActionsSurface/utils.ts +79 -0
- package/src/helperComponents/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/types.ts +0 -5
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
|
-
|
|
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
|
-
|
|
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
|
|
310
|
+
onClick вызывается при клике по карточке.
|
|
323
311
|
|
|
324
312
|
```tsx
|
|
325
313
|
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
@@ -369,16 +357,19 @@ 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
|
-
| `
|
|
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
|
-
| `
|
|
380
|
-
| `promoTag` | `PromoTagOwnProps` \| `PromoTagProps` | — | Настройки promo tag. При отсутствии не отображается |
|
|
370
|
+
| `promoTag` | `PromoTagPredefinedBaseProps` \| `PromoTagPredefinedProps` | — | Настройки promo tag. При отсутствии не отображается |
|
|
381
371
|
| `title` | `string` | — | Заголовок карточки |
|
|
372
|
+
| `tooltip` | `TooltipProps` | — | Подсказка с иконкой «?» рядом с заголовком |
|
|
382
373
|
| `truncate` | `{ title?: number; }` | — | Настройки обрезки текста заголовка |
|
|
383
374
|
|
|
384
375
|
##### Related types
|
|
@@ -390,7 +381,215 @@ export function PolymorphicLink() {
|
|
|
390
381
|
| `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
|
|
391
382
|
| `enabled` | `boolean` | — | Включить отображение кнопки избранного |
|
|
392
383
|
| `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
|
|
393
|
-
|
|
384
|
+
|
|
385
|
+
- `VisibilityStrategy` = `"always"` \| `"hover"`
|
|
386
|
+
|
|
387
|
+
## CardServiceInfo
|
|
388
|
+
|
|
389
|
+
Карточка сервиса с описанием — иконка, заголовок, описание, promo tag и кнопка «Избранное».
|
|
390
|
+
|
|
391
|
+
Карточка сервиса с описанием: иконка + заголовок + описание + promo tag + кнопка «Избранное». Подробный вариант рядом с `CardServiceLight`.
|
|
392
|
+
|
|
393
|
+
### Когда использовать
|
|
394
|
+
|
|
395
|
+
- Подробный режим списка сервисов (заголовок + описание).
|
|
396
|
+
- Когда `CardServiceLight` слишком компактен и нужно показать `description`.
|
|
397
|
+
|
|
398
|
+
### Примеры использования
|
|
399
|
+
|
|
400
|
+
#### Базовый пример
|
|
401
|
+
|
|
402
|
+
Карточка с иконкой, заголовком и описанием.
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
406
|
+
import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
407
|
+
|
|
408
|
+
export function Basic() {
|
|
409
|
+
return (
|
|
410
|
+
<CardServiceInfo
|
|
411
|
+
title='Мой сервис'
|
|
412
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
413
|
+
icon={<PlaceholderSVG size={24} />}
|
|
414
|
+
/>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
#### Promo tag
|
|
420
|
+
|
|
421
|
+
Через promoTag рядом с заголовком отображается промо-бейдж.
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
425
|
+
import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
426
|
+
|
|
427
|
+
export function WithPromoTag() {
|
|
428
|
+
return (
|
|
429
|
+
<CardServiceInfo
|
|
430
|
+
title='Мой сервис'
|
|
431
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
432
|
+
icon={<PlaceholderSVG size={24} />}
|
|
433
|
+
promoTag={{
|
|
434
|
+
variant: 'preview',
|
|
435
|
+
}}
|
|
436
|
+
/>
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
#### Кнопка «Избранное» (always)
|
|
442
|
+
|
|
443
|
+
actionsVisibility="always" — действия видны постоянно; favorite.checked и onChange задают controlled-режим избранного.
|
|
444
|
+
|
|
445
|
+
```tsx
|
|
446
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
447
|
+
import { CardServiceInfo, VISIBILITY_STRATEGY } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
448
|
+
import { useState } from 'react';
|
|
449
|
+
|
|
450
|
+
export function WithFavorite() {
|
|
451
|
+
const [isFavorite, setIsFavorite] = useState(false);
|
|
452
|
+
|
|
453
|
+
return (
|
|
454
|
+
<CardServiceInfo
|
|
455
|
+
title='Мой сервис'
|
|
456
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
457
|
+
icon={<PlaceholderSVG size={24} />}
|
|
458
|
+
actionsVisibility={VISIBILITY_STRATEGY.always}
|
|
459
|
+
favorite={{
|
|
460
|
+
enabled: true,
|
|
461
|
+
checked: isFavorite,
|
|
462
|
+
onChange: setIsFavorite,
|
|
463
|
+
}}
|
|
464
|
+
/>
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### Кнопка «Избранное» (hover)
|
|
470
|
+
|
|
471
|
+
actionsVisibility="hover" — действия появляются при наведении и фокусе на карточке.
|
|
472
|
+
|
|
473
|
+
```tsx
|
|
474
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
475
|
+
import { CardServiceInfo, VISIBILITY_STRATEGY } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
476
|
+
|
|
477
|
+
export function WithFavoriteHover() {
|
|
478
|
+
return (
|
|
479
|
+
<CardServiceInfo
|
|
480
|
+
title='Мой сервис'
|
|
481
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
482
|
+
icon={<PlaceholderSVG size={24} />}
|
|
483
|
+
actionsVisibility={VISIBILITY_STRATEGY.hover}
|
|
484
|
+
favorite={{
|
|
485
|
+
enabled: true,
|
|
486
|
+
}}
|
|
487
|
+
/>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
#### Неактивное состояние
|
|
493
|
+
|
|
494
|
+
disabled блокирует взаимодействие с карточкой.
|
|
495
|
+
|
|
496
|
+
```tsx
|
|
497
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
498
|
+
import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
499
|
+
|
|
500
|
+
export function Disabled() {
|
|
501
|
+
return (
|
|
502
|
+
<CardServiceInfo
|
|
503
|
+
title='Мой сервис'
|
|
504
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
505
|
+
icon={<PlaceholderSVG size={24} />}
|
|
506
|
+
disabled
|
|
507
|
+
/>
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
#### Обработка клика
|
|
513
|
+
|
|
514
|
+
onClick вызывается при клике по карточке.
|
|
515
|
+
|
|
516
|
+
```tsx
|
|
517
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
518
|
+
import { Typography } from '@cloud-ru/ds-typography';
|
|
519
|
+
import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
520
|
+
import { useState } from 'react';
|
|
521
|
+
|
|
522
|
+
export function WithOnClick() {
|
|
523
|
+
const [clicks, setClicks] = useState(0);
|
|
524
|
+
|
|
525
|
+
return (
|
|
526
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
527
|
+
<CardServiceInfo
|
|
528
|
+
title='Мой сервис'
|
|
529
|
+
description='Краткое описание сервиса для подробного режима карточки.'
|
|
530
|
+
icon={<PlaceholderSVG size={24} />}
|
|
531
|
+
onClick={() => setClicks(c => c + 1)}
|
|
532
|
+
/>
|
|
533
|
+
|
|
534
|
+
<Typography variant='body' size='m'>
|
|
535
|
+
Кликов по карточке: {clicks}
|
|
536
|
+
</Typography>
|
|
537
|
+
</div>
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### Ссылка (polymorphic)
|
|
543
|
+
|
|
544
|
+
Через as и href карточка рендерится как якорь.
|
|
545
|
+
|
|
546
|
+
```tsx
|
|
547
|
+
import { PlaceholderSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
548
|
+
import { CardServiceInfo } from '@cloud-ru/ds-uikit-product-card-predefined';
|
|
549
|
+
|
|
550
|
+
export function PolymorphicLink() {
|
|
551
|
+
return (
|
|
552
|
+
<CardServiceInfo
|
|
553
|
+
as='a'
|
|
554
|
+
href='https://cloud.ru'
|
|
555
|
+
target='_blank'
|
|
556
|
+
title='Ссылка-сервис'
|
|
557
|
+
description='Карточка рендерится как якорь через as и href.'
|
|
558
|
+
icon={<PlaceholderSVG size={24} />}
|
|
559
|
+
/>
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### Props
|
|
565
|
+
|
|
566
|
+
**CardServiceInfoProps**
|
|
567
|
+
|
|
568
|
+
| Prop | Type | Default | Description |
|
|
569
|
+
|------|------|---------|-------------|
|
|
570
|
+
| `actionsSize` | `"m"` \| `"s"` | — | Размер кнопок действий, для мобильного вида предполагается использовать `s` |
|
|
571
|
+
| `actionsVisibility` | `"always"` \| `"hover"` | `hover` | Формат отображения дополнительных действий: всегда или при наведении и фокусе |
|
|
572
|
+
| `as` | `T` | — | Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. |
|
|
573
|
+
| `className` | `string` | — | CSS-класс корневого элемента |
|
|
574
|
+
| `data-test-id` | `string` | — | Support prop для тестов |
|
|
575
|
+
| `description` | `string` | — | Описание сервиса |
|
|
576
|
+
| `disabled` | `boolean` | — | Неактивное состояние |
|
|
577
|
+
| `expandable` | `{ value: boolean; onClick(): void; }` | — | |
|
|
578
|
+
| `favorite` | `FavoriteProps` | — | Настройки кнопки «Избранное». <br/> Keyboard: ArrowRight на карточке → Favorite → expand; ArrowLeft — в обратном порядке. |
|
|
579
|
+
| `icon` | `ReactElement<any, string \| JSXElementConstructor<any>>` | — | Иконка сервиса |
|
|
580
|
+
| `innerRef` | `PolymorphicRef` \| `T` | — | Ref на реальный DOM-элемент / инстанс |
|
|
581
|
+
| `promoTag` | `PromoTagPredefinedBaseProps` \| `PromoTagPredefinedProps` | — | Настройки promo tag. При отсутствии не отображается |
|
|
582
|
+
| `title` | `string` | — | Заголовок карточки |
|
|
583
|
+
|
|
584
|
+
##### Related types
|
|
585
|
+
|
|
586
|
+
**FavoriteProps**
|
|
587
|
+
|
|
588
|
+
| Prop | Type | Default | Description |
|
|
589
|
+
|------|------|---------|-------------|
|
|
590
|
+
| `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
|
|
591
|
+
| `enabled` | `boolean` | — | Включить отображение кнопки избранного |
|
|
592
|
+
| `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
|
|
394
593
|
|
|
395
594
|
- `VisibilityStrategy` = `"always"` \| `"hover"`
|
|
396
595
|
|
|
@@ -626,9 +825,6 @@ export function PolymorphicLink() {
|
|
|
626
825
|
| `checked` | `boolean \| undefined` | — | Состояние избранного (controlled) |
|
|
627
826
|
| `enabled` | `boolean` | — | Включить отображение кнопки избранного |
|
|
628
827
|
| `onChange` | `((value: boolean) => void) \| undefined` | — | Колбэк изменения состояния избранного |
|
|
629
|
-
| `visibilityStrategy` | `"always"` \| `"hover"` | — | Формат отображения: всегда или при наведении и фокусе |
|
|
630
|
-
|
|
631
|
-
- `VisibilityStrategy` = `"always"` \| `"hover"`
|
|
632
828
|
|
|
633
829
|
## CardSuggest
|
|
634
830
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
|
+
import { PromoTagPredefinedProps } from '@cloud-ru/ds-uikit-product-promo-tag-predefined';
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
|
|
4
|
+
import { CardActionsSurfaceProps } from '../../helperComponents';
|
|
5
|
+
import { FavoriteProps, VisibilityStrategy } from '../../types';
|
|
6
|
+
type BaseCardServiceInfoProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
|
|
7
|
+
/** Иконка сервиса */
|
|
8
|
+
icon?: ReactElement;
|
|
9
|
+
/** Заголовок карточки */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Описание сервиса */
|
|
12
|
+
description: string;
|
|
13
|
+
/** Настройки promo tag. При отсутствии не отображается */
|
|
14
|
+
promoTag?: Omit<PromoTagPredefinedProps, 'trigger' | 'as' | 'innerRef'>;
|
|
15
|
+
/**
|
|
16
|
+
* Формат отображения дополнительных действий: всегда или при наведении и фокусе
|
|
17
|
+
* @default 'hover'
|
|
18
|
+
*/
|
|
19
|
+
actionsVisibility?: VisibilityStrategy;
|
|
20
|
+
/**
|
|
21
|
+
* Настройки кнопки «Избранное».
|
|
22
|
+
* Keyboard: ArrowRight на карточке → Favorite → expand; ArrowLeft — в обратном порядке.
|
|
23
|
+
*/
|
|
24
|
+
favorite?: FavoriteProps;
|
|
25
|
+
/** Неактивное состояние */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** CSS-класс корневого элемента */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** Support prop для тестов */
|
|
30
|
+
'data-test-id'?: string;
|
|
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, favorite, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceInfoProps<T>): ReactElement | null;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 uikit_product_promo_tag_predefined_1 = require("@cloud-ru/ds-uikit-product-promo-tag-predefined");
|
|
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
|
+
function CardServiceInfo({ as, innerRef, icon, title, description, promoTag, actionsVisibility = constants_1.VISIBILITY_STRATEGY.hover, favorite, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }) {
|
|
21
|
+
const cardRef = (0, react_1.useRef)(null);
|
|
22
|
+
const favoriteRef = (0, react_1.useRef)(null);
|
|
23
|
+
const expandButtonRef = (0, react_1.useRef)(null);
|
|
24
|
+
const promoTagTooltipTriggerRef = (0, react_1.useRef)(null);
|
|
25
|
+
const compactThemeClassName = (0, theme_1.useThemeClassnames)({ density: 'compact' });
|
|
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-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)(uikit_product_promo_tag_predefined_1.PromoTagPredefined, { ...promoTag, variant: promoTag.variant, as: 'span', tabIndex: -1, tooltip: {
|
|
51
|
+
...promoTag.tooltip,
|
|
52
|
+
trigger: tooltipTrigger,
|
|
53
|
+
'data-test-id': constants_1.TEST_IDS.cardServiceInfoPromoTagTooltip,
|
|
54
|
+
}, 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, visibilityStrategy: actionsVisibility, className: styles_module_scss_1.default.actions, favorite: favorite?.enabled
|
|
55
|
+
? {
|
|
56
|
+
enabled: favorite.enabled,
|
|
57
|
+
checked: isFavorite,
|
|
58
|
+
onChange: setIsFavorite,
|
|
59
|
+
buttonRef: favoriteRef,
|
|
60
|
+
'data-test-id': constants_1.TEST_IDS.cardServiceInfoFavorite,
|
|
61
|
+
}
|
|
62
|
+
: undefined, expandable: expandable
|
|
63
|
+
? {
|
|
64
|
+
value: expandable.value,
|
|
65
|
+
onClick: expandable.onClick,
|
|
66
|
+
buttonRef: expandButtonRef,
|
|
67
|
+
}
|
|
68
|
+
: 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' }) })] })] }) }));
|
|
69
|
+
}
|
|
70
|
+
(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,95 @@
|
|
|
1
|
+
.actions{
|
|
2
|
+
position:absolute;
|
|
3
|
+
top:var(--sn-primitive-dimension-4, 4px);
|
|
4
|
+
right:var(--sn-primitive-dimension-4, 4px);
|
|
5
|
+
}
|
|
6
|
+
.actions[data-visibility-strategy=hover]{
|
|
7
|
+
top:var(--sn-primitive-dimension-4, 4px);
|
|
8
|
+
right:var(--sn-primitive-dimension-4, 4px);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.titleContainer{
|
|
12
|
+
display:flex;
|
|
13
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
14
|
+
align-items:center;
|
|
15
|
+
width:100%;
|
|
16
|
+
min-width:0;
|
|
17
|
+
}
|
|
18
|
+
.titleContainer[data-actions-visibility=always][data-visible-actions="1"]{
|
|
19
|
+
padding-right:var(--sn-primitive-dimension-32, 32px);
|
|
20
|
+
}
|
|
21
|
+
.titleContainer[data-actions-visibility=always][data-visible-actions="2"]{
|
|
22
|
+
padding-right:var(--sn-primitive-dimension-64, 64px);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.root{
|
|
26
|
+
cursor:pointer;
|
|
27
|
+
position:relative;
|
|
28
|
+
box-sizing:border-box;
|
|
29
|
+
width:100%;
|
|
30
|
+
padding:0;
|
|
31
|
+
border:none;
|
|
32
|
+
font:inherit;
|
|
33
|
+
color:inherit;
|
|
34
|
+
text-decoration:none;
|
|
35
|
+
background-color:transparent;
|
|
36
|
+
outline:none;
|
|
37
|
+
}
|
|
38
|
+
.root:hover .actions, .root:focus-visible .actions, .root:has(*:focus-visible) .actions{
|
|
39
|
+
transform:translateX(0);
|
|
40
|
+
visibility:visible;
|
|
41
|
+
}
|
|
42
|
+
.root:hover .titleContainer[data-visible-actions="1"], .root:focus-visible .titleContainer[data-visible-actions="1"], .root:has(*:focus-visible) .titleContainer[data-visible-actions="1"]{
|
|
43
|
+
padding-right:var(--sn-primitive-dimension-32, 32px);
|
|
44
|
+
}
|
|
45
|
+
.root:hover .titleContainer[data-visible-actions="2"], .root:focus-visible .titleContainer[data-visible-actions="2"], .root:has(*:focus-visible) .titleContainer[data-visible-actions="2"]{
|
|
46
|
+
padding-right:var(--sn-primitive-dimension-64, 64px);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.container{
|
|
50
|
+
display:flex;
|
|
51
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
52
|
+
align-items:flex-start;
|
|
53
|
+
box-sizing:border-box;
|
|
54
|
+
width:100%;
|
|
55
|
+
min-width:0;
|
|
56
|
+
padding:var(--sn-density-spacing-interval-s, var(--sn-primitive-dimension-8, 8px));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.icon{
|
|
60
|
+
flex-shrink:0;
|
|
61
|
+
width:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
62
|
+
height:var(--sn-density-size-icon-s, var(--sn-primitive-dimension-24, 24px));
|
|
63
|
+
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.textContent{
|
|
67
|
+
display:flex;
|
|
68
|
+
flex:1;
|
|
69
|
+
flex-direction:column;
|
|
70
|
+
align-items:flex-start;
|
|
71
|
+
min-width:0;
|
|
72
|
+
text-align:left;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.titleRow{
|
|
76
|
+
display:flex;
|
|
77
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
78
|
+
align-items:center;
|
|
79
|
+
justify-content:space-between;
|
|
80
|
+
width:100%;
|
|
81
|
+
min-height:var(--sn-primitive-dimension-24, 24px);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.title{
|
|
85
|
+
overflow:hidden;
|
|
86
|
+
display:block;
|
|
87
|
+
flex-shrink:1;
|
|
88
|
+
min-width:0;
|
|
89
|
+
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #41424e));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.description{
|
|
93
|
+
width:100%;
|
|
94
|
+
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
95
|
+
}
|
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
3
|
+
import { PromoTagPredefinedProps } from '@cloud-ru/ds-uikit-product-promo-tag-predefined';
|
|
4
|
+
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
|
|
5
|
+
import { CardActionsSurfaceProps } from '../../helperComponents';
|
|
6
|
+
import { FavoriteProps, VisibilityStrategy } from '../../types';
|
|
7
|
+
type BaseCardServiceLightProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
|
|
6
8
|
/** Иконка сервиса */
|
|
7
9
|
icon?: ReactElement;
|
|
8
10
|
/** Заголовок карточки */
|
|
9
11
|
title: string;
|
|
10
12
|
/** Настройки promo tag. При отсутствии не отображается */
|
|
11
|
-
promoTag?:
|
|
13
|
+
promoTag?: Omit<PromoTagPredefinedProps, 'trigger' | 'as' | 'innerRef'>;
|
|
12
14
|
/** Настройки обрезки текста заголовка */
|
|
13
15
|
truncate?: {
|
|
14
16
|
/** Максимальное количество строк заголовка */
|
|
15
17
|
title?: number;
|
|
16
18
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Формат отображения дополнительных действий: всегда или при наведении и фокусе
|
|
21
|
+
* @default 'hover'
|
|
22
|
+
*/
|
|
23
|
+
actionsVisibility?: VisibilityStrategy;
|
|
24
|
+
/** Подсказка с иконкой «?» рядом с заголовком */
|
|
25
|
+
tooltip?: Omit<TooltipProps, 'trigger' | 'size'>;
|
|
19
26
|
/**
|
|
20
27
|
* Настройки кнопки «Избранное».
|
|
21
|
-
* Keyboard: ArrowRight на карточке →
|
|
28
|
+
* Keyboard: ArrowRight на карточке → tooltip (если есть) → Favorite; ArrowLeft — в обратном порядке.
|
|
22
29
|
*/
|
|
23
30
|
favorite?: FavoriteProps;
|
|
24
|
-
/**
|
|
25
|
-
|
|
31
|
+
/** Неактивное состояние */
|
|
32
|
+
disabled?: boolean;
|
|
26
33
|
/** CSS-класс корневого элемента */
|
|
27
34
|
className?: string;
|
|
28
35
|
/** Support prop для тестов */
|
|
29
36
|
'data-test-id'?: string;
|
|
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, favorite, tooltip, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
|
|
38
49
|
export {};
|