@astral/ui 4.27.1 → 4.28.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/components/BottomDrawer/BottomDrawer.js +1 -1
- package/components/CheckableTag/CheckableTag.d.ts +7 -7
- package/components/CheckableTag/CheckableTag.js +7 -7
- package/components/Chip/Chip.d.ts +2 -0
- package/components/Chip/Chip.js +28 -0
- package/components/Chip/ChipStatusIcon/ChipStatusIcon.d.ts +5 -0
- package/components/Chip/ChipStatusIcon/ChipStatusIcon.js +15 -0
- package/components/Chip/ChipStatusIcon/constants.d.ts +6 -0
- package/components/Chip/ChipStatusIcon/constants.js +7 -0
- package/components/Chip/ChipStatusIcon/index.d.ts +1 -0
- package/components/Chip/ChipStatusIcon/index.js +1 -0
- package/components/Chip/ChipStatusIcon/styled.d.ts +9 -0
- package/components/Chip/ChipStatusIcon/styled.js +16 -0
- package/components/Chip/constants.d.ts +29 -0
- package/components/Chip/constants.js +21 -0
- package/components/Chip/index.d.ts +2 -0
- package/components/Chip/index.js +1 -0
- package/components/Chip/public.d.ts +2 -0
- package/components/Chip/public.js +1 -0
- package/components/Chip/styles.d.ts +26 -0
- package/components/Chip/styles.js +141 -0
- package/components/Chip/types.d.ts +43 -0
- package/components/Chip/types.js +1 -0
- package/components/Chip/useLogic/index.d.ts +1 -0
- package/components/Chip/useLogic/index.js +1 -0
- package/components/Chip/useLogic/useLogic.d.ts +20 -0
- package/components/Chip/useLogic/useLogic.js +34 -0
- package/node/components/BottomDrawer/BottomDrawer.js +1 -1
- package/node/components/CheckableTag/CheckableTag.d.ts +7 -7
- package/node/components/CheckableTag/CheckableTag.js +7 -7
- package/node/components/Chip/Chip.d.ts +2 -0
- package/node/components/Chip/Chip.js +32 -0
- package/node/components/Chip/ChipStatusIcon/ChipStatusIcon.d.ts +5 -0
- package/node/components/Chip/ChipStatusIcon/ChipStatusIcon.js +19 -0
- package/node/components/Chip/ChipStatusIcon/constants.d.ts +6 -0
- package/node/components/Chip/ChipStatusIcon/constants.js +10 -0
- package/node/components/Chip/ChipStatusIcon/index.d.ts +1 -0
- package/node/components/Chip/ChipStatusIcon/index.js +17 -0
- package/node/components/Chip/ChipStatusIcon/styled.d.ts +9 -0
- package/node/components/Chip/ChipStatusIcon/styled.js +19 -0
- package/node/components/Chip/constants.d.ts +29 -0
- package/node/components/Chip/constants.js +24 -0
- package/node/components/Chip/index.d.ts +2 -0
- package/node/components/Chip/index.js +5 -0
- package/node/components/Chip/public.d.ts +2 -0
- package/node/components/Chip/public.js +5 -0
- package/node/components/Chip/styles.d.ts +26 -0
- package/node/components/Chip/styles.js +144 -0
- package/node/components/Chip/types.d.ts +43 -0
- package/node/components/Chip/types.js +2 -0
- package/node/components/Chip/useLogic/index.d.ts +1 -0
- package/node/components/Chip/useLogic/index.js +17 -0
- package/node/components/Chip/useLogic/useLogic.d.ts +20 -0
- package/node/components/Chip/useLogic/useLogic.js +38 -0
- package/package.json +1 -1
|
@@ -9,5 +9,5 @@ export const BottomDrawer = ({ title, drawerHeaderHeight = DEFAULT_HEADER_HEIGHT
|
|
|
9
9
|
onClose(event, 'escapeKeyDown');
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
return (_jsxs(StyledDrawer, { ...props, anchor: "bottom", onClose: onClose, children: [_jsxs(Header, { drawerHeaderHeight: drawerHeaderHeight, children: [_jsx(HeaderTitle, { variant: "h6", noWrap: true, children: title }), headerContent, _jsx(IconButton, { variant: "text", onClick: handleClose, size: "
|
|
12
|
+
return (_jsxs(StyledDrawer, { ...props, anchor: "bottom", onClose: onClose, children: [_jsxs(Header, { drawerHeaderHeight: drawerHeaderHeight, children: [_jsx(HeaderTitle, { variant: "h6", noWrap: true, children: title }), headerContent, _jsx(IconButton, { variant: "text", onClick: handleClose, size: "medium", children: _jsx(CrossOutlineMd, {}) })] }), _jsx(Body, { className: bottomDrawerClassnames.content, children: children })] }));
|
|
13
13
|
};
|
|
@@ -31,14 +31,14 @@ export type CheckableTagProps = Omit<TagProps, 'onChange' | 'startAddon' | 'endA
|
|
|
31
31
|
* Тег с возможностью быть checked (по логике Checkbox)
|
|
32
32
|
* @example
|
|
33
33
|
* <CheckableTag
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
* label="tag"
|
|
35
|
+
* variant="contained"
|
|
36
|
+
* color="success"
|
|
37
|
+
* checked
|
|
38
|
+
* onChange={handleChecked}
|
|
39
|
+
* endAddon={(props: TagBadgeProps) => (<TagBadge {...props} badgeContent={'12'} />)}
|
|
40
40
|
* />
|
|
41
|
-
|
|
41
|
+
* @deprecated Используйте компонент Chip
|
|
42
42
|
*/
|
|
43
43
|
export declare const CheckableTag: import("react").ForwardRefExoticComponent<Omit<TagProps, "onChange" | "variant" | "startAddon" | "endAddon"> & {
|
|
44
44
|
/**
|
|
@@ -5,14 +5,14 @@ import { HiddenInput, StyledTag, Wrapper } from './styles';
|
|
|
5
5
|
* Тег с возможностью быть checked (по логике Checkbox)
|
|
6
6
|
* @example
|
|
7
7
|
* <CheckableTag
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
* label="tag"
|
|
9
|
+
* variant="contained"
|
|
10
|
+
* color="success"
|
|
11
|
+
* checked
|
|
12
|
+
* onChange={handleChecked}
|
|
13
|
+
* endAddon={(props: TagBadgeProps) => (<TagBadge {...props} badgeContent={'12'} />)}
|
|
14
14
|
* />
|
|
15
|
-
|
|
15
|
+
* @deprecated Используйте компонент Chip
|
|
16
16
|
*/
|
|
17
17
|
export const CheckableTag = forwardRef(({ checked, variant = 'light', color = 'grey', onChange, disabled, startAddon: StartAddon, endAddon: EndAddon, ...tagProps }, ref) => {
|
|
18
18
|
const checkableStartAddon = StartAddon
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from '../Typography';
|
|
3
|
+
import { ChipStatusIcon } from './ChipStatusIcon';
|
|
4
|
+
import { chipClassnames } from './constants';
|
|
5
|
+
import { AdornmentWrapper, Counter, HiddenInput, Label, Wrapper, } from './styles';
|
|
6
|
+
import { useLogic } from './useLogic';
|
|
7
|
+
export const Chip = (props) => {
|
|
8
|
+
const { classnames, inputProps, label, status, icon, counter, endAdornment, hasStartAdornment, hasEndAdornment, } = useLogic(props);
|
|
9
|
+
const renderStartAdornment = () => {
|
|
10
|
+
if (status) {
|
|
11
|
+
return _jsx(ChipStatusIcon, { status: status });
|
|
12
|
+
}
|
|
13
|
+
if (icon) {
|
|
14
|
+
return icon;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
const renderEndAdornment = () => {
|
|
19
|
+
if (counter) {
|
|
20
|
+
return _jsx(Counter, { children: counter });
|
|
21
|
+
}
|
|
22
|
+
if (endAdornment) {
|
|
23
|
+
return endAdornment;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs(Label, { children: [_jsx(HiddenInput, { ...inputProps }), _jsxs(Wrapper, { className: classnames, children: [hasStartAdornment && (_jsx(AdornmentWrapper, { component: "span", className: chipClassnames.startAdornment, children: renderStartAdornment() })), _jsx(Typography, { className: chipClassnames.label, component: "span", children: label }), hasEndAdornment && (_jsx(AdornmentWrapper, { component: "span", className: chipClassnames.endAdornment, children: renderEndAdornment() }))] })] }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { classNames } from '../../utils/classNames';
|
|
4
|
+
import { chipStatusIconClassnames } from './constants';
|
|
5
|
+
import { StatusIcon } from './styled';
|
|
6
|
+
export const ChipStatusIcon = ({ status }) => {
|
|
7
|
+
const classnames = useMemo(() => {
|
|
8
|
+
return classNames(chipStatusIconClassnames.root, {
|
|
9
|
+
[chipStatusIconClassnames.success]: status === 'success',
|
|
10
|
+
[chipStatusIconClassnames.warning]: status === 'warning',
|
|
11
|
+
[chipStatusIconClassnames.error]: status === 'error',
|
|
12
|
+
});
|
|
13
|
+
}, [status]);
|
|
14
|
+
return (_jsx(StatusIcon, { className: classnames, viewBox: "0 0 20 20", width: "20px", height: "20px", children: _jsx("circle", { cx: "10", cy: "10", r: "3.33333" }) }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createUIKitClassname } from '../../utils/createUIKitClassname';
|
|
2
|
+
export const chipStatusIconClassnames = {
|
|
3
|
+
root: createUIKitClassname('chip-status-icon'),
|
|
4
|
+
success: createUIKitClassname('chip-status-icon_success'),
|
|
5
|
+
warning: createUIKitClassname('chip-status-icon_warning'),
|
|
6
|
+
error: createUIKitClassname('chip-status-icon_error'),
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChipStatusIcon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChipStatusIcon';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StatusIcon: import("../../styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
color?: string | undefined;
|
|
5
|
+
titleAccess?: string | undefined;
|
|
6
|
+
size?: "sm" | "md" | undefined;
|
|
7
|
+
} & import("react").SVGProps<SVGSVGElement> & {
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvgIcon } from '../../SvgIcon';
|
|
2
|
+
import { styled } from '../../styled';
|
|
3
|
+
import { chipStatusIconClassnames } from './constants';
|
|
4
|
+
export const StatusIcon = styled(SvgIcon) `
|
|
5
|
+
&.${chipStatusIconClassnames.success} {
|
|
6
|
+
color: ${({ theme }) => theme.palette.success[900]};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&.${chipStatusIconClassnames.warning} {
|
|
10
|
+
color: ${({ theme }) => theme.palette.warning[900]};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&.${chipStatusIconClassnames.error} {
|
|
14
|
+
color: ${({ theme }) => theme.palette.error[900]};
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const chipClassnames: {
|
|
2
|
+
root: string;
|
|
3
|
+
sizeSmall: string;
|
|
4
|
+
sizeMedium: string;
|
|
5
|
+
sizeLarge: string;
|
|
6
|
+
disabled: string;
|
|
7
|
+
selected: string;
|
|
8
|
+
label: string;
|
|
9
|
+
hasStatusIcon: string;
|
|
10
|
+
hasCounter: string;
|
|
11
|
+
hasEndAdornment: string;
|
|
12
|
+
hasIcon: string;
|
|
13
|
+
startAdornment: string;
|
|
14
|
+
endAdornment: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const chipSize: {
|
|
17
|
+
small: {
|
|
18
|
+
desktop: string;
|
|
19
|
+
mobile: string;
|
|
20
|
+
};
|
|
21
|
+
medium: {
|
|
22
|
+
desktop: string;
|
|
23
|
+
mobile: string;
|
|
24
|
+
};
|
|
25
|
+
large: {
|
|
26
|
+
desktop: string;
|
|
27
|
+
mobile: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createUIKitClassname } from '../utils/createUIKitClassname';
|
|
2
|
+
export const chipClassnames = {
|
|
3
|
+
root: createUIKitClassname('chip'),
|
|
4
|
+
sizeSmall: createUIKitClassname('chip_size-small'),
|
|
5
|
+
sizeMedium: createUIKitClassname('chip_size-medium'),
|
|
6
|
+
sizeLarge: createUIKitClassname('chip_size-large'),
|
|
7
|
+
disabled: createUIKitClassname('chip_disabled'),
|
|
8
|
+
selected: createUIKitClassname('chip_selected'),
|
|
9
|
+
label: createUIKitClassname('chip__label'),
|
|
10
|
+
hasStatusIcon: createUIKitClassname('chip_has-status-icon'),
|
|
11
|
+
hasCounter: createUIKitClassname('chip_has-counter'),
|
|
12
|
+
hasEndAdornment: createUIKitClassname('chip_has-end-adornment'),
|
|
13
|
+
hasIcon: createUIKitClassname('chip_has-icon'),
|
|
14
|
+
startAdornment: createUIKitClassname('chip__start-adornment'),
|
|
15
|
+
endAdornment: createUIKitClassname('chip__end-adornment'),
|
|
16
|
+
};
|
|
17
|
+
export const chipSize = {
|
|
18
|
+
small: { desktop: '20px', mobile: '24px' },
|
|
19
|
+
medium: { desktop: '24px', mobile: '32px' },
|
|
20
|
+
large: { desktop: '32px', mobile: '40px' },
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Chip } from './Chip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Chip } from './Chip';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Wrapper: import("../styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export declare const HiddenInput: import("../styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
|
|
10
|
+
export declare const Counter: import("../styled").StyledComponent<{
|
|
11
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
12
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
13
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
14
|
+
export declare const AdornmentWrapper: import("../styled").StyledComponent<import("../Typography/types").TypographyPropsBase & {
|
|
15
|
+
color?: import("../Typography").TypographyColor | undefined;
|
|
16
|
+
variant?: import("../Typography").TypographyVariant | undefined;
|
|
17
|
+
colorIntensity?: import("../Typography").Intensity | undefined;
|
|
18
|
+
component?: import("../Typography/types").ComponentProp | undefined;
|
|
19
|
+
isUpperCase?: boolean | undefined;
|
|
20
|
+
} & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
|
|
21
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
export declare const Label: import("../styled").StyledComponent<{
|
|
24
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
25
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
26
|
+
}, import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {}>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { styled } from '../styled';
|
|
2
|
+
import { Typography } from '../Typography';
|
|
3
|
+
import { chipClassnames, chipSize } from './constants';
|
|
4
|
+
export const Wrapper = styled.div `
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
user-select: none;
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
|
|
12
|
+
padding: ${({ theme }) => theme.spacing(0, 2)};
|
|
13
|
+
|
|
14
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
15
|
+
border: 1px solid ${({ theme }) => theme.palette.grey[400]};
|
|
16
|
+
border-radius: ${({ theme }) => theme.shape.medium};
|
|
17
|
+
|
|
18
|
+
transition: ${({ theme }) => theme.transitions.create(['border-color', 'background-color'], {
|
|
19
|
+
duration: theme.transitions.duration.shortest,
|
|
20
|
+
})};
|
|
21
|
+
|
|
22
|
+
&:hover {
|
|
23
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
24
|
+
border-color: ${({ theme }) => theme.palette.grey[400]};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:active {
|
|
28
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
29
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.${chipClassnames.hasIcon},
|
|
33
|
+
&.${chipClassnames.hasEndAdornment}:not(.${chipClassnames.hasStatusIcon}),
|
|
34
|
+
&.${chipClassnames.hasCounter}:not(.${chipClassnames.hasStatusIcon}) {
|
|
35
|
+
gap: ${({ theme }) => theme.spacing(1)};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.${chipClassnames.hasStatusIcon} {
|
|
39
|
+
& .${chipClassnames.label} {
|
|
40
|
+
margin-left: ${({ theme }) => theme.microSpacing(1)};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.${chipClassnames.hasCounter} .${chipClassnames.label},
|
|
44
|
+
&.${chipClassnames.hasEndAdornment} .${chipClassnames.label} {
|
|
45
|
+
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.${chipClassnames.hasStatusIcon} {
|
|
50
|
+
padding-left: ${({ theme }) => theme.microSpacing(1)};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.${chipClassnames.sizeSmall} {
|
|
54
|
+
height: ${chipSize.small.desktop};
|
|
55
|
+
|
|
56
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
57
|
+
height: ${chipSize.small.mobile};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.${chipClassnames.sizeMedium} {
|
|
62
|
+
height: ${chipSize.medium.desktop};
|
|
63
|
+
|
|
64
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
65
|
+
height: ${chipSize.medium.mobile};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&.${chipClassnames.sizeLarge} {
|
|
70
|
+
height: ${chipSize.large.desktop};
|
|
71
|
+
padding: ${({ theme }) => theme.spacing(0, 3)};
|
|
72
|
+
|
|
73
|
+
&.${chipClassnames.hasStatusIcon} {
|
|
74
|
+
padding-left: ${({ theme }) => theme.spacing(2)};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
78
|
+
height: ${chipSize.large.mobile};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.${chipClassnames.selected} {
|
|
83
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
84
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
85
|
+
|
|
86
|
+
&:hover {
|
|
87
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
88
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&:active {
|
|
92
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
93
|
+
border-color: ${({ theme }) => theme.palette.grey[400]};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&.${chipClassnames.disabled} {
|
|
98
|
+
cursor: default;
|
|
99
|
+
|
|
100
|
+
background-color: ${({ theme }) => theme.palette.components.disabled};
|
|
101
|
+
border-color: transparent;
|
|
102
|
+
mix-blend-mode: luminosity;
|
|
103
|
+
|
|
104
|
+
& .${chipClassnames.startAdornment},
|
|
105
|
+
& .${chipClassnames.endAdornment},
|
|
106
|
+
& .${chipClassnames.label} {
|
|
107
|
+
opacity: 0.3;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
export const HiddenInput = styled.input `
|
|
112
|
+
display: none;
|
|
113
|
+
`;
|
|
114
|
+
export const Counter = styled.div `
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
|
|
118
|
+
&::before {
|
|
119
|
+
content: '';
|
|
120
|
+
|
|
121
|
+
display: inline-block;
|
|
122
|
+
|
|
123
|
+
width: 2px;
|
|
124
|
+
height: 2px;
|
|
125
|
+
|
|
126
|
+
/* Сдвигаем точку ниже, чтобы визуально выровнять её по центру строчных букв */
|
|
127
|
+
margin-top: 0.15em;
|
|
128
|
+
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
129
|
+
|
|
130
|
+
background-color: ${({ theme }) => theme.palette.grey[800]};
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
export const AdornmentWrapper = styled(Typography) `
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
`;
|
|
138
|
+
export const Label = styled.label `
|
|
139
|
+
/* Убираем подсветку при нажатии на компонент */
|
|
140
|
+
-webkit-tap-highlight-color: transparent;
|
|
141
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ChangeEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type ChipProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Содержимое компонента
|
|
5
|
+
*/
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Размер компонента
|
|
9
|
+
*/
|
|
10
|
+
size?: 'small' | 'medium' | 'large';
|
|
11
|
+
/**
|
|
12
|
+
* Статус компонента. Заменяет параметр `icon`
|
|
13
|
+
*/
|
|
14
|
+
status?: 'success' | 'warning' | 'error';
|
|
15
|
+
/**
|
|
16
|
+
* Иконка слева от `label`
|
|
17
|
+
*/
|
|
18
|
+
icon?: ReactElement;
|
|
19
|
+
/**
|
|
20
|
+
* Название класса, применяется к корневому компоненту.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Если `true`, компонент будет недоступен для взаимодействия
|
|
25
|
+
*/
|
|
26
|
+
isDisabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Если `true`, компонент отображается в выбранном состоянии
|
|
29
|
+
*/
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Число счетчика справа от `label`. Заменяет параметр `endAdornment`
|
|
33
|
+
*/
|
|
34
|
+
counter?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Элемент, который добавляется в конец компонента
|
|
37
|
+
*/
|
|
38
|
+
endAdornment?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Обработчик изменения состояния компонента
|
|
41
|
+
*/
|
|
42
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ChipProps } from '../types';
|
|
3
|
+
type UseLogicParams = ChipProps;
|
|
4
|
+
export declare const useLogic: ({ className, isDisabled, isSelected, onChange, size, label, status, icon, counter, endAdornment, }: UseLogicParams) => {
|
|
5
|
+
classnames: string;
|
|
6
|
+
inputProps: {
|
|
7
|
+
checked: boolean | undefined;
|
|
8
|
+
onChange: ((event: import("react").ChangeEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
9
|
+
type: string;
|
|
10
|
+
disabled: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
label: import("react").ReactNode;
|
|
13
|
+
status: "success" | "warning" | "error" | undefined;
|
|
14
|
+
icon: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
15
|
+
counter: number | undefined;
|
|
16
|
+
endAdornment: import("react").ReactNode;
|
|
17
|
+
hasStartAdornment: boolean;
|
|
18
|
+
hasEndAdornment: boolean;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { classNames } from '../../utils/classNames';
|
|
3
|
+
import { chipClassnames } from '../constants';
|
|
4
|
+
export const useLogic = ({ className, isDisabled, isSelected, onChange, size = 'medium', label, status, icon, counter, endAdornment, }) => {
|
|
5
|
+
const classnames = useMemo(() => classNames(className, chipClassnames.root, {
|
|
6
|
+
[chipClassnames.disabled]: isDisabled,
|
|
7
|
+
[chipClassnames.selected]: isSelected,
|
|
8
|
+
[chipClassnames.sizeSmall]: size === 'small',
|
|
9
|
+
[chipClassnames.sizeMedium]: size === 'medium',
|
|
10
|
+
[chipClassnames.sizeLarge]: size === 'large',
|
|
11
|
+
[chipClassnames.hasStatusIcon]: Boolean(status),
|
|
12
|
+
[chipClassnames.hasCounter]: Boolean(counter),
|
|
13
|
+
[chipClassnames.hasEndAdornment]: Boolean(endAdornment) && !counter,
|
|
14
|
+
[chipClassnames.hasIcon]: Boolean(icon) && !status,
|
|
15
|
+
}), [isSelected, isDisabled, size, status, counter, endAdornment, icon]);
|
|
16
|
+
const hasStartAdornment = Boolean(status || icon);
|
|
17
|
+
const hasEndAdornment = Boolean(endAdornment || counter);
|
|
18
|
+
return {
|
|
19
|
+
classnames,
|
|
20
|
+
inputProps: {
|
|
21
|
+
checked: isSelected,
|
|
22
|
+
onChange,
|
|
23
|
+
type: 'checkbox',
|
|
24
|
+
disabled: isDisabled,
|
|
25
|
+
},
|
|
26
|
+
label,
|
|
27
|
+
status,
|
|
28
|
+
icon,
|
|
29
|
+
counter,
|
|
30
|
+
endAdornment,
|
|
31
|
+
hasStartAdornment,
|
|
32
|
+
hasEndAdornment,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -12,6 +12,6 @@ const BottomDrawer = ({ title, drawerHeaderHeight = constants_1.DEFAULT_HEADER_H
|
|
|
12
12
|
onClose(event, 'escapeKeyDown');
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.StyledDrawer, { ...props, anchor: "bottom", onClose: onClose, children: [(0, jsx_runtime_1.jsxs)(styles_1.Header, { drawerHeaderHeight: drawerHeaderHeight, children: [(0, jsx_runtime_1.jsx)(styles_1.HeaderTitle, { variant: "h6", noWrap: true, children: title }), headerContent, (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleClose, size: "
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.StyledDrawer, { ...props, anchor: "bottom", onClose: onClose, children: [(0, jsx_runtime_1.jsxs)(styles_1.Header, { drawerHeaderHeight: drawerHeaderHeight, children: [(0, jsx_runtime_1.jsx)(styles_1.HeaderTitle, { variant: "h6", noWrap: true, children: title }), headerContent, (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleClose, size: "medium", children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) })] }), (0, jsx_runtime_1.jsx)(styles_1.Body, { className: constants_1.bottomDrawerClassnames.content, children: children })] }));
|
|
16
16
|
};
|
|
17
17
|
exports.BottomDrawer = BottomDrawer;
|
|
@@ -31,14 +31,14 @@ export type CheckableTagProps = Omit<TagProps, 'onChange' | 'startAddon' | 'endA
|
|
|
31
31
|
* Тег с возможностью быть checked (по логике Checkbox)
|
|
32
32
|
* @example
|
|
33
33
|
* <CheckableTag
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
* label="tag"
|
|
35
|
+
* variant="contained"
|
|
36
|
+
* color="success"
|
|
37
|
+
* checked
|
|
38
|
+
* onChange={handleChecked}
|
|
39
|
+
* endAddon={(props: TagBadgeProps) => (<TagBadge {...props} badgeContent={'12'} />)}
|
|
40
40
|
* />
|
|
41
|
-
|
|
41
|
+
* @deprecated Используйте компонент Chip
|
|
42
42
|
*/
|
|
43
43
|
export declare const CheckableTag: import("react").ForwardRefExoticComponent<Omit<TagProps, "onChange" | "variant" | "startAddon" | "endAddon"> & {
|
|
44
44
|
/**
|
|
@@ -8,14 +8,14 @@ const styles_1 = require("./styles");
|
|
|
8
8
|
* Тег с возможностью быть checked (по логике Checkbox)
|
|
9
9
|
* @example
|
|
10
10
|
* <CheckableTag
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
* label="tag"
|
|
12
|
+
* variant="contained"
|
|
13
|
+
* color="success"
|
|
14
|
+
* checked
|
|
15
|
+
* onChange={handleChecked}
|
|
16
|
+
* endAddon={(props: TagBadgeProps) => (<TagBadge {...props} badgeContent={'12'} />)}
|
|
17
17
|
* />
|
|
18
|
-
|
|
18
|
+
* @deprecated Используйте компонент Chip
|
|
19
19
|
*/
|
|
20
20
|
exports.CheckableTag = (0, react_1.forwardRef)(({ checked, variant = 'light', color = 'grey', onChange, disabled, startAddon: StartAddon, endAddon: EndAddon, ...tagProps }, ref) => {
|
|
21
21
|
const checkableStartAddon = StartAddon
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Chip = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Typography_1 = require("../Typography");
|
|
6
|
+
const ChipStatusIcon_1 = require("./ChipStatusIcon");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const styles_1 = require("./styles");
|
|
9
|
+
const useLogic_1 = require("./useLogic");
|
|
10
|
+
const Chip = (props) => {
|
|
11
|
+
const { classnames, inputProps, label, status, icon, counter, endAdornment, hasStartAdornment, hasEndAdornment, } = (0, useLogic_1.useLogic)(props);
|
|
12
|
+
const renderStartAdornment = () => {
|
|
13
|
+
if (status) {
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(ChipStatusIcon_1.ChipStatusIcon, { status: status });
|
|
15
|
+
}
|
|
16
|
+
if (icon) {
|
|
17
|
+
return icon;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
const renderEndAdornment = () => {
|
|
22
|
+
if (counter) {
|
|
23
|
+
return (0, jsx_runtime_1.jsx)(styles_1.Counter, { children: counter });
|
|
24
|
+
}
|
|
25
|
+
if (endAdornment) {
|
|
26
|
+
return endAdornment;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Label, { children: [(0, jsx_runtime_1.jsx)(styles_1.HiddenInput, { ...inputProps }), (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: classnames, children: [hasStartAdornment && ((0, jsx_runtime_1.jsx)(styles_1.AdornmentWrapper, { component: "span", className: constants_1.chipClassnames.startAdornment, children: renderStartAdornment() })), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { className: constants_1.chipClassnames.label, component: "span", children: label }), hasEndAdornment && ((0, jsx_runtime_1.jsx)(styles_1.AdornmentWrapper, { component: "span", className: constants_1.chipClassnames.endAdornment, children: renderEndAdornment() }))] })] }));
|
|
31
|
+
};
|
|
32
|
+
exports.Chip = Chip;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChipStatusIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const classNames_1 = require("../../utils/classNames");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const styled_1 = require("./styled");
|
|
9
|
+
const ChipStatusIcon = ({ status }) => {
|
|
10
|
+
const classnames = (0, react_1.useMemo)(() => {
|
|
11
|
+
return (0, classNames_1.classNames)(constants_1.chipStatusIconClassnames.root, {
|
|
12
|
+
[constants_1.chipStatusIconClassnames.success]: status === 'success',
|
|
13
|
+
[constants_1.chipStatusIconClassnames.warning]: status === 'warning',
|
|
14
|
+
[constants_1.chipStatusIconClassnames.error]: status === 'error',
|
|
15
|
+
});
|
|
16
|
+
}, [status]);
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(styled_1.StatusIcon, { className: classnames, viewBox: "0 0 20 20", width: "20px", height: "20px", children: (0, jsx_runtime_1.jsx)("circle", { cx: "10", cy: "10", r: "3.33333" }) }));
|
|
18
|
+
};
|
|
19
|
+
exports.ChipStatusIcon = ChipStatusIcon;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chipStatusIconClassnames = void 0;
|
|
4
|
+
const createUIKitClassname_1 = require("../../utils/createUIKitClassname");
|
|
5
|
+
exports.chipStatusIconClassnames = {
|
|
6
|
+
root: (0, createUIKitClassname_1.createUIKitClassname)('chip-status-icon'),
|
|
7
|
+
success: (0, createUIKitClassname_1.createUIKitClassname)('chip-status-icon_success'),
|
|
8
|
+
warning: (0, createUIKitClassname_1.createUIKitClassname)('chip-status-icon_warning'),
|
|
9
|
+
error: (0, createUIKitClassname_1.createUIKitClassname)('chip-status-icon_error'),
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChipStatusIcon';
|
|
@@ -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("./ChipStatusIcon"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StatusIcon: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
color?: string | undefined;
|
|
5
|
+
titleAccess?: string | undefined;
|
|
6
|
+
size?: "sm" | "md" | undefined;
|
|
7
|
+
} & import("react").SVGProps<SVGSVGElement> & {
|
|
8
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
9
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatusIcon = void 0;
|
|
4
|
+
const SvgIcon_1 = require("../../SvgIcon");
|
|
5
|
+
const styled_1 = require("../../styled");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
exports.StatusIcon = (0, styled_1.styled)(SvgIcon_1.SvgIcon) `
|
|
8
|
+
&.${constants_1.chipStatusIconClassnames.success} {
|
|
9
|
+
color: ${({ theme }) => theme.palette.success[900]};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.${constants_1.chipStatusIconClassnames.warning} {
|
|
13
|
+
color: ${({ theme }) => theme.palette.warning[900]};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.${constants_1.chipStatusIconClassnames.error} {
|
|
17
|
+
color: ${({ theme }) => theme.palette.error[900]};
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const chipClassnames: {
|
|
2
|
+
root: string;
|
|
3
|
+
sizeSmall: string;
|
|
4
|
+
sizeMedium: string;
|
|
5
|
+
sizeLarge: string;
|
|
6
|
+
disabled: string;
|
|
7
|
+
selected: string;
|
|
8
|
+
label: string;
|
|
9
|
+
hasStatusIcon: string;
|
|
10
|
+
hasCounter: string;
|
|
11
|
+
hasEndAdornment: string;
|
|
12
|
+
hasIcon: string;
|
|
13
|
+
startAdornment: string;
|
|
14
|
+
endAdornment: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const chipSize: {
|
|
17
|
+
small: {
|
|
18
|
+
desktop: string;
|
|
19
|
+
mobile: string;
|
|
20
|
+
};
|
|
21
|
+
medium: {
|
|
22
|
+
desktop: string;
|
|
23
|
+
mobile: string;
|
|
24
|
+
};
|
|
25
|
+
large: {
|
|
26
|
+
desktop: string;
|
|
27
|
+
mobile: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chipSize = exports.chipClassnames = void 0;
|
|
4
|
+
const createUIKitClassname_1 = require("../utils/createUIKitClassname");
|
|
5
|
+
exports.chipClassnames = {
|
|
6
|
+
root: (0, createUIKitClassname_1.createUIKitClassname)('chip'),
|
|
7
|
+
sizeSmall: (0, createUIKitClassname_1.createUIKitClassname)('chip_size-small'),
|
|
8
|
+
sizeMedium: (0, createUIKitClassname_1.createUIKitClassname)('chip_size-medium'),
|
|
9
|
+
sizeLarge: (0, createUIKitClassname_1.createUIKitClassname)('chip_size-large'),
|
|
10
|
+
disabled: (0, createUIKitClassname_1.createUIKitClassname)('chip_disabled'),
|
|
11
|
+
selected: (0, createUIKitClassname_1.createUIKitClassname)('chip_selected'),
|
|
12
|
+
label: (0, createUIKitClassname_1.createUIKitClassname)('chip__label'),
|
|
13
|
+
hasStatusIcon: (0, createUIKitClassname_1.createUIKitClassname)('chip_has-status-icon'),
|
|
14
|
+
hasCounter: (0, createUIKitClassname_1.createUIKitClassname)('chip_has-counter'),
|
|
15
|
+
hasEndAdornment: (0, createUIKitClassname_1.createUIKitClassname)('chip_has-end-adornment'),
|
|
16
|
+
hasIcon: (0, createUIKitClassname_1.createUIKitClassname)('chip_has-icon'),
|
|
17
|
+
startAdornment: (0, createUIKitClassname_1.createUIKitClassname)('chip__start-adornment'),
|
|
18
|
+
endAdornment: (0, createUIKitClassname_1.createUIKitClassname)('chip__end-adornment'),
|
|
19
|
+
};
|
|
20
|
+
exports.chipSize = {
|
|
21
|
+
small: { desktop: '20px', mobile: '24px' },
|
|
22
|
+
medium: { desktop: '24px', mobile: '32px' },
|
|
23
|
+
large: { desktop: '32px', mobile: '40px' },
|
|
24
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export declare const HiddenInput: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
|
|
10
|
+
export declare const Counter: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
11
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
12
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
13
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
14
|
+
export declare const AdornmentWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("../Typography/types").TypographyPropsBase & {
|
|
15
|
+
color?: import("../Typography").TypographyColor | undefined;
|
|
16
|
+
variant?: import("../Typography").TypographyVariant | undefined;
|
|
17
|
+
colorIntensity?: import("../Typography").Intensity | undefined;
|
|
18
|
+
component?: import("../Typography/types").ComponentProp | undefined;
|
|
19
|
+
isUpperCase?: boolean | undefined;
|
|
20
|
+
} & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
|
|
21
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
export declare const Label: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
24
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
25
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
26
|
+
}, import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {}>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Label = exports.AdornmentWrapper = exports.Counter = exports.HiddenInput = exports.Wrapper = void 0;
|
|
4
|
+
const styled_1 = require("../styled");
|
|
5
|
+
const Typography_1 = require("../Typography");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
exports.Wrapper = styled_1.styled.div `
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
user-select: none;
|
|
10
|
+
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
|
|
15
|
+
padding: ${({ theme }) => theme.spacing(0, 2)};
|
|
16
|
+
|
|
17
|
+
background-color: ${({ theme }) => theme.palette.background.default};
|
|
18
|
+
border: 1px solid ${({ theme }) => theme.palette.grey[400]};
|
|
19
|
+
border-radius: ${({ theme }) => theme.shape.medium};
|
|
20
|
+
|
|
21
|
+
transition: ${({ theme }) => theme.transitions.create(['border-color', 'background-color'], {
|
|
22
|
+
duration: theme.transitions.duration.shortest,
|
|
23
|
+
})};
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
27
|
+
border-color: ${({ theme }) => theme.palette.grey[400]};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:active {
|
|
31
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
32
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.${constants_1.chipClassnames.hasIcon},
|
|
36
|
+
&.${constants_1.chipClassnames.hasEndAdornment}:not(.${constants_1.chipClassnames.hasStatusIcon}),
|
|
37
|
+
&.${constants_1.chipClassnames.hasCounter}:not(.${constants_1.chipClassnames.hasStatusIcon}) {
|
|
38
|
+
gap: ${({ theme }) => theme.spacing(1)};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.${constants_1.chipClassnames.hasStatusIcon} {
|
|
42
|
+
& .${constants_1.chipClassnames.label} {
|
|
43
|
+
margin-left: ${({ theme }) => theme.microSpacing(1)};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.${constants_1.chipClassnames.hasCounter} .${constants_1.chipClassnames.label},
|
|
47
|
+
&.${constants_1.chipClassnames.hasEndAdornment} .${constants_1.chipClassnames.label} {
|
|
48
|
+
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&.${constants_1.chipClassnames.hasStatusIcon} {
|
|
53
|
+
padding-left: ${({ theme }) => theme.microSpacing(1)};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&.${constants_1.chipClassnames.sizeSmall} {
|
|
57
|
+
height: ${constants_1.chipSize.small.desktop};
|
|
58
|
+
|
|
59
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
60
|
+
height: ${constants_1.chipSize.small.mobile};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.${constants_1.chipClassnames.sizeMedium} {
|
|
65
|
+
height: ${constants_1.chipSize.medium.desktop};
|
|
66
|
+
|
|
67
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
68
|
+
height: ${constants_1.chipSize.medium.mobile};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&.${constants_1.chipClassnames.sizeLarge} {
|
|
73
|
+
height: ${constants_1.chipSize.large.desktop};
|
|
74
|
+
padding: ${({ theme }) => theme.spacing(0, 3)};
|
|
75
|
+
|
|
76
|
+
&.${constants_1.chipClassnames.hasStatusIcon} {
|
|
77
|
+
padding-left: ${({ theme }) => theme.spacing(2)};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
81
|
+
height: ${constants_1.chipSize.large.mobile};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&.${constants_1.chipClassnames.selected} {
|
|
86
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
87
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
88
|
+
|
|
89
|
+
&:hover {
|
|
90
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
91
|
+
border-color: ${({ theme }) => theme.palette.grey[800]};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:active {
|
|
95
|
+
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
96
|
+
border-color: ${({ theme }) => theme.palette.grey[400]};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&.${constants_1.chipClassnames.disabled} {
|
|
101
|
+
cursor: default;
|
|
102
|
+
|
|
103
|
+
background-color: ${({ theme }) => theme.palette.components.disabled};
|
|
104
|
+
border-color: transparent;
|
|
105
|
+
mix-blend-mode: luminosity;
|
|
106
|
+
|
|
107
|
+
& .${constants_1.chipClassnames.startAdornment},
|
|
108
|
+
& .${constants_1.chipClassnames.endAdornment},
|
|
109
|
+
& .${constants_1.chipClassnames.label} {
|
|
110
|
+
opacity: 0.3;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
exports.HiddenInput = styled_1.styled.input `
|
|
115
|
+
display: none;
|
|
116
|
+
`;
|
|
117
|
+
exports.Counter = styled_1.styled.div `
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
|
|
121
|
+
&::before {
|
|
122
|
+
content: '';
|
|
123
|
+
|
|
124
|
+
display: inline-block;
|
|
125
|
+
|
|
126
|
+
width: 2px;
|
|
127
|
+
height: 2px;
|
|
128
|
+
|
|
129
|
+
/* Сдвигаем точку ниже, чтобы визуально выровнять её по центру строчных букв */
|
|
130
|
+
margin-top: 0.15em;
|
|
131
|
+
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
132
|
+
|
|
133
|
+
background-color: ${({ theme }) => theme.palette.grey[800]};
|
|
134
|
+
border-radius: 50%;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
exports.AdornmentWrapper = (0, styled_1.styled)(Typography_1.Typography) `
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
`;
|
|
141
|
+
exports.Label = styled_1.styled.label `
|
|
142
|
+
/* Убираем подсветку при нажатии на компонент */
|
|
143
|
+
-webkit-tap-highlight-color: transparent;
|
|
144
|
+
`;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ChangeEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type ChipProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Содержимое компонента
|
|
5
|
+
*/
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Размер компонента
|
|
9
|
+
*/
|
|
10
|
+
size?: 'small' | 'medium' | 'large';
|
|
11
|
+
/**
|
|
12
|
+
* Статус компонента. Заменяет параметр `icon`
|
|
13
|
+
*/
|
|
14
|
+
status?: 'success' | 'warning' | 'error';
|
|
15
|
+
/**
|
|
16
|
+
* Иконка слева от `label`
|
|
17
|
+
*/
|
|
18
|
+
icon?: ReactElement;
|
|
19
|
+
/**
|
|
20
|
+
* Название класса, применяется к корневому компоненту.
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Если `true`, компонент будет недоступен для взаимодействия
|
|
25
|
+
*/
|
|
26
|
+
isDisabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Если `true`, компонент отображается в выбранном состоянии
|
|
29
|
+
*/
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Число счетчика справа от `label`. Заменяет параметр `endAdornment`
|
|
33
|
+
*/
|
|
34
|
+
counter?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Элемент, который добавляется в конец компонента
|
|
37
|
+
*/
|
|
38
|
+
endAdornment?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Обработчик изменения состояния компонента
|
|
41
|
+
*/
|
|
42
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -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("./useLogic"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ChipProps } from '../types';
|
|
3
|
+
type UseLogicParams = ChipProps;
|
|
4
|
+
export declare const useLogic: ({ className, isDisabled, isSelected, onChange, size, label, status, icon, counter, endAdornment, }: UseLogicParams) => {
|
|
5
|
+
classnames: string;
|
|
6
|
+
inputProps: {
|
|
7
|
+
checked: boolean | undefined;
|
|
8
|
+
onChange: ((event: import("react").ChangeEvent<HTMLInputElement, Element>) => void) | undefined;
|
|
9
|
+
type: string;
|
|
10
|
+
disabled: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
label: import("react").ReactNode;
|
|
13
|
+
status: "success" | "warning" | "error" | undefined;
|
|
14
|
+
icon: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
15
|
+
counter: number | undefined;
|
|
16
|
+
endAdornment: import("react").ReactNode;
|
|
17
|
+
hasStartAdornment: boolean;
|
|
18
|
+
hasEndAdornment: boolean;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogic = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const classNames_1 = require("../../utils/classNames");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const useLogic = ({ className, isDisabled, isSelected, onChange, size = 'medium', label, status, icon, counter, endAdornment, }) => {
|
|
8
|
+
const classnames = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(className, constants_1.chipClassnames.root, {
|
|
9
|
+
[constants_1.chipClassnames.disabled]: isDisabled,
|
|
10
|
+
[constants_1.chipClassnames.selected]: isSelected,
|
|
11
|
+
[constants_1.chipClassnames.sizeSmall]: size === 'small',
|
|
12
|
+
[constants_1.chipClassnames.sizeMedium]: size === 'medium',
|
|
13
|
+
[constants_1.chipClassnames.sizeLarge]: size === 'large',
|
|
14
|
+
[constants_1.chipClassnames.hasStatusIcon]: Boolean(status),
|
|
15
|
+
[constants_1.chipClassnames.hasCounter]: Boolean(counter),
|
|
16
|
+
[constants_1.chipClassnames.hasEndAdornment]: Boolean(endAdornment) && !counter,
|
|
17
|
+
[constants_1.chipClassnames.hasIcon]: Boolean(icon) && !status,
|
|
18
|
+
}), [isSelected, isDisabled, size, status, counter, endAdornment, icon]);
|
|
19
|
+
const hasStartAdornment = Boolean(status || icon);
|
|
20
|
+
const hasEndAdornment = Boolean(endAdornment || counter);
|
|
21
|
+
return {
|
|
22
|
+
classnames,
|
|
23
|
+
inputProps: {
|
|
24
|
+
checked: isSelected,
|
|
25
|
+
onChange,
|
|
26
|
+
type: 'checkbox',
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
},
|
|
29
|
+
label,
|
|
30
|
+
status,
|
|
31
|
+
icon,
|
|
32
|
+
counter,
|
|
33
|
+
endAdornment,
|
|
34
|
+
hasStartAdornment,
|
|
35
|
+
hasEndAdornment,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.useLogic = useLogic;
|