@astral/ui 4.0.0-alpha.28 → 4.0.0-alpha.29
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/Checkbox/Checkbox.js +1 -1
- package/components/Checkbox/constants.d.ts +3 -0
- package/components/Checkbox/constants.js +3 -0
- package/components/Checkbox/index.d.ts +1 -1
- package/components/Checkbox/index.js +1 -1
- package/components/Checkbox/styles.js +25 -25
- package/components/ScrollWrapper/ScrollWrapper.d.ts +7 -0
- package/components/ScrollWrapper/ScrollWrapper.js +3 -0
- package/components/ScrollWrapper/index.d.ts +1 -0
- package/components/ScrollWrapper/index.js +1 -0
- package/components/ScrollWrapper/styles.d.ts +7 -0
- package/components/ScrollWrapper/styles.js +7 -0
- package/components/Tree/MultipleTreeList/TreeItem/styles.js +16 -2
- package/components/Tree/MultipleTreeList/styles.d.ts +0 -6
- package/components/Tree/MultipleTreeList/styles.js +0 -3
- package/components/Tree/TreeItem/constants.d.ts +1 -0
- package/components/Tree/TreeItem/constants.js +2 -1
- package/components/Tree/TreeItem/styles.d.ts +0 -4
- package/components/Tree/TreeItem/styles.js +15 -8
- package/components/TreeAutocomplete/Input/Input.js +7 -5
- package/components/TreeAutocomplete/Input/constants.d.ts +1 -0
- package/components/TreeAutocomplete/Input/constants.js +1 -0
- package/components/TreeAutocomplete/Input/styles.d.ts +3 -10
- package/components/TreeAutocomplete/Input/styles.js +3 -18
- package/components/TreeAutocomplete/OptionsModal/ErrorMessage/ErrorMessage.js +1 -1
- package/components/TreeAutocomplete/OptionsModal/OptionsModal.js +2 -1
- package/components/TreeAutocomplete/OptionsModal/styles.js +3 -6
- package/components/TreeAutocomplete/TreeAutocomplete.d.ts +1 -57
- package/components/TreeAutocomplete/types.d.ts +56 -0
- package/components/TreeAutocomplete/useLogic/useLogic.d.ts +1 -1
- package/components/TreeLikeAutocomplete/Input/Input.js +5 -5
- package/components/TreeLikeAutocomplete/Input/styles.d.ts +1 -25
- package/components/TreeLikeAutocomplete/Input/styles.js +7 -20
- package/components/TreeLikeAutocomplete/OptionsModal/ErrorMessage/ErrorMessage.js +1 -1
- package/components/TreeLikeAutocomplete/OptionsModal/OptionsModal.js +2 -1
- package/components/TreeLikeAutocomplete/OptionsModal/styles.js +2 -6
- package/components/TreeLikeAutocomplete/TreeLikeAutocomplete.d.ts +1 -62
- package/components/TreeLikeAutocomplete/types.d.ts +61 -1
- package/components/TreeLikeAutocomplete/useLogic/useLogic.d.ts +2 -2
- package/node/components/Checkbox/Checkbox.js +1 -1
- package/node/components/Checkbox/constants.d.ts +3 -0
- package/node/components/Checkbox/constants.js +4 -1
- package/node/components/Checkbox/index.d.ts +1 -1
- package/node/components/Checkbox/index.js +3 -1
- package/node/components/Checkbox/styles.js +24 -24
- package/node/components/ScrollWrapper/ScrollWrapper.d.ts +7 -0
- package/node/components/ScrollWrapper/ScrollWrapper.js +7 -0
- package/node/components/ScrollWrapper/index.d.ts +1 -0
- package/node/components/ScrollWrapper/index.js +17 -0
- package/node/components/ScrollWrapper/styles.d.ts +7 -0
- package/node/components/ScrollWrapper/styles.js +10 -0
- package/node/components/Tree/MultipleTreeList/TreeItem/styles.js +15 -1
- package/node/components/Tree/MultipleTreeList/styles.d.ts +0 -6
- package/node/components/Tree/MultipleTreeList/styles.js +1 -4
- package/node/components/Tree/TreeItem/constants.d.ts +1 -0
- package/node/components/Tree/TreeItem/constants.js +2 -1
- package/node/components/Tree/TreeItem/styles.d.ts +0 -4
- package/node/components/Tree/TreeItem/styles.js +15 -8
- package/node/components/TreeAutocomplete/Input/Input.js +4 -2
- package/node/components/TreeAutocomplete/Input/constants.d.ts +1 -0
- package/node/components/TreeAutocomplete/Input/constants.js +4 -0
- package/node/components/TreeAutocomplete/Input/styles.d.ts +3 -10
- package/node/components/TreeAutocomplete/Input/styles.js +4 -19
- package/node/components/TreeAutocomplete/OptionsModal/ErrorMessage/ErrorMessage.js +1 -1
- package/node/components/TreeAutocomplete/OptionsModal/OptionsModal.js +2 -1
- package/node/components/TreeAutocomplete/OptionsModal/styles.js +3 -6
- package/node/components/TreeAutocomplete/TreeAutocomplete.d.ts +1 -57
- package/node/components/TreeAutocomplete/types.d.ts +56 -0
- package/node/components/TreeAutocomplete/useLogic/useLogic.d.ts +1 -1
- package/node/components/TreeLikeAutocomplete/Input/Input.js +3 -3
- package/node/components/TreeLikeAutocomplete/Input/styles.d.ts +1 -25
- package/node/components/TreeLikeAutocomplete/Input/styles.js +8 -21
- package/node/components/TreeLikeAutocomplete/OptionsModal/ErrorMessage/ErrorMessage.js +1 -1
- package/node/components/TreeLikeAutocomplete/OptionsModal/OptionsModal.js +2 -1
- package/node/components/TreeLikeAutocomplete/OptionsModal/styles.js +2 -6
- package/node/components/TreeLikeAutocomplete/TreeLikeAutocomplete.d.ts +1 -62
- package/node/components/TreeLikeAutocomplete/types.d.ts +61 -1
- package/node/components/TreeLikeAutocomplete/useLogic/useLogic.d.ts +2 -2
- package/package.json +1 -1
- package/components/TreeLikeList/faker.d.ts +0 -8
- package/components/TreeLikeList/faker.js +0 -17
- package/node/components/TreeLikeList/faker.d.ts +0 -8
- package/node/components/TreeLikeList/faker.js +0 -21
|
@@ -6,5 +6,5 @@ import { IconWrapper, Input, Wrapper } from './styles';
|
|
|
6
6
|
import { useLogic } from './useLogic';
|
|
7
7
|
export const Checkbox = forwardRef((props, ref) => {
|
|
8
8
|
const { onChange, color, isChecked, indeterminate, isError, disabled, restProps, className, role, style, name, inputRef, value, id, } = useLogic(props);
|
|
9
|
-
return (_jsxs(Wrapper, Object.assign({ role: role, "$isDisabled": disabled, "$isError": isError, "$isChecked": isChecked, "$isIndeterminate": indeterminate, className: className, style: style, ref: ref }, restProps, { children: [_jsx(Input, { type: "checkbox", checked: isChecked, disabled: disabled, onChange: onChange, "aria-checked": indeterminate ? 'mixed' : isChecked, "aria-disabled": disabled, name: name, ref: inputRef, value: value, id: id }), _jsx(IconWrapper, { className: checkboxClassnames.iconWrapper, children: _jsx(Icon, { className: checkboxClassnames.icon, color: color }) })] })));
|
|
9
|
+
return (_jsxs(Wrapper, Object.assign({ role: role, "$isDisabled": disabled, "$isError": isError, "$isChecked": isChecked, "$isIndeterminate": indeterminate, className: className, style: style, ref: ref }, restProps, { children: [_jsx(Input, { type: "checkbox", checked: isChecked, disabled: disabled, onChange: onChange, "aria-checked": indeterminate ? 'mixed' : isChecked, "aria-disabled": disabled, name: name, ref: inputRef, value: value, id: id, className: checkboxClassnames.input }), _jsx(IconWrapper, { className: checkboxClassnames.iconWrapper, children: _jsx(Icon, { className: checkboxClassnames.icon, color: color }) })] })));
|
|
10
10
|
});
|
|
@@ -10,4 +10,7 @@ export const checkboxClassnames = {
|
|
|
10
10
|
symbol: createUIKitClassname('checkbox__symbol'),
|
|
11
11
|
iconChecked: createUIKitClassname('checkbox__icon_checked'),
|
|
12
12
|
iconIndeterminate: createUIKitClassname('checkbox__icon_indeterminate'),
|
|
13
|
+
input: createUIKitClassname('checkbox__input'),
|
|
13
14
|
};
|
|
15
|
+
export const CHECKBOX_SIZE = '32px';
|
|
16
|
+
export const MOBILE_CHECKBOX_SIZE = '40px';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './Checkbox';
|
|
2
|
-
export { checkboxClassnames } from './constants';
|
|
2
|
+
export { checkboxClassnames, CHECKBOX_SIZE, MOBILE_CHECKBOX_SIZE, } from './constants';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styled } from '../styles';
|
|
2
2
|
import { easeOutBackTransition } from '../styles/mixins';
|
|
3
|
-
import { checkboxClassnames } from './constants';
|
|
3
|
+
import { CHECKBOX_SIZE, checkboxClassnames, MOBILE_CHECKBOX_SIZE, } from './constants';
|
|
4
4
|
const getOutlineColor = ({ theme, isHover, isDisabled, isError, isChecked, isIndeterminate, }) => {
|
|
5
5
|
if (isDisabled) {
|
|
6
6
|
return theme.palette.grey[300];
|
|
@@ -19,19 +19,18 @@ export const Wrapper = styled('span', {
|
|
|
19
19
|
display: flex;
|
|
20
20
|
justify-content: center;
|
|
21
21
|
|
|
22
|
-
.${checkboxClassnames.icon} {
|
|
22
|
+
.${checkboxClassnames.icon} {
|
|
23
23
|
fill: ${({ $isDisabled, theme }) => $isDisabled && theme.palette.components.disabled};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.${checkboxClassnames.symbol} {
|
|
27
|
-
fill: ${({ $isDisabled, theme }) =>
|
|
27
|
+
fill: ${({ $isDisabled, theme }) => $isDisabled ? theme.palette.grey[500] : 'white'};
|
|
28
28
|
|
|
29
29
|
${easeOutBackTransition};
|
|
30
|
-
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
.${checkboxClassnames.outline} {
|
|
34
|
-
fill: ${({ $isDisabled, $isChecked, $isIndeterminate }) =>
|
|
33
|
+
fill: ${({ $isDisabled, $isChecked, $isIndeterminate }) => !$isDisabled && !$isChecked && !$isIndeterminate && 'white'};
|
|
35
34
|
stroke: ${({ theme, $isDisabled, $isError, $isChecked, $isIndeterminate, }) => getOutlineColor({
|
|
36
35
|
theme,
|
|
37
36
|
isHover: false,
|
|
@@ -42,30 +41,31 @@ export const Wrapper = styled('span', {
|
|
|
42
41
|
})};
|
|
43
42
|
|
|
44
43
|
${easeOutBackTransition};
|
|
45
|
-
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
.${checkboxClassnames.iconChecked} {
|
|
49
47
|
transform-origin: bottom;
|
|
50
|
-
transform: ${({ $isChecked, $isIndeterminate }) =>
|
|
48
|
+
transform: ${({ $isChecked, $isIndeterminate }) => $isChecked && !$isIndeterminate ? 'scale(1)' : 'scale(0)'};
|
|
51
49
|
|
|
52
|
-
opacity: ${({ $isChecked, $isIndeterminate }) =>
|
|
50
|
+
opacity: ${({ $isChecked, $isIndeterminate }) => $isChecked && !$isIndeterminate ? 1 : 0};
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
.${checkboxClassnames.iconIndeterminate} {
|
|
56
54
|
transform-origin: bottom;
|
|
57
|
-
transform: ${({ $isIndeterminate }) =>
|
|
55
|
+
transform: ${({ $isIndeterminate }) => $isIndeterminate ? 'scale(1)' : 'scale(0)'};
|
|
58
56
|
|
|
59
57
|
opacity: ${({ $isIndeterminate }) => ($isIndeterminate ? 1 : 0)};
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
&:hover {
|
|
63
61
|
.${checkboxClassnames.icon} {
|
|
64
|
-
color: ${({ $isError, theme }) => $isError ? theme.palette.error[700] : theme.palette.primary[700]}
|
|
62
|
+
color: ${({ $isError, theme }) => $isError ? theme.palette.error[700] : theme.palette.primary[700]};
|
|
65
63
|
}
|
|
66
|
-
|
|
64
|
+
|
|
67
65
|
.${checkboxClassnames.outline} {
|
|
68
|
-
fill: ${({ theme, $isDisabled, $isChecked, $isIndeterminate }) =>
|
|
66
|
+
fill: ${({ theme, $isDisabled, $isChecked, $isIndeterminate }) => !$isDisabled &&
|
|
67
|
+
!$isChecked &&
|
|
68
|
+
!$isIndeterminate &&
|
|
69
69
|
theme.palette.background.elementHover};
|
|
70
70
|
stroke: ${({ theme, $isDisabled, $isError, $isChecked, $isIndeterminate, }) => getOutlineColor({
|
|
71
71
|
theme,
|
|
@@ -80,22 +80,22 @@ export const Wrapper = styled('span', {
|
|
|
80
80
|
`;
|
|
81
81
|
export const Input = styled.input `
|
|
82
82
|
cursor: ${({ disabled }) => !disabled && 'pointer'};
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
position: absolute;
|
|
85
85
|
|
|
86
|
-
width:
|
|
87
|
-
height:
|
|
86
|
+
width: ${CHECKBOX_SIZE};
|
|
87
|
+
height: ${CHECKBOX_SIZE};
|
|
88
88
|
margin: 0;
|
|
89
89
|
|
|
90
90
|
opacity: 0;
|
|
91
91
|
|
|
92
92
|
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
93
|
+
width: ${MOBILE_CHECKBOX_SIZE};
|
|
94
|
+
height: ${MOBILE_CHECKBOX_SIZE};
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
&:focus-visible {
|
|
98
|
-
|
|
98
|
+
~ .${checkboxClassnames.iconWrapper} > .${checkboxClassnames.icon} {
|
|
99
99
|
border-radius: ${({ theme }) => theme.shape.small};
|
|
100
100
|
outline: 2px solid ${({ theme }) => theme.palette.components.focused};
|
|
101
101
|
outline-offset: -2px;
|
|
@@ -107,12 +107,12 @@ export const IconWrapper = styled.span `
|
|
|
107
107
|
align-items: center;
|
|
108
108
|
justify-content: center;
|
|
109
109
|
|
|
110
|
-
width:
|
|
111
|
-
height:
|
|
110
|
+
width: ${CHECKBOX_SIZE};
|
|
111
|
+
height: ${CHECKBOX_SIZE};
|
|
112
112
|
|
|
113
113
|
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
114
|
-
width:
|
|
115
|
-
height:
|
|
114
|
+
width: ${MOBILE_CHECKBOX_SIZE};
|
|
115
|
+
height: ${MOBILE_CHECKBOX_SIZE};
|
|
116
116
|
|
|
117
117
|
.${checkboxClassnames.icon} {
|
|
118
118
|
width: 20px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ScrollWrapper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ScrollWrapper';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Wrapper: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
$shape: 'small' | 'medium' | 'large';
|
|
7
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formControlLabelClasses } from '@mui/material';
|
|
2
|
+
import { CHECKBOX_SIZE, Checkbox, checkboxClassnames } from '../../../Checkbox';
|
|
2
3
|
import { styled } from '../../../styles';
|
|
3
4
|
import { listContainer } from '../../../styles/mixins';
|
|
4
5
|
import { TreeItem, treeClassnames } from '../../TreeItem';
|
|
5
6
|
export const StyledCheckbox = styled(Checkbox) `
|
|
6
7
|
padding-top: 0;
|
|
7
8
|
padding-bottom: 0;
|
|
9
|
+
|
|
10
|
+
& > .${checkboxClassnames.input}, .${checkboxClassnames.iconWrapper} {
|
|
11
|
+
width: 32px;
|
|
12
|
+
height: 16px;
|
|
13
|
+
|
|
14
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
15
|
+
height: 20px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
`;
|
|
9
19
|
export const StyledTreeItem = styled(TreeItem) `
|
|
20
|
+
.${formControlLabelClasses.root} .${formControlLabelClasses.label} {
|
|
21
|
+
margin-left: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
.${treeClassnames.note} {
|
|
11
25
|
/* cSpell:ignore чекбоксом */
|
|
12
26
|
|
|
13
27
|
/* Добавляем к отступу ширину контейнера с чекбоксом */
|
|
14
|
-
margin-left: ${
|
|
28
|
+
margin-left: ${CHECKBOX_SIZE};
|
|
15
29
|
}
|
|
16
30
|
`;
|
|
17
31
|
export const List = styled.ul `
|
|
@@ -3,9 +3,3 @@ export declare const List: import("@emotion/styled").StyledComponent<{
|
|
|
3
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
4
4
|
as?: import("react").ElementType<any> | undefined;
|
|
5
5
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
|
|
6
|
-
export declare const InnerList: import("@emotion/styled").StyledComponent<{
|
|
7
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
-
as?: import("react").ElementType<any> | undefined;
|
|
9
|
-
} & import("react").ClassAttributes<HTMLUListElement> & import("react").HTMLAttributes<HTMLUListElement> & {
|
|
10
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
11
|
-
}, {}, {}>;
|
|
@@ -5,5 +5,6 @@ export const GAP_WIDTH = '4px';
|
|
|
5
5
|
export const HALF_PADDING_COLLAPSE_BUTTON_WIDTH = '14px';
|
|
6
6
|
export const TOOLTIP_PLACEMENT = 'bottom-start';
|
|
7
7
|
export const treeClassnames = {
|
|
8
|
-
note: createUIKitClassname('
|
|
8
|
+
note: createUIKitClassname('tree-item__note'),
|
|
9
|
+
label: createUIKitClassname('tree-item__label'),
|
|
9
10
|
};
|
|
@@ -45,10 +45,6 @@ export declare const ChevronIcon: import("@emotion/styled").StyledComponent<{
|
|
|
45
45
|
} & {
|
|
46
46
|
$isActive?: boolean | undefined;
|
|
47
47
|
}, {}, {}>;
|
|
48
|
-
export declare const List: import("@emotion/styled").StyledComponent<{
|
|
49
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
50
|
-
as?: import("react").ElementType<any> | undefined;
|
|
51
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
|
|
52
48
|
export declare const LabelWrapper: import("@emotion/styled").StyledComponent<{
|
|
53
49
|
theme?: import("@emotion/react").Theme | undefined;
|
|
54
50
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { typographyClasses } from '@mui/material';
|
|
1
|
+
import { svgIconClasses, typographyClasses } from '@mui/material';
|
|
2
2
|
import { ChevronROutlineMd } from '../../../icons';
|
|
3
|
+
import { buttonClasses } from '../../Button';
|
|
3
4
|
import { descriptionClassnames } from '../../Description';
|
|
4
5
|
import { IconButton } from '../../IconButton';
|
|
5
6
|
import { OverflowTypography } from '../../OverflowTypography';
|
|
6
7
|
import { styled } from '../../styles';
|
|
7
|
-
import { listContainer } from '../../styles/mixins';
|
|
8
8
|
import { Typography } from '../../Typography';
|
|
9
9
|
import { COLLAPSE_BUTTON_WIDTH, GAP_WIDTH, HALF_PADDING_COLLAPSE_BUTTON_WIDTH, TREE_LINE_WIDTH, } from './constants';
|
|
10
|
-
const
|
|
10
|
+
const getBackgroundColor = (theme, isSelected, isDisabled) => {
|
|
11
11
|
if (isDisabled) {
|
|
12
12
|
return 'transparent';
|
|
13
13
|
}
|
|
@@ -58,11 +58,11 @@ export const ItemContent = styled('div', {
|
|
|
58
58
|
})};
|
|
59
59
|
|
|
60
60
|
&:hover {
|
|
61
|
-
background-color: ${({ theme, $isSelected, $isDisabled }) =>
|
|
61
|
+
background-color: ${({ theme, $isSelected, $isDisabled }) => getBackgroundColor(theme, $isSelected, $isDisabled)};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&:focus {
|
|
65
|
-
background-color: ${({ theme }) => theme
|
|
65
|
+
background-color: ${({ theme, $isSelected, $isDisabled }) => getBackgroundColor(theme, $isSelected, $isDisabled)};
|
|
66
66
|
border: 0;
|
|
67
67
|
outline: 0;
|
|
68
68
|
}
|
|
@@ -79,6 +79,16 @@ export const CollapseButton = styled(IconButton, {
|
|
|
79
79
|
|
|
80
80
|
color: ${({ theme, $isNotBlockingExpandList }) => $isNotBlockingExpandList ? theme.palette.text.primary : 'inherit'};
|
|
81
81
|
|
|
82
|
+
&.${buttonClasses.root} .${svgIconClasses.root}, &.${buttonClasses.root} {
|
|
83
|
+
width: 24px;
|
|
84
|
+
height: 24px;
|
|
85
|
+
|
|
86
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
87
|
+
width: 24px;
|
|
88
|
+
height: 24px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
&:hover {
|
|
83
93
|
background-color: ${({ theme }) => theme.palette.grey[300]};
|
|
84
94
|
}
|
|
@@ -93,9 +103,6 @@ export const ChevronIcon = styled(ChevronROutlineMd, {
|
|
|
93
103
|
duration: theme.transitions.duration.short,
|
|
94
104
|
})};
|
|
95
105
|
`;
|
|
96
|
-
export const List = styled.ul `
|
|
97
|
-
${listContainer};
|
|
98
|
-
`;
|
|
99
106
|
export const LabelWrapper = styled('div', {
|
|
100
107
|
shouldForwardProp: (prop) => prop !== '$level',
|
|
101
108
|
}) `
|
|
@@ -9,15 +9,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx,
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from 'react';
|
|
14
|
-
import {
|
|
14
|
+
import { CrossOutlineMd, DownOutlineMd } from '../../../icons';
|
|
15
|
+
import { IconButton } from '../../IconButton';
|
|
15
16
|
import { TextField } from '../../TextField';
|
|
16
|
-
import {
|
|
17
|
+
import { CLEAR_TEXT } from './constants';
|
|
18
|
+
import { IconWrapper } from './styles';
|
|
17
19
|
import { useLogic } from './useLogic';
|
|
18
|
-
const ClearButton = ({ disabled, onClick }) => (_jsx(
|
|
20
|
+
const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, onClick: onClick, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, children: _jsx(CrossOutlineMd, {}) }));
|
|
19
21
|
export const Input = forwardRef((props, forwardedRef) => {
|
|
20
22
|
const { inputRef, isVisibleClearButton, handleClearAll } = useLogic(props);
|
|
21
23
|
const { disabled, onChange } = props, restProps = __rest(props, ["disabled", "onChange"]);
|
|
22
|
-
return (_jsx(TextField, Object.assign({}, restProps, { ref: forwardedRef, inputRef: inputRef, disabled: disabled, inputProps: { readOnly: true }, endAdornment: _jsxs(
|
|
24
|
+
return (_jsx(TextField, Object.assign({}, restProps, { ref: forwardedRef, inputRef: inputRef, disabled: disabled, inputProps: { readOnly: true }, endAdornment: _jsxs(IconWrapper, { children: [isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }) })));
|
|
23
25
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLEAR_TEXT = "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CLEAR_TEXT = 'Очистить';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const
|
|
3
|
-
variant?: "link" | "outlined" | "text" | "contained" | "light" | undefined;
|
|
4
|
-
loading?: boolean | undefined;
|
|
5
|
-
color?: "grey" | "primary" | "error" | "warning" | "success" | undefined;
|
|
6
|
-
component?: import("react").ElementType | undefined;
|
|
7
|
-
selected?: boolean | undefined;
|
|
8
|
-
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
9
|
-
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
10
|
-
}, ""> & import("react").RefAttributes<HTMLButtonElement> & {
|
|
2
|
+
export declare const IconWrapper: import("@emotion/styled").StyledComponent<{
|
|
11
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
|
-
|
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import { IconButton } from '../../IconButton';
|
|
2
1
|
import { styled } from '../../styles';
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
svg {
|
|
7
|
-
width: 16px;
|
|
8
|
-
height: 16px;
|
|
9
|
-
|
|
10
|
-
fill: ${({ theme }) => theme.palette.grey['500']};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&:hover {
|
|
14
|
-
background-color: transparent;
|
|
15
|
-
|
|
16
|
-
svg {
|
|
17
|
-
fill: ${({ theme }) => theme.palette.grey['700']};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
2
|
+
export const IconWrapper = styled.div `
|
|
3
|
+
display: flex;
|
|
4
|
+
gap: ${({ theme }) => theme.spacing(1)};
|
|
20
5
|
`;
|
|
@@ -3,4 +3,4 @@ import { Button } from '../../../Button';
|
|
|
3
3
|
import { Typography } from '../../../Typography';
|
|
4
4
|
import { Wrapper } from './styles';
|
|
5
5
|
const DEFAULT_ERROR_MSG = 'Не удалось загрузить данные';
|
|
6
|
-
export const ErrorMessage = ({ loadingErrorMsg = DEFAULT_ERROR_MSG, onRetry, }) => (_jsxs(Wrapper, { children: [_jsx(Typography, { color: "
|
|
6
|
+
export const ErrorMessage = ({ loadingErrorMsg = DEFAULT_ERROR_MSG, onRetry, }) => (_jsxs(Wrapper, { children: [_jsx(Typography, { color: "grey", children: loadingErrorMsg }), onRetry && (_jsx(Button, { onClick: onRetry, variant: "light", color: "grey", children: "\u041F\u043E\u043F\u0440\u043E\u0431\u043E\u0432\u0430\u0442\u044C \u0441\u043D\u043E\u0432\u0430" }))] }));
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Button } from '../../Button';
|
|
14
14
|
import { Dialog } from '../../Dialog';
|
|
15
15
|
import { DialogActions } from '../../DialogActions';
|
|
16
|
+
import { ScrollWrapper } from '../../ScrollWrapper';
|
|
16
17
|
import { SearchField } from '../../SearchField';
|
|
17
18
|
import { TreeList } from '../../Tree';
|
|
18
19
|
import { ErrorMessage } from './ErrorMessage';
|
|
@@ -35,5 +36,5 @@ export const OptionsModal = (props) => {
|
|
|
35
36
|
}
|
|
36
37
|
return _jsx(TreeList, Object.assign({}, treeProps, treeListProps));
|
|
37
38
|
};
|
|
38
|
-
return (_jsxs(Dialog, Object.assign({}, externalDialogProps, { disableRestoreFocus: true, open: isOpen }, modalProps, { children: [_jsxs(StyledDialogContent, { children: [_jsx(SearchField, Object.assign({ fullWidth: true }, searchFieldProps)), _jsx(TreeListWrapper, { children: renderComponent() })] }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ variant: "text" }, cancelButtonProps, { children: "\u041E\u0442\u043C\u0435\u043D\u0430" })), _jsx(Button, Object.assign({}, confirmButtonProps, { children: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C" }))] })] })));
|
|
39
|
+
return (_jsxs(Dialog, Object.assign({}, externalDialogProps, { disableRestoreFocus: true, open: isOpen }, modalProps, { children: [_jsxs(StyledDialogContent, { children: [_jsx(SearchField, Object.assign({ fullWidth: true }, searchFieldProps)), _jsx(ScrollWrapper, { children: _jsx(TreeListWrapper, { children: renderComponent() }) })] }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ variant: "text" }, cancelButtonProps, { children: "\u041E\u0442\u043C\u0435\u043D\u0430" })), _jsx(Button, Object.assign({}, confirmButtonProps, { children: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C" }))] })] })));
|
|
39
40
|
};
|
|
@@ -4,17 +4,14 @@ export const StyledDialogContent = styled(DialogContent) `
|
|
|
4
4
|
display: grid;
|
|
5
5
|
grid-template-columns: 100%;
|
|
6
6
|
grid-template-rows: max-content 1fr;
|
|
7
|
-
gap: ${({ theme }) => theme.spacing(
|
|
7
|
+
gap: ${({ theme }) => theme.spacing(4)};
|
|
8
8
|
|
|
9
9
|
width: 500px;
|
|
10
10
|
height: 500px;
|
|
11
|
+
padding-bottom: ${({ theme }) => theme.spacing(4)};
|
|
11
12
|
`;
|
|
12
13
|
export const TreeListWrapper = styled.div `
|
|
13
14
|
overflow: auto;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
background-color: ${({ theme }) => theme.palette.background.element};
|
|
18
|
-
border: 2px solid ${({ theme }) => theme.palette.grey[300]};
|
|
19
|
-
border-radius: 3px;
|
|
16
|
+
height: 100%;
|
|
20
17
|
`;
|
|
@@ -1,59 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import { type TextFieldProps } from '../TextField';
|
|
4
|
-
import { type TreeListData, type TreeListProps } from '../Tree';
|
|
5
|
-
import type { TreeAutocompleteValue } from './types';
|
|
6
|
-
export type TreeAutocompleteTreeProps = Pick<TreeListProps, 'disabledItems' | 'renderItem'>;
|
|
7
|
-
export type TreeAutocompleteProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Выбранное значения
|
|
10
|
-
*/
|
|
11
|
-
value?: TreeAutocompleteValue;
|
|
12
|
-
/**
|
|
13
|
-
* Опции, которые необходимо отобразить в виде дерева.
|
|
14
|
-
*/
|
|
15
|
-
options: TreeListData[];
|
|
16
|
-
/**
|
|
17
|
-
* Если true, поля будут недоступны для взаимодействия
|
|
18
|
-
*/
|
|
19
|
-
isDisabled?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Если true, поля будут подсвечены, как содержащие ошибку
|
|
22
|
-
*/
|
|
23
|
-
isError?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Флаг загрузки options
|
|
26
|
-
* Если true, вместо дерева options будет отображен лоадер
|
|
27
|
-
*/
|
|
28
|
-
isLoading?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Флаг ошибки загрузки options
|
|
31
|
-
* Если true, вместо дерева options будет отображен плейсхолдер с ошибкой
|
|
32
|
-
*/
|
|
33
|
-
isLoadingError?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Текст ошибки при загрузке данных
|
|
36
|
-
*/
|
|
37
|
-
loadingErrorMsg?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Предназначен для конфигурации всплывающего окна
|
|
40
|
-
*/
|
|
41
|
-
dialogProps: Omit<DialogProps, 'open' | 'onClose'>;
|
|
42
|
-
/**
|
|
43
|
-
* Предназначен для конфигурации дерева опций
|
|
44
|
-
*/
|
|
45
|
-
treeProps?: TreeAutocompleteTreeProps;
|
|
46
|
-
/**
|
|
47
|
-
* Функция обработки нажатия на кнопку "Повторить запрос"
|
|
48
|
-
*/
|
|
49
|
-
onRetry?: () => void;
|
|
50
|
-
/**
|
|
51
|
-
* Функция для поиска элементов по дереву, если не определено, то будет использован встроенный поиск
|
|
52
|
-
*/
|
|
53
|
-
filterOptions?: (node: TreeListData, searchValue: string) => boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Функция, которая запускается при выборе item
|
|
56
|
-
*/
|
|
57
|
-
onChange?: (newValue: TreeAutocompleteValue | undefined) => void;
|
|
58
|
-
} & Omit<TextFieldProps, 'autoComplete' | 'defaultValue' | 'select' | 'error' | 'disabled' | 'multiline' | 'rows' | 'maxRows' | 'minRows' | 'SelectProps' | 'endAdornment' | 'onChange'>;
|
|
2
|
+
import type { TreeAutocompleteProps } from './types';
|
|
59
3
|
export declare const TreeAutocomplete: import("react").ForwardRefExoticComponent<Omit<TreeAutocompleteProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1,57 @@
|
|
|
1
|
+
import type { DialogProps } from '../Dialog';
|
|
2
|
+
import type { TextFieldProps } from '../TextField';
|
|
3
|
+
import type { TreeListData, TreeListProps } from '../Tree';
|
|
1
4
|
export type TreeAutocompleteValue = string;
|
|
5
|
+
export type TreeAutocompleteTreeProps = Pick<TreeListProps, 'disabledItems' | 'renderItem'>;
|
|
6
|
+
export type TreeAutocompleteProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Выбранное значения
|
|
9
|
+
*/
|
|
10
|
+
value?: TreeAutocompleteValue;
|
|
11
|
+
/**
|
|
12
|
+
* Опции, которые необходимо отобразить в виде дерева.
|
|
13
|
+
*/
|
|
14
|
+
options: TreeListData[];
|
|
15
|
+
/**
|
|
16
|
+
* Если true, поля будут недоступны для взаимодействия
|
|
17
|
+
*/
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Если true, поля будут подсвечены, как содержащие ошибку
|
|
21
|
+
*/
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Флаг загрузки options
|
|
25
|
+
* Если true, вместо дерева options будет отображен лоадер
|
|
26
|
+
*/
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Флаг ошибки загрузки options
|
|
30
|
+
* Если true, вместо дерева options будет отображен плейсхолдер с ошибкой
|
|
31
|
+
*/
|
|
32
|
+
isLoadingError?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Текст ошибки при загрузке данных
|
|
35
|
+
*/
|
|
36
|
+
loadingErrorMsg?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Предназначен для конфигурации всплывающего окна
|
|
39
|
+
*/
|
|
40
|
+
dialogProps: Omit<DialogProps, 'open' | 'onClose'>;
|
|
41
|
+
/**
|
|
42
|
+
* Предназначен для конфигурации дерева опций
|
|
43
|
+
*/
|
|
44
|
+
treeProps?: TreeAutocompleteTreeProps;
|
|
45
|
+
/**
|
|
46
|
+
* Функция обработки нажатия на кнопку "Повторить запрос"
|
|
47
|
+
*/
|
|
48
|
+
onRetry?: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Функция для поиска элементов по дереву, если не определено, то будет использован встроенный поиск
|
|
51
|
+
*/
|
|
52
|
+
filterOptions?: (node: TreeListData, searchValue: string) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Функция, которая запускается при выборе item
|
|
55
|
+
*/
|
|
56
|
+
onChange?: (newValue: TreeAutocompleteValue | undefined) => void;
|
|
57
|
+
} & Omit<TextFieldProps, 'autoComplete' | 'defaultValue' | 'select' | 'error' | 'disabled' | 'multiline' | 'rows' | 'maxRows' | 'minRows' | 'SelectProps' | 'endAdornment' | 'onChange'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FocusEvent, type KeyboardEvent, type SyntheticEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { TreeAutocompleteProps } from '../types';
|
|
3
3
|
type UseLogicProps = TreeAutocompleteProps;
|
|
4
4
|
export declare const useLogic: ({ value, options, onBlur }: UseLogicProps) => {
|
|
5
5
|
inputProps: {
|
|
@@ -11,14 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { forwardRef } from 'react';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { CrossOutlineMd, DownOutlineMd } from '../../../icons';
|
|
15
|
+
import { IconButton } from '../../IconButton';
|
|
16
16
|
import { CLEAR_TEXT } from './constants';
|
|
17
|
-
import { EndAdornmentWrapper,
|
|
17
|
+
import { EndAdornmentWrapper, StyledLoader, StyledTagsList, StyledTextField, } from './styles';
|
|
18
18
|
import { useLogic } from './useLogic';
|
|
19
|
-
const ClearButton = ({ disabled, onClick }) => (_jsx(
|
|
19
|
+
const ClearButton = ({ disabled, onClick }) => (_jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, title: CLEAR_TEXT, "aria-label": CLEAR_TEXT, onClick: onClick, children: _jsx(CrossOutlineMd, {}) }));
|
|
20
20
|
export const Input = forwardRef((props, forwardedRef) => {
|
|
21
21
|
const { textFieldProps, isVisibleTagsList, isVisibleClearButton, handleChange, handleClearAll, } = useLogic(props);
|
|
22
22
|
const { value, valueToRender, disabled, isLoading, onChange, onClick } = props, restProps = __rest(props, ["value", "valueToRender", "disabled", "isLoading", "onChange", "onClick"]);
|
|
23
|
-
return (_jsx(StyledTextField, Object.assign({}, restProps, { ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(
|
|
23
|
+
return (_jsx(StyledTextField, Object.assign({}, restProps, { ref: forwardedRef, disabled: disabled, inputProps: { readOnly: true }, startAdornment: isVisibleTagsList && (_jsx(StyledTagsList, { data: valueToRender, keyId: "id", isDisabled: disabled, getOptionLabel: (option) => option.label, onClick: onClick, onChange: handleChange })), endAdornment: _jsxs(EndAdornmentWrapper, { children: [isLoading && _jsx(StyledLoader, {}), isVisibleClearButton && (_jsx(ClearButton, { disabled: disabled, onClick: handleClearAll })), _jsx(IconButton, { variant: "text", color: "grey", disabled: disabled, children: _jsx(DownOutlineMd, {}) })] }), onClick: onClick }, textFieldProps)));
|
|
24
24
|
});
|