@cloud-ru/ds-uikit-product-card-predefined 4.2.4 → 4.2.5-preview-67c3d8fb.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/dist/cjs/components/CardNavigation/CardNavigation.js +3 -0
- package/dist/cjs/components/CardServiceLight/CardServiceLight.js +3 -0
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +1 -0
- package/dist/cjs/helperComponents/CardActionsSurface/CardActionsSurface.js +9 -1
- package/dist/esm/components/CardNavigation/CardNavigation.js +3 -0
- package/dist/esm/components/CardServiceLight/CardServiceLight.js +3 -0
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.d.ts +1 -0
- package/dist/esm/helperComponents/CardActionsSurface/CardActionsSurface.js +10 -2
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +18 -17
- package/src/components/CardNavigation/CardNavigation.tsx +3 -0
- package/src/components/CardServiceLight/CardServiceLight.tsx +3 -0
- package/src/helperComponents/CardActionsSurface/CardActionsSurface.tsx +33 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-uikit-product-card-predefined",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5-preview-67c3d8fb.0",
|
|
4
4
|
"description": "Пресеты карточек Product UI Kit — CardBanner, CardService, CardServiceLight, CardServiceSmall, CardSuggest, CardCustom.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,22 +41,23 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"classnames": "^2.5.1",
|
|
43
43
|
"merge-refs": "^2.0.0",
|
|
44
|
-
"@cloud-ru/ds-
|
|
45
|
-
"@cloud-ru/ds-
|
|
46
|
-
"@cloud-ru/ds-
|
|
47
|
-
"@cloud-ru/ds-
|
|
48
|
-
"@cloud-ru/ds-
|
|
49
|
-
"@cloud-ru/ds-
|
|
50
|
-
"@cloud-ru/ds-
|
|
51
|
-
"@cloud-ru/ds-
|
|
52
|
-
"@cloud-ru/ds-
|
|
53
|
-
"@cloud-ru/ds-
|
|
54
|
-
"@cloud-ru/ds-
|
|
55
|
-
"@cloud-ru/ds-
|
|
56
|
-
"@cloud-ru/ds-truncate-string": "
|
|
57
|
-
"@cloud-ru/ds-typography": "
|
|
58
|
-
"@cloud-ru/ds-
|
|
59
|
-
"@cloud-ru/ds-utils": "
|
|
44
|
+
"@cloud-ru/ds-adaptive": "1.0.6",
|
|
45
|
+
"@cloud-ru/ds-icon-predefined": "1.0.7",
|
|
46
|
+
"@cloud-ru/ds-card": "1.0.41-preview-67c3d8fb.0",
|
|
47
|
+
"@cloud-ru/ds-icons": "1.8.0",
|
|
48
|
+
"@cloud-ru/ds-button": "1.0.9",
|
|
49
|
+
"@cloud-ru/ds-materials": "2.0.5",
|
|
50
|
+
"@cloud-ru/ds-list": "3.2.1-preview-67c3d8fb.0",
|
|
51
|
+
"@cloud-ru/ds-tag": "1.2.7-preview-67c3d8fb.0",
|
|
52
|
+
"@cloud-ru/ds-locale": "1.0.0",
|
|
53
|
+
"@cloud-ru/ds-promo-tag": "1.0.8",
|
|
54
|
+
"@cloud-ru/ds-theme": "2.1.0",
|
|
55
|
+
"@cloud-ru/ds-toggles": "1.1.19",
|
|
56
|
+
"@cloud-ru/ds-truncate-string": "1.0.23",
|
|
57
|
+
"@cloud-ru/ds-typography": "1.0.3-preview-67c3d8fb.0",
|
|
58
|
+
"@cloud-ru/ds-tooltip": "1.0.22",
|
|
59
|
+
"@cloud-ru/ds-utils": "1.4.2",
|
|
60
|
+
"@cloud-ru/ds-uikit-product-promo-tag-predefined": "1.0.25"
|
|
60
61
|
},
|
|
61
62
|
"publishConfig": {
|
|
62
63
|
"access": "public"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
1
2
|
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
3
|
import { BACKGROUND_PREDEFINED_FILL, backgroundPredefinedFillToAcrylic } from '@cloud-ru/ds-materials';
|
|
3
4
|
import { useThemeClassnames } from '@cloud-ru/ds-theme';
|
|
@@ -111,6 +112,7 @@ export function CardNavigation<T extends ElementType = 'button'>({
|
|
|
111
112
|
const favoriteRef = useRef<HTMLButtonElement>(null);
|
|
112
113
|
const expandButtonRef = useRef<HTMLButtonElement>(null);
|
|
113
114
|
|
|
115
|
+
const { layoutType } = useAdaptiveLayout();
|
|
114
116
|
const compactThemeClassName = useThemeClassnames({ density: 'compact' });
|
|
115
117
|
|
|
116
118
|
const isDetailed = description !== undefined;
|
|
@@ -296,6 +298,7 @@ export function CardNavigation<T extends ElementType = 'button'>({
|
|
|
296
298
|
enabled: favorite.enabled,
|
|
297
299
|
checked: isFavorite,
|
|
298
300
|
onChange: setIsFavorite,
|
|
301
|
+
showTooltip: !isMobileLayout(layoutType),
|
|
299
302
|
buttonRef: favoriteRef,
|
|
300
303
|
'data-test-id': TEST_IDS.cardNavigationFavorite,
|
|
301
304
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
1
2
|
import { PolymorphicRef } from '@cloud-ru/ds-card';
|
|
2
3
|
import { useThemeClassnames } from '@cloud-ru/ds-theme';
|
|
3
4
|
import { TooltipProps } from '@cloud-ru/ds-tooltip';
|
|
@@ -91,6 +92,7 @@ export function CardServiceLight<T extends ElementType = 'button'>({
|
|
|
91
92
|
const favoriteRef = useRef<HTMLButtonElement>(null);
|
|
92
93
|
const expandButtonRef = useRef<HTMLButtonElement>(null);
|
|
93
94
|
|
|
95
|
+
const { layoutType } = useAdaptiveLayout();
|
|
94
96
|
const compactThemeClassName = useThemeClassnames({ density: 'compact' });
|
|
95
97
|
|
|
96
98
|
const actionsVisibility = actionsVisibilityProp ?? VISIBILITY_STRATEGY.hover;
|
|
@@ -221,6 +223,7 @@ export function CardServiceLight<T extends ElementType = 'button'>({
|
|
|
221
223
|
enabled: favorite.enabled,
|
|
222
224
|
checked: isFavorite,
|
|
223
225
|
onChange: setIsFavorite,
|
|
226
|
+
showTooltip: !isMobileLayout(layoutType),
|
|
224
227
|
buttonRef: favoriteRef,
|
|
225
228
|
'data-test-id': TEST_IDS.cardServiceLightFavorite,
|
|
226
229
|
}
|
|
@@ -4,7 +4,7 @@ import { CollapseVerticalSVG, ExpandVerticalSVG, StarFilledSVG, StarSVG } from '
|
|
|
4
4
|
import { Tooltip, TooltipProps, TRIGGER } from '@cloud-ru/ds-tooltip';
|
|
5
5
|
import { preventEventDefault, preventEventDefaultAndPropagation } from '@cloud-ru/ds-utils';
|
|
6
6
|
import cn from 'classnames';
|
|
7
|
-
import { MouseEvent, ReactElement, RefObject, useCallback, useRef, useState } from 'react';
|
|
7
|
+
import { MouseEvent, ReactElement, RefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
import { TOOLTIP_HOVER_DELAY_OPEN_MS, VISIBILITY_STRATEGY } from '../../constants';
|
|
10
10
|
import { cardPredefinedLocale } from '../../locale';
|
|
@@ -26,6 +26,7 @@ export type CardActionsSurfaceProps = {
|
|
|
26
26
|
};
|
|
27
27
|
/** Кнопка «Избранное» */
|
|
28
28
|
favorite?: FavoriteProps & {
|
|
29
|
+
showTooltip?: boolean;
|
|
29
30
|
buttonRef?: RefObject<HTMLButtonElement>;
|
|
30
31
|
'data-test-id'?: string;
|
|
31
32
|
};
|
|
@@ -53,6 +54,7 @@ export function CardActionsSurface({
|
|
|
53
54
|
|
|
54
55
|
const [visibleTooltip, setVisibleTooltip] = useState<TooltipType | undefined>(undefined);
|
|
55
56
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
57
|
+
const showFavoriteTooltip = favorite?.showTooltip ?? true;
|
|
56
58
|
|
|
57
59
|
const tooltipTrigger =
|
|
58
60
|
tooltip?.trigger ??
|
|
@@ -71,6 +73,12 @@ export function CardActionsSurface({
|
|
|
71
73
|
[onTooltipOpenChange, tooltipTrigger],
|
|
72
74
|
);
|
|
73
75
|
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!showFavoriteTooltip && visibleTooltip === 'favorite') {
|
|
78
|
+
getHandleTooltipOpenChange('favorite')(false);
|
|
79
|
+
}
|
|
80
|
+
}, [getHandleTooltipOpenChange, showFavoriteTooltip, visibleTooltip]);
|
|
81
|
+
|
|
74
82
|
if (!tooltip && !favorite && !expandable) {
|
|
75
83
|
return null;
|
|
76
84
|
}
|
|
@@ -96,6 +104,25 @@ export function CardActionsSurface({
|
|
|
96
104
|
};
|
|
97
105
|
|
|
98
106
|
const { buttonRef: tooltipButtonRef, 'data-test-id': tooltipTestId, ...tooltipProps } = tooltip ?? {};
|
|
107
|
+
const favoriteLabel = favorite?.checked ? t('actions.favoriteRemove') : t('actions.favoriteAdd');
|
|
108
|
+
const favoriteButton = favorite?.enabled && (
|
|
109
|
+
<Button
|
|
110
|
+
as='span'
|
|
111
|
+
role='button'
|
|
112
|
+
aria-label={favoriteLabel}
|
|
113
|
+
aria-pressed={Boolean(favorite.checked)}
|
|
114
|
+
size='m'
|
|
115
|
+
appearance='neutral'
|
|
116
|
+
view='simple'
|
|
117
|
+
icon={favorite.checked ? <StarFilledSVG /> : <StarSVG />}
|
|
118
|
+
onClick={handleFavoriteClick}
|
|
119
|
+
className={styles.favorite}
|
|
120
|
+
innerRef={favorite.buttonRef}
|
|
121
|
+
tabIndex={-1}
|
|
122
|
+
data-test-id={favorite['data-test-id']}
|
|
123
|
+
data-checked={favorite.checked || undefined}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
99
126
|
|
|
100
127
|
return (
|
|
101
128
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -134,31 +161,19 @@ export function CardActionsSurface({
|
|
|
134
161
|
</Tooltip>
|
|
135
162
|
)}
|
|
136
163
|
|
|
137
|
-
{
|
|
164
|
+
{favoriteButton && showFavoriteTooltip ? (
|
|
138
165
|
<Tooltip
|
|
139
|
-
tip={
|
|
166
|
+
tip={favoriteLabel}
|
|
140
167
|
trigger={tooltipTrigger}
|
|
141
168
|
triggerClassName={styles.tooltipTrigger}
|
|
142
169
|
hoverDelayOpen={TOOLTIP_HOVER_DELAY_OPEN_MS}
|
|
143
170
|
open={visibleTooltip === 'favorite'}
|
|
144
171
|
onOpenChange={getHandleTooltipOpenChange('favorite')}
|
|
145
172
|
>
|
|
146
|
-
|
|
147
|
-
as='span'
|
|
148
|
-
role='button'
|
|
149
|
-
aria-pressed={Boolean(favorite.checked)}
|
|
150
|
-
size='m'
|
|
151
|
-
appearance='neutral'
|
|
152
|
-
view='simple'
|
|
153
|
-
icon={favorite.checked ? <StarFilledSVG /> : <StarSVG />}
|
|
154
|
-
onClick={handleFavoriteClick}
|
|
155
|
-
className={styles.favorite}
|
|
156
|
-
innerRef={favorite.buttonRef}
|
|
157
|
-
tabIndex={-1}
|
|
158
|
-
data-test-id={favorite['data-test-id']}
|
|
159
|
-
data-checked={favorite.checked || undefined}
|
|
160
|
-
/>
|
|
173
|
+
{favoriteButton}
|
|
161
174
|
</Tooltip>
|
|
175
|
+
) : (
|
|
176
|
+
favoriteButton
|
|
162
177
|
)}
|
|
163
178
|
|
|
164
179
|
{expandable && (
|