@cloud-ru/uikit-product-card-predefined 0.8.12

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +830 -0
  2. package/LICENSE +201 -0
  3. package/README.md +49 -0
  4. package/dist/cjs/components/CardBanner/CardBanner.d.ts +14 -0
  5. package/dist/cjs/components/CardBanner/CardBanner.js +36 -0
  6. package/dist/cjs/components/CardBanner/index.d.ts +1 -0
  7. package/dist/cjs/components/CardBanner/index.js +17 -0
  8. package/dist/cjs/components/CardBanner/styles.module.css +33 -0
  9. package/dist/cjs/components/CardService/CardService.d.ts +7 -0
  10. package/dist/cjs/components/CardService/CardService.js +27 -0
  11. package/dist/cjs/components/CardService/index.d.ts +1 -0
  12. package/dist/cjs/components/CardService/index.js +17 -0
  13. package/dist/cjs/components/CardServiceSmall/CardServiceSmall.d.ts +14 -0
  14. package/dist/cjs/components/CardServiceSmall/CardServiceSmall.js +61 -0
  15. package/dist/cjs/components/CardServiceSmall/index.d.ts +1 -0
  16. package/dist/cjs/components/CardServiceSmall/index.js +17 -0
  17. package/dist/cjs/components/CardServiceSmall/styles.module.css +52 -0
  18. package/dist/cjs/components/CardSuggest/CardSuggest.d.ts +12 -0
  19. package/dist/cjs/components/CardSuggest/CardSuggest.js +28 -0
  20. package/dist/cjs/components/CardSuggest/constants.d.ts +4 -0
  21. package/dist/cjs/components/CardSuggest/constants.js +7 -0
  22. package/dist/cjs/components/CardSuggest/index.d.ts +1 -0
  23. package/dist/cjs/components/CardSuggest/index.js +17 -0
  24. package/dist/cjs/components/index.d.ts +4 -0
  25. package/dist/cjs/components/index.js +20 -0
  26. package/dist/cjs/index.d.ts +1 -0
  27. package/dist/cjs/index.js +17 -0
  28. package/dist/esm/components/CardBanner/CardBanner.d.ts +14 -0
  29. package/dist/esm/components/CardBanner/CardBanner.js +30 -0
  30. package/dist/esm/components/CardBanner/index.d.ts +1 -0
  31. package/dist/esm/components/CardBanner/index.js +1 -0
  32. package/dist/esm/components/CardBanner/styles.module.css +33 -0
  33. package/dist/esm/components/CardService/CardService.d.ts +7 -0
  34. package/dist/esm/components/CardService/CardService.js +24 -0
  35. package/dist/esm/components/CardService/index.d.ts +1 -0
  36. package/dist/esm/components/CardService/index.js +1 -0
  37. package/dist/esm/components/CardServiceSmall/CardServiceSmall.d.ts +14 -0
  38. package/dist/esm/components/CardServiceSmall/CardServiceSmall.js +55 -0
  39. package/dist/esm/components/CardServiceSmall/index.d.ts +1 -0
  40. package/dist/esm/components/CardServiceSmall/index.js +1 -0
  41. package/dist/esm/components/CardServiceSmall/styles.module.css +52 -0
  42. package/dist/esm/components/CardSuggest/CardSuggest.d.ts +12 -0
  43. package/dist/esm/components/CardSuggest/CardSuggest.js +25 -0
  44. package/dist/esm/components/CardSuggest/constants.d.ts +4 -0
  45. package/dist/esm/components/CardSuggest/constants.js +4 -0
  46. package/dist/esm/components/CardSuggest/index.d.ts +1 -0
  47. package/dist/esm/components/CardSuggest/index.js +1 -0
  48. package/dist/esm/components/index.d.ts +4 -0
  49. package/dist/esm/components/index.js +4 -0
  50. package/dist/esm/index.d.ts +1 -0
  51. package/dist/esm/index.js +1 -0
  52. package/package.json +52 -0
  53. package/src/components/CardBanner/CardBanner.tsx +83 -0
  54. package/src/components/CardBanner/index.ts +1 -0
  55. package/src/components/CardBanner/styles.module.scss +33 -0
  56. package/src/components/CardService/CardService.tsx +41 -0
  57. package/src/components/CardService/index.ts +1 -0
  58. package/src/components/CardServiceSmall/CardServiceSmall.tsx +140 -0
  59. package/src/components/CardServiceSmall/index.ts +1 -0
  60. package/src/components/CardServiceSmall/styles.module.scss +60 -0
  61. package/src/components/CardSuggest/CardSuggest.tsx +54 -0
  62. package/src/components/CardSuggest/constants.ts +4 -0
  63. package/src/components/CardSuggest/index.ts +1 -0
  64. package/src/components/index.ts +4 -0
  65. package/src/index.ts +1 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CardSuggest"), exports);
@@ -0,0 +1,4 @@
1
+ export * from './CardBanner';
2
+ export * from './CardSuggest';
3
+ export * from './CardService';
4
+ export * from './CardServiceSmall';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CardBanner"), exports);
18
+ __exportStar(require("./CardSuggest"), exports);
19
+ __exportStar(require("./CardService"), exports);
20
+ __exportStar(require("./CardServiceSmall"), exports);
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./components"), exports);
@@ -0,0 +1,14 @@
1
+ import { MouseEventHandler } from 'react';
2
+ import { CardProps } from '@snack-uikit/card';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ export type CardBannerProps = WithSupportProps<Pick<CardProps, 'onClick' | 'className' | 'disabled' | 'href'> & {
5
+ title: string;
6
+ description: string;
7
+ actionLabel: string;
8
+ image: {
9
+ src: string;
10
+ alt: string;
11
+ };
12
+ onClose?: MouseEventHandler<HTMLElement>;
13
+ }>;
14
+ export declare function CardBanner({ href, title, description, onClick, actionLabel, image, className, onClose, disabled, ...rest }: CardBannerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { ArrowRightSVG, CrossSVG } from '@sbercloud/uikit-product-icons';
14
+ import { ButtonTonal } from '@snack-uikit/button';
15
+ import { Card } from '@snack-uikit/card';
16
+ import { TruncateString } from '@snack-uikit/truncate-string';
17
+ import { Typography } from '@snack-uikit/typography';
18
+ import { extractSupportProps } from '@snack-uikit/utils';
19
+ import styles from './styles.module.css';
20
+ export function CardBanner(_a) {
21
+ var { href, title, description, onClick, actionLabel, image, className, onClose, disabled } = _a, rest = __rest(_a, ["href", "title", "description", "onClick", "actionLabel", "image", "className", "onClose", "disabled"]);
22
+ return (_jsx(Card
23
+ // TODO: typescript error
24
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25
+ // @ts-ignore
26
+ , Object.assign({}, extractSupportProps(rest), { href: href, className: className, onClick: onClick, disabled: disabled, functionBadge: onClose ? (_jsx("div", { className: styles.cardFunctionBadgeWrapper, children: _jsx(ButtonTonal, { icon: _jsx(CrossSVG, {}), appearance: 'neutral', onClick: e => {
27
+ e.stopPropagation();
28
+ onClose(e);
29
+ }, size: 'xs' }) })) : undefined, children: _jsxs("div", { className: styles.cardBannerContent, children: [_jsxs("div", { className: styles.cardBannerLeft, children: [_jsx(Card.Header, { title: title, truncate: { title: 2 } }), _jsx(Typography.SansBodyM, { children: _jsx(TruncateString, { "data-test-id": 'card-banner__description', maxLines: 2, text: description, className: styles.cardBannerDescription }) }), _jsx(Card.Footer.CallToAction, { label: actionLabel, icon: _jsx(ArrowRightSVG, {}) })] }), _jsx("img", { src: image.src, alt: image.alt, className: styles.cardBannerImage, "data-test-id": 'card-banner__image' })] }) })));
30
+ }
@@ -0,0 +1 @@
1
+ export * from './CardBanner';
@@ -0,0 +1 @@
1
+ export * from './CardBanner';
@@ -0,0 +1,33 @@
1
+ .cardBannerContent{
2
+ display:flex;
3
+ flex-direction:row;
4
+ justify-content:space-between;
5
+ gap:var(--dimension-2m, 16px);
6
+ width:100%;
7
+ }
8
+
9
+ .cardBannerLeft{
10
+ display:flex;
11
+ flex-direction:column;
12
+ flex-grow:1;
13
+ gap:calc(var(--dimension-050m, 4px) + var(--dimension-1m, 8px));
14
+ }
15
+
16
+ .cardBannerDescription{
17
+ color:var(--sys-neutral-text-support, #6d707f);
18
+ }
19
+
20
+ .cardBannerImage{
21
+ width:calc(var(--dimension-5m, 40px) + var(--dimension-7m, 56px));
22
+ flex-shrink:0;
23
+ -o-object-position:center;
24
+ object-position:center;
25
+ -o-object-fit:cover;
26
+ object-fit:cover;
27
+ }
28
+
29
+ .cardFunctionBadgeWrapper{
30
+ display:flex;
31
+ align-items:flex-end;
32
+ justify-content:flex-start;
33
+ }
@@ -0,0 +1,7 @@
1
+ import { Card, CardProps } from '@snack-uikit/card';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ export type CardServiceProps = WithSupportProps<Pick<CardProps, 'onClick' | 'className' | 'disabled' | 'href'> & Required<Pick<Card.HeaderProps, 'title' | 'emblem'>> & {
4
+ description: string;
5
+ actionLabel: string;
6
+ }>;
7
+ export declare function CardService({ href, title, description, actionLabel, emblem, onClick, className, disabled, ...rest }: CardServiceProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { ArrowRightSVG } from '@sbercloud/uikit-product-icons';
14
+ import { Card } from '@snack-uikit/card';
15
+ import { TruncateString } from '@snack-uikit/truncate-string';
16
+ import { extractSupportProps } from '@snack-uikit/utils';
17
+ export function CardService(_a) {
18
+ var { href, title, description, actionLabel, emblem, onClick, className, disabled } = _a, rest = __rest(_a, ["href", "title", "description", "actionLabel", "emblem", "onClick", "className", "disabled"]);
19
+ return (_jsx(Card
20
+ // TODO: typescript error
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
+ // @ts-ignore
23
+ , Object.assign({}, extractSupportProps(rest), { href: href, disabled: disabled, className: className, header: _jsx(Card.Header, { title: title, emblem: emblem, truncate: { title: 2 } }), onClick: onClick, footer: _jsx(Card.Footer.CallToAction, { label: actionLabel, icon: _jsx(ArrowRightSVG, {}) }), children: _jsx(TruncateString, { text: description, maxLines: 3, "data-test-id": 'card-service__description' }) })));
24
+ }
@@ -0,0 +1 @@
1
+ export * from './CardService';
@@ -0,0 +1 @@
1
+ export * from './CardService';
@@ -0,0 +1,14 @@
1
+ import { PromoTagPredefinedProps } from '@sbercloud/uikit-product-promo-tag-predefined';
2
+ import { Card, CardProps } from '@snack-uikit/card';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ export type CardServiceSmallProps = WithSupportProps<Pick<CardProps, 'onClick' | 'className' | 'disabled' | 'outline' | 'href' | 'checked'> & Required<Pick<Card.HeaderProps, 'title' | 'emblem'>> & {
5
+ truncate?: Pick<NonNullable<Card.HeaderProps['truncate']>, 'title'>;
6
+ favorite?: {
7
+ enabled: boolean;
8
+ visibilityStrategy: 'always' | 'hover';
9
+ checked?: boolean;
10
+ onChange?(value: boolean): void;
11
+ };
12
+ promoBadge?: PromoTagPredefinedProps | CardProps['promoBadge'];
13
+ }>;
14
+ export declare function CardServiceSmall({ href, promoBadge, title, emblem, onClick, className, disabled, truncate, outline, checked, favorite, ...rest }: CardServiceSmallProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,55 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import { useRef } from 'react';
15
+ import { useUncontrolledProp } from 'uncontrollable';
16
+ import { PromoTagPredefined } from '@sbercloud/uikit-product-promo-tag-predefined';
17
+ import { Card } from '@snack-uikit/card';
18
+ import { PromoTag } from '@snack-uikit/promo-tag';
19
+ import { Favorite } from '@snack-uikit/toggles';
20
+ import { TruncateString } from '@snack-uikit/truncate-string';
21
+ import { Typography } from '@snack-uikit/typography';
22
+ import { extractSupportProps } from '@snack-uikit/utils';
23
+ import styles from './styles.module.css';
24
+ function isIconProps(props) {
25
+ return Boolean(props && 'icon' in props);
26
+ }
27
+ export function CardServiceSmall(_a) {
28
+ var { href, promoBadge, title, emblem, onClick, className, disabled, truncate, outline, checked, favorite } = _a, rest = __rest(_a, ["href", "promoBadge", "title", "emblem", "onClick", "className", "disabled", "truncate", "outline", "checked", "favorite"]);
29
+ const [isFavourite, setIsFavorite] = useUncontrolledProp(favorite === null || favorite === void 0 ? void 0 : favorite.checked, false, favorite === null || favorite === void 0 ? void 0 : favorite.onChange);
30
+ const favoriteRef = useRef(null);
31
+ const cardRef = useRef(null);
32
+ const Icon = isIconProps(emblem) ? emblem.icon : undefined;
33
+ const onCardKeyDown = event => {
34
+ var _a;
35
+ if (event.code === 'ArrowRight') {
36
+ (_a = favoriteRef.current) === null || _a === void 0 ? void 0 : _a.focus();
37
+ }
38
+ };
39
+ const onFavoriteKeyUp = event => {
40
+ var _a;
41
+ event.preventDefault();
42
+ if (event.code === 'ArrowLeft') {
43
+ (_a = cardRef.current) === null || _a === void 0 ? void 0 : _a.focus();
44
+ }
45
+ if (event.code === 'Space' || event.code === 'Enter') {
46
+ setIsFavorite(!isFavourite);
47
+ }
48
+ };
49
+ const onFavoriteClick = event => {
50
+ var _a;
51
+ event.stopPropagation();
52
+ (_a = favoriteRef.current) === null || _a === void 0 ? void 0 : _a.blur();
53
+ };
54
+ return (_jsxs("div", { className: cn(styles.wrapper, className), children: [_jsx(Card, Object.assign({}, extractSupportProps(rest), { href: href, ref: cardRef, onKeyDown: onCardKeyDown, header: _jsxs("div", { className: styles.contentWrapper, children: [Icon && _jsx(Icon, { className: styles.icon }), _jsx("div", { className: styles.contentLayout, children: _jsx(Typography, { family: 'sans', size: 's', purpose: 'title', className: styles.title, "data-test-id": 'card-service-small__title', children: _jsx(TruncateString, { text: title, maxLines: truncate === null || truncate === void 0 ? void 0 : truncate.title, variant: 'end' }) }) }), favorite && favorite.enabled && (_jsx("div", { className: styles.favoriteWrapper, "data-visibility-strategy": favorite.visibilityStrategy, children: _jsx(Favorite, { size: 'm', checked: isFavourite, inputRef: favoriteRef, onChange: setIsFavorite, tabIndex: -1, onKeyUp: onFavoriteKeyUp, onClick: onFavoriteClick, "data-test-id": 'card-service-small__favorite', icon: 'star' }) }))] }), onClick: onClick, disabled: disabled, outline: outline, checked: checked, size: 's' })), promoBadge && (_jsx("div", { className: styles.promoTagWrapper, children: typeof promoBadge === 'object' && 'variant' in promoBadge ? (_jsx(PromoTagPredefined, Object.assign({ "data-test-id": 'card-service-small__promo-badge' }, promoBadge))) : (_jsx(PromoTag, Object.assign({ color: 'decor' }, (typeof promoBadge === 'string' ? { text: promoBadge, appearance: 'primary' } : promoBadge), { "data-test-id": 'card-service-small__promo-badge' }))) }))] }));
55
+ }
@@ -0,0 +1 @@
1
+ export * from './CardServiceSmall';
@@ -0,0 +1 @@
1
+ export * from './CardServiceSmall';
@@ -0,0 +1,52 @@
1
+ .favoriteWrapper{
2
+ flex-shrink:0;
3
+ z-index:1;
4
+ }
5
+ .favoriteWrapper[data-visibility-strategy=hover]{
6
+ display:none;
7
+ }
8
+ .favoriteWrapper[data-visibility-strategy=always]{
9
+ display:flex;
10
+ }
11
+
12
+ .wrapper{
13
+ position:relative;
14
+ }
15
+ .wrapper:hover .favoriteWrapper, .wrapper:focus-within .favoriteWrapper{
16
+ display:flex;
17
+ }
18
+
19
+ .contentWrapper{
20
+ box-sizing:border-box;
21
+ display:flex;
22
+ align-items:center;
23
+ justify-content:space-between;
24
+ width:100%;
25
+ height:var(--dimension-4m, 32px);
26
+ gap:var(--dimension-1m, 8px);
27
+ color:var(--sys-neutral-text-main, #41424e);
28
+ }
29
+
30
+ .contentLayout{
31
+ overflow:hidden;
32
+ display:block;
33
+ max-width:100%;
34
+ min-width:0;
35
+ flex-grow:1;
36
+ }
37
+
38
+ .icon{
39
+ flex-shrink:0;
40
+ }
41
+
42
+ .title{
43
+ display:block;
44
+ max-width:100%;
45
+ }
46
+
47
+ .promoTagWrapper{
48
+ position:absolute;
49
+ top:-4px;
50
+ right:-4px;
51
+ display:flex;
52
+ }
@@ -0,0 +1,12 @@
1
+ import { CardProps } from '@snack-uikit/card';
2
+ import { WithSupportProps } from '@snack-uikit/utils';
3
+ export type CardSuggestProps = WithSupportProps<Pick<CardProps, 'promoBadge' | 'onClick' | 'className' | 'disabled' | 'href'> & {
4
+ size?: 's' | 'm';
5
+ title: string;
6
+ description: string;
7
+ truncate?: {
8
+ title?: number;
9
+ description?: number;
10
+ };
11
+ }>;
12
+ export declare function CardSuggest({ title, description, truncate, onClick, className, disabled, href, promoBadge, size, ...rest }: CardSuggestProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Card } from '@snack-uikit/card';
14
+ import { TruncateString } from '@snack-uikit/truncate-string';
15
+ import { extractSupportProps } from '@snack-uikit/utils';
16
+ import { TRUNCATE_DEFAULTS } from './constants';
17
+ export function CardSuggest(_a) {
18
+ var { title, description, truncate, onClick, className, disabled, href, promoBadge, size } = _a, rest = __rest(_a, ["title", "description", "truncate", "onClick", "className", "disabled", "href", "promoBadge", "size"]);
19
+ const truncateLines = Object.assign(Object.assign({}, TRUNCATE_DEFAULTS), truncate);
20
+ return (_jsx(Card
21
+ // TODO: typescript error
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ , Object.assign({}, extractSupportProps(rest), { size: size, promoBadge: promoBadge, href: href, disabled: disabled, header: _jsx(Card.Header, { title: title, truncate: { title: truncateLines.title } }), onClick: onClick, className: className, children: _jsx(TruncateString, { text: description, maxLines: truncateLines.description, "data-test-id": 'card-suggest__description' }) })));
25
+ }
@@ -0,0 +1,4 @@
1
+ export declare const TRUNCATE_DEFAULTS: {
2
+ title: number;
3
+ description: number;
4
+ };
@@ -0,0 +1,4 @@
1
+ export const TRUNCATE_DEFAULTS = {
2
+ title: 2,
3
+ description: 3,
4
+ };
@@ -0,0 +1 @@
1
+ export * from './CardSuggest';
@@ -0,0 +1 @@
1
+ export * from './CardSuggest';
@@ -0,0 +1,4 @@
1
+ export * from './CardBanner';
2
+ export * from './CardSuggest';
3
+ export * from './CardService';
4
+ export * from './CardServiceSmall';
@@ -0,0 +1,4 @@
1
+ export * from './CardBanner';
2
+ export * from './CardSuggest';
3
+ export * from './CardService';
4
+ export * from './CardServiceSmall';
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1 @@
1
+ export * from './components';
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@cloud-ru/uikit-product-card-predefined",
3
+ "title": "Card Predefined",
4
+ "version": "0.8.12",
5
+ "sideEffects": [
6
+ "*.css",
7
+ "*.woff",
8
+ "*.woff2"
9
+ ],
10
+ "description": "",
11
+ "types": "./dist/esm/index.d.ts",
12
+ "exports": {
13
+ "import": "./dist/esm/index.js",
14
+ "require": "./dist/cjs/index.js"
15
+ },
16
+ "files": [
17
+ "dist/esm",
18
+ "dist/cjs",
19
+ "src",
20
+ "./CHANGELOG.md",
21
+ "./LICENSE"
22
+ ],
23
+ "homepage": "https://gitverse.ru/cloud-ru-tech/uikit-product/-/tree/master/packages/card-predefined",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://gitverse.ru/cloud-ru-tech/uikit-product.git",
27
+ "directory": "packages/card-predefined"
28
+ },
29
+ "author": {
30
+ "name": "Akhremenko Grigorii",
31
+ "url": "https://github.com/AGrigorii"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {},
38
+ "dependencies": {
39
+ "@cloud-ru/uikit-product-icons": "15.1.1",
40
+ "@cloud-ru/uikit-product-promo-tag-predefined": "0.2.4",
41
+ "@snack-uikit/button": "0.19.16",
42
+ "@snack-uikit/card": "0.16.19",
43
+ "@snack-uikit/promo-tag": "0.7.1",
44
+ "@snack-uikit/toggles": "0.13.5",
45
+ "@snack-uikit/truncate-string": "0.6.9",
46
+ "@snack-uikit/typography": "0.8.4",
47
+ "@snack-uikit/utils": "3.7.0",
48
+ "classnames": "2.5.1",
49
+ "uncontrollable": "8.0.4"
50
+ },
51
+ "gitHead": "e8bd79bc92b26a8f52611972eec98a867536ccd3"
52
+ }
@@ -0,0 +1,83 @@
1
+ import { MouseEventHandler } from 'react';
2
+
3
+ import { ArrowRightSVG, CrossSVG } from '@cloud-ru/uikit-product-icons';
4
+ import { ButtonTonal } from '@snack-uikit/button';
5
+ import { Card, CardProps } from '@snack-uikit/card';
6
+ import { TruncateString } from '@snack-uikit/truncate-string';
7
+ import { Typography } from '@snack-uikit/typography';
8
+ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
9
+
10
+ import styles from './styles.module.scss';
11
+
12
+ export type CardBannerProps = WithSupportProps<
13
+ Pick<CardProps, 'onClick' | 'className' | 'disabled' | 'href'> & {
14
+ title: string;
15
+ description: string;
16
+ actionLabel: string;
17
+ image: {
18
+ src: string;
19
+ alt: string;
20
+ };
21
+ onClose?: MouseEventHandler<HTMLElement>;
22
+ }
23
+ >;
24
+
25
+ export function CardBanner({
26
+ href,
27
+ title,
28
+ description,
29
+ onClick,
30
+ actionLabel,
31
+ image,
32
+ className,
33
+ onClose,
34
+ disabled,
35
+ ...rest
36
+ }: CardBannerProps) {
37
+ return (
38
+ <Card
39
+ // TODO: typescript error
40
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
+ // @ts-ignore
42
+ {...extractSupportProps(rest)}
43
+ href={href}
44
+ className={className}
45
+ onClick={onClick}
46
+ disabled={disabled}
47
+ functionBadge={
48
+ onClose ? (
49
+ <div className={styles.cardFunctionBadgeWrapper}>
50
+ <ButtonTonal
51
+ icon={<CrossSVG />}
52
+ appearance='neutral'
53
+ onClick={e => {
54
+ e.stopPropagation();
55
+ onClose(e);
56
+ }}
57
+ size='xs'
58
+ />
59
+ </div>
60
+ ) : undefined
61
+ }
62
+ >
63
+ <div className={styles.cardBannerContent}>
64
+ <div className={styles.cardBannerLeft}>
65
+ <Card.Header title={title} truncate={{ title: 2 }} />
66
+
67
+ <Typography.SansBodyM>
68
+ <TruncateString
69
+ data-test-id='card-banner__description'
70
+ maxLines={2}
71
+ text={description}
72
+ className={styles.cardBannerDescription}
73
+ />
74
+ </Typography.SansBodyM>
75
+
76
+ <Card.Footer.CallToAction label={actionLabel} icon={<ArrowRightSVG />} />
77
+ </div>
78
+
79
+ <img src={image.src} alt={image.alt} className={styles.cardBannerImage} data-test-id='card-banner__image' />
80
+ </div>
81
+ </Card>
82
+ );
83
+ }
@@ -0,0 +1 @@
1
+ export * from './CardBanner';
@@ -0,0 +1,33 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables.scss';
2
+
3
+ .cardBannerContent {
4
+ display: flex;
5
+ flex-direction: row;
6
+ justify-content: space-between;
7
+ gap: styles-theme-variables.$dimension-2m;
8
+ width: 100%;
9
+ }
10
+
11
+ .cardBannerLeft {
12
+ display: flex;
13
+ flex-direction: column;
14
+ flex-grow: 1;
15
+ gap: calc(styles-theme-variables.$dimension-050m + styles-theme-variables.$dimension-1m);
16
+ }
17
+
18
+ .cardBannerDescription {
19
+ color: styles-theme-variables.$sys-neutral-text-support;
20
+ }
21
+
22
+ .cardBannerImage {
23
+ width: calc(styles-theme-variables.$dimension-5m + styles-theme-variables.$dimension-7m);
24
+ flex-shrink: 0;
25
+ object-position: center;
26
+ object-fit: cover;
27
+ }
28
+
29
+ .cardFunctionBadgeWrapper {
30
+ display: flex;
31
+ align-items: flex-end;
32
+ justify-content: flex-start;
33
+ }
@@ -0,0 +1,41 @@
1
+ import { ArrowRightSVG } from '@cloud-ru/uikit-product-icons';
2
+ import { Card, CardProps } from '@snack-uikit/card';
3
+ import { TruncateString } from '@snack-uikit/truncate-string';
4
+ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
5
+
6
+ export type CardServiceProps = WithSupportProps<
7
+ Pick<CardProps, 'onClick' | 'className' | 'disabled' | 'href'> &
8
+ Required<Pick<Card.HeaderProps, 'title' | 'emblem'>> & {
9
+ description: string;
10
+ actionLabel: string;
11
+ }
12
+ >;
13
+
14
+ export function CardService({
15
+ href,
16
+ title,
17
+ description,
18
+ actionLabel,
19
+ emblem,
20
+ onClick,
21
+ className,
22
+ disabled,
23
+ ...rest
24
+ }: CardServiceProps) {
25
+ return (
26
+ <Card
27
+ // TODO: typescript error
28
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
+ // @ts-ignore
30
+ {...extractSupportProps(rest)}
31
+ href={href}
32
+ disabled={disabled}
33
+ className={className}
34
+ header={<Card.Header title={title} emblem={emblem} truncate={{ title: 2 }} />}
35
+ onClick={onClick}
36
+ footer={<Card.Footer.CallToAction label={actionLabel} icon={<ArrowRightSVG />} />}
37
+ >
38
+ <TruncateString text={description} maxLines={3} data-test-id='card-service__description' />
39
+ </Card>
40
+ );
41
+ }
@@ -0,0 +1 @@
1
+ export * from './CardService';