@snack-uikit/card 0.5.1 → 0.6.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/Card/Card.d.ts +1 -4
  3. package/dist/components/Card/Card.js +4 -5
  4. package/dist/components/Card/constants.d.ts +0 -4
  5. package/dist/components/Card/constants.js +0 -6
  6. package/dist/components/Footer/components/Action/Action.js +1 -1
  7. package/dist/components/Footer/components/Dimension/Dimension.d.ts +1 -1
  8. package/dist/components/Footer/components/Dimension/Dimension.js +1 -1
  9. package/dist/components/Footer/components/Dimension/constants.d.ts +2 -4
  10. package/dist/components/Footer/components/Dimension/constants.js +3 -4
  11. package/dist/components/Footer/components/Promo/Promo.d.ts +1 -4
  12. package/dist/components/Footer/components/Promo/Promo.js +1 -3
  13. package/dist/components/FunctionBadge/FunctionBadge.js +1 -1
  14. package/dist/components/Header/Header.d.ts +1 -4
  15. package/dist/components/Header/Header.js +1 -2
  16. package/dist/components/Header/constants.d.ts +4 -8
  17. package/dist/components/Header/constants.js +5 -6
  18. package/dist/components/Image/Image.d.ts +3 -6
  19. package/dist/components/Image/Image.js +2 -3
  20. package/dist/components/Image/constants.d.ts +5 -5
  21. package/dist/components/Image/constants.js +5 -6
  22. package/dist/components/Image/types.d.ts +3 -0
  23. package/dist/components/Image/types.js +1 -0
  24. package/dist/constants.d.ts +4 -4
  25. package/dist/constants.js +4 -5
  26. package/dist/context.d.ts +1 -1
  27. package/dist/context.js +2 -2
  28. package/dist/helperComponents/Emblem/Emblem.d.ts +0 -3
  29. package/dist/helperComponents/Emblem/Emblem.js +1 -2
  30. package/dist/helperComponents/PromoBadge/PromoBadge.js +1 -1
  31. package/dist/types.d.ts +3 -0
  32. package/dist/types.js +1 -0
  33. package/package.json +9 -9
  34. package/src/components/Card/Card.tsx +5 -11
  35. package/src/components/Card/constants.ts +0 -9
  36. package/src/components/Footer/components/Action/Action.tsx +2 -14
  37. package/src/components/Footer/components/Dimension/Dimension.tsx +3 -13
  38. package/src/components/Footer/components/Dimension/constants.ts +5 -5
  39. package/src/components/Footer/components/Promo/Promo.tsx +2 -11
  40. package/src/components/FunctionBadge/FunctionBadge.tsx +2 -2
  41. package/src/components/Header/Header.tsx +8 -24
  42. package/src/components/Header/constants.ts +9 -8
  43. package/src/components/Image/Image.tsx +4 -6
  44. package/src/components/Image/constants.ts +5 -5
  45. package/src/components/Image/types.ts +5 -0
  46. package/src/constants.ts +4 -4
  47. package/src/context.ts +3 -2
  48. package/src/helperComponents/Emblem/Emblem.tsx +1 -3
  49. package/src/helperComponents/PromoBadge/PromoBadge.tsx +1 -1
  50. package/src/types.ts +5 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
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.6.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
17
+ ## 0.5.2 (2023-12-07)
18
+
19
+ ### Only dependencies have been changed
20
+ * [@snack-uikit/droplist@0.11.2](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/droplist/CHANGELOG.md)
21
+
22
+
23
+
24
+
25
+
6
26
  ## 0.5.1 (2023-12-06)
7
27
 
8
28
 
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
- import { Size } from '../../constants';
3
+ import { Size } from '../../types';
4
4
  import { HeaderProps } from '../Header';
5
5
  export type CardProps = WithSupportProps<{
6
6
  /** Управление состоянием интерактивности */
@@ -31,6 +31,3 @@ export type CardProps = WithSupportProps<{
31
31
  className?: string;
32
32
  }>;
33
33
  export declare function Card({ onClick, disabled, checked, outline, multipleSelection, size, children, header, footer, functionBadge, promoBadge, image, className, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
34
- export declare namespace Card {
35
- var sizes: typeof Size;
36
- }
@@ -14,13 +14,13 @@ import cn from 'classnames';
14
14
  import { useCallback, useRef } from 'react';
15
15
  import { Typography } from '@snack-uikit/typography';
16
16
  import { extractSupportProps } from '@snack-uikit/utils';
17
- import { Size } from '../../constants';
17
+ import { SIZE } from '../../constants';
18
18
  import { CardContext } from '../../context';
19
19
  import { Check, FunctionBadgeWrapper, PromoBadge } from '../../helperComponents';
20
- import { BODY_TEXT_SIZE_MAP, TRIGGER_CLICK_KEY_CODES } from './constants';
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 } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className"]);
23
+ var { onClick, disabled = false, checked, outline, multipleSelection = false, size = SIZE.M, children, header, footer, functionBadge, promoBadge, image, className } = _a, rest = __rest(_a, ["onClick", "disabled", "checked", "outline", "multipleSelection", "size", "children", "header", "footer", "functionBadge", "promoBadge", "image", "className"]);
24
24
  const localRef = useRef(null);
25
25
  const onKeyDown = useCallback((e) => {
26
26
  if (e.target === localRef.current) {
@@ -31,6 +31,5 @@ export function Card(_a) {
31
31
  }, [onClick]);
32
32
  return (_jsx(CardContext.Provider, Object.assign({ value: { size, disabled } }, { children: _jsxs("div", Object.assign({ ref: localRef, className: cn(styles.card, className) }, extractSupportProps(rest), { onClick: onClick, "data-disabled": disabled || undefined, "data-checked": checked || undefined, "data-outline": outline || undefined, "data-pointer": onClick ? true : undefined,
33
33
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
34
- tabIndex: 0, onKeyDown: onKeyDown }, { children: [image, promoBadge && _jsx(PromoBadge, { text: promoBadge }), _jsxs("div", Object.assign({ className: styles.composition, tabIndex: -1 }, { children: [!disabled && functionBadge && (_jsx(FunctionBadgeWrapper, Object.assign({ className: styles.functionBadgeWrapper }, { children: functionBadge }))), _jsxs("div", Object.assign({ className: styles.contentWrapper }, { children: [_jsxs("div", Object.assign({ className: styles.content, "data-size": size }, { children: [header || null, _jsx(Typography, Object.assign({ family: Typography.families.Sans, size: BODY_TEXT_SIZE_MAP[size], role: Typography.roles.Body, className: styles.body }, { children: children }))] })), footer && _jsx("div", Object.assign({ className: styles.footer }, { children: footer }))] }))] })), !disabled && checked && multipleSelection && _jsx(Check, { className: styles.check })] })) })));
34
+ tabIndex: 0, onKeyDown: onKeyDown }, { children: [image, promoBadge && _jsx(PromoBadge, { text: promoBadge }), _jsxs("div", Object.assign({ className: styles.composition, tabIndex: -1 }, { children: [!disabled && functionBadge && (_jsx(FunctionBadgeWrapper, Object.assign({ className: styles.functionBadgeWrapper }, { children: functionBadge }))), _jsxs("div", Object.assign({ className: styles.contentWrapper }, { children: [_jsxs("div", Object.assign({ className: styles.content, "data-size": size }, { children: [header || null, _jsx(Typography, Object.assign({ family: 'sans', size: size, purpose: 'body', className: styles.body }, { children: children }))] })), footer && _jsx("div", Object.assign({ className: styles.footer }, { children: footer }))] }))] })), !disabled && checked && multipleSelection && _jsx(Check, { className: styles.check })] })) })));
35
35
  }
36
- Card.sizes = Size;
@@ -1,5 +1 @@
1
- export declare const BODY_TEXT_SIZE_MAP: {
2
- m: import("@snack-uikit/typography/dist/components/contants").Size;
3
- l: import("@snack-uikit/typography/dist/components/contants").Size;
4
- };
5
1
  export declare const TRIGGER_CLICK_KEY_CODES: string[];
@@ -1,7 +1 @@
1
- import { Typography } from '@snack-uikit/typography';
2
- import { Size } from '../../constants';
3
- export const BODY_TEXT_SIZE_MAP = {
4
- [Size.M]: Typography.sizes.M,
5
- [Size.L]: Typography.sizes.L,
6
- };
7
1
  export const TRIGGER_CLICK_KEY_CODES = ['Enter', 'Space'];
@@ -18,5 +18,5 @@ import styles from './styles.module.css';
18
18
  export function FooterAction(_a) {
19
19
  var { button, secondaryButton, className } = _a, rest = __rest(_a, ["button", "secondaryButton", "className"]);
20
20
  const { disabled } = useCardContext();
21
- return (_jsxs("div", Object.assign({ className: cn(styles.action, className) }, excludeSupportProps(rest), { children: [_jsx(ButtonFilled, Object.assign({}, button, { appearance: ButtonFilled.appearances.Primary, size: ButtonFilled.sizes.M, disabled: disabled })), secondaryButton && (_jsx(ButtonTonal, Object.assign({}, secondaryButton, { appearance: ButtonTonal.appearances.Neutral, size: ButtonTonal.sizes.M, disabled: disabled })))] })));
21
+ return (_jsxs("div", Object.assign({ className: cn(styles.action, className) }, excludeSupportProps(rest), { children: [_jsx(ButtonFilled, Object.assign({}, button, { appearance: 'primary', size: 'm', disabled: disabled })), secondaryButton && _jsx(ButtonTonal, Object.assign({}, secondaryButton, { appearance: 'neutral', size: 'm', disabled: disabled }))] })));
22
22
  }
@@ -1,4 +1,4 @@
1
- import { Size } from '../../../../constants';
1
+ import { Size } from '../../../../types';
2
2
  export type DimensionProps = {
3
3
  /** Единица измерения */
4
4
  dimension?: string;
@@ -6,5 +6,5 @@ import styles from './styles.module.css';
6
6
  export function Dimension({ dimension, currentValue, oldValue, size: sizeProp }) {
7
7
  const { size: sizeContext } = useCardContext();
8
8
  const size = TYPOGRAPHY_SIZE_MAP[sizeProp || sizeContext];
9
- return (_jsxs("div", Object.assign({ className: styles.wrapper }, { children: [dimension && (_jsx(Typography, Object.assign({ role: Typography.roles.Title, family: Typography.families.Sans, size: size, className: styles.dimension }, { children: dimension }))), _jsxs("div", Object.assign({ className: styles.valueContainer }, { children: [_jsx(Typography, Object.assign({ role: Typography.roles.Title, family: Typography.families.Sans, size: size, className: styles.currentValue }, { children: currentValue })), oldValue && _jsx(Typography.CrossedOutBodyS, Object.assign({ className: styles.oldValue }, { children: oldValue }))] }))] })));
9
+ return (_jsxs("div", Object.assign({ className: styles.wrapper }, { children: [dimension && (_jsx(Typography, Object.assign({ purpose: 'title', family: 'sans', size: size, className: styles.dimension }, { children: dimension }))), _jsxs("div", Object.assign({ className: styles.valueContainer }, { children: [_jsx(Typography, Object.assign({ purpose: 'title', family: 'sans', size: size, className: styles.currentValue }, { children: currentValue })), oldValue && _jsx(Typography.CrossedOutBodyS, Object.assign({ className: styles.oldValue }, { children: oldValue }))] }))] })));
10
10
  }
@@ -1,4 +1,2 @@
1
- export declare const TYPOGRAPHY_SIZE_MAP: {
2
- m: import("@snack-uikit/typography/dist/components/contants").Size;
3
- l: import("@snack-uikit/typography/dist/components/contants").Size;
4
- };
1
+ import { TypographyProps } from '@snack-uikit/typography';
2
+ export declare const TYPOGRAPHY_SIZE_MAP: Record<string, TypographyProps['size']>;
@@ -1,6 +1,5 @@
1
- import { Typography } from '@snack-uikit/typography';
2
- import { Size } from '../../../../constants';
1
+ import { SIZE } from '../../../../constants';
3
2
  export const TYPOGRAPHY_SIZE_MAP = {
4
- [Size.M]: Typography.sizes.M,
5
- [Size.L]: Typography.sizes.L,
3
+ [SIZE.M]: 'm',
4
+ [SIZE.L]: 'l',
6
5
  };
@@ -1,6 +1,6 @@
1
1
  import { ButtonFilledProps } from '@snack-uikit/button';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
- import { Size } from '../../../../constants';
3
+ import { Size } from '../../../../types';
4
4
  import { DimensionProps } from '../Dimension';
5
5
  export type FooterPromoProps = WithSupportProps<{
6
6
  /** Параметры для блока значений */
@@ -13,6 +13,3 @@ export type FooterPromoProps = WithSupportProps<{
13
13
  size?: Size;
14
14
  }>;
15
15
  export declare function FooterPromo({ volume, button, className, size, ...rest }: FooterPromoProps): import("react/jsx-runtime").JSX.Element;
16
- export declare namespace FooterPromo {
17
- var sizes: typeof Size;
18
- }
@@ -13,13 +13,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { ButtonFilled } from '@snack-uikit/button';
15
15
  import { excludeSupportProps } from '@snack-uikit/utils';
16
- import { Size } from '../../../../constants';
17
16
  import { useCardContext } from '../../../../context';
18
17
  import { Dimension } from '../Dimension';
19
18
  import styles from './styles.module.css';
20
19
  export function FooterPromo(_a) {
21
20
  var { volume, button, className, size } = _a, rest = __rest(_a, ["volume", "button", "className", "size"]);
22
21
  const { disabled } = useCardContext();
23
- return (_jsxs("div", Object.assign({ className: cn(styles.promo, className) }, excludeSupportProps(rest), { children: [button && (_jsx(ButtonFilled, Object.assign({}, button, { appearance: ButtonFilled.appearances.Primary, size: ButtonFilled.sizes.M, disabled: disabled }))), volume && _jsx(Dimension, Object.assign({}, volume, { size: size }))] })));
22
+ return (_jsxs("div", Object.assign({ className: cn(styles.promo, className) }, excludeSupportProps(rest), { children: [button && _jsx(ButtonFilled, Object.assign({}, button, { appearance: 'primary', size: 'm', disabled: disabled })), volume && _jsx(Dimension, Object.assign({}, volume, { size: size }))] })));
24
23
  }
25
- FooterPromo.sizes = Size;
@@ -17,7 +17,7 @@ export function FunctionBadge({ icon, options }) {
17
17
  e.stopPropagation();
18
18
  setIsOpen(isOpen => !isOpen);
19
19
  }, []);
20
- return (_jsx("span", Object.assign({ className: styles.wrapper }, { children: _jsx(Droplist, Object.assign({ open: isOpen, onOpenChange: setIsOpen, firstElementRefCallback: firstElementRefCallback, widthStrategy: Droplist.widthStrategies.Gte, useScroll: true, onFocusLeave: handleDroplistFocusLeave, "data-test-id": TEST_IDS.droplist, triggerClassName: styles.triggerClassName, placement: Droplist.placements.BottomEnd, triggerElement: _jsx("button", Object.assign({ "data-test-id": TEST_IDS.functionBadge, className: styles.button, onKeyDown: handleTriggerKeyDown, onClick: onClick, ref: triggerElementRef }, { children: icon || _jsx(KebabSVG, {}) })) }, { children: options.map(item => (_createElement(Droplist.ItemSingle, Object.assign({}, item, { key: item.option, className: styles.item, "data-test-id": TEST_IDS.option, onClick: e => {
20
+ return (_jsx("span", Object.assign({ className: styles.wrapper }, { children: _jsx(Droplist, Object.assign({ open: isOpen, onOpenChange: setIsOpen, firstElementRefCallback: firstElementRefCallback, widthStrategy: 'gte', useScroll: true, onFocusLeave: handleDroplistFocusLeave, "data-test-id": TEST_IDS.droplist, triggerClassName: styles.triggerClassName, placement: 'bottom-end', triggerElement: _jsx("button", Object.assign({ "data-test-id": TEST_IDS.functionBadge, className: styles.button, onKeyDown: handleTriggerKeyDown, onClick: onClick, ref: triggerElementRef }, { children: icon || _jsx(KebabSVG, {}) })) }, { children: options.map(item => (_createElement(Droplist.ItemSingle, Object.assign({}, item, { key: item.option, className: styles.item, "data-test-id": TEST_IDS.option, onClick: e => {
21
21
  handleDroplistItemClick(e, item.onClick);
22
22
  }, onKeyDown: handleDroplistItemKeyDown })))) })) })));
23
23
  }
@@ -1,6 +1,6 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
- import { Size } from '../../constants';
3
2
  import { EmblemProps } from '../../helperComponents';
3
+ import { Size } from '../../types';
4
4
  export type HeaderProps = WithSupportProps<{
5
5
  /** Заголовок */
6
6
  title: string;
@@ -16,6 +16,3 @@ export type HeaderProps = WithSupportProps<{
16
16
  size?: Size;
17
17
  }>;
18
18
  export declare function Header({ title, description, metadata, emblem, className, size: sizeProp, ...rest }: HeaderProps): import("react/jsx-runtime").JSX.Element;
19
- export declare namespace Header {
20
- var emblemIconAppearances: typeof import("@snack-uikit/icon-predefined/dist/constants").Appearance;
21
- }
@@ -23,6 +23,5 @@ export function Header(_a) {
23
23
  var { title, description, metadata, emblem, className, size: sizeProp } = _a, rest = __rest(_a, ["title", "description", "metadata", "emblem", "className", "size"]);
24
24
  const { size: sizeContext } = useCardContext();
25
25
  const size = sizeProp || sizeContext;
26
- return (_jsxs("div", Object.assign({ className: cn(styles.titleLayout, className) }, excludeSupportProps(rest), { "data-size": size }, { children: [emblem && _jsx(Emblem, Object.assign({}, emblem)), _jsxs("div", Object.assign({ className: styles.contentLayout }, { children: [_jsx(Typography, Object.assign({ family: Typography.families.Sans, size: TITLE_SIZE_MAP[size], role: Typography.roles.Title, className: styles.title, "data-test-id": TEST_IDS.title }, { children: _jsx(TruncateString, { variant: TruncateString.variants.End, maxLines: 1, text: title }) })), metadata && (_jsx(Typography.SansBodyS, Object.assign({ className: styles.metadata }, { children: _jsx(TruncateString, { variant: TruncateString.variants.End, maxLines: 1, text: metadata, "data-test-id": TEST_IDS.metadata }) }))), description && (_jsx(Typography, Object.assign({ family: Typography.families.Sans, size: DESCRIPTION_SIZE_MAP[size], role: Typography.roles.Body, className: styles.description }, { children: _jsx(TruncateString, { variant: TruncateString.variants.End, maxLines: 2, text: description, "data-test-id": TEST_IDS.description }) })))] }))] })));
26
+ return (_jsxs("div", Object.assign({ className: cn(styles.titleLayout, className) }, excludeSupportProps(rest), { "data-size": size }, { children: [emblem && _jsx(Emblem, Object.assign({}, emblem)), _jsxs("div", Object.assign({ className: styles.contentLayout }, { children: [_jsx(Typography, Object.assign({ family: 'sans', size: TITLE_SIZE_MAP[size], purpose: 'title', className: styles.title, "data-test-id": TEST_IDS.title }, { children: _jsx(TruncateString, { variant: 'end', maxLines: 1, text: title }) })), metadata && (_jsx(Typography.SansBodyS, Object.assign({ className: styles.metadata }, { children: _jsx(TruncateString, { variant: 'end', maxLines: 1, text: metadata, "data-test-id": TEST_IDS.metadata }) }))), description && (_jsx(Typography, Object.assign({ family: 'sans', size: DESCRIPTION_SIZE_MAP[size], purpose: 'body', className: styles.description }, { children: _jsx(TruncateString, { variant: 'end', maxLines: 2, text: description, "data-test-id": TEST_IDS.description }) })))] }))] })));
27
27
  }
28
- Header.emblemIconAppearances = Emblem.appearances;
@@ -1,8 +1,4 @@
1
- export declare const TITLE_SIZE_MAP: {
2
- m: import("@snack-uikit/typography/dist/components/contants").Size;
3
- l: import("@snack-uikit/typography/dist/components/contants").Size;
4
- };
5
- export declare const DESCRIPTION_SIZE_MAP: {
6
- m: import("@snack-uikit/typography/dist/components/contants").Size;
7
- l: import("@snack-uikit/typography/dist/components/contants").Size;
8
- };
1
+ import { TypographyProps } from '@snack-uikit/typography';
2
+ import { Size } from '../../types';
3
+ export declare const TITLE_SIZE_MAP: Record<Size, TypographyProps['size']>;
4
+ export declare const DESCRIPTION_SIZE_MAP: Record<Size, TypographyProps['size']>;
@@ -1,10 +1,9 @@
1
- import { Typography } from '@snack-uikit/typography';
2
- import { Size } from '../../constants';
1
+ import { SIZE } from '../../constants';
3
2
  export const TITLE_SIZE_MAP = {
4
- [Size.M]: Typography.sizes.S,
5
- [Size.L]: Typography.sizes.L,
3
+ [SIZE.M]: 's',
4
+ [SIZE.L]: 'l',
6
5
  };
7
6
  export const DESCRIPTION_SIZE_MAP = {
8
- [Size.M]: Typography.sizes.M,
9
- [Size.L]: Typography.sizes.L,
7
+ [SIZE.M]: 'm',
8
+ [SIZE.L]: 'l',
10
9
  };
@@ -1,17 +1,14 @@
1
- import { Mode } from './constants';
1
+ import { MODE } from './constants';
2
2
  export type ImageProps = {
3
3
  /** Путь до картинки */
4
4
  src: string;
5
5
  /** Описание картинки */
6
6
  alt: string;
7
7
  } /** Image mode */ & ({
8
- mode?: Mode.Little | Mode.Middle;
8
+ mode?: typeof MODE.Little | typeof MODE.Middle;
9
9
  hideFading?: never;
10
10
  } | {
11
- mode: Mode.Background;
11
+ mode: typeof MODE.Background;
12
12
  hideFading?: boolean;
13
13
  });
14
14
  export declare function Image({ src, alt, mode, hideFading }: ImageProps): import("react/jsx-runtime").JSX.Element;
15
- export declare namespace Image {
16
- var modes: typeof Mode;
17
- }
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Mode } from './constants';
2
+ import { MODE } from './constants';
3
3
  import styles from './styles.module.css';
4
- export function Image({ src, alt, mode = Mode.Little, hideFading }) {
4
+ export function Image({ src, alt, mode = MODE.Little, hideFading }) {
5
5
  return _jsx("img", { src: src, alt: alt, "data-mode": mode, className: styles.image, "data-fading": !hideFading || undefined });
6
6
  }
7
- Image.modes = Mode;
@@ -1,5 +1,5 @@
1
- export declare enum Mode {
2
- Little = "little",
3
- Middle = "middle",
4
- Background = "background"
5
- }
1
+ export declare const MODE: {
2
+ readonly Little: "little";
3
+ readonly Middle: "middle";
4
+ readonly Background: "background";
5
+ };
@@ -1,6 +1,5 @@
1
- export var Mode;
2
- (function (Mode) {
3
- Mode["Little"] = "little";
4
- Mode["Middle"] = "middle";
5
- Mode["Background"] = "background";
6
- })(Mode || (Mode = {}));
1
+ export const MODE = {
2
+ Little: 'little',
3
+ Middle: 'middle',
4
+ Background: 'background',
5
+ };
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { MODE } from './constants';
3
+ export type Mode = ValueOf<typeof MODE>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
- export declare enum Size {
2
- M = "m",
3
- L = "l"
4
- }
1
+ export declare const SIZE: {
2
+ readonly M: "m";
3
+ readonly L: "l";
4
+ };
5
5
  export declare const TEST_IDS: {
6
6
  promoBadge: string;
7
7
  functionBadge: string;
package/dist/constants.js CHANGED
@@ -1,8 +1,7 @@
1
- export var Size;
2
- (function (Size) {
3
- Size["M"] = "m";
4
- Size["L"] = "l";
5
- })(Size || (Size = {}));
1
+ export const SIZE = {
2
+ M: 'm',
3
+ L: 'l',
4
+ };
6
5
  export const TEST_IDS = {
7
6
  promoBadge: 'card__promo-badge',
8
7
  functionBadge: 'card__function-badge',
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Size } from './constants';
2
+ import { Size } from './types';
3
3
  type CardContextValue = {
4
4
  size: Size;
5
5
  disabled: boolean;
package/dist/context.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createContext, useContext } from 'react';
2
- import { Size } from './constants';
2
+ import { SIZE } from './constants';
3
3
  export const CardContext = createContext({
4
- size: Size.M,
4
+ size: SIZE.M,
5
5
  disabled: false,
6
6
  });
7
7
  export function useCardContext() {
@@ -5,7 +5,4 @@ type PictureProps = {
5
5
  };
6
6
  export type EmblemProps = PictureProps | Pick<IconPredefinedProps, 'icon' | 'decor' | 'appearance'>;
7
7
  export declare function Emblem(props: EmblemProps): import("react/jsx-runtime").JSX.Element;
8
- export declare namespace Emblem {
9
- var appearances: typeof import("@snack-uikit/icon-predefined/dist/constants").Appearance;
10
- }
11
8
  export {};
@@ -12,6 +12,5 @@ export function Emblem(props) {
12
12
  if (isPictureProps(props)) {
13
13
  return (_jsx("img", { src: props.src, alt: props.alt, "data-size": size || undefined, className: styles.img, "data-test-id": TEST_IDS.emblemPicture }));
14
14
  }
15
- return (_jsx(IconPredefined, { icon: props.icon, appearance: (_a = props.appearance) !== null && _a !== void 0 ? _a : IconPredefined.appearances.Primary, decor: (_b = props.decor) !== null && _b !== void 0 ? _b : true, size: size, "data-test-id": TEST_IDS.emblemIcon }));
15
+ return (_jsx(IconPredefined, { icon: props.icon, appearance: (_a = props.appearance) !== null && _a !== void 0 ? _a : 'primary', decor: (_b = props.decor) !== null && _b !== void 0 ? _b : true, size: size, "data-test-id": TEST_IDS.emblemIcon }));
16
16
  }
17
- Emblem.appearances = IconPredefined.appearances;
@@ -3,5 +3,5 @@ import { PromoTag } from '@snack-uikit/promo-tag';
3
3
  import { TEST_IDS } from '../../constants';
4
4
  import styles from './styles.module.css';
5
5
  export function PromoBadge({ text }) {
6
- return (_jsx("div", Object.assign({ className: styles.promoBadge }, { children: _jsx(PromoTag, { appearance: PromoTag.appearances.Primary, text: text, "data-test-id": TEST_IDS.promoBadge }) })));
6
+ return (_jsx("div", Object.assign({ className: styles.promoBadge }, { children: _jsx(PromoTag, { appearance: 'primary', text: text, "data-test-id": TEST_IDS.promoBadge }) })));
7
7
  }
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { SIZE } from './constants';
3
+ export type Size = ValueOf<typeof SIZE>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Card",
7
- "version": "0.5.1",
7
+ "version": "0.6.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,15 +32,15 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/button": "0.14.1",
36
- "@snack-uikit/droplist": "0.11.1",
37
- "@snack-uikit/icon-predefined": "0.3.1",
35
+ "@snack-uikit/button": "0.15.0",
36
+ "@snack-uikit/droplist": "0.12.0",
37
+ "@snack-uikit/icon-predefined": "0.4.0",
38
38
  "@snack-uikit/icons": "0.19.0",
39
- "@snack-uikit/promo-tag": "0.3.1",
40
- "@snack-uikit/truncate-string": "0.3.1",
41
- "@snack-uikit/typography": "0.5.1",
42
- "@snack-uikit/utils": "3.1.0",
39
+ "@snack-uikit/promo-tag": "0.4.0",
40
+ "@snack-uikit/truncate-string": "0.4.0",
41
+ "@snack-uikit/typography": "0.6.0",
42
+ "@snack-uikit/utils": "3.2.0",
43
43
  "classnames": "2.3.2"
44
44
  },
45
- "gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
45
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
46
46
  }
@@ -4,11 +4,12 @@ import { KeyboardEvent, ReactElement, ReactNode, useCallback, useRef } from 'rea
4
4
  import { Typography } from '@snack-uikit/typography';
5
5
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
6
 
7
- import { Size } from '../../constants';
7
+ import { SIZE } from '../../constants';
8
8
  import { CardContext } from '../../context';
9
9
  import { Check, FunctionBadgeWrapper, PromoBadge } from '../../helperComponents';
10
+ import { Size } from '../../types';
10
11
  import { HeaderProps } from '../Header';
11
- import { BODY_TEXT_SIZE_MAP, TRIGGER_CLICK_KEY_CODES } from './constants';
12
+ import { TRIGGER_CLICK_KEY_CODES } from './constants';
12
13
  import styles from './styles.module.scss';
13
14
 
14
15
  export type CardProps = WithSupportProps<{
@@ -46,7 +47,7 @@ export function Card({
46
47
  checked,
47
48
  outline,
48
49
  multipleSelection = false,
49
- size = Size.M,
50
+ size = SIZE.M,
50
51
  children,
51
52
  header,
52
53
  footer,
@@ -98,12 +99,7 @@ export function Card({
98
99
  <div className={styles.content} data-size={size}>
99
100
  {header || null}
100
101
 
101
- <Typography
102
- family={Typography.families.Sans}
103
- size={BODY_TEXT_SIZE_MAP[size]}
104
- role={Typography.roles.Body}
105
- className={styles.body}
106
- >
102
+ <Typography family='sans' size={size} purpose='body' className={styles.body}>
107
103
  {children}
108
104
  </Typography>
109
105
  </div>
@@ -117,5 +113,3 @@ export function Card({
117
113
  </CardContext.Provider>
118
114
  );
119
115
  }
120
-
121
- Card.sizes = Size;
@@ -1,10 +1 @@
1
- import { Typography } from '@snack-uikit/typography';
2
-
3
- import { Size } from '../../constants';
4
-
5
- export const BODY_TEXT_SIZE_MAP = {
6
- [Size.M]: Typography.sizes.M,
7
- [Size.L]: Typography.sizes.L,
8
- };
9
-
10
1
  export const TRIGGER_CLICK_KEY_CODES = ['Enter', 'Space'];
@@ -20,20 +20,8 @@ export function FooterAction({ button, secondaryButton, className, ...rest }: Fo
20
20
 
21
21
  return (
22
22
  <div className={cn(styles.action, className)} {...excludeSupportProps(rest)}>
23
- <ButtonFilled
24
- {...button}
25
- appearance={ButtonFilled.appearances.Primary}
26
- size={ButtonFilled.sizes.M}
27
- disabled={disabled}
28
- />
29
- {secondaryButton && (
30
- <ButtonTonal
31
- {...secondaryButton}
32
- appearance={ButtonTonal.appearances.Neutral}
33
- size={ButtonTonal.sizes.M}
34
- disabled={disabled}
35
- />
36
- )}
23
+ <ButtonFilled {...button} appearance='primary' size='m' disabled={disabled} />
24
+ {secondaryButton && <ButtonTonal {...secondaryButton} appearance='neutral' size='m' disabled={disabled} />}
37
25
  </div>
38
26
  );
39
27
  }
@@ -1,7 +1,7 @@
1
1
  import { Typography } from '@snack-uikit/typography';
2
2
 
3
- import { Size } from '../../../../constants';
4
3
  import { useCardContext } from '../../../../context';
4
+ import { Size } from '../../../../types';
5
5
  import { TYPOGRAPHY_SIZE_MAP } from './constants';
6
6
  import styles from './styles.module.scss';
7
7
 
@@ -24,22 +24,12 @@ export function Dimension({ dimension, currentValue, oldValue, size: sizeProp }:
24
24
  return (
25
25
  <div className={styles.wrapper}>
26
26
  {dimension && (
27
- <Typography
28
- role={Typography.roles.Title}
29
- family={Typography.families.Sans}
30
- size={size}
31
- className={styles.dimension}
32
- >
27
+ <Typography purpose='title' family='sans' size={size} className={styles.dimension}>
33
28
  {dimension}
34
29
  </Typography>
35
30
  )}
36
31
  <div className={styles.valueContainer}>
37
- <Typography
38
- role={Typography.roles.Title}
39
- family={Typography.families.Sans}
40
- size={size}
41
- className={styles.currentValue}
42
- >
32
+ <Typography purpose='title' family='sans' size={size} className={styles.currentValue}>
43
33
  {currentValue}
44
34
  </Typography>
45
35
 
@@ -1,8 +1,8 @@
1
- import { Typography } from '@snack-uikit/typography';
1
+ import { TypographyProps } from '@snack-uikit/typography';
2
2
 
3
- import { Size } from '../../../../constants';
3
+ import { SIZE } from '../../../../constants';
4
4
 
5
- export const TYPOGRAPHY_SIZE_MAP = {
6
- [Size.M]: Typography.sizes.M,
7
- [Size.L]: Typography.sizes.L,
5
+ export const TYPOGRAPHY_SIZE_MAP: Record<string, TypographyProps['size']> = {
6
+ [SIZE.M]: 'm',
7
+ [SIZE.L]: 'l',
8
8
  };
@@ -3,8 +3,8 @@ import cn from 'classnames';
3
3
  import { ButtonFilled, ButtonFilledProps } from '@snack-uikit/button';
4
4
  import { excludeSupportProps, WithSupportProps } from '@snack-uikit/utils';
5
5
 
6
- import { Size } from '../../../../constants';
7
6
  import { useCardContext } from '../../../../context';
7
+ import { Size } from '../../../../types';
8
8
  import { Dimension, DimensionProps } from '../Dimension';
9
9
  import styles from './styles.module.scss';
10
10
 
@@ -24,17 +24,8 @@ export function FooterPromo({ volume, button, className, size, ...rest }: Footer
24
24
 
25
25
  return (
26
26
  <div className={cn(styles.promo, className)} {...excludeSupportProps(rest)}>
27
- {button && (
28
- <ButtonFilled
29
- {...button}
30
- appearance={ButtonFilled.appearances.Primary}
31
- size={ButtonFilled.sizes.M}
32
- disabled={disabled}
33
- />
34
- )}
27
+ {button && <ButtonFilled {...button} appearance='primary' size='m' disabled={disabled} />}
35
28
  {volume && <Dimension {...volume} size={size} />}
36
29
  </div>
37
30
  );
38
31
  }
39
-
40
- FooterPromo.sizes = Size;
@@ -43,12 +43,12 @@ export function FunctionBadge({ icon, options }: FunctionBadgeProps) {
43
43
  open={isOpen}
44
44
  onOpenChange={setIsOpen}
45
45
  firstElementRefCallback={firstElementRefCallback}
46
- widthStrategy={Droplist.widthStrategies.Gte}
46
+ widthStrategy='gte'
47
47
  useScroll
48
48
  onFocusLeave={handleDroplistFocusLeave}
49
49
  data-test-id={TEST_IDS.droplist}
50
50
  triggerClassName={styles.triggerClassName}
51
- placement={Droplist.placements.BottomEnd}
51
+ placement='bottom-end'
52
52
  triggerElement={
53
53
  <button
54
54
  data-test-id={TEST_IDS.functionBadge}
@@ -4,9 +4,10 @@ import { TruncateString } from '@snack-uikit/truncate-string';
4
4
  import { Typography } from '@snack-uikit/typography';
5
5
  import { excludeSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
6
 
7
- import { Size, TEST_IDS } from '../../constants';
7
+ import { TEST_IDS } from '../../constants';
8
8
  import { useCardContext } from '../../context';
9
9
  import { Emblem, EmblemProps } from '../../helperComponents';
10
+ import { Size } from '../../types';
10
11
  import { DESCRIPTION_SIZE_MAP, TITLE_SIZE_MAP } from './constants';
11
12
  import styles from './styles.module.scss';
12
13
 
@@ -36,44 +37,27 @@ export function Header({ title, description, metadata, emblem, className, size:
36
37
 
37
38
  <div className={styles.contentLayout}>
38
39
  <Typography
39
- family={Typography.families.Sans}
40
+ family='sans'
40
41
  size={TITLE_SIZE_MAP[size]}
41
- role={Typography.roles.Title}
42
+ purpose='title'
42
43
  className={styles.title}
43
44
  data-test-id={TEST_IDS.title}
44
45
  >
45
- <TruncateString variant={TruncateString.variants.End} maxLines={1} text={title} />
46
+ <TruncateString variant='end' maxLines={1} text={title} />
46
47
  </Typography>
47
48
 
48
49
  {metadata && (
49
50
  <Typography.SansBodyS className={styles.metadata}>
50
- <TruncateString
51
- variant={TruncateString.variants.End}
52
- maxLines={1}
53
- text={metadata}
54
- data-test-id={TEST_IDS.metadata}
55
- />
51
+ <TruncateString variant='end' maxLines={1} text={metadata} data-test-id={TEST_IDS.metadata} />
56
52
  </Typography.SansBodyS>
57
53
  )}
58
54
 
59
55
  {description && (
60
- <Typography
61
- family={Typography.families.Sans}
62
- size={DESCRIPTION_SIZE_MAP[size]}
63
- role={Typography.roles.Body}
64
- className={styles.description}
65
- >
66
- <TruncateString
67
- variant={TruncateString.variants.End}
68
- maxLines={2}
69
- text={description}
70
- data-test-id={TEST_IDS.description}
71
- />
56
+ <Typography family='sans' size={DESCRIPTION_SIZE_MAP[size]} purpose='body' className={styles.description}>
57
+ <TruncateString variant='end' maxLines={2} text={description} data-test-id={TEST_IDS.description} />
72
58
  </Typography>
73
59
  )}
74
60
  </div>
75
61
  </div>
76
62
  );
77
63
  }
78
-
79
- Header.emblemIconAppearances = Emblem.appearances;
@@ -1,13 +1,14 @@
1
- import { Typography } from '@snack-uikit/typography';
1
+ import { TypographyProps } from '@snack-uikit/typography';
2
2
 
3
- import { Size } from '../../constants';
3
+ import { SIZE } from '../../constants';
4
+ import { Size } from '../../types';
4
5
 
5
- export const TITLE_SIZE_MAP = {
6
- [Size.M]: Typography.sizes.S,
7
- [Size.L]: Typography.sizes.L,
6
+ export const TITLE_SIZE_MAP: Record<Size, TypographyProps['size']> = {
7
+ [SIZE.M]: 's',
8
+ [SIZE.L]: 'l',
8
9
  };
9
10
 
10
- export const DESCRIPTION_SIZE_MAP = {
11
- [Size.M]: Typography.sizes.M,
12
- [Size.L]: Typography.sizes.L,
11
+ export const DESCRIPTION_SIZE_MAP: Record<Size, TypographyProps['size']> = {
12
+ [SIZE.M]: 'm',
13
+ [SIZE.L]: 'l',
13
14
  };
@@ -1,4 +1,4 @@
1
- import { Mode } from './constants';
1
+ import { MODE } from './constants';
2
2
  import styles from './styles.module.scss';
3
3
 
4
4
  export type ImageProps = {
@@ -7,12 +7,10 @@ export type ImageProps = {
7
7
  /** Описание картинки */
8
8
  alt: string;
9
9
  } /** Image mode */ & (
10
- | { mode?: Mode.Little | Mode.Middle; hideFading?: never }
11
- | { mode: Mode.Background; hideFading?: boolean }
10
+ | { mode?: typeof MODE.Little | typeof MODE.Middle; hideFading?: never }
11
+ | { mode: typeof MODE.Background; hideFading?: boolean }
12
12
  );
13
13
 
14
- export function Image({ src, alt, mode = Mode.Little, hideFading }: ImageProps) {
14
+ export function Image({ src, alt, mode = MODE.Little, hideFading }: ImageProps) {
15
15
  return <img src={src} alt={alt} data-mode={mode} className={styles.image} data-fading={!hideFading || undefined} />;
16
16
  }
17
-
18
- Image.modes = Mode;
@@ -1,5 +1,5 @@
1
- export enum Mode {
2
- Little = 'little',
3
- Middle = 'middle',
4
- Background = 'background',
5
- }
1
+ export const MODE = {
2
+ Little: 'little',
3
+ Middle: 'middle',
4
+ Background: 'background',
5
+ } as const;
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { MODE } from './constants';
4
+
5
+ export type Mode = ValueOf<typeof MODE>;
package/src/constants.ts CHANGED
@@ -1,7 +1,7 @@
1
- export enum Size {
2
- M = 'm',
3
- L = 'l',
4
- }
1
+ export const SIZE = {
2
+ M: 'm',
3
+ L: 'l',
4
+ } as const;
5
5
 
6
6
  export const TEST_IDS = {
7
7
  promoBadge: 'card__promo-badge',
package/src/context.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createContext, useContext } from 'react';
2
2
 
3
- import { Size } from './constants';
3
+ import { SIZE } from './constants';
4
+ import { Size } from './types';
4
5
 
5
6
  type CardContextValue = {
6
7
  size: Size;
@@ -8,7 +9,7 @@ type CardContextValue = {
8
9
  };
9
10
 
10
11
  export const CardContext = createContext<CardContextValue>({
11
- size: Size.M,
12
+ size: SIZE.M,
12
13
  disabled: false,
13
14
  });
14
15
 
@@ -33,12 +33,10 @@ export function Emblem(props: EmblemProps) {
33
33
  return (
34
34
  <IconPredefined
35
35
  icon={props.icon}
36
- appearance={props.appearance ?? IconPredefined.appearances.Primary}
36
+ appearance={props.appearance ?? 'primary'}
37
37
  decor={props.decor ?? true}
38
38
  size={size}
39
39
  data-test-id={TEST_IDS.emblemIcon}
40
40
  />
41
41
  );
42
42
  }
43
-
44
- Emblem.appearances = IconPredefined.appearances;
@@ -10,7 +10,7 @@ export type PromoBadgeProps = {
10
10
  export function PromoBadge({ text }: PromoBadgeProps) {
11
11
  return (
12
12
  <div className={styles.promoBadge}>
13
- <PromoTag appearance={PromoTag.appearances.Primary} text={text} data-test-id={TEST_IDS.promoBadge} />
13
+ <PromoTag appearance='primary' text={text} data-test-id={TEST_IDS.promoBadge} />
14
14
  </div>
15
15
  );
16
16
  }
package/src/types.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { SIZE } from './constants';
4
+
5
+ export type Size = ValueOf<typeof SIZE>;