@snack-uikit/card 0.14.0 → 0.14.2-preview-d1a63029.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.14.1 (2024-10-31)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-438:** stylelint update ([9d40d4e](https://github.com/cloud-ru-tech/snack-uikit/commit/9d40d4eb445eeaaca5a2dc1f6421d496f86aeac3))
12
+
13
+
14
+
15
+
16
+
6
17
  # 0.14.0 (2024-10-28)
7
18
 
8
19
 
package/README.md CHANGED
@@ -42,6 +42,7 @@ import { Card, SearchPrivate } from "@snack-uikit/card";
42
42
  | functionBadge | `ReactNode` | - | Вложенный FunctionBadge |
43
43
  | className | `string` | - | CSS-класс для элемента с контентом |
44
44
  | href | `string` | - | Ссылка карточки |
45
+ | onKeyDown | `KeyboardEventHandler<HTMLDivElement>` | - | Колбек нажатия клавиши клавиатуры |
45
46
 
46
47
 
47
48
  [//]: DOCUMENTATION_SECTION_END
@@ -1,4 +1,4 @@
1
- import { MouseEvent, ReactElement, ReactNode } from 'react';
1
+ import { KeyboardEventHandler, MouseEvent, ReactElement, ReactNode } from 'react';
2
2
  import { PromoTagProps } from '@snack-uikit/promo-tag';
3
3
  import { WithSupportProps } from '@snack-uikit/utils';
4
4
  import { Size } from '../../types';
@@ -32,5 +32,7 @@ export type CardProps = WithSupportProps<{
32
32
  className?: string;
33
33
  /** Ссылка карточки */
34
34
  href?: string;
35
+ /** Колбек нажатия клавиши клавиатуры */
36
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
35
37
  }>;
36
- export declare function Card({ onClick, disabled, checked, outline, multipleSelection, size, children, header, footer, functionBadge, promoBadge, image, className, href, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
38
+ export declare function Card({ onClick, disabled, checked, outline, multipleSelection, size, children, header, footer, functionBadge, promoBadge, image, className, href, onKeyDown: onKeyDownProp, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
@@ -42,9 +42,10 @@ function Card(_a) {
42
42
  promoBadge,
43
43
  image,
44
44
  className,
45
- href
45
+ href,
46
+ onKeyDown: onKeyDownProp
46
47
  } = _a,
47
- rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href"]);
48
+ rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown"]);
48
49
  const localDivRef = (0, react_1.useRef)(null);
49
50
  const localAnchorRef = (0, react_1.useRef)(null);
50
51
  const onKeyDown = (0, react_1.useCallback)(e => {
@@ -53,8 +54,9 @@ function Card(_a) {
53
54
  if (constants_2.TRIGGER_CLICK_KEY_CODES.includes(e.code) || e.key === ' ') {
54
55
  href ? (_a = localAnchorRef.current) === null || _a === void 0 ? void 0 : _a.click() : (_b = localDivRef.current) === null || _b === void 0 ? void 0 : _b.click();
55
56
  }
57
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(e);
56
58
  }
57
- }, [href]);
59
+ }, [href, onKeyDownProp]);
58
60
  const supportProps = (0, utils_1.extractSupportProps)(rest);
59
61
  return (0, jsx_runtime_1.jsx)(context_1.CardContext.Provider, {
60
62
  value: {
@@ -2,7 +2,6 @@
2
2
  padding-top:var(--space-card-padding-function-badge, 8px);
3
3
  padding-right:var(--space-card-padding-function-badge, 8px);
4
4
  position:absolute;
5
- z-index:1;
6
5
  top:0;
7
6
  right:0;
8
7
  box-sizing:border-box;
@@ -1,4 +1,4 @@
1
- import { MouseEvent, ReactElement, ReactNode } from 'react';
1
+ import { KeyboardEventHandler, MouseEvent, ReactElement, ReactNode } from 'react';
2
2
  import { PromoTagProps } from '@snack-uikit/promo-tag';
3
3
  import { WithSupportProps } from '@snack-uikit/utils';
4
4
  import { Size } from '../../types';
@@ -32,5 +32,7 @@ export type CardProps = WithSupportProps<{
32
32
  className?: string;
33
33
  /** Ссылка карточки */
34
34
  href?: string;
35
+ /** Колбек нажатия клавиши клавиатуры */
36
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
35
37
  }>;
36
- export declare function Card({ onClick, disabled, checked, outline, multipleSelection, size, children, header, footer, functionBadge, promoBadge, image, className, href, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
38
+ export declare function Card({ onClick, disabled, checked, outline, multipleSelection, size, children, header, footer, functionBadge, promoBadge, image, className, href, onKeyDown: onKeyDownProp, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
@@ -20,7 +20,7 @@ import { Check, FunctionBadgeWrapper, PromoBadge } from '../../helperComponents'
20
20
  import { TRIGGER_CLICK_KEY_CODES } from './constants';
21
21
  import styles from './styles.module.css';
22
22
  export function Card(_a) {
23
- var { onClick, disabled = false, checked, outline, multipleSelection = false, size = SIZE.M, children, header, footer, functionBadge, promoBadge, image, className, href } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href"]);
23
+ var { onClick, disabled = false, checked, outline, multipleSelection = false, size = SIZE.M, children, header, footer, functionBadge, promoBadge, image, className, href, onKeyDown: onKeyDownProp } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown"]);
24
24
  const localDivRef = useRef(null);
25
25
  const localAnchorRef = useRef(null);
26
26
  const onKeyDown = useCallback((e) => {
@@ -29,8 +29,9 @@ export function Card(_a) {
29
29
  if (TRIGGER_CLICK_KEY_CODES.includes(e.code) || e.key === ' ') {
30
30
  href ? (_a = localAnchorRef.current) === null || _a === void 0 ? void 0 : _a.click() : (_b = localDivRef.current) === null || _b === void 0 ? void 0 : _b.click();
31
31
  }
32
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(e);
32
33
  }
33
- }, [href]);
34
+ }, [href, onKeyDownProp]);
34
35
  const supportProps = extractSupportProps(rest);
35
36
  return (_jsx(CardContext.Provider, { value: { size, disabled }, children: _jsxs("div", Object.assign({ ref: localDivRef, className: cn(styles.card, className) }, supportProps, { onClick: onClick, "data-disabled": disabled || undefined, "data-checked": checked || undefined, "data-outline": outline || undefined, "data-pointer": onClick ? true : undefined,
36
37
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
@@ -2,7 +2,6 @@
2
2
  padding-top:var(--space-card-padding-function-badge, 8px);
3
3
  padding-right:var(--space-card-padding-function-badge, 8px);
4
4
  position:absolute;
5
- z-index:1;
6
5
  top:0;
7
6
  right:0;
8
7
  box-sizing:border-box;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Card",
7
- "version": "0.14.0",
7
+ "version": "0.14.2-preview-d1a63029.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -36,16 +36,16 @@
36
36
  "license": "Apache-2.0",
37
37
  "scripts": {},
38
38
  "dependencies": {
39
- "@snack-uikit/button": "0.19.0",
39
+ "@snack-uikit/button": "0.19.1",
40
40
  "@snack-uikit/icon-predefined": "0.7.0",
41
41
  "@snack-uikit/icons": "0.24.0",
42
- "@snack-uikit/list": "0.20.0",
42
+ "@snack-uikit/list": "0.21.1-preview-d1a63029.0",
43
43
  "@snack-uikit/promo-tag": "0.6.0",
44
- "@snack-uikit/tag": "0.11.0",
44
+ "@snack-uikit/tag": "0.11.1",
45
45
  "@snack-uikit/truncate-string": "0.6.0",
46
46
  "@snack-uikit/typography": "0.8.0",
47
47
  "@snack-uikit/utils": "3.5.0",
48
48
  "classnames": "2.3.2"
49
49
  },
50
- "gitHead": "8499829efa0c118b704de17411ae2328a024adb5"
50
+ "gitHead": "167f0c505b9958dc320111f7ee9e8ed2ebc58796"
51
51
  }
@@ -1,5 +1,5 @@
1
1
  import cn from 'classnames';
2
- import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, useCallback, useRef } from 'react';
2
+ import { KeyboardEvent, KeyboardEventHandler, MouseEvent, ReactElement, ReactNode, useCallback, useRef } from 'react';
3
3
 
4
4
  import { PromoTagProps } from '@snack-uikit/promo-tag';
5
5
  import { Typography } from '@snack-uikit/typography';
@@ -42,6 +42,8 @@ export type CardProps = WithSupportProps<{
42
42
  className?: string;
43
43
  /** Ссылка карточки */
44
44
  href?: string;
45
+ /** Колбек нажатия клавиши клавиатуры */
46
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
45
47
  }>;
46
48
 
47
49
  export function Card({
@@ -59,6 +61,7 @@ export function Card({
59
61
  image,
60
62
  className,
61
63
  href,
64
+ onKeyDown: onKeyDownProp,
62
65
  ...rest
63
66
  }: CardProps) {
64
67
  const localDivRef = useRef<HTMLDivElement>(null);
@@ -70,9 +73,11 @@ export function Card({
70
73
  if (TRIGGER_CLICK_KEY_CODES.includes(e.code) || e.key === ' ') {
71
74
  href ? localAnchorRef.current?.click() : localDivRef.current?.click();
72
75
  }
76
+
77
+ onKeyDownProp?.(e);
73
78
  }
74
79
  },
75
- [href],
80
+ [href, onKeyDownProp],
76
81
  );
77
82
 
78
83
  const supportProps = extractSupportProps(rest);
@@ -5,6 +5,7 @@ $sizes: 's', 'm', 'l';
5
5
 
6
6
  .functionBadgeWrapper {
7
7
  position: absolute;
8
+ /* stylelint-disable-next-line declaration-property-value-allowed-list */
8
9
  z-index: 1;
9
10
  top: 0;
10
11
  right: 0;
@@ -32,6 +33,7 @@ $sizes: 's', 'm', 'l';
32
33
  @include styles-tokens-card.composite-var(styles-tokens-card.$card-container);
33
34
 
34
35
  position: relative;
36
+ /* stylelint-disable-next-line declaration-property-value-allowed-list */
35
37
  z-index: 0;
36
38
 
37
39
  overflow: hidden;
@@ -180,6 +182,7 @@ $sizes: 's', 'm', 'l';
180
182
 
181
183
  .anchor {
182
184
  position: absolute;
185
+ /* stylelint-disable-next-line declaration-property-value-allowed-list */
183
186
  z-index: 1;
184
187
  top: 0;
185
188
  right: 0;
@@ -4,10 +4,8 @@
4
4
  @include styles-tokens-card.composite-var(styles-tokens-card.$card-function-badge);
5
5
 
6
6
  position: absolute;
7
- z-index: 1;
8
7
  top: 0;
9
8
  right: 0;
10
-
11
9
  box-sizing: border-box;
12
10
  }
13
11