@snack-uikit/chips 0.9.2 → 0.10.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 (45) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +16 -16
  3. package/dist/components/ChipAssist/ChipAssist.d.ts +1 -5
  4. package/dist/components/ChipAssist/ChipAssist.js +5 -6
  5. package/dist/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.js +5 -5
  6. package/dist/components/ChipChoice/components/ChipChoiceDate.js +3 -3
  7. package/dist/components/ChipChoice/components/ChipChoiceDateRange.js +3 -3
  8. package/dist/components/ChipChoice/components/ChipChoiceMulti.js +2 -2
  9. package/dist/components/ChipChoice/components/ChipChoiceSingle.js +2 -2
  10. package/dist/components/ChipChoice/constants.d.ts +14 -22
  11. package/dist/components/ChipChoice/constants.js +19 -22
  12. package/dist/components/ChipChoice/index.d.ts +0 -7
  13. package/dist/components/ChipChoice/index.js +0 -8
  14. package/dist/components/ChipChoice/types.d.ts +5 -6
  15. package/dist/components/ChipChoiceRow/ChipChoiceRow.d.ts +3 -7
  16. package/dist/components/ChipChoiceRow/ChipChoiceRow.js +3 -4
  17. package/dist/components/ChipChoiceRow/components/constants.js +5 -4
  18. package/dist/components/ChipChoiceRow/constants.d.ts +10 -13
  19. package/dist/components/ChipChoiceRow/constants.js +12 -14
  20. package/dist/components/ChipChoiceRow/types.d.ts +9 -6
  21. package/dist/components/ChipToggle/ChipToggle.d.ts +1 -5
  22. package/dist/components/ChipToggle/ChipToggle.js +5 -6
  23. package/dist/constants.d.ts +14 -14
  24. package/dist/constants.js +14 -17
  25. package/dist/helperComponents/ButtonClearValue/ButtonClearValue.d.ts +1 -1
  26. package/dist/helperComponents/ButtonClearValue/ButtonClearValue.js +2 -2
  27. package/dist/types.d.ts +5 -0
  28. package/package.json +7 -7
  29. package/src/components/ChipAssist/ChipAssist.tsx +7 -9
  30. package/src/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.tsx +9 -9
  31. package/src/components/ChipChoice/components/ChipChoiceDate.tsx +3 -3
  32. package/src/components/ChipChoice/components/ChipChoiceDateRange.tsx +3 -3
  33. package/src/components/ChipChoice/components/ChipChoiceMulti.tsx +2 -2
  34. package/src/components/ChipChoice/components/ChipChoiceSingle.tsx +2 -2
  35. package/src/components/ChipChoice/constants.ts +24 -23
  36. package/src/components/ChipChoice/index.ts +0 -9
  37. package/src/components/ChipChoice/types.ts +5 -6
  38. package/src/components/ChipChoiceRow/ChipChoiceRow.tsx +6 -8
  39. package/src/components/ChipChoiceRow/components/constants.ts +5 -4
  40. package/src/components/ChipChoiceRow/constants.ts +14 -14
  41. package/src/components/ChipChoiceRow/types.ts +11 -6
  42. package/src/components/ChipToggle/ChipToggle.tsx +7 -9
  43. package/src/constants.ts +14 -14
  44. package/src/helperComponents/ButtonClearValue/ButtonClearValue.tsx +4 -3
  45. package/src/types.ts +10 -0
@@ -1,16 +1,19 @@
1
- import { ChipChoiceDateProps, ChipChoiceDateRangeProps, ChipChoiceMultiProps, ChipChoiceSingleProps } from '../ChipChoice/components';
2
- import { ChipChoiceType } from '../ChipChoice/constants';
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { ChipChoiceDateProps, ChipChoiceDateRangeProps, ChipChoiceMultiProps, ChipChoiceSingleProps } from '../ChipChoice';
3
+ import { CHIP_CHOICE_TYPE } from '../ChipChoice/constants';
4
+ import { CHIP_CHOICE_ROW_SIZE } from './constants';
5
+ export type ChipChoiceRowSize = ValueOf<typeof CHIP_CHOICE_ROW_SIZE>;
3
6
  type ChipChoiceMultiType = {
4
- type: ChipChoiceType.Multi;
7
+ type: typeof CHIP_CHOICE_TYPE.Multi;
5
8
  } & ChipChoiceMultiProps;
6
9
  type ChipChoiceSingleType = {
7
- type: ChipChoiceType.Single;
10
+ type: typeof CHIP_CHOICE_TYPE.Single;
8
11
  } & ChipChoiceSingleProps;
9
12
  type ChipChoiceDateType = {
10
- type: ChipChoiceType.Date;
13
+ type: typeof CHIP_CHOICE_TYPE.Date;
11
14
  } & ChipChoiceDateProps;
12
15
  type ChipChoiceDateRangeType = {
13
- type: ChipChoiceType.DateRange;
16
+ type: typeof CHIP_CHOICE_TYPE.DateRange;
14
17
  } & ChipChoiceDateRangeProps;
15
18
  export type ChipChoiceProps = {
16
19
  id: string;
@@ -1,7 +1,6 @@
1
1
  import { ChangeEvent } from 'react';
2
2
  import { WithSupportProps } from '@snack-uikit/utils';
3
- import { Size } from '../../constants';
4
- import { BaseChipProps } from '../../types';
3
+ import { BaseChipProps, Size } from '../../types';
5
4
  export type ChipToggleProps = WithSupportProps<BaseChipProps & {
6
5
  /** Отмечен ли компонент */
7
6
  checked: boolean;
@@ -12,6 +11,3 @@ export type ChipToggleProps = WithSupportProps<BaseChipProps & {
12
11
  }>;
13
12
  /** Чип с состоянием выбран/не выбран */
14
13
  export declare function ChipToggle({ icon, size, label, checked, disabled, loading, onChange, className, tabIndex, ...rest }: ChipToggleProps): import("react/jsx-runtime").JSX.Element;
15
- export declare namespace ChipToggle {
16
- var sizes: typeof Size;
17
- }
@@ -13,19 +13,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { Sun } from '@snack-uikit/loaders';
15
15
  import { extractSupportProps } from '@snack-uikit/utils';
16
- import { CHIP_TOGGLE_TEST_IDS, Size, Variant } from '../../constants';
16
+ import { CHIP_TOGGLE_TEST_IDS, SIZE, VARIANT } from '../../constants';
17
17
  import styles from './styles.module.css';
18
18
  /** Чип с состоянием выбран/не выбран */
19
19
  export function ChipToggle(_a) {
20
- var { icon, size = ChipToggle.sizes.S, label, checked, disabled, loading, onChange, className, tabIndex = 0 } = _a, rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex"]);
21
- const variant = icon && size !== Size.Xs ? Variant.IconBefore : Variant.LabelOnly;
22
- const spinnerSize = size === Size.Xs ? Sun.sizes.XS : Sun.sizes.S;
20
+ var { icon, size = SIZE.S, label, checked, disabled, loading, onChange, className, tabIndex = 0 } = _a, rest = __rest(_a, ["icon", "size", "label", "checked", "disabled", "loading", "onChange", "className", "tabIndex"]);
21
+ const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
22
+ const spinnerSize = size === SIZE.Xs ? 'xs' : 's';
23
23
  const handleChange = e => {
24
24
  if (disabled || loading) {
25
25
  return;
26
26
  }
27
27
  onChange === null || onChange === void 0 ? void 0 : onChange(!checked, e);
28
28
  };
29
- return (_jsxs("label", Object.assign({}, extractSupportProps(rest), { "data-size": size, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, "data-variant": variant, "data-checked": checked || undefined, className: cn(styles.toggleChip, className) }, { children: [_jsx("input", { "data-test-id": CHIP_TOGGLE_TEST_IDS.input, type: 'checkbox', checked: checked, onChange: handleChange, disabled: !loading && disabled, tabIndex: disabled ? -1 : tabIndex, className: styles.toggleChipInput }), _jsxs("span", Object.assign({ className: styles.toggleChipContent }, { children: [variant === Variant.IconBefore && !loading && (_jsx("span", Object.assign({ className: styles.icon, "data-test-id": CHIP_TOGGLE_TEST_IDS.icon }, { children: icon }))), loading && (_jsx("span", Object.assign({ className: styles.spinner, "data-test-id": CHIP_TOGGLE_TEST_IDS.spinner }, { children: _jsx(Sun, { size: spinnerSize }) }))), _jsx("span", Object.assign({ className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_TOGGLE_TEST_IDS.label }, { children: label }))] }))] })));
29
+ return (_jsxs("label", Object.assign({}, extractSupportProps(rest), { "data-size": size, "data-loading": loading || undefined, "data-disabled": (!loading && disabled) || undefined, "data-variant": variant, "data-checked": checked || undefined, className: cn(styles.toggleChip, className) }, { children: [_jsx("input", { "data-test-id": CHIP_TOGGLE_TEST_IDS.input, type: 'checkbox', checked: checked, onChange: handleChange, disabled: !loading && disabled, tabIndex: disabled ? -1 : tabIndex, className: styles.toggleChipInput }), _jsxs("span", Object.assign({ className: styles.toggleChipContent }, { children: [variant === VARIANT.IconBefore && !loading && (_jsx("span", Object.assign({ className: styles.icon, "data-test-id": CHIP_TOGGLE_TEST_IDS.icon }, { children: icon }))), loading && (_jsx("span", Object.assign({ className: styles.spinner, "data-test-id": CHIP_TOGGLE_TEST_IDS.spinner }, { children: _jsx(Sun, { size: spinnerSize }) }))), _jsx("span", Object.assign({ className: cn(styles.labelLayout, styles.label), "data-test-id": CHIP_TOGGLE_TEST_IDS.label }, { children: label }))] }))] })));
30
30
  }
31
- ChipToggle.sizes = Size;
@@ -1,17 +1,17 @@
1
- export declare enum Size {
2
- Xs = "xs",
3
- S = "s",
4
- M = "m",
5
- L = "l"
6
- }
7
- export declare enum ButtonSize {
8
- Xxs = "xxs",
9
- Xs = "xs"
10
- }
11
- export declare enum Variant {
12
- LabelOnly = "label-only",
13
- IconBefore = "icon-before"
14
- }
1
+ export declare const SIZE: {
2
+ readonly Xs: "xs";
3
+ readonly S: "s";
4
+ readonly M: "m";
5
+ readonly L: "l";
6
+ };
7
+ export declare const BUTTON_SIZE: {
8
+ readonly Xxs: "xxs";
9
+ readonly Xs: "xs";
10
+ };
11
+ export declare const VARIANT: {
12
+ readonly LabelOnly: "label-only";
13
+ readonly IconBefore: "icon-before";
14
+ };
15
15
  export declare const CHIP_ASSIST_TEST_IDS: {
16
16
  icon: string;
17
17
  spinner: string;
package/dist/constants.js CHANGED
@@ -1,20 +1,17 @@
1
- export var Size;
2
- (function (Size) {
3
- Size["Xs"] = "xs";
4
- Size["S"] = "s";
5
- Size["M"] = "m";
6
- Size["L"] = "l";
7
- })(Size || (Size = {}));
8
- export var ButtonSize;
9
- (function (ButtonSize) {
10
- ButtonSize["Xxs"] = "xxs";
11
- ButtonSize["Xs"] = "xs";
12
- })(ButtonSize || (ButtonSize = {}));
13
- export var Variant;
14
- (function (Variant) {
15
- Variant["LabelOnly"] = "label-only";
16
- Variant["IconBefore"] = "icon-before";
17
- })(Variant || (Variant = {}));
1
+ export const SIZE = {
2
+ Xs: 'xs',
3
+ S: 's',
4
+ M: 'm',
5
+ L: 'l',
6
+ };
7
+ export const BUTTON_SIZE = {
8
+ Xxs: 'xxs',
9
+ Xs: 'xs',
10
+ };
11
+ export const VARIANT = {
12
+ LabelOnly: 'label-only',
13
+ IconBefore: 'icon-before',
14
+ };
18
15
  export const CHIP_ASSIST_TEST_IDS = {
19
16
  icon: 'chip-assist__icon',
20
17
  spinner: 'chip-assist__spinner',
@@ -1,5 +1,5 @@
1
1
  import { KeyboardEventHandler, MouseEventHandler } from 'react';
2
- import { ButtonSize } from '../../constants';
2
+ import { ButtonSize } from '../../types';
3
3
  type ButtonClearValueProps = {
4
4
  size: ButtonSize;
5
5
  onClick: MouseEventHandler<HTMLButtonElement>;
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { CrossSVG } from '@snack-uikit/icons';
4
- import { ButtonSize } from '../../constants';
4
+ import { BUTTON_SIZE } from '../../constants';
5
5
  import styles from './styles.module.css';
6
6
  export const ButtonClearValue = forwardRef(({ size, onClick, tabIndex = -1, onKeyDown, 'data-test-id': dataTestId }, ref) => {
7
7
  const handleClick = event => {
8
8
  event.stopPropagation();
9
9
  onClick(event);
10
10
  };
11
- return (_jsxs("button", Object.assign({ className: styles.buttonClearValue, "data-size": size, onClick: handleClick, "data-test-id": dataTestId, type: 'button', ref: ref, onKeyDown: onKeyDown, tabIndex: tabIndex }, { children: [size === ButtonSize.Xxs && _jsx(CrossSVG, { size: 16 }), size === ButtonSize.Xs && _jsx(CrossSVG, {})] })));
11
+ return (_jsxs("button", Object.assign({ className: styles.buttonClearValue, "data-size": size, onClick: handleClick, "data-test-id": dataTestId, type: 'button', ref: ref, onKeyDown: onKeyDown, tabIndex: tabIndex }, { children: [size === BUTTON_SIZE.Xxs && _jsx(CrossSVG, { size: 16 }), size === BUTTON_SIZE.Xs && _jsx(CrossSVG, {})] })));
12
12
  });
package/dist/types.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { ReactElement } from 'react';
2
+ import { ValueOf } from '@snack-uikit/utils';
3
+ import { BUTTON_SIZE, SIZE, VARIANT } from './constants';
4
+ export type Size = ValueOf<typeof SIZE>;
5
+ export type ButtonSize = ValueOf<typeof BUTTON_SIZE>;
6
+ export type Variant = ValueOf<typeof VARIANT>;
2
7
  export type BaseChipProps = {
3
8
  /** Лейбл */
4
9
  label: string;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Chips",
7
- "version": "0.9.2",
7
+ "version": "0.10.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/button": "0.14.1",
36
- "@snack-uikit/calendar": "0.5.1",
37
- "@snack-uikit/droplist": "0.11.2",
35
+ "@snack-uikit/button": "0.15.0",
36
+ "@snack-uikit/calendar": "0.6.0",
37
+ "@snack-uikit/droplist": "0.12.0",
38
38
  "@snack-uikit/icons": "0.19.0",
39
- "@snack-uikit/loaders": "0.4.1",
40
- "@snack-uikit/utils": "3.1.0",
39
+ "@snack-uikit/loaders": "0.5.0",
40
+ "@snack-uikit/utils": "3.2.0",
41
41
  "classnames": "2.3.2",
42
42
  "uncontrollable": "8.0.2"
43
43
  },
44
- "gitHead": "e124e31699926810648702f97db72413d7ebd2b2"
44
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
45
45
  }
@@ -1,11 +1,11 @@
1
1
  import cn from 'classnames';
2
2
  import { MouseEventHandler } from 'react';
3
3
 
4
- import { Sun } from '@snack-uikit/loaders';
4
+ import { Sun, SunProps } from '@snack-uikit/loaders';
5
5
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
6
6
 
7
- import { CHIP_ASSIST_TEST_IDS, Size, Variant } from '../../constants';
8
- import { BaseChipProps } from '../../types';
7
+ import { CHIP_ASSIST_TEST_IDS, SIZE, VARIANT } from '../../constants';
8
+ import { BaseChipProps, Size } from '../../types';
9
9
  import styles from './styles.module.scss';
10
10
 
11
11
  export type ChipAssistProps = WithSupportProps<
@@ -20,7 +20,7 @@ export type ChipAssistProps = WithSupportProps<
20
20
  /** Чип с лейблом */
21
21
  export function ChipAssist({
22
22
  icon,
23
- size = ChipAssist.sizes.S,
23
+ size = SIZE.S,
24
24
  label,
25
25
  disabled,
26
26
  loading,
@@ -29,8 +29,8 @@ export function ChipAssist({
29
29
  tabIndex,
30
30
  ...rest
31
31
  }: ChipAssistProps) {
32
- const variant = icon && size !== Size.Xs ? Variant.IconBefore : Variant.LabelOnly;
33
- const spinnerSize = size === Size.Xs ? Sun.sizes.XS : Sun.sizes.S;
32
+ const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
33
+ const spinnerSize: SunProps['size'] = size === SIZE.Xs ? 'xs' : 's';
34
34
 
35
35
  const handleClick: MouseEventHandler<HTMLButtonElement> = e => {
36
36
  if (disabled || loading) {
@@ -51,7 +51,7 @@ export function ChipAssist({
51
51
  onClick={handleClick}
52
52
  className={cn(styles.assistChip, className)}
53
53
  >
54
- {variant === Variant.IconBefore && !loading && (
54
+ {variant === VARIANT.IconBefore && !loading && (
55
55
  <span className={styles.icon} data-test-id={CHIP_ASSIST_TEST_IDS.icon}>
56
56
  {icon}
57
57
  </span>
@@ -69,5 +69,3 @@ export function ChipAssist({
69
69
  </button>
70
70
  );
71
71
  }
72
-
73
- ChipAssist.sizes = Size;
@@ -2,10 +2,10 @@ import cn from 'classnames';
2
2
  import { KeyboardEventHandler, MouseEventHandler, ReactNode, useCallback, useRef, useState } from 'react';
3
3
 
4
4
  import { Droplist } from '@snack-uikit/droplist';
5
- import { Sun } from '@snack-uikit/loaders';
5
+ import { Sun, SunProps } from '@snack-uikit/loaders';
6
6
  import { extractSupportProps } from '@snack-uikit/utils';
7
7
 
8
- import { CHIP_CHOICE_TEST_IDS, Size, Variant } from '../../../../constants';
8
+ import { CHIP_CHOICE_TEST_IDS, SIZE, VARIANT } from '../../../../constants';
9
9
  import { ButtonClearValue } from '../../../../helperComponents';
10
10
  import { BUTTON_CLEAR_VALUE_SIZE_MAP, DROPLIST_SIZE_MAP } from '../../constants';
11
11
  import { ChipChoiceCommonProps } from '../../types';
@@ -34,7 +34,7 @@ export type ChipChoiceCustomProps = ChipChoiceCommonProps & {
34
34
  };
35
35
 
36
36
  export function ChipChoiceCustom({
37
- size = Size.S,
37
+ size = SIZE.S,
38
38
  disabled,
39
39
  loading,
40
40
  icon,
@@ -44,16 +44,16 @@ export function ChipChoiceCustom({
44
44
  onClick,
45
45
  className,
46
46
  tabIndex = 0,
47
- placement = Droplist.placements.BottomStart,
48
- widthStrategy = Droplist.widthStrategies.Gte,
47
+ placement = 'bottom-start',
48
+ widthStrategy = 'gte',
49
49
  onClearButtonClick,
50
50
  showClearButton: showClearButtonProp = true,
51
51
  children,
52
52
  'data-test-id': testId,
53
53
  ...rest
54
54
  }: ChipChoiceCustomProps) {
55
- const variant = icon && size !== Size.Xs ? Variant.IconBefore : Variant.LabelOnly;
56
- const spinnerSize = size === Size.Xs ? Sun.sizes.XS : Sun.sizes.S;
55
+ const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
56
+ const spinnerSize: SunProps['size'] = size === SIZE.Xs ? 'xs' : 's';
57
57
 
58
58
  const clearButtonRef = useRef<HTMLButtonElement>(null);
59
59
 
@@ -121,7 +121,7 @@ export function ChipChoiceCustom({
121
121
 
122
122
  return (
123
123
  <Droplist
124
- trigger={Droplist.triggers.Click}
124
+ trigger='click'
125
125
  open={isDroplistOpened}
126
126
  firstElementRefCallback={firstElementRefCallback}
127
127
  onOpenChange={onOpenChangeHandler}
@@ -146,7 +146,7 @@ export function ChipChoiceCustom({
146
146
  onKeyDown={handleChipKeyDown}
147
147
  tabIndex={tabIndex}
148
148
  >
149
- {variant === Variant.IconBefore && (
149
+ {variant === VARIANT.IconBefore && (
150
150
  <span className={styles.icon} data-test-id={CHIP_CHOICE_TEST_IDS.icon}>
151
151
  {icon}
152
152
  </span>
@@ -2,7 +2,7 @@ import { useUncontrolledProp } from 'uncontrollable';
2
2
 
3
3
  import { Calendar } from '@snack-uikit/calendar';
4
4
 
5
- import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
5
+ import { DEFAULT_EMPTY_VALUE, SIZE } from '../../../constants';
6
6
  import { CALENDAR_SIZE_MAP } from '../constants';
7
7
  import { ChipChoiceCommonProps } from '../types';
8
8
  import { ChipChoiceCustom } from './ChipChoiceCustom';
@@ -19,7 +19,7 @@ export type ChipChoiceDateProps = ChipChoiceCommonProps & {
19
19
  };
20
20
 
21
21
  export function ChipChoiceDate({
22
- size = Size.S,
22
+ size = SIZE.S,
23
23
  value,
24
24
  defaultValue,
25
25
  onChange,
@@ -44,7 +44,7 @@ export function ChipChoiceDate({
44
44
  >
45
45
  {({ closeDroplist }) => (
46
46
  <Calendar
47
- mode={Calendar.modes.Date}
47
+ mode='date'
48
48
  size={CALENDAR_SIZE_MAP[size]}
49
49
  value={selectedValue}
50
50
  onChangeValue={value => {
@@ -2,7 +2,7 @@ import { useUncontrolledProp } from 'uncontrollable';
2
2
 
3
3
  import { Calendar } from '@snack-uikit/calendar';
4
4
 
5
- import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
5
+ import { DEFAULT_EMPTY_VALUE, SIZE } from '../../../constants';
6
6
  import { CALENDAR_SIZE_MAP } from '../constants';
7
7
  import { ChipChoiceCommonProps } from '../types';
8
8
  import { ChipChoiceCustom } from './ChipChoiceCustom';
@@ -29,7 +29,7 @@ function defaultRangeFormatter(value?: Range) {
29
29
  }
30
30
 
31
31
  export function ChipChoiceDateRange({
32
- size = Size.S,
32
+ size = SIZE.S,
33
33
  value,
34
34
  defaultValue,
35
35
  onChange,
@@ -52,7 +52,7 @@ export function ChipChoiceDateRange({
52
52
  >
53
53
  {({ closeDroplist }) => (
54
54
  <Calendar
55
- mode={Calendar.modes.Range}
55
+ mode='range'
56
56
  size={CALENDAR_SIZE_MAP[size]}
57
57
  value={selectedValue}
58
58
  onChangeValue={range => {
@@ -3,7 +3,7 @@ import { useUncontrolledProp } from 'uncontrollable';
3
3
 
4
4
  import { Droplist } from '@snack-uikit/droplist';
5
5
 
6
- import { Size } from '../../../constants';
6
+ import { SIZE } from '../../../constants';
7
7
  import { ChipChoiceCommonProps, FilterOption } from '../types';
8
8
  import { defaultMultiValueLabelFormatter, normalizeValueForMultiChoice } from '../utils';
9
9
  import { ChipChoiceCustom } from './ChipChoiceCustom';
@@ -27,7 +27,7 @@ export function ChipChoiceMulti({
27
27
  options,
28
28
  onChange,
29
29
  valueFormatter,
30
- size = Size.S,
30
+ size = SIZE.S,
31
31
  'data-test-id': dataTestId,
32
32
  ...rest
33
33
  }: ChipChoiceMultiProps) {
@@ -3,7 +3,7 @@ import { useUncontrolledProp } from 'uncontrollable';
3
3
 
4
4
  import { Droplist } from '@snack-uikit/droplist';
5
5
 
6
- import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
6
+ import { DEFAULT_EMPTY_VALUE, SIZE } from '../../../constants';
7
7
  import { ChipChoiceCommonProps, FilterOption } from '../types';
8
8
  import { normalizeValueForSingleChoice } from '../utils';
9
9
  import { ChipChoiceCustom } from './ChipChoiceCustom';
@@ -27,7 +27,7 @@ export function ChipChoiceSingle({
27
27
  options,
28
28
  onChange,
29
29
  valueFormatter,
30
- size = Size.S,
30
+ size = SIZE.S,
31
31
  'data-test-id': dataTestId,
32
32
  ...rest
33
33
  }: ChipChoiceSingleProps) {
@@ -1,32 +1,33 @@
1
- import { Calendar } from '@snack-uikit/calendar';
2
- import { Droplist } from '@snack-uikit/droplist';
1
+ import { CalendarProps } from '@snack-uikit/calendar';
2
+ import { DroplistProps } from '@snack-uikit/droplist';
3
3
 
4
- import { ButtonSize, Size } from '../../constants';
4
+ import { BUTTON_SIZE, SIZE } from '../../constants';
5
+ import { Size } from '../../types';
5
6
 
6
7
  export const BUTTON_CLEAR_VALUE_SIZE_MAP = {
7
- [Size.Xs]: ButtonSize.Xxs,
8
- [Size.S]: ButtonSize.Xs,
9
- [Size.M]: ButtonSize.Xs,
10
- [Size.L]: ButtonSize.Xs,
8
+ [SIZE.Xs]: BUTTON_SIZE.Xxs,
9
+ [SIZE.S]: BUTTON_SIZE.Xs,
10
+ [SIZE.M]: BUTTON_SIZE.Xs,
11
+ [SIZE.L]: BUTTON_SIZE.Xs,
11
12
  };
12
13
 
13
- export const CALENDAR_SIZE_MAP = {
14
- [Size.Xs]: Calendar.sizes.S,
15
- [Size.S]: Calendar.sizes.S,
16
- [Size.M]: Calendar.sizes.M,
17
- [Size.L]: Calendar.sizes.M,
14
+ export const CALENDAR_SIZE_MAP: Record<Size, CalendarProps['size']> = {
15
+ [SIZE.Xs]: 's',
16
+ [SIZE.S]: 's',
17
+ [SIZE.M]: 'm',
18
+ [SIZE.L]: 'm',
18
19
  };
19
20
 
20
- export const DROPLIST_SIZE_MAP = {
21
- [Size.Xs]: Droplist.sizes.S,
22
- [Size.S]: Droplist.sizes.S,
23
- [Size.M]: Droplist.sizes.M,
24
- [Size.L]: Droplist.sizes.L,
21
+ export const DROPLIST_SIZE_MAP: Record<Size, DroplistProps['size']> = {
22
+ [SIZE.Xs]: 's',
23
+ [SIZE.S]: 's',
24
+ [SIZE.M]: 'm',
25
+ [SIZE.L]: 'l',
25
26
  };
26
27
 
27
- export enum ChipChoiceType {
28
- Multi = 'multi',
29
- Date = 'date',
30
- DateRange = 'date-range',
31
- Single = 'single',
32
- }
28
+ export const CHIP_CHOICE_TYPE = {
29
+ Multi: 'multi',
30
+ Date: 'date',
31
+ DateRange: 'date-range',
32
+ Single: 'single',
33
+ } as const;
@@ -1,6 +1,3 @@
1
- import { Droplist } from '@snack-uikit/droplist';
2
-
3
- import { Size, Variant } from '../../constants';
4
1
  import {
5
2
  ChipChoiceCustom,
6
3
  ChipChoiceCustomProps,
@@ -13,7 +10,6 @@ import {
13
10
  ChipChoiceSingle,
14
11
  ChipChoiceSingleProps,
15
12
  } from './components';
16
- import { ChipChoiceType } from './constants';
17
13
 
18
14
  export type { FilterOption } from './types';
19
15
 
@@ -31,9 +27,4 @@ export namespace ChipChoice {
31
27
  export const Multi = ChipChoiceMulti;
32
28
  export const Date = ChipChoiceDate;
33
29
  export const DateRange = ChipChoiceDateRange;
34
- export const sizes = Size;
35
- export const variants = Variant;
36
- export const placements = Droplist.placements;
37
- export const widthStrategies = Droplist.widthStrategies;
38
- export const types = ChipChoiceType;
39
30
  }
@@ -3,8 +3,7 @@ import { MouseEventHandler } from 'react';
3
3
  import { DroplistProps, ItemSingleProps } from '@snack-uikit/droplist';
4
4
  import { WithSupportProps } from '@snack-uikit/utils';
5
5
 
6
- import { Size } from '../../constants';
7
- import { BaseChipProps } from '../../types';
6
+ import { BaseChipProps, Size } from '../../types';
8
7
 
9
8
  export type FilterOption = Pick<ItemSingleProps, 'caption' | 'description' | 'tagLabel' | 'icon' | 'avatar'> & {
10
9
  label: string;
@@ -23,10 +22,10 @@ export type ChipChoiceCommonProps = WithSupportProps<
23
22
  placement?: DroplistProps['placement'];
24
23
  /**
25
24
  * Стратегия управления шириной контейнера поповера
26
- * <br> - `Auto` - соответствует ширине контента,
27
- * <br> - `Gte` - Great Than or Equal, равен ширине таргета или больше ее, если контент в поповере шире,
28
- * <br> - `Eq` - Equal, строго равен ширине таргета.
29
- * @default Gte
25
+ * <br> - `auto` - соответствует ширине контента,
26
+ * <br> - `gte` - Great Than or Equal, равен ширине таргета или больше ее, если контент в поповере шире,
27
+ * <br> - `eq` - Equal, строго равен ширине таргета.
28
+ * @default gte
30
29
  */
31
30
  widthStrategy?: DroplistProps['widthStrategy'];
32
31
  }
@@ -7,9 +7,9 @@ import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
7
7
 
8
8
  import { CHIP_CHOICE_ROW_IDS } from '../../constants';
9
9
  import { ForwardedChipChoice } from './components';
10
- import { MAP_ROW_SIZE_TO_BUTTON_SIZE, MAP_ROW_SIZE_TO_CHOICE_SIZE, Size } from './constants';
10
+ import { CHIP_CHOICE_ROW_SIZE, MAP_ROW_SIZE_TO_BUTTON_SIZE, MAP_ROW_SIZE_TO_CHOICE_SIZE } from './constants';
11
11
  import styles from './styles.module.scss';
12
- import { ChipChoiceProps, FilterValue, OmitBetter } from './types';
12
+ import { ChipChoiceProps, ChipChoiceRowSize, FilterValue, OmitBetter } from './types';
13
13
 
14
14
  export type FiltersState = Record<string, unknown>;
15
15
 
@@ -22,8 +22,8 @@ export type ChipChoiceRowProps<TState extends FiltersState> = WithSupportProps<{
22
22
  onChange?(filters: TState): void;
23
23
  /** Массив чипов */
24
24
  filters: OmitBetter<ChipChoiceProps, 'onChange' | 'value' | 'size' | 'defaultValue'>[];
25
- /** Размер @default Size.S */
26
- size?: Size;
25
+ /** Размер @default 's' */
26
+ size?: ChipChoiceRowSize;
27
27
  /** CSS-класс */
28
28
  className?: string;
29
29
  /** Скрыть/показать кнопку очиски @default true */
@@ -40,7 +40,7 @@ export function ChipChoiceRow<TState extends FiltersState>({
40
40
  className,
41
41
  value,
42
42
  defaultValue,
43
- size = Size.S,
43
+ size = CHIP_CHOICE_ROW_SIZE.S,
44
44
  ...rest
45
45
  }: ChipChoiceRowProps<TState>) {
46
46
  const [state, setState] = useUncontrolledProp<TState>(value, (defaultValue ?? {}) as TState, newState => {
@@ -88,7 +88,7 @@ export function ChipChoiceRow<TState extends FiltersState>({
88
88
  onClick={handleFiltersClear}
89
89
  label={clearAllButtonLabel}
90
90
  icon={<CrossSVG />}
91
- iconPosition={ButtonFunction.iconPositions.Before}
91
+ iconPosition='before'
92
92
  size={MAP_ROW_SIZE_TO_BUTTON_SIZE[size]}
93
93
  data-test-id={CHIP_CHOICE_ROW_IDS.clearAllButton}
94
94
  />
@@ -96,5 +96,3 @@ export function ChipChoiceRow<TState extends FiltersState>({
96
96
  </div>
97
97
  );
98
98
  }
99
-
100
- ChipChoiceRow.sizes = Size;
@@ -1,8 +1,9 @@
1
1
  import { ChipChoice } from '../../ChipChoice';
2
+ import { CHIP_CHOICE_TYPE } from '../../ChipChoice/constants';
2
3
 
3
4
  export const MAP_CHIP_TYPE_TO_COMPONENT = {
4
- [ChipChoice.types.Single]: ChipChoice.Single,
5
- [ChipChoice.types.Multi]: ChipChoice.Multi,
6
- [ChipChoice.types.Date]: ChipChoice.Date,
7
- [ChipChoice.types.DateRange]: ChipChoice.DateRange,
5
+ [CHIP_CHOICE_TYPE.Single]: ChipChoice.Single,
6
+ [CHIP_CHOICE_TYPE.Multi]: ChipChoice.Multi,
7
+ [CHIP_CHOICE_TYPE.Date]: ChipChoice.Date,
8
+ [CHIP_CHOICE_TYPE.DateRange]: ChipChoice.DateRange,
8
9
  };
@@ -1,21 +1,21 @@
1
- import { ButtonFunction } from '@snack-uikit/button';
1
+ import { ButtonFunctionProps } from '@snack-uikit/button';
2
2
 
3
- import { ChipChoice } from '../ChipChoice';
3
+ import { SIZE } from '../../constants';
4
4
 
5
- export enum Size {
6
- Xs = 'xs',
7
- S = 's',
8
- M = 'm',
9
- }
5
+ export const CHIP_CHOICE_ROW_SIZE = {
6
+ Xs: 'xs',
7
+ S: 's',
8
+ M: 'm',
9
+ } as const;
10
10
 
11
11
  export const MAP_ROW_SIZE_TO_CHOICE_SIZE = {
12
- [Size.Xs]: ChipChoice.sizes.Xs,
13
- [Size.S]: ChipChoice.sizes.S,
14
- [Size.M]: ChipChoice.sizes.M,
12
+ [CHIP_CHOICE_ROW_SIZE.Xs]: SIZE.Xs,
13
+ [CHIP_CHOICE_ROW_SIZE.S]: SIZE.S,
14
+ [CHIP_CHOICE_ROW_SIZE.M]: SIZE.M,
15
15
  };
16
16
 
17
- export const MAP_ROW_SIZE_TO_BUTTON_SIZE = {
18
- [Size.Xs]: ButtonFunction.sizes.Xs,
19
- [Size.S]: ButtonFunction.sizes.S,
20
- [Size.M]: ButtonFunction.sizes.M,
17
+ export const MAP_ROW_SIZE_TO_BUTTON_SIZE: Record<string, ButtonFunctionProps['size']> = {
18
+ [CHIP_CHOICE_ROW_SIZE.Xs]: 'xs',
19
+ [CHIP_CHOICE_ROW_SIZE.S]: 's',
20
+ [CHIP_CHOICE_ROW_SIZE.M]: 'm',
21
21
  };