@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.
- package/CHANGELOG.md +11 -0
- package/README.md +16 -16
- package/dist/components/ChipAssist/ChipAssist.d.ts +1 -5
- package/dist/components/ChipAssist/ChipAssist.js +5 -6
- package/dist/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.js +5 -5
- package/dist/components/ChipChoice/components/ChipChoiceDate.js +3 -3
- package/dist/components/ChipChoice/components/ChipChoiceDateRange.js +3 -3
- package/dist/components/ChipChoice/components/ChipChoiceMulti.js +2 -2
- package/dist/components/ChipChoice/components/ChipChoiceSingle.js +2 -2
- package/dist/components/ChipChoice/constants.d.ts +14 -22
- package/dist/components/ChipChoice/constants.js +19 -22
- package/dist/components/ChipChoice/index.d.ts +0 -7
- package/dist/components/ChipChoice/index.js +0 -8
- package/dist/components/ChipChoice/types.d.ts +5 -6
- package/dist/components/ChipChoiceRow/ChipChoiceRow.d.ts +3 -7
- package/dist/components/ChipChoiceRow/ChipChoiceRow.js +3 -4
- package/dist/components/ChipChoiceRow/components/constants.js +5 -4
- package/dist/components/ChipChoiceRow/constants.d.ts +10 -13
- package/dist/components/ChipChoiceRow/constants.js +12 -14
- package/dist/components/ChipChoiceRow/types.d.ts +9 -6
- package/dist/components/ChipToggle/ChipToggle.d.ts +1 -5
- package/dist/components/ChipToggle/ChipToggle.js +5 -6
- package/dist/constants.d.ts +14 -14
- package/dist/constants.js +14 -17
- package/dist/helperComponents/ButtonClearValue/ButtonClearValue.d.ts +1 -1
- package/dist/helperComponents/ButtonClearValue/ButtonClearValue.js +2 -2
- package/dist/types.d.ts +5 -0
- package/package.json +7 -7
- package/src/components/ChipAssist/ChipAssist.tsx +7 -9
- package/src/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.tsx +9 -9
- package/src/components/ChipChoice/components/ChipChoiceDate.tsx +3 -3
- package/src/components/ChipChoice/components/ChipChoiceDateRange.tsx +3 -3
- package/src/components/ChipChoice/components/ChipChoiceMulti.tsx +2 -2
- package/src/components/ChipChoice/components/ChipChoiceSingle.tsx +2 -2
- package/src/components/ChipChoice/constants.ts +24 -23
- package/src/components/ChipChoice/index.ts +0 -9
- package/src/components/ChipChoice/types.ts +5 -6
- package/src/components/ChipChoiceRow/ChipChoiceRow.tsx +6 -8
- package/src/components/ChipChoiceRow/components/constants.ts +5 -4
- package/src/components/ChipChoiceRow/constants.ts +14 -14
- package/src/components/ChipChoiceRow/types.ts +11 -6
- package/src/components/ChipToggle/ChipToggle.tsx +7 -9
- package/src/constants.ts +14 -14
- package/src/helperComponents/ButtonClearValue/ButtonClearValue.tsx +4 -3
- package/src/types.ts +10 -0
|
@@ -1,25 +1,30 @@
|
|
|
1
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
ChipChoiceDateProps,
|
|
3
5
|
ChipChoiceDateRangeProps,
|
|
4
6
|
ChipChoiceMultiProps,
|
|
5
7
|
ChipChoiceSingleProps,
|
|
6
|
-
} from '../ChipChoice
|
|
7
|
-
import {
|
|
8
|
+
} from '../ChipChoice';
|
|
9
|
+
import { CHIP_CHOICE_TYPE } from '../ChipChoice/constants';
|
|
10
|
+
import { CHIP_CHOICE_ROW_SIZE } from './constants';
|
|
11
|
+
|
|
12
|
+
export type ChipChoiceRowSize = ValueOf<typeof CHIP_CHOICE_ROW_SIZE>;
|
|
8
13
|
|
|
9
14
|
type ChipChoiceMultiType = {
|
|
10
|
-
type:
|
|
15
|
+
type: typeof CHIP_CHOICE_TYPE.Multi;
|
|
11
16
|
} & ChipChoiceMultiProps;
|
|
12
17
|
|
|
13
18
|
type ChipChoiceSingleType = {
|
|
14
|
-
type:
|
|
19
|
+
type: typeof CHIP_CHOICE_TYPE.Single;
|
|
15
20
|
} & ChipChoiceSingleProps;
|
|
16
21
|
|
|
17
22
|
type ChipChoiceDateType = {
|
|
18
|
-
type:
|
|
23
|
+
type: typeof CHIP_CHOICE_TYPE.Date;
|
|
19
24
|
} & ChipChoiceDateProps;
|
|
20
25
|
|
|
21
26
|
type ChipChoiceDateRangeType = {
|
|
22
|
-
type:
|
|
27
|
+
type: typeof CHIP_CHOICE_TYPE.DateRange;
|
|
23
28
|
} & ChipChoiceDateRangeProps;
|
|
24
29
|
|
|
25
30
|
export type ChipChoiceProps = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
2
|
import { ChangeEvent, ChangeEventHandler } 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_TOGGLE_TEST_IDS,
|
|
8
|
-
import { BaseChipProps } from '../../types';
|
|
7
|
+
import { CHIP_TOGGLE_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 ChipToggleProps = WithSupportProps<
|
|
@@ -22,7 +22,7 @@ export type ChipToggleProps = WithSupportProps<
|
|
|
22
22
|
/** Чип с состоянием выбран/не выбран */
|
|
23
23
|
export function ChipToggle({
|
|
24
24
|
icon,
|
|
25
|
-
size =
|
|
25
|
+
size = SIZE.S,
|
|
26
26
|
label,
|
|
27
27
|
checked,
|
|
28
28
|
disabled,
|
|
@@ -32,8 +32,8 @@ export function ChipToggle({
|
|
|
32
32
|
tabIndex = 0,
|
|
33
33
|
...rest
|
|
34
34
|
}: ChipToggleProps) {
|
|
35
|
-
const variant = icon && size !==
|
|
36
|
-
const spinnerSize = size ===
|
|
35
|
+
const variant = icon && size !== SIZE.Xs ? VARIANT.IconBefore : VARIANT.LabelOnly;
|
|
36
|
+
const spinnerSize: SunProps['size'] = size === SIZE.Xs ? 'xs' : 's';
|
|
37
37
|
|
|
38
38
|
const handleChange: ChangeEventHandler<HTMLInputElement> = e => {
|
|
39
39
|
if (disabled || loading) {
|
|
@@ -64,7 +64,7 @@ export function ChipToggle({
|
|
|
64
64
|
/>
|
|
65
65
|
|
|
66
66
|
<span className={styles.toggleChipContent}>
|
|
67
|
-
{variant ===
|
|
67
|
+
{variant === VARIANT.IconBefore && !loading && (
|
|
68
68
|
<span className={styles.icon} data-test-id={CHIP_TOGGLE_TEST_IDS.icon}>
|
|
69
69
|
{icon}
|
|
70
70
|
</span>
|
|
@@ -83,5 +83,3 @@ export function ChipToggle({
|
|
|
83
83
|
</label>
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
ChipToggle.sizes = Size;
|
package/src/constants.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
Xs
|
|
3
|
-
S
|
|
4
|
-
M
|
|
5
|
-
L
|
|
6
|
-
}
|
|
1
|
+
export const SIZE = {
|
|
2
|
+
Xs: 'xs',
|
|
3
|
+
S: 's',
|
|
4
|
+
M: 'm',
|
|
5
|
+
L: 'l',
|
|
6
|
+
} as const;
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
Xxs
|
|
10
|
-
Xs
|
|
11
|
-
}
|
|
8
|
+
export const BUTTON_SIZE = {
|
|
9
|
+
Xxs: 'xxs',
|
|
10
|
+
Xs: 'xs',
|
|
11
|
+
} as const;
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
LabelOnly
|
|
15
|
-
IconBefore
|
|
16
|
-
}
|
|
13
|
+
export const VARIANT = {
|
|
14
|
+
LabelOnly: 'label-only',
|
|
15
|
+
IconBefore: 'icon-before',
|
|
16
|
+
} as const;
|
|
17
17
|
|
|
18
18
|
export const CHIP_ASSIST_TEST_IDS = {
|
|
19
19
|
icon: 'chip-assist__icon',
|
|
@@ -2,7 +2,8 @@ import { forwardRef, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { CrossSVG } from '@snack-uikit/icons';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { BUTTON_SIZE } from '../../constants';
|
|
6
|
+
import { ButtonSize } from '../../types';
|
|
6
7
|
import styles from './styles.module.scss';
|
|
7
8
|
|
|
8
9
|
type ButtonClearValueProps = {
|
|
@@ -31,8 +32,8 @@ export const ButtonClearValue = forwardRef<HTMLButtonElement, ButtonClearValuePr
|
|
|
31
32
|
onKeyDown={onKeyDown}
|
|
32
33
|
tabIndex={tabIndex}
|
|
33
34
|
>
|
|
34
|
-
{size ===
|
|
35
|
-
{size ===
|
|
35
|
+
{size === BUTTON_SIZE.Xxs && <CrossSVG size={16} />}
|
|
36
|
+
{size === BUTTON_SIZE.Xs && <CrossSVG />}
|
|
36
37
|
</button>
|
|
37
38
|
);
|
|
38
39
|
},
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
+
import { ValueOf } from '@snack-uikit/utils';
|
|
4
|
+
|
|
5
|
+
import { BUTTON_SIZE, SIZE, VARIANT } from './constants';
|
|
6
|
+
|
|
7
|
+
export type Size = ValueOf<typeof SIZE>;
|
|
8
|
+
|
|
9
|
+
export type ButtonSize = ValueOf<typeof BUTTON_SIZE>;
|
|
10
|
+
|
|
11
|
+
export type Variant = ValueOf<typeof VARIANT>;
|
|
12
|
+
|
|
3
13
|
export type BaseChipProps = {
|
|
4
14
|
/** Лейбл */
|
|
5
15
|
label: string;
|