@snack-uikit/card 0.19.16 → 0.20.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 +11 -0
- package/README.md +1 -0
- package/dist/cjs/components/Card/Card.d.ts +4 -0
- package/dist/cjs/components/Card/Card.js +4 -2
- package/dist/cjs/helperComponents/FunctionBadgeWrapper/FunctionBadgeWrapper.d.ts +2 -1
- package/dist/cjs/helperComponents/FunctionBadgeWrapper/FunctionBadgeWrapper.js +5 -3
- package/dist/esm/components/Card/Card.d.ts +4 -0
- package/dist/esm/components/Card/Card.js +2 -2
- package/dist/esm/helperComponents/FunctionBadgeWrapper/FunctionBadgeWrapper.d.ts +2 -1
- package/dist/esm/helperComponents/FunctionBadgeWrapper/FunctionBadgeWrapper.js +3 -2
- package/package.json +2 -2
- package/src/components/Card/Card.tsx +6 -1
- package/src/helperComponents/FunctionBadgeWrapper/FunctionBadgeWrapper.tsx +6 -3
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.20.0 (2025-07-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **VMWDEV-2607:** add prop for always show badge ([4076c9b](https://github.com/cloud-ru-tech/snack-uikit/commit/4076c9bb0c5f7c376cb138fee236751c58a02e6a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.19.16 (2025-07-17)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ import { Card, SearchPrivate } from "@snack-uikit/card";
|
|
|
43
43
|
| functionBadge | `ReactNode` | - | Вложенный FunctionBadge |
|
|
44
44
|
| className | `string` | - | CSS-класс для элемента с контентом |
|
|
45
45
|
| href | `string` | - | Ссылка карточки |
|
|
46
|
+
| badgeAlwaysVisible | `boolean` | - | Всегда показывать FunctionBadge |
|
|
46
47
|
| onKeyDown | `KeyboardEventHandler<HTMLDivElement>` | - | Колбек нажатия клавиши клавиатуры |
|
|
47
48
|
| ref | `LegacyRef<HTMLDivElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|
|
48
49
|
| key | `Key` | - | |
|
|
@@ -34,6 +34,8 @@ export type CardProps = WithSupportProps<{
|
|
|
34
34
|
className?: string;
|
|
35
35
|
/** Ссылка карточки */
|
|
36
36
|
href?: string;
|
|
37
|
+
/** Всегда показывать FunctionBadge */
|
|
38
|
+
badgeAlwaysVisible?: boolean;
|
|
37
39
|
/** Колбек нажатия клавиши клавиатуры */
|
|
38
40
|
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
|
39
41
|
}>;
|
|
@@ -70,6 +72,8 @@ export declare const Card: import("react").ForwardRefExoticComponent<{
|
|
|
70
72
|
className?: string;
|
|
71
73
|
/** Ссылка карточки */
|
|
72
74
|
href?: string;
|
|
75
|
+
/** Всегда показывать FunctionBadge */
|
|
76
|
+
badgeAlwaysVisible?: boolean;
|
|
73
77
|
/** Колбек нажатия клавиши клавиатуры */
|
|
74
78
|
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
|
75
79
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -45,9 +45,10 @@ exports.Card = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
45
45
|
className,
|
|
46
46
|
href,
|
|
47
47
|
onKeyDown: onKeyDownProp,
|
|
48
|
-
name
|
|
48
|
+
name,
|
|
49
|
+
badgeAlwaysVisible
|
|
49
50
|
} = _a,
|
|
50
|
-
rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown", "name"]);
|
|
51
|
+
rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown", "name", "badgeAlwaysVisible"]);
|
|
51
52
|
const localDivRef = (0, react_1.useRef)(null);
|
|
52
53
|
const localAnchorRef = (0, react_1.useRef)(null);
|
|
53
54
|
const onKeyDown = (0, react_1.useCallback)(e => {
|
|
@@ -88,6 +89,7 @@ exports.Card = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
88
89
|
className: styles_module_scss_1.default.anchor,
|
|
89
90
|
"aria-label": supportProps['aria-label']
|
|
90
91
|
}), !disabled && functionBadge && (0, jsx_runtime_1.jsx)(helperComponents_1.FunctionBadgeWrapper, {
|
|
92
|
+
alwaysVisible: badgeAlwaysVisible,
|
|
91
93
|
className: styles_module_scss_1.default.functionBadgeWrapper,
|
|
92
94
|
children: functionBadge
|
|
93
95
|
}), (0, jsx_runtime_1.jsx)("div", {
|
|
@@ -2,5 +2,6 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
export type FunctionBadgeWrapperProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
alwaysVisible?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function FunctionBadgeWrapper({ children, className }: FunctionBadgeWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function FunctionBadgeWrapper({ children, className, alwaysVisible }: FunctionBadgeWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,17 +16,19 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
|
16
16
|
function FunctionBadgeWrapper(_ref) {
|
|
17
17
|
let {
|
|
18
18
|
children,
|
|
19
|
-
className
|
|
19
|
+
className,
|
|
20
|
+
alwaysVisible
|
|
20
21
|
} = _ref;
|
|
21
22
|
const [visible, setVisible] = (0, react_1.useState)(false);
|
|
23
|
+
const show = alwaysVisible ? true : visible;
|
|
22
24
|
return (0, jsx_runtime_1.jsx)(context_1.FunctionBadgeContext.Provider, {
|
|
23
25
|
value: {
|
|
24
|
-
visible,
|
|
26
|
+
visible: show,
|
|
25
27
|
setVisible
|
|
26
28
|
},
|
|
27
29
|
children: (0, jsx_runtime_1.jsx)("div", {
|
|
28
30
|
className: className,
|
|
29
|
-
"data-visible":
|
|
31
|
+
"data-visible": show || undefined,
|
|
30
32
|
tabIndex: -1,
|
|
31
33
|
children: (0, jsx_runtime_1.jsx)("div", {
|
|
32
34
|
className: styles_module_scss_1.default.functionBadge,
|
|
@@ -34,6 +34,8 @@ export type CardProps = WithSupportProps<{
|
|
|
34
34
|
className?: string;
|
|
35
35
|
/** Ссылка карточки */
|
|
36
36
|
href?: string;
|
|
37
|
+
/** Всегда показывать FunctionBadge */
|
|
38
|
+
badgeAlwaysVisible?: boolean;
|
|
37
39
|
/** Колбек нажатия клавиши клавиатуры */
|
|
38
40
|
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
|
39
41
|
}>;
|
|
@@ -70,6 +72,8 @@ export declare const Card: import("react").ForwardRefExoticComponent<{
|
|
|
70
72
|
className?: string;
|
|
71
73
|
/** Ссылка карточки */
|
|
72
74
|
href?: string;
|
|
75
|
+
/** Всегда показывать FunctionBadge */
|
|
76
|
+
badgeAlwaysVisible?: boolean;
|
|
73
77
|
/** Колбек нажатия клавиши клавиатуры */
|
|
74
78
|
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
|
75
79
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -21,7 +21,7 @@ import { Check, FunctionBadgeWrapper, PromoBadge } from '../../helperComponents'
|
|
|
21
21
|
import { TRIGGER_CLICK_KEY_CODES } from './constants';
|
|
22
22
|
import styles from './styles.module.css';
|
|
23
23
|
export const Card = forwardRef((_a, ref) => {
|
|
24
|
-
var { onClick, disabled = false, checked, outline, multipleSelection = false, size = SIZE.M, children, header, footer, functionBadge, promoBadge, image, className, href, onKeyDown: onKeyDownProp, name } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown", "name"]);
|
|
24
|
+
var { onClick, disabled = false, checked, outline, multipleSelection = false, size = SIZE.M, children, header, footer, functionBadge, promoBadge, image, className, href, onKeyDown: onKeyDownProp, name, badgeAlwaysVisible } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className", "href", "onKeyDown", "name", "badgeAlwaysVisible"]);
|
|
25
25
|
const localDivRef = useRef(null);
|
|
26
26
|
const localAnchorRef = useRef(null);
|
|
27
27
|
const onKeyDown = useCallback((e) => {
|
|
@@ -36,5 +36,5 @@ export const Card = forwardRef((_a, ref) => {
|
|
|
36
36
|
const supportProps = extractSupportProps(rest);
|
|
37
37
|
return (_jsx(CardContext.Provider, { value: { size, disabled }, children: _jsxs("div", Object.assign({ ref: mergeRefs(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,
|
|
38
38
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
39
|
-
tabIndex: 0, onKeyDown: onKeyDown, children: [image, _jsxs("div", { className: styles.composition, tabIndex: -1, children: [href && (_jsx("a", { ref: localAnchorRef, "data-test-id": TEST_IDS.anchor, tabIndex: -1, href: href, className: styles.anchor, "aria-label": supportProps['aria-label'] })), !disabled && functionBadge && (_jsx(FunctionBadgeWrapper, { className: styles.functionBadgeWrapper, children: functionBadge })), _jsx("div", { className: styles.contentWrapper, children: _jsxs("div", { className: styles.content, "data-size": size, children: [header || null, children && (_jsx(Typography, { family: 'sans', size: size, purpose: 'body', className: styles.body, tag: 'div', children: children })), footer && _jsx("div", { className: styles.footer, children: footer })] }) }), promoBadge && _jsx(PromoBadge, Object.assign({}, (typeof promoBadge === 'string' ? { text: promoBadge } : promoBadge)))] }), checked && multipleSelection && _jsx(Check, { className: styles.check }), name && _jsx("input", { name: name, type: 'checkbox', checked: checked, style: { display: 'none' } })] })) }));
|
|
39
|
+
tabIndex: 0, onKeyDown: onKeyDown, children: [image, _jsxs("div", { className: styles.composition, tabIndex: -1, children: [href && (_jsx("a", { ref: localAnchorRef, "data-test-id": TEST_IDS.anchor, tabIndex: -1, href: href, className: styles.anchor, "aria-label": supportProps['aria-label'] })), !disabled && functionBadge && (_jsx(FunctionBadgeWrapper, { alwaysVisible: badgeAlwaysVisible, className: styles.functionBadgeWrapper, children: functionBadge })), _jsx("div", { className: styles.contentWrapper, children: _jsxs("div", { className: styles.content, "data-size": size, children: [header || null, children && (_jsx(Typography, { family: 'sans', size: size, purpose: 'body', className: styles.body, tag: 'div', children: children })), footer && _jsx("div", { className: styles.footer, children: footer })] }) }), promoBadge && _jsx(PromoBadge, Object.assign({}, (typeof promoBadge === 'string' ? { text: promoBadge } : promoBadge)))] }), checked && multipleSelection && _jsx(Check, { className: styles.check }), name && _jsx("input", { name: name, type: 'checkbox', checked: checked, style: { display: 'none' } })] })) }));
|
|
40
40
|
});
|
|
@@ -2,5 +2,6 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
export type FunctionBadgeWrapperProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
alwaysVisible?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function FunctionBadgeWrapper({ children, className }: FunctionBadgeWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function FunctionBadgeWrapper({ children, className, alwaysVisible }: FunctionBadgeWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { FunctionBadgeContext } from '../../context';
|
|
4
4
|
import styles from './styles.module.css';
|
|
5
|
-
export function FunctionBadgeWrapper({ children, className }) {
|
|
5
|
+
export function FunctionBadgeWrapper({ children, className, alwaysVisible }) {
|
|
6
6
|
const [visible, setVisible] = useState(false);
|
|
7
|
-
|
|
7
|
+
const show = alwaysVisible ? true : visible;
|
|
8
|
+
return (_jsx(FunctionBadgeContext.Provider, { value: { visible: show, setVisible }, children: _jsx("div", { className: className, "data-visible": show || undefined, tabIndex: -1, children: _jsx("div", { className: styles.functionBadge, children: _jsx("div", { className: styles.functionRow, children: children }) }) }) }));
|
|
8
9
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Card",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.20.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"classnames": "2.5.1",
|
|
49
49
|
"merge-refs": "1.3.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "93f66a95830871b0c0c29d43d6d9c28488a4c10a"
|
|
52
52
|
}
|
|
@@ -54,6 +54,8 @@ export type CardProps = WithSupportProps<{
|
|
|
54
54
|
className?: string;
|
|
55
55
|
/** Ссылка карточки */
|
|
56
56
|
href?: string;
|
|
57
|
+
/** Всегда показывать FunctionBadge */
|
|
58
|
+
badgeAlwaysVisible?: boolean;
|
|
57
59
|
/** Колбек нажатия клавиши клавиатуры */
|
|
58
60
|
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
|
59
61
|
}>;
|
|
@@ -77,6 +79,7 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
|
77
79
|
href,
|
|
78
80
|
onKeyDown: onKeyDownProp,
|
|
79
81
|
name,
|
|
82
|
+
badgeAlwaysVisible,
|
|
80
83
|
...rest
|
|
81
84
|
},
|
|
82
85
|
ref,
|
|
@@ -130,7 +133,9 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
|
130
133
|
)}
|
|
131
134
|
|
|
132
135
|
{!disabled && functionBadge && (
|
|
133
|
-
<FunctionBadgeWrapper className={styles.functionBadgeWrapper}>
|
|
136
|
+
<FunctionBadgeWrapper alwaysVisible={badgeAlwaysVisible} className={styles.functionBadgeWrapper}>
|
|
137
|
+
{functionBadge}
|
|
138
|
+
</FunctionBadgeWrapper>
|
|
134
139
|
)}
|
|
135
140
|
|
|
136
141
|
<div className={styles.contentWrapper}>
|
|
@@ -6,14 +6,17 @@ import styles from './styles.module.scss';
|
|
|
6
6
|
export type FunctionBadgeWrapperProps = {
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
className?: string;
|
|
9
|
+
alwaysVisible?: boolean;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export function FunctionBadgeWrapper({ children, className }: FunctionBadgeWrapperProps) {
|
|
12
|
+
export function FunctionBadgeWrapper({ children, className, alwaysVisible }: FunctionBadgeWrapperProps) {
|
|
12
13
|
const [visible, setVisible] = useState<boolean>(false);
|
|
13
14
|
|
|
15
|
+
const show = alwaysVisible ? true : visible;
|
|
16
|
+
|
|
14
17
|
return (
|
|
15
|
-
<FunctionBadgeContext.Provider value={{ visible, setVisible }}>
|
|
16
|
-
<div className={className} data-visible={
|
|
18
|
+
<FunctionBadgeContext.Provider value={{ visible: show, setVisible }}>
|
|
19
|
+
<div className={className} data-visible={show || undefined} tabIndex={-1}>
|
|
17
20
|
<div className={styles.functionBadge}>
|
|
18
21
|
<div className={styles.functionRow}>{children}</div>
|
|
19
22
|
</div>
|