@cloud-ru/ds-uikit-product-card-predefined 2.0.3-preview-6d260fa4.0 → 2.0.3-preview-3405f207.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 CHANGED
@@ -357,7 +357,6 @@ export function PolymorphicLink() {
357
357
 
358
358
  | Prop | Type | Default | Description |
359
359
  |------|------|---------|-------------|
360
- | `actionsSize` | `"m"` \| `"s"` | — | Размер кнопок действий, для мобильного вида предполагается использовать `s` |
361
360
  | `actionsVisibility` | `"always"` \| `"hover"` | `'hover'` | Формат отображения дополнительных действий: всегда или при наведении и фокусе |
362
361
  | `as` | `ElementType` | — | Полиморфный элемент: `'button'`, `'a'`, `{Link}` и т.д. |
363
362
  | `className` | `string` | — | CSS-класс корневого элемента |
@@ -376,8 +375,6 @@ export function PolymorphicLink() {
376
375
 
377
376
  - `CardPromoTagProps` = `PromoTagPredefinedProps & { as?: never; innerRef?: never; }`
378
377
 
379
- - `CardSize` = `"m"` \| `"s"`
380
-
381
378
  **FavoriteProps**
382
379
 
383
380
  | Prop | Type | Default | Description |
@@ -393,6 +390,16 @@ export function PolymorphicLink() {
393
390
  Проп карточки `actionsVisibility` (`'hover'` по умолчанию) управляет всеми
394
391
  действиями сразу — тултипом, избранным и кнопкой раскрытия.
395
392
 
393
+ ### Адаптивность
394
+
395
+ Desktop-first: раскладку берёт `AdaptiveProvider`. На mobile:
396
+
397
+ - у внутреннего `.container` ставится `data-mobile` — `min-height` 40 вместо 32;
398
+ - кнопки действий рендерятся с размером `s` вместо `m`.
399
+
400
+ Отдельного пропа раскладки нет; форс — toolbar-global `layoutType` / вложенный
401
+ `AdaptiveProvider` / `withLayoutType`.
402
+
396
403
  ## CardServiceInfo
397
404
 
398
405
  Карточка сервиса с описанием — иконка, заголовок, описание, promo tag и кнопка «Избранное».
@@ -1,9 +1,8 @@
1
1
  import { PolymorphicRef } from '@cloud-ru/ds-card';
2
2
  import { TooltipProps } from '@cloud-ru/ds-tooltip';
3
3
  import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
4
- import { CardActionsSurfaceProps } from '../../helperComponents';
5
4
  import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
6
- type BaseCardServiceLightProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
5
+ type BaseCardServiceLightProps = {
7
6
  /** Иконка сервиса */
8
7
  icon?: ReactElement;
9
8
  /** Заголовок карточки */
@@ -45,5 +44,5 @@ export type CardServiceLightProps<T extends ElementType = 'button'> = BaseCardSe
45
44
  /** Ref на реальный DOM-элемент / инстанс */
46
45
  innerRef?: PolymorphicRef<T>;
47
46
  } & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardServiceLightProps | 'as' | 'ref'>;
48
- export declare function CardServiceLight<T extends ElementType = 'button'>({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
47
+ export declare function CardServiceLight<T extends ElementType = 'button'>({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
49
48
  export {};
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CardServiceLight = CardServiceLight;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const adaptive_1 = require("@cloud-ru/ds-adaptive");
8
9
  const theme_1 = require("@cloud-ru/ds-theme");
9
10
  const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
10
11
  const typography_1 = require("@cloud-ru/ds-typography");
@@ -16,7 +17,9 @@ const constants_1 = require("../../constants");
16
17
  const helperComponents_1 = require("../../helperComponents");
17
18
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
18
19
  const TARGET_BLANK = '_blank';
19
- function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
20
+ function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
21
+ const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
22
+ const isMobile = (0, adaptive_1.isMobileLayout)(layoutType);
20
23
  const Component = as ?? 'button';
21
24
  const cardRef = (0, react_1.useRef)(null);
22
25
  const tooltipTriggerRef = (0, react_1.useRef)(null);
@@ -88,7 +91,7 @@ function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actio
88
91
  : onClick,
89
92
  };
90
93
  }
91
- return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.outlineBorder, "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceLightTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceLightPromoTag, className: (0, classnames_1.default)(styles_module_scss_1.default.promoTag, compactThemeClassName) }))] })] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, tooltip: tooltip
94
+ return ((0, jsx_runtime_1.jsxs)(Component, { ref: (0, merge_refs_1.default)(innerRef, cardRef), className: (0, classnames_1.default)(styles_module_scss_1.default.root, className), "data-test-id": dataTestId ?? constants_1.TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.outlineBorder, "aria-hidden": true }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, "data-mobile": isMobile || undefined, children: [icon && (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.icon, children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { as: 'span', variant: 'body', size: 'm', className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.cardServiceLightTitle, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && ((0, jsx_runtime_1.jsx)(helperComponents_1.CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": constants_1.TEST_IDS.cardServiceLightPromoTag, className: (0, classnames_1.default)(styles_module_scss_1.default.promoTag, compactThemeClassName) }))] })] }), (0, jsx_runtime_1.jsx)(helperComponents_1.CardActionsSurface, { actionsSize: isMobile ? 's' : 'm', actionsVisibility: actionsVisibility, className: styles_module_scss_1.default.cardActions, tooltip: tooltip
92
95
  ? {
93
96
  ...tooltip,
94
97
  'data-test-id': constants_1.TEST_IDS.cardServiceLightTooltip,
@@ -44,9 +44,13 @@
44
44
  box-sizing:border-box;
45
45
  width:100%;
46
46
  min-width:0;
47
+ min-height:var(--sn-primitive-dimension-32, 32px);
47
48
  padding:var(--sn-primitive-dimension-4, 4px);
48
49
  border-radius:inherit;
49
50
  }
51
+ .container[data-mobile]{
52
+ min-height:var(--sn-primitive-dimension-40, 40px);
53
+ }
50
54
 
51
55
  .icon{
52
56
  flex-shrink:0;
@@ -537,9 +537,13 @@
537
537
  box-sizing:border-box;
538
538
  width:100%;
539
539
  min-width:0;
540
+ min-height:var(--sn-primitive-dimension-32, 32px);
540
541
  padding:var(--sn-primitive-dimension-4, 4px);
541
542
  border-radius:inherit;
542
543
  }
544
+ .container[data-mobile]{
545
+ min-height:var(--sn-primitive-dimension-40, 40px);
546
+ }
543
547
 
544
548
  .icon{
545
549
  flex-shrink:0;
@@ -1,9 +1,8 @@
1
1
  import { PolymorphicRef } from '@cloud-ru/ds-card';
2
2
  import { TooltipProps } from '@cloud-ru/ds-tooltip';
3
3
  import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
4
- import { CardActionsSurfaceProps } from '../../helperComponents/index.js';
5
4
  import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types.js';
6
- type BaseCardServiceLightProps = Pick<CardActionsSurfaceProps, 'actionsSize'> & {
5
+ type BaseCardServiceLightProps = {
7
6
  /** Иконка сервиса */
8
7
  icon?: ReactElement;
9
8
  /** Заголовок карточки */
@@ -45,5 +44,5 @@ export type CardServiceLightProps<T extends ElementType = 'button'> = BaseCardSe
45
44
  /** Ref на реальный DOM-элемент / инстанс */
46
45
  innerRef?: PolymorphicRef<T>;
47
46
  } & Omit<ComponentPropsWithoutRef<T>, keyof BaseCardServiceLightProps | 'as' | 'ref'>;
48
- export declare function CardServiceLight<T extends ElementType = 'button'>({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
47
+ export declare function CardServiceLight<T extends ElementType = 'button'>({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled, expandable, 'data-test-id': dataTestId, ...rest }: CardServiceLightProps<T>): ReactElement | null;
49
48
  export {};
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
2
3
  import { useThemeClassnames } from '@cloud-ru/ds-theme';
3
4
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
4
5
  import { Typography } from '@cloud-ru/ds-typography';
@@ -7,10 +8,12 @@ import cn from 'classnames';
7
8
  import mergeRefs from 'merge-refs';
8
9
  import { useRef, useState, } from 'react';
9
10
  import { TEST_IDS, TOOLTIP_HOVER_DELAY_OPEN_MS, VISIBILITY_STRATEGY } from '../../constants.js';
10
- import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler, } from '../../helperComponents/index.js';
11
+ import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler } from '../../helperComponents/index.js';
11
12
  import styles from './styles.module.css';
12
13
  const TARGET_BLANK = '_blank';
13
- export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, actionsSize, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
14
+ export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate, actionsVisibility: actionsVisibilityProp, favorite, tooltip, className, disabled = false, expandable, 'data-test-id': dataTestId, ...rest }) {
15
+ const { layoutType } = useAdaptiveLayout();
16
+ const isMobile = isMobileLayout(layoutType);
14
17
  const Component = as ?? 'button';
15
18
  const cardRef = useRef(null);
16
19
  const tooltipTriggerRef = useRef(null);
@@ -82,7 +85,7 @@ export function CardServiceLight({ as, innerRef, icon, title, promoTag, truncate
82
85
  : onClick,
83
86
  };
84
87
  }
85
- return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [_jsx("span", { className: styles.outlineBorder, "aria-hidden": true }), _jsxs("div", { className: styles.container, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceLightTitle, children: _jsx(TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceLightPromoTag, className: cn(styles.promoTag, compactThemeClassName) }))] })] }), _jsx(CardActionsSurface, { actionsSize: actionsSize, actionsVisibility: actionsVisibility, className: styles.cardActions, tooltip: tooltip
88
+ return (_jsxs(Component, { ref: mergeRefs(innerRef, cardRef), className: cn(styles.root, className), "data-test-id": dataTestId ?? TEST_IDS.cardServiceLight, "data-disabled": disabled || undefined, "aria-disabled": Component !== 'button' && disabled ? true : undefined, tabIndex: Component !== 'button' && disabled ? -1 : undefined, onKeyDown: handleKeyDown, "data-tooltip-open": isTooltipOpen || undefined, ...polymorphicProps, children: [_jsx("span", { className: styles.outlineBorder, "aria-hidden": true }), _jsxs("div", { className: styles.container, "data-mobile": isMobile || undefined, children: [icon && _jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, children: [_jsx(Typography, { as: 'span', variant: 'body', size: 'm', className: styles.title, "data-test-id": TEST_IDS.cardServiceLightTitle, children: _jsx(TruncateString, { text: title, maxLines: truncate?.title, variant: 'end' }) }), promoTag && (_jsx(CardPromoTag, { promoTag: promoTag, tooltipTrigger: tooltipTrigger, innerRef: promoTagTooltipTriggerRef, "data-test-id": TEST_IDS.cardServiceLightPromoTag, className: cn(styles.promoTag, compactThemeClassName) }))] })] }), _jsx(CardActionsSurface, { actionsSize: isMobile ? 's' : 'm', actionsVisibility: actionsVisibility, className: styles.cardActions, tooltip: tooltip
86
89
  ? {
87
90
  ...tooltip,
88
91
  'data-test-id': TEST_IDS.cardServiceLightTooltip,
@@ -44,9 +44,13 @@
44
44
  box-sizing:border-box;
45
45
  width:100%;
46
46
  min-width:0;
47
+ min-height:var(--sn-primitive-dimension-32, 32px);
47
48
  padding:var(--sn-primitive-dimension-4, 4px);
48
49
  border-radius:inherit;
49
50
  }
51
+ .container[data-mobile]{
52
+ min-height:var(--sn-primitive-dimension-40, 40px);
53
+ }
50
54
 
51
55
  .icon{
52
56
  flex-shrink:0;
@@ -537,9 +537,13 @@
537
537
  box-sizing:border-box;
538
538
  width:100%;
539
539
  min-width:0;
540
+ min-height:var(--sn-primitive-dimension-32, 32px);
540
541
  padding:var(--sn-primitive-dimension-4, 4px);
541
542
  border-radius:inherit;
542
543
  }
544
+ .container[data-mobile]{
545
+ min-height:var(--sn-primitive-dimension-40, 40px);
546
+ }
543
547
 
544
548
  .icon{
545
549
  flex-shrink:0;