@cloud-ru/uikit-product-card-predefined 1.2.1 → 1.2.2-preview-22781d61.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.
@@ -1,9 +1,9 @@
1
1
  import { KeyboardEventHandler, MouseEvent, ReactElement } from 'react';
2
2
  import { PromoTagPredefinedProps } from '@cloud-ru/uikit-product-promo-tag-predefined';
3
- import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { WithLayoutType, WithSupportProps } from '@cloud-ru/uikit-product-utils';
4
4
  import { VisibilityStrategy } from './types';
5
5
  type CardElement = HTMLAnchorElement | HTMLButtonElement;
6
- export type CardServiceLightProps = WithSupportProps<{
6
+ export type CardServiceLightProps = WithLayoutType<WithSupportProps<{
7
7
  /** Иконка сервиса */
8
8
  icon: ReactElement;
9
9
  /** Заголовок карточки */
@@ -39,7 +39,7 @@ export type CardServiceLightProps = WithSupportProps<{
39
39
  };
40
40
  /** CSS-класс корневого элемента */
41
41
  className?: string;
42
- }>;
42
+ }>>;
43
43
  export declare const CardServiceLight: import("react").ForwardRefExoticComponent<{
44
44
  'data-test-id'?: string;
45
45
  } & import("react").AriaAttributes & {
@@ -78,5 +78,7 @@ export declare const CardServiceLight: import("react").ForwardRefExoticComponent
78
78
  };
79
79
  /** CSS-класс корневого элемента */
80
80
  className?: string;
81
+ } & {
82
+ layoutType: import("@cloud-ru/uikit-product-utils/.").LayoutType;
81
83
  } & import("react").RefAttributes<CardElement>>;
82
84
  export {};
@@ -21,14 +21,14 @@ const merge_refs_1 = __importDefault(require("merge-refs"));
21
21
  const react_1 = require("react");
22
22
  const uncontrollable_1 = require("uncontrollable");
23
23
  const uikit_product_promo_tag_predefined_1 = require("@cloud-ru/uikit-product-promo-tag-predefined");
24
+ const uikit_product_utils_1 = require("@cloud-ru/uikit-product-utils");
24
25
  const toggles_1 = require("@snack-uikit/toggles");
25
26
  const truncate_string_1 = require("@snack-uikit/truncate-string");
26
27
  const typography_1 = require("@snack-uikit/typography");
27
- const utils_1 = require("@snack-uikit/utils");
28
28
  const constants_1 = require("./constants");
29
29
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
30
30
  exports.CardServiceLight = (0, react_1.forwardRef)((_a, ref) => {
31
- var { href, type: typeProp, promoTag, title, icon, onClick, onKeyDown: onKeyDownProp, className, truncate, favorite } = _a, rest = __rest(_a, ["href", "type", "promoTag", "title", "icon", "onClick", "onKeyDown", "className", "truncate", "favorite"]);
31
+ var { href, type: typeProp, promoTag, title, icon, onClick, onKeyDown: onKeyDownProp, className, truncate, favorite, layoutType } = _a, rest = __rest(_a, ["href", "type", "promoTag", "title", "icon", "onClick", "onKeyDown", "className", "truncate", "favorite", "layoutType"]);
32
32
  const [isFavorite, setIsFavorite] = (0, uncontrollable_1.useUncontrolledProp)(favorite === null || favorite === void 0 ? void 0 : favorite.checked, false, favorite === null || favorite === void 0 ? void 0 : favorite.onChange);
33
33
  const componentRef = (0, react_1.useRef)(null);
34
34
  const favoriteRef = (0, react_1.useRef)(null);
@@ -81,5 +81,5 @@ exports.CardServiceLight = (0, react_1.forwardRef)((_a, ref) => {
81
81
  const tooltipProps = Object.assign(Object.assign({}, ((promoTag === null || promoTag === void 0 ? void 0 : promoTag.tooltip) || {})), { trigger: 'hover' });
82
82
  return Object.assign(Object.assign({}, promoTag), { tooltip: tooltipProps });
83
83
  }, [promoTag]);
84
- return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ ref: (0, merge_refs_1.default)(ref, componentRef), className: (0, classnames_1.default)(styles_module_scss_1.default.card, className) }, (0, utils_1.extractSupportProps)(rest), attributes, { onClick: onClick, onKeyDown: onKeyDown, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [(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.SansBodyM, { className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.title, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate === null || truncate === void 0 ? void 0 : truncate.title, variant: 'end' }) }), promoTagProps && (0, jsx_runtime_1.jsx)(uikit_product_promo_tag_predefined_1.PromoTagPredefined, Object.assign({}, promoTagProps, { "data-test-id": constants_1.TEST_IDS.promoTag }))] }), (favorite === null || favorite === void 0 ? void 0 : favorite.enabled) && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.favoriteWrapper, "data-visibility-strategy": favorite.visibilityStrategy || constants_1.VISIBILITY_STRATEGY.hover, "data-checked": isFavorite || undefined, children: (0, jsx_runtime_1.jsx)(toggles_1.Favorite, { size: 'm', checked: isFavorite, inputRef: favoriteRef, onChange: setIsFavorite, tabIndex: -1, onKeyUp: onFavoriteKeyUp, onClick: onFavoriteClick, "data-test-id": constants_1.TEST_IDS.favorite, icon: 'star' }) }))] }) })));
84
+ return ((0, jsx_runtime_1.jsx)(Component, Object.assign({ ref: (0, merge_refs_1.default)(ref, componentRef), className: (0, classnames_1.default)(styles_module_scss_1.default.card, className) }, (0, uikit_product_utils_1.extractSupportProps)(rest), attributes, { onClick: onClick, onKeyDown: onKeyDown, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.container, children: [(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, "data-layout-type": layoutType, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography.SansBodyM, { className: styles_module_scss_1.default.title, "data-test-id": constants_1.TEST_IDS.title, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: title, maxLines: truncate === null || truncate === void 0 ? void 0 : truncate.title, variant: 'end' }) }), promoTagProps && (0, jsx_runtime_1.jsx)(uikit_product_promo_tag_predefined_1.PromoTagPredefined, Object.assign({}, promoTagProps, { "data-test-id": constants_1.TEST_IDS.promoTag }))] }), (favorite === null || favorite === void 0 ? void 0 : favorite.enabled) && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.favoriteWrapper, "data-visibility-strategy": favorite.visibilityStrategy || constants_1.VISIBILITY_STRATEGY.hover, "data-checked": isFavorite || undefined, children: (0, jsx_runtime_1.jsx)(toggles_1.Favorite, { size: 'm', checked: isFavorite, inputRef: favoriteRef, onChange: setIsFavorite, tabIndex: -1, onKeyUp: onFavoriteKeyUp, onClick: onFavoriteClick, "data-test-id": constants_1.TEST_IDS.favorite, icon: 'star' }) }))] }) })));
85
85
  });
@@ -9,8 +9,6 @@
9
9
  }
10
10
  .favoriteWrapper[data-visibility-strategy=hover]{
11
11
  visibility:hidden;
12
- }
13
- .favoriteWrapper[data-visibility-strategy=hover]:not(.favoriteWrapper[data-visibility-strategy=hover][data-checked]){
14
12
  position:absolute;
15
13
  right:4px;
16
14
  }
@@ -53,6 +51,10 @@
53
51
  .card:hover .favoriteWrapper, .card:focus-within .favoriteWrapper{
54
52
  visibility:visible;
55
53
  }
54
+ .card:hover .favoriteWrapper[data-checked], .card:focus-within .favoriteWrapper[data-checked]{
55
+ position:relative;
56
+ right:0;
57
+ }
56
58
 
57
59
  .container{
58
60
  position:relative;
@@ -73,6 +75,9 @@
73
75
  min-width:0;
74
76
  flex-grow:1;
75
77
  }
78
+ .content[data-layout-type=mobile]{
79
+ min-height:32px;
80
+ }
76
81
 
77
82
  .icon{
78
83
  height:var(--size-icon-container-s, 24px);
@@ -1,9 +1,9 @@
1
1
  import { KeyboardEventHandler, MouseEvent, ReactElement } from 'react';
2
2
  import { PromoTagPredefinedProps } from '@cloud-ru/uikit-product-promo-tag-predefined';
3
- import { WithSupportProps } from '@snack-uikit/utils';
3
+ import { WithLayoutType, WithSupportProps } from '@cloud-ru/uikit-product-utils';
4
4
  import { VisibilityStrategy } from './types';
5
5
  type CardElement = HTMLAnchorElement | HTMLButtonElement;
6
- export type CardServiceLightProps = WithSupportProps<{
6
+ export type CardServiceLightProps = WithLayoutType<WithSupportProps<{
7
7
  /** Иконка сервиса */
8
8
  icon: ReactElement;
9
9
  /** Заголовок карточки */
@@ -39,7 +39,7 @@ export type CardServiceLightProps = WithSupportProps<{
39
39
  };
40
40
  /** CSS-класс корневого элемента */
41
41
  className?: string;
42
- }>;
42
+ }>>;
43
43
  export declare const CardServiceLight: import("react").ForwardRefExoticComponent<{
44
44
  'data-test-id'?: string;
45
45
  } & import("react").AriaAttributes & {
@@ -78,5 +78,7 @@ export declare const CardServiceLight: import("react").ForwardRefExoticComponent
78
78
  };
79
79
  /** CSS-класс корневого элемента */
80
80
  className?: string;
81
+ } & {
82
+ layoutType: import("@cloud-ru/uikit-product-utils/.").LayoutType;
81
83
  } & import("react").RefAttributes<CardElement>>;
82
84
  export {};
@@ -15,14 +15,14 @@ import mergeRefs from 'merge-refs';
15
15
  import { forwardRef, useMemo, useRef, } from 'react';
16
16
  import { useUncontrolledProp } from 'uncontrollable';
17
17
  import { PromoTagPredefined } from '@cloud-ru/uikit-product-promo-tag-predefined';
18
+ import { extractSupportProps } from '@cloud-ru/uikit-product-utils';
18
19
  import { Favorite } from '@snack-uikit/toggles';
19
20
  import { TruncateString } from '@snack-uikit/truncate-string';
20
21
  import { Typography } from '@snack-uikit/typography';
21
- import { extractSupportProps } from '@snack-uikit/utils';
22
22
  import { TEST_IDS, TRIGGER_CLICK_KEY_CODES, VISIBILITY_STRATEGY } from './constants';
23
23
  import styles from './styles.module.css';
24
24
  export const CardServiceLight = forwardRef((_a, ref) => {
25
- var { href, type: typeProp, promoTag, title, icon, onClick, onKeyDown: onKeyDownProp, className, truncate, favorite } = _a, rest = __rest(_a, ["href", "type", "promoTag", "title", "icon", "onClick", "onKeyDown", "className", "truncate", "favorite"]);
25
+ var { href, type: typeProp, promoTag, title, icon, onClick, onKeyDown: onKeyDownProp, className, truncate, favorite, layoutType } = _a, rest = __rest(_a, ["href", "type", "promoTag", "title", "icon", "onClick", "onKeyDown", "className", "truncate", "favorite", "layoutType"]);
26
26
  const [isFavorite, setIsFavorite] = useUncontrolledProp(favorite === null || favorite === void 0 ? void 0 : favorite.checked, false, favorite === null || favorite === void 0 ? void 0 : favorite.onChange);
27
27
  const componentRef = useRef(null);
28
28
  const favoriteRef = useRef(null);
@@ -75,5 +75,5 @@ export const CardServiceLight = forwardRef((_a, ref) => {
75
75
  const tooltipProps = Object.assign(Object.assign({}, ((promoTag === null || promoTag === void 0 ? void 0 : promoTag.tooltip) || {})), { trigger: 'hover' });
76
76
  return Object.assign(Object.assign({}, promoTag), { tooltip: tooltipProps });
77
77
  }, [promoTag]);
78
- return (_jsx(Component, Object.assign({ ref: mergeRefs(ref, componentRef), className: cn(styles.card, className) }, extractSupportProps(rest), attributes, { onClick: onClick, onKeyDown: onKeyDown, children: _jsxs("div", { className: styles.container, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, children: [_jsx(Typography.SansBodyM, { className: styles.title, "data-test-id": TEST_IDS.title, children: _jsx(TruncateString, { text: title, maxLines: truncate === null || truncate === void 0 ? void 0 : truncate.title, variant: 'end' }) }), promoTagProps && _jsx(PromoTagPredefined, Object.assign({}, promoTagProps, { "data-test-id": TEST_IDS.promoTag }))] }), (favorite === null || favorite === void 0 ? void 0 : favorite.enabled) && (_jsx("div", { className: styles.favoriteWrapper, "data-visibility-strategy": favorite.visibilityStrategy || VISIBILITY_STRATEGY.hover, "data-checked": isFavorite || undefined, children: _jsx(Favorite, { size: 'm', checked: isFavorite, inputRef: favoriteRef, onChange: setIsFavorite, tabIndex: -1, onKeyUp: onFavoriteKeyUp, onClick: onFavoriteClick, "data-test-id": TEST_IDS.favorite, icon: 'star' }) }))] }) })));
78
+ return (_jsx(Component, Object.assign({ ref: mergeRefs(ref, componentRef), className: cn(styles.card, className) }, extractSupportProps(rest), attributes, { onClick: onClick, onKeyDown: onKeyDown, children: _jsxs("div", { className: styles.container, children: [_jsx("div", { className: styles.icon, children: icon }), _jsxs("div", { className: styles.content, "data-layout-type": layoutType, children: [_jsx(Typography.SansBodyM, { className: styles.title, "data-test-id": TEST_IDS.title, children: _jsx(TruncateString, { text: title, maxLines: truncate === null || truncate === void 0 ? void 0 : truncate.title, variant: 'end' }) }), promoTagProps && _jsx(PromoTagPredefined, Object.assign({}, promoTagProps, { "data-test-id": TEST_IDS.promoTag }))] }), (favorite === null || favorite === void 0 ? void 0 : favorite.enabled) && (_jsx("div", { className: styles.favoriteWrapper, "data-visibility-strategy": favorite.visibilityStrategy || VISIBILITY_STRATEGY.hover, "data-checked": isFavorite || undefined, children: _jsx(Favorite, { size: 'm', checked: isFavorite, inputRef: favoriteRef, onChange: setIsFavorite, tabIndex: -1, onKeyUp: onFavoriteKeyUp, onClick: onFavoriteClick, "data-test-id": TEST_IDS.favorite, icon: 'star' }) }))] }) })));
79
79
  });
@@ -9,8 +9,6 @@
9
9
  }
10
10
  .favoriteWrapper[data-visibility-strategy=hover]{
11
11
  visibility:hidden;
12
- }
13
- .favoriteWrapper[data-visibility-strategy=hover]:not(.favoriteWrapper[data-visibility-strategy=hover][data-checked]){
14
12
  position:absolute;
15
13
  right:4px;
16
14
  }
@@ -53,6 +51,10 @@
53
51
  .card:hover .favoriteWrapper, .card:focus-within .favoriteWrapper{
54
52
  visibility:visible;
55
53
  }
54
+ .card:hover .favoriteWrapper[data-checked], .card:focus-within .favoriteWrapper[data-checked]{
55
+ position:relative;
56
+ right:0;
57
+ }
56
58
 
57
59
  .container{
58
60
  position:relative;
@@ -73,6 +75,9 @@
73
75
  min-width:0;
74
76
  flex-grow:1;
75
77
  }
78
+ .content[data-layout-type=mobile]{
79
+ min-height:32px;
80
+ }
76
81
 
77
82
  .icon{
78
83
  height:var(--size-icon-container-s, 24px);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-card-predefined",
3
3
  "title": "Card Predefined",
4
- "version": "1.2.1",
4
+ "version": "1.2.2-preview-22781d61.0",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -38,6 +38,7 @@
38
38
  "dependencies": {
39
39
  "@cloud-ru/uikit-product-icons": "17.3.0",
40
40
  "@cloud-ru/uikit-product-promo-tag-predefined": "2.0.5",
41
+ "@cloud-ru/uikit-product-utils": "9.1.0",
41
42
  "@snack-uikit/button": "0.19.16",
42
43
  "@snack-uikit/card": "0.20.18",
43
44
  "@snack-uikit/promo-tag": "0.7.1",
@@ -49,5 +50,5 @@
49
50
  "merge-refs": "1.3.0",
50
51
  "uncontrollable": "8.0.4"
51
52
  },
52
- "gitHead": "da8b19d789a4e79dcc731e414807083cd389f811"
53
+ "gitHead": "c22ea4b8cb0fd4b661b770a0dbbe4e3d7d7a43cd"
53
54
  }
@@ -14,10 +14,10 @@ import {
14
14
  import { useUncontrolledProp } from 'uncontrollable';
15
15
 
16
16
  import { PromoTagPredefined, PromoTagPredefinedProps } from '@cloud-ru/uikit-product-promo-tag-predefined';
17
+ import { extractSupportProps, WithLayoutType, WithSupportProps } from '@cloud-ru/uikit-product-utils';
17
18
  import { Favorite } from '@snack-uikit/toggles';
18
19
  import { TruncateString } from '@snack-uikit/truncate-string';
19
20
  import { Typography } from '@snack-uikit/typography';
20
- import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
21
21
 
22
22
  import { TEST_IDS, TRIGGER_CLICK_KEY_CODES, VISIBILITY_STRATEGY } from './constants';
23
23
  import styles from './styles.module.scss';
@@ -25,43 +25,45 @@ import { VisibilityStrategy } from './types';
25
25
 
26
26
  type CardElement = HTMLAnchorElement | HTMLButtonElement;
27
27
 
28
- export type CardServiceLightProps = WithSupportProps<{
29
- /** Иконка сервиса */
30
- icon: ReactElement;
31
- /** Заголовок карточки */
32
- title: string;
33
- /** Ссылка, открываемая при клике по карточке */
34
- href?: string;
35
- /** Тип кнопки */
36
- type?: 'button' | 'submit' | 'reset';
37
- /** Настройки promo tag. При отсутствии не отображается */
38
- promoTag?: Omit<PromoTagPredefinedProps, 'trigger'>;
39
- /** Колбек на клик по карточке */
40
- onClick?(event: MouseEvent<CardElement>): void;
41
- /** Колбек нажатия клавиши клавиатуры на карточке */
42
- onKeyDown?: KeyboardEventHandler<CardElement>;
43
- /** Настройки обрезки текста заголовка */
44
- truncate?: {
45
- /** Максимальное количество строк заголовка */
46
- title?: number;
47
- };
48
- /** Настройки кнопки «Избранное» */
49
- favorite?: {
50
- /** Включить отображение кнопки избранного */
51
- enabled: boolean;
52
- /**
53
- * Формат отображения: всегда или при наведении и фокусе
54
- * @default 'hover'
55
- */
56
- visibilityStrategy?: VisibilityStrategy;
57
- /** Состояние избранного. При передаче вместе с `onChange` компонент работает в controlled-режиме */
58
- checked?: boolean;
59
- /** Колбек изменения состояния избранного. При передаче вместе с `checked` компонент работает в controlled-режиме */
60
- onChange?(value: boolean): void;
61
- };
62
- /** CSS-класс корневого элемента */
63
- className?: string;
64
- }>;
28
+ export type CardServiceLightProps = WithLayoutType<
29
+ WithSupportProps<{
30
+ /** Иконка сервиса */
31
+ icon: ReactElement;
32
+ /** Заголовок карточки */
33
+ title: string;
34
+ /** Ссылка, открываемая при клике по карточке */
35
+ href?: string;
36
+ /** Тип кнопки */
37
+ type?: 'button' | 'submit' | 'reset';
38
+ /** Настройки promo tag. При отсутствии не отображается */
39
+ promoTag?: Omit<PromoTagPredefinedProps, 'trigger'>;
40
+ /** Колбек на клик по карточке */
41
+ onClick?(event: MouseEvent<CardElement>): void;
42
+ /** Колбек нажатия клавиши клавиатуры на карточке */
43
+ onKeyDown?: KeyboardEventHandler<CardElement>;
44
+ /** Настройки обрезки текста заголовка */
45
+ truncate?: {
46
+ /** Максимальное количество строк заголовка */
47
+ title?: number;
48
+ };
49
+ /** Настройки кнопки «Избранное» */
50
+ favorite?: {
51
+ /** Включить отображение кнопки избранного */
52
+ enabled: boolean;
53
+ /**
54
+ * Формат отображения: всегда или при наведении и фокусе
55
+ * @default 'hover'
56
+ */
57
+ visibilityStrategy?: VisibilityStrategy;
58
+ /** Состояние избранного. При передаче вместе с `onChange` компонент работает в controlled-режиме */
59
+ checked?: boolean;
60
+ /** Колбек изменения состояния избранного. При передаче вместе с `checked` компонент работает в controlled-режиме */
61
+ onChange?(value: boolean): void;
62
+ };
63
+ /** CSS-класс корневого элемента */
64
+ className?: string;
65
+ }>
66
+ >;
65
67
 
66
68
  export const CardServiceLight = forwardRef<CardElement, CardServiceLightProps>(
67
69
  (
@@ -76,6 +78,7 @@ export const CardServiceLight = forwardRef<CardElement, CardServiceLightProps>(
76
78
  className,
77
79
  truncate,
78
80
  favorite,
81
+ layoutType,
79
82
  ...rest
80
83
  },
81
84
  ref,
@@ -163,7 +166,7 @@ export const CardServiceLight = forwardRef<CardElement, CardServiceLightProps>(
163
166
  <div className={styles.container}>
164
167
  <div className={styles.icon}>{icon}</div>
165
168
 
166
- <div className={styles.content}>
169
+ <div className={styles.content} data-layout-type={layoutType}>
167
170
  <Typography.SansBodyM className={styles.title} data-test-id={TEST_IDS.title}>
168
171
  <TruncateString text={title} maxLines={truncate?.title} variant='end' />
169
172
  </Typography.SansBodyM>
@@ -13,11 +13,8 @@ $side: ste.$icon-s;
13
13
 
14
14
  &[data-visibility-strategy='hover'] {
15
15
  visibility: hidden;
16
-
17
- &:not(&[data-checked]) {
18
- position: absolute;
19
- right: 4px;
20
- }
16
+ position: absolute;
17
+ right: 4px;
21
18
  }
22
19
 
23
20
  &[data-visibility-strategy='always'] {
@@ -66,6 +63,11 @@ $side: ste.$icon-s;
66
63
 
67
64
  .favoriteWrapper {
68
65
  visibility: visible;
66
+
67
+ &[data-checked] {
68
+ position: relative;
69
+ right: 0;
70
+ }
69
71
  }
70
72
  }
71
73
  }
@@ -88,6 +90,10 @@ $side: ste.$icon-s;
88
90
  max-width: 100%;
89
91
  min-width: 0;
90
92
  flex-grow: 1;
93
+
94
+ &[data-layout-type='mobile'] {
95
+ min-height: 32px;
96
+ }
91
97
  }
92
98
 
93
99
  .icon {