@snack-uikit/card 0.14.1 → 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/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: {
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Card",
|
|
7
|
-
"version": "0.14.
|
|
7
|
+
"version": "0.14.2-preview-d1a63029.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
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.21.0",
|
|
42
|
+
"@snack-uikit/list": "0.21.1-preview-d1a63029.0",
|
|
43
43
|
"@snack-uikit/promo-tag": "0.6.0",
|
|
44
44
|
"@snack-uikit/tag": "0.11.1",
|
|
45
45
|
"@snack-uikit/truncate-string": "0.6.0",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"@snack-uikit/utils": "3.5.0",
|
|
48
48
|
"classnames": "2.3.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
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);
|