@cloud-ru/ds-uikit-product-card-predefined 4.3.2 → 4.3.3-preview-7f0ca3f7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-uikit-product-card-predefined",
3
- "version": "4.3.2",
3
+ "version": "4.3.3-preview-7f0ca3f7.0",
4
4
  "description": "Пресеты карточек Product UI Kit — CardBanner, CardService, CardServiceLight, CardServiceSmall, CardSuggest, CardCustom.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,23 +41,23 @@
41
41
  "dependencies": {
42
42
  "classnames": "^2.5.1",
43
43
  "merge-refs": "^2.0.0",
44
- "@cloud-ru/ds-adaptive": "^1.0.7",
45
- "@cloud-ru/ds-card": "^1.0.45",
46
- "@cloud-ru/ds-button": "^1.1.0",
47
- "@cloud-ru/ds-list": "^3.2.6",
48
- "@cloud-ru/ds-locale": "^1.0.0",
49
- "@cloud-ru/ds-icons": "^1.8.1",
50
- "@cloud-ru/ds-materials": "^2.0.6",
51
- "@cloud-ru/ds-icon-predefined": "^1.0.8",
52
- "@cloud-ru/ds-promo-tag": "^1.1.0",
53
- "@cloud-ru/ds-theme": "^2.1.0",
54
- "@cloud-ru/ds-tag": "^1.2.11",
55
- "@cloud-ru/ds-toggles": "^1.1.20",
56
- "@cloud-ru/ds-truncate-string": "^1.1.0",
57
- "@cloud-ru/ds-tooltip": "^1.0.23",
58
- "@cloud-ru/ds-typography": "^1.0.3",
59
- "@cloud-ru/ds-uikit-product-promo-tag-predefined": "^1.0.27",
60
- "@cloud-ru/ds-utils": "^1.5.0"
44
+ "@cloud-ru/ds-adaptive": "1.0.8-preview-7f0ca3f7.0",
45
+ "@cloud-ru/ds-button": "1.1.1-preview-7f0ca3f7.0",
46
+ "@cloud-ru/ds-card": "1.0.46-preview-7f0ca3f7.0",
47
+ "@cloud-ru/ds-icon-predefined": "1.0.9-preview-7f0ca3f7.0",
48
+ "@cloud-ru/ds-icons": "1.8.2-preview-7f0ca3f7.0",
49
+ "@cloud-ru/ds-list": "3.2.7-preview-7f0ca3f7.0",
50
+ "@cloud-ru/ds-locale": "1.0.0",
51
+ "@cloud-ru/ds-materials": "2.0.7-preview-7f0ca3f7.0",
52
+ "@cloud-ru/ds-promo-tag": "1.1.1-preview-7f0ca3f7.0",
53
+ "@cloud-ru/ds-tag": "1.2.12-preview-7f0ca3f7.0",
54
+ "@cloud-ru/ds-theme": "2.1.0",
55
+ "@cloud-ru/ds-toggles": "1.1.21-preview-7f0ca3f7.0",
56
+ "@cloud-ru/ds-tooltip": "1.0.24-preview-7f0ca3f7.0",
57
+ "@cloud-ru/ds-truncate-string": "1.1.1-preview-7f0ca3f7.0",
58
+ "@cloud-ru/ds-typography": "1.0.3",
59
+ "@cloud-ru/ds-uikit-product-promo-tag-predefined": "1.0.28-preview-7f0ca3f7.0",
60
+ "@cloud-ru/ds-utils": "1.5.1-preview-7f0ca3f7.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
@@ -4,7 +4,7 @@ import { useThemeClassnames } from '@cloud-ru/ds-theme';
4
4
  import { TooltipProps } from '@cloud-ru/ds-tooltip';
5
5
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
6
6
  import { Typography } from '@cloud-ru/ds-typography';
7
- import { useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
7
+ import { getLinkElementProps, useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
8
8
  import cn from 'classnames';
9
9
  import mergeRefs from 'merge-refs';
10
10
  import {
@@ -12,8 +12,6 @@ import {
12
12
  ElementType,
13
13
  FocusEvent,
14
14
  KeyboardEventHandler,
15
- MouseEvent,
16
- MouseEventHandler,
17
15
  PointerEvent,
18
16
  ReactElement,
19
17
  useMemo,
@@ -26,8 +24,6 @@ import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler } fro
26
24
  import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
27
25
  import styles from './styles.module.scss';
28
26
 
29
- const TARGET_BLANK = '_blank';
30
-
31
27
  const { appearance: ACRYLIC_APPEARANCE, level: ACRYLIC_LEVEL } = backgroundPredefinedFillToAcrylic(
32
28
  BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level,
33
29
  );
@@ -177,21 +173,7 @@ export function CardNavigation<T extends ElementType = 'button'>({
177
173
  );
178
174
 
179
175
  let polymorphicProps: Record<string, unknown>;
180
- if (Component === 'a') {
181
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown as ComponentPropsWithoutRef<'a'>;
182
- polymorphicProps = {
183
- ...anchorRest,
184
- href: href ?? '#',
185
- target,
186
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
187
- onClick: disabled
188
- ? (e: MouseEvent<HTMLAnchorElement>) => {
189
- e.preventDefault();
190
- onClick?.(e);
191
- }
192
- : onClick,
193
- };
194
- } else if (Component === 'button') {
176
+ if (Component === 'button') {
195
177
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown as ComponentPropsWithoutRef<'button'>;
196
178
  polymorphicProps = {
197
179
  type,
@@ -200,17 +182,7 @@ export function CardNavigation<T extends ElementType = 'button'>({
200
182
  ...buttonRest,
201
183
  };
202
184
  } else {
203
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
204
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
205
- const { onClick, ...componentRest } = restWithoutKeyDown as { onClick?: MouseEventHandler<HTMLElement> };
206
- polymorphicProps = {
207
- ...componentRest,
208
- onClick: disabled
209
- ? (e: MouseEvent<HTMLElement>) => {
210
- e.preventDefault();
211
- }
212
- : onClick,
213
- };
185
+ polymorphicProps = getLinkElementProps(Component, restWithoutKeyDown, disabled);
214
186
  }
215
187
 
216
188
  return (
@@ -224,8 +196,6 @@ export function CardNavigation<T extends ElementType = 'button'>({
224
196
  data-visible-actions={visibleActionsCount}
225
197
  data-acrylic-appearance={ACRYLIC_APPEARANCE}
226
198
  data-acrylic-level={ACRYLIC_LEVEL}
227
- aria-disabled={Component !== 'button' && disabled ? true : undefined}
228
- tabIndex={Component !== 'button' && disabled ? -1 : undefined}
229
199
  onKeyDown={handleKeyDown}
230
200
  onPointerEnter={handlePointerEnter}
231
201
  onFocus={handleFocus}
@@ -3,27 +3,16 @@ import { useThemeClassnames } from '@cloud-ru/ds-theme';
3
3
  import { TooltipProps } from '@cloud-ru/ds-tooltip';
4
4
  import { TruncateString } from '@cloud-ru/ds-truncate-string';
5
5
  import { Typography } from '@cloud-ru/ds-typography';
6
- import { useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
6
+ import { getLinkElementProps, useValueControl, withInnerRefSupport } from '@cloud-ru/ds-utils';
7
7
  import cn from 'classnames';
8
8
  import mergeRefs from 'merge-refs';
9
- import {
10
- ComponentPropsWithoutRef,
11
- ElementType,
12
- KeyboardEventHandler,
13
- MouseEvent,
14
- MouseEventHandler,
15
- ReactElement,
16
- useRef,
17
- useState,
18
- } from 'react';
9
+ import { ComponentPropsWithoutRef, ElementType, KeyboardEventHandler, ReactElement, useRef, useState } from 'react';
19
10
 
20
11
  import { TEST_IDS, VISIBILITY_STRATEGY } from '../../constants';
21
12
  import { CardActionsSurface, CardPromoTag, createCardActionsKeyDownHandler } from '../../helperComponents';
22
13
  import { CardPromoTagProps, FavoriteProps, VisibilityStrategy } from '../../types';
23
14
  import styles from './styles.module.scss';
24
15
 
25
- const TARGET_BLANK = '_blank';
26
-
27
16
  type BaseCardServiceLightProps = {
28
17
  /** Иконка сервиса */
29
18
  icon?: ReactElement;
@@ -127,21 +116,7 @@ export function CardServiceLight<T extends ElementType = 'button'>({
127
116
  });
128
117
 
129
118
  let polymorphicProps: Record<string, unknown>;
130
- if (Component === 'a') {
131
- const { href, target, onClick, ...anchorRest } = restWithoutKeyDown as ComponentPropsWithoutRef<'a'>;
132
- polymorphicProps = {
133
- ...anchorRest,
134
- href: href ?? '#',
135
- target,
136
- rel: target === TARGET_BLANK ? 'noopener noreferrer' : undefined,
137
- onClick: disabled
138
- ? (e: MouseEvent<HTMLAnchorElement>) => {
139
- e.preventDefault();
140
- onClick?.(e);
141
- }
142
- : onClick,
143
- };
144
- } else if (Component === 'button') {
119
+ if (Component === 'button') {
145
120
  const { type = 'button', onClick, ...buttonRest } = restWithoutKeyDown as ComponentPropsWithoutRef<'button'>;
146
121
  polymorphicProps = {
147
122
  type,
@@ -150,17 +125,7 @@ export function CardServiceLight<T extends ElementType = 'button'>({
150
125
  ...buttonRest,
151
126
  };
152
127
  } else {
153
- // Кастомный компонент (роутерный Link и т.п.) нативный `disabled` не понимает: гасим переход
154
- // тем же preventDefault, что и на анкоре — иначе disabled-карточка остаётся кликабельной.
155
- const { onClick, ...componentRest } = restWithoutKeyDown as { onClick?: MouseEventHandler<HTMLElement> };
156
- polymorphicProps = {
157
- ...componentRest,
158
- onClick: disabled
159
- ? (e: MouseEvent<HTMLElement>) => {
160
- e.preventDefault();
161
- }
162
- : onClick,
163
- };
128
+ polymorphicProps = getLinkElementProps(Component, restWithoutKeyDown, disabled);
164
129
  }
165
130
 
166
131
  return (
@@ -169,8 +134,6 @@ export function CardServiceLight<T extends ElementType = 'button'>({
169
134
  className={cn(styles.root, className)}
170
135
  data-test-id={dataTestId ?? TEST_IDS.cardServiceLight}
171
136
  data-disabled={disabled || undefined}
172
- aria-disabled={Component !== 'button' && disabled ? true : undefined}
173
- tabIndex={Component !== 'button' && disabled ? -1 : undefined}
174
137
  onKeyDown={handleKeyDown}
175
138
  data-tooltip-open={isTooltipOpen || undefined}
176
139
  {...polymorphicProps}