@astral/ui 4.53.0 → 4.53.2

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.
@@ -7,9 +7,29 @@ import { SuccessFillMd } from '../../icons/SuccessFillMd';
7
7
  import { WarningFillMd } from '../../icons/WarningFillMd';
8
8
  import { Collapse } from '../Collapse';
9
9
  import { classNames } from '../utils/classNames';
10
+ import { cva } from '../utils/cva';
10
11
  import { alertClassnames } from './constants';
11
12
  import { Content, IconWrapper, StyledGrid, StyledIconButton, StyledTypography, Title, Wrapper, } from './styles';
12
13
  import { useLogic } from './useLogic';
14
+ const alertCva = cva(alertClassnames.root, {
15
+ variants: {
16
+ hasTitle: {
17
+ true: alertClassnames.hasTitle,
18
+ },
19
+ hasCloseButton: {
20
+ true: alertClassnames.hasCloseButton,
21
+ },
22
+ hasActions: {
23
+ true: alertClassnames.hasActions,
24
+ },
25
+ severity: {
26
+ info: alertClassnames.severityInfo,
27
+ error: alertClassnames.severityError,
28
+ success: alertClassnames.severitySuccess,
29
+ warning: alertClassnames.severityWarning,
30
+ },
31
+ },
32
+ });
13
33
  export const Alert = forwardRef(({ children, title, closeText = 'Скрыть', display = true, actions, onClose, severity = 'info', style, className, icon, unmountOnExit, }, ref) => {
14
34
  const { shouldRenderParagraph } = useLogic({ children });
15
35
  const renderCloseButton = () => {
@@ -22,7 +42,12 @@ export const Alert = forwardRef(({ children, title, closeText = 'Скрыть',
22
42
  success: _jsx(SuccessFillMd, {}),
23
43
  warning: _jsx(WarningFillMd, {}),
24
44
  };
25
- return (_jsx(IconWrapper, { "$hasTitle": Boolean(title), "$severity": severity, "$hasCloseButton": Boolean(onClose), className: alertClassnames.iconWrapper, children: icon ?? iconMapping[severity] }));
45
+ return (_jsx(IconWrapper, { className: alertClassnames.iconWrapper, children: icon ?? iconMapping[severity] }));
26
46
  };
27
- return (_jsx(Collapse, { in: display, unmountOnExit: unmountOnExit, children: _jsxs(Wrapper, { style: style, className: classNames(className, alertClassnames.root), role: "alert", ref: ref, "$severity": severity, "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), "$hasActions": Boolean(actions), children: [_jsxs(Content, { "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), className: alertClassnames.contentWrapper, children: [renderIcon(), title && (_jsx(Title, { variant: "h5", "$hasCloseButton": Boolean(onClose), className: alertClassnames.title, children: title })), onClose && renderCloseButton(), _jsx(StyledTypography, { component: shouldRenderParagraph ? 'p' : 'div', "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), "$hasActions": Boolean(actions), className: alertClassnames.content, children: children })] }), actions && (_jsx(StyledGrid, { container: true, spacing: 4, children: actions }))] }) }));
47
+ return (_jsx(Collapse, { in: display, unmountOnExit: unmountOnExit, children: _jsxs(Wrapper, { style: style, className: classNames(alertCva({
48
+ hasTitle: Boolean(title),
49
+ hasCloseButton: Boolean(onClose),
50
+ hasActions: Boolean(actions),
51
+ severity,
52
+ }), className), role: "alert", ref: ref, children: [_jsxs(Content, { className: alertClassnames.contentWrapper, children: [renderIcon(), title && (_jsx(Title, { variant: "h5", className: alertClassnames.title, children: title })), onClose && renderCloseButton(), _jsx(StyledTypography, { component: shouldRenderParagraph ? 'p' : 'div', className: alertClassnames.content, children: children })] }), actions && (_jsx(StyledGrid, { container: true, spacing: 4, children: actions }))] }) }));
28
53
  });
@@ -5,4 +5,11 @@ export declare const alertClassnames: {
5
5
  closeButton: string;
6
6
  contentWrapper: string;
7
7
  content: string;
8
+ hasTitle: string;
9
+ hasCloseButton: string;
10
+ hasActions: string;
11
+ severityInfo: string;
12
+ severityError: string;
13
+ severitySuccess: string;
14
+ severityWarning: string;
8
15
  };
@@ -6,4 +6,11 @@ export const alertClassnames = {
6
6
  closeButton: createUIKitClassname('alert__close-button'),
7
7
  contentWrapper: createUIKitClassname('alert__content-wrapper'),
8
8
  content: createUIKitClassname('alert__content'),
9
+ hasTitle: createUIKitClassname('alert_has-title'),
10
+ hasCloseButton: createUIKitClassname('alert_has-close-button'),
11
+ hasActions: createUIKitClassname('alert_has-actions'),
12
+ severityInfo: createUIKitClassname('alert_severity_info'),
13
+ severityError: createUIKitClassname('alert_severity_error'),
14
+ severitySuccess: createUIKitClassname('alert_severity_success'),
15
+ severityWarning: createUIKitClassname('alert_severity_warning'),
9
16
  };
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { AlertSeverity } from './types';
3
2
  export declare const StyledGrid: import("../styled").StyledComponent<Omit<import("../Grid/GridComponent").GridComponentProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
4
3
  theme?: import("@emotion/react").Theme | undefined;
5
4
  } & import("../Grid/styles").StyledGridProps, {}, {}>;
@@ -15,26 +14,14 @@ export declare const StyledIconButton: import("../styled").StyledComponent<Omit<
15
14
  export declare const Wrapper: import("../styled").StyledComponent<{
16
15
  theme?: import("@emotion/react").Theme | undefined;
17
16
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
18
- } & {
19
- $hasTitle?: boolean | undefined;
20
- $severity: AlertSeverity;
21
- $hasCloseButton?: boolean | undefined;
22
- $hasActions?: boolean | undefined;
23
17
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
24
18
  export declare const IconWrapper: import("../styled").StyledComponent<{
25
19
  theme?: import("@emotion/react").Theme | undefined;
26
20
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
27
- } & {
28
- $severity: AlertSeverity;
29
- $hasTitle?: boolean | undefined;
30
- $hasCloseButton?: boolean | undefined;
31
21
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
32
22
  export declare const Content: import("../styled").StyledComponent<{
33
23
  theme?: import("@emotion/react").Theme | undefined;
34
24
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
35
- } & {
36
- $hasTitle: boolean;
37
- $hasCloseButton?: boolean | undefined;
38
25
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
39
26
  export declare const StyledTypography: import("../styled").StyledComponent<import("../Typography/types").TypographyPropsBase & {
40
27
  color?: import("../Typography").TypographyColor | undefined;
@@ -45,10 +32,6 @@ export declare const StyledTypography: import("../styled").StyledComponent<impor
45
32
  withoutCalt?: boolean | undefined;
46
33
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
47
34
  theme?: import("@emotion/react").Theme | undefined;
48
- } & {
49
- $hasTitle?: boolean | undefined;
50
- $hasCloseButton?: boolean | undefined;
51
- $hasActions?: boolean | undefined;
52
35
  }, {}, {}>;
53
36
  export declare const Title: import("../styled").StyledComponent<import("../Typography/types").TypographyPropsBase & {
54
37
  color?: import("../Typography").TypographyColor | undefined;
@@ -59,6 +42,4 @@ export declare const Title: import("../styled").StyledComponent<import("../Typog
59
42
  withoutCalt?: boolean | undefined;
60
43
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
61
44
  theme?: import("@emotion/react").Theme | undefined;
62
- } & {
63
- $hasCloseButton?: boolean | undefined;
64
45
  }, {}, {}>;
@@ -3,87 +3,7 @@ import { IconButton } from '../IconButton';
3
3
  import { svgIconClassnames } from '../SvgIcon';
4
4
  import { styled } from '../styled';
5
5
  import { Typography } from '../Typography';
6
- const getBgColor = (theme, severity) => {
7
- const bgColors = {
8
- info: theme.palette.primary[100],
9
- success: theme.palette.success[100],
10
- error: theme.palette.error[100],
11
- warning: theme.palette.warning[100],
12
- };
13
- return bgColors[severity];
14
- };
15
- const getBorderColor = (theme, severity) => {
16
- const borderColors = {
17
- info: theme.palette.primary[300],
18
- success: theme.palette.success[300],
19
- error: theme.palette.error[300],
20
- warning: theme.palette.warning[300],
21
- };
22
- return borderColors[severity];
23
- };
24
- const getIconColor = (theme, severity) => {
25
- const iconColor = {
26
- info: theme.palette.primary[800],
27
- success: theme.palette.success[800],
28
- error: theme.palette.error[800],
29
- warning: theme.palette.warning[800],
30
- };
31
- return iconColor[severity];
32
- };
33
- const getPadding = (theme, hasActions = false, hasCloseButton = false, hasTitle = false) => {
34
- const paddingMap = {
35
- '111': [6, 6, 8, 8],
36
- '110': [6, 8, 8, 8],
37
- '101': [6, 6, 6, 8],
38
- '100': [6, 8, 6, 8],
39
- '011': [6, 6, 8, 8],
40
- '010': [9, 8, 8, 8],
41
- '001': [6, 6, 6, 8],
42
- '000': [9, 8, 9, 8],
43
- };
44
- const key = `${hasTitle ? 1 : 0}${hasActions ? 1 : 0}${hasCloseButton ? 1 : 0}`;
45
- const [top, right, bottom, left] = paddingMap[key];
46
- return theme.microSpacing(top, right, bottom, left);
47
- };
48
- const getMobilePadding = (theme, hasActions = false, hasCloseButton = false, hasTitle = false) => {
49
- const mobilePaddingMap = {
50
- '111': [4, 4, 10, 8],
51
- '110': [8, 8, 10, 8],
52
- '101': [4, 4, 8, 8],
53
- '100': [8, 8, 8, 8],
54
- '011': [4, 4, 10, 8],
55
- '010': [8, 8, 10, 8],
56
- '001': [4, 4, 9, 8],
57
- '000': [8, 8, 9, 8],
58
- };
59
- const key = `${hasTitle ? 1 : 0}${hasActions ? 1 : 0}${hasCloseButton ? 1 : 0}`;
60
- const [top, right, bottom, left] = mobilePaddingMap[key];
61
- return theme.microSpacing(top, right, bottom, left);
62
- };
63
- const getMobileContentPadding = (theme, hasTitle, hasCloseButton) => {
64
- if (hasTitle) {
65
- return '0';
66
- }
67
- return hasCloseButton ? theme.microSpacing(5) : theme.microSpacing(1);
68
- };
69
- const getContentPadding = (theme, hasTitle, hasCloseButton, hasActions) => {
70
- if (hasTitle || !hasCloseButton) {
71
- return '0';
72
- }
73
- return hasActions ? theme.microSpacing(3, 0, 0) : theme.microSpacing(3, 0);
74
- };
75
- const getMobileIconPadding = (theme, hasTitle, hasCloseButton) => {
76
- if (hasTitle || !hasCloseButton) {
77
- return '0';
78
- }
79
- return theme.spacing(2);
80
- };
81
- const getContentGridRows = (hasTitle, hasCloseButton) => {
82
- if (hasCloseButton) {
83
- return hasTitle ? 'minmax(32px, auto) auto' : 'minmax(32px, auto)';
84
- }
85
- return hasTitle ? 'minmax(32px, auto) auto' : 'minmax(20px, auto)';
86
- };
6
+ import { alertClassnames } from './constants';
87
7
  export const StyledGrid = styled(Grid) `
88
8
  grid-auto-flow: column;
89
9
  grid-column: 2 / -1;
@@ -100,32 +20,223 @@ export const StyledIconButton = styled(IconButton) `
100
20
  export const Wrapper = styled.div `
101
21
  display: grid;
102
22
  grid-template-columns: 20px 1fr 32px;
103
- gap: ${({ theme, $hasTitle }) => $hasTitle ? theme.spacing(3, 2) : theme.microSpacing(7, 4)};
23
+ gap: ${({ theme }) => theme.microSpacing(7, 4)};
104
24
 
105
- padding: ${({ theme, $hasCloseButton, $hasActions, $hasTitle }) => getPadding(theme, $hasActions, $hasCloseButton, $hasTitle)};
25
+ padding: ${({ theme }) => theme.microSpacing(9, 8, 9, 8)};
106
26
 
107
- background-color: ${({ theme, $severity }) => getBgColor(theme, $severity)};
108
- border: 1px solid
109
- ${({ theme, $severity }) => getBorderColor(theme, $severity)};
27
+ border: 1px solid transparent;
110
28
  border-radius: ${({ theme }) => theme.shape.medium};
111
29
 
30
+ &.${alertClassnames.severityInfo} {
31
+ background-color: ${({ theme }) => theme.palette.primary[100]};
32
+ border-color: ${({ theme }) => theme.palette.primary[300]};
33
+
34
+ .${alertClassnames.iconWrapper} {
35
+ color: ${({ theme }) => theme.palette.primary[800]};
36
+ }
37
+ }
38
+
39
+ &.${alertClassnames.severitySuccess} {
40
+ background-color: ${({ theme }) => theme.palette.success[100]};
41
+ border-color: ${({ theme }) => theme.palette.success[300]};
42
+
43
+ .${alertClassnames.iconWrapper} {
44
+ color: ${({ theme }) => theme.palette.success[800]};
45
+ }
46
+ }
47
+
48
+ &.${alertClassnames.severityError} {
49
+ background-color: ${({ theme }) => theme.palette.error[100]};
50
+ border-color: ${({ theme }) => theme.palette.error[300]};
51
+
52
+ .${alertClassnames.iconWrapper} {
53
+ color: ${({ theme }) => theme.palette.error[800]};
54
+ }
55
+ }
56
+
57
+ &.${alertClassnames.severityWarning} {
58
+ background-color: ${({ theme }) => theme.palette.warning[100]};
59
+ border-color: ${({ theme }) => theme.palette.warning[300]};
60
+
61
+ .${alertClassnames.iconWrapper} {
62
+ color: ${({ theme }) => theme.palette.warning[800]};
63
+ }
64
+ }
65
+
66
+ /* hasCloseButton only */
67
+ &.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasActions}) {
68
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 6, 8)};
69
+ }
70
+
71
+ /* hasActions only */
72
+ &.${alertClassnames.hasActions}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasCloseButton}) {
73
+ padding: ${({ theme }) => theme.microSpacing(9, 8, 8, 8)};
74
+ }
75
+
76
+ /* hasActions and hasCloseButton */
77
+ &.${alertClassnames.hasActions}.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}) {
78
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 8, 8)};
79
+ }
80
+
81
+ /* hasTitle only */
82
+ &.${alertClassnames.hasTitle}:not(.${alertClassnames.hasActions}):not(.${alertClassnames.hasCloseButton}) {
83
+ padding: ${({ theme }) => theme.microSpacing(6, 8, 6, 8)};
84
+ }
85
+
86
+ /* hasTitle and hasCloseButton */
87
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasActions}) {
88
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 6, 8)};
89
+ }
90
+
91
+ /* hasTitle and hasActions */
92
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasActions}:not(.${alertClassnames.hasCloseButton}) {
93
+ padding: ${({ theme }) => theme.microSpacing(6, 8, 8, 8)};
94
+ }
95
+
96
+ /* all three */
97
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasActions}.${alertClassnames.hasCloseButton} {
98
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 8, 8)};
99
+ }
100
+
101
+ &.${alertClassnames.hasTitle} {
102
+ gap: ${({ theme }) => theme.spacing(3, 2)};
103
+
104
+ .${alertClassnames.contentWrapper} {
105
+ grid-template-rows: minmax(32px, auto) auto;
106
+ align-items: center;
107
+ }
108
+
109
+ .${alertClassnames.content} {
110
+ grid-row: 2;
111
+ }
112
+ }
113
+
114
+ &:not(.${alertClassnames.hasTitle}) {
115
+ .${alertClassnames.contentWrapper} {
116
+ align-items: flex-start;
117
+ }
118
+ }
119
+
120
+ &.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}) {
121
+ .${alertClassnames.iconWrapper} {
122
+ padding-top: ${({ theme }) => theme.microSpacing(3)};
123
+ }
124
+ }
125
+
126
+ &.${alertClassnames.hasCloseButton} {
127
+ .${alertClassnames.title} {
128
+ grid-column: 2;
129
+ }
130
+
131
+ &:not(.${alertClassnames.hasTitle}) {
132
+ .${alertClassnames.content} {
133
+ grid-column: 2;
134
+ }
135
+
136
+ .${alertClassnames.contentWrapper} {
137
+ grid-template-rows: minmax(32px, auto);
138
+ }
139
+
140
+ .${alertClassnames.content} {
141
+ padding: ${({ theme }) => theme.microSpacing(3, 0)};
142
+ }
143
+ }
144
+
145
+ &.${alertClassnames.hasActions}:not(.${alertClassnames.hasTitle}) {
146
+ .${alertClassnames.content} {
147
+ padding: ${({ theme }) => theme.microSpacing(3, 0, 0)};
148
+ }
149
+ }
150
+ }
151
+
112
152
  ${({ theme }) => theme.breakpoints.down('sm')} {
113
153
  grid-row-gap: ${({ theme }) => theme.spacing(4)};
114
154
  grid-template-columns: 24px 1fr 40px;
115
155
 
116
- padding: ${({ theme, $hasCloseButton, $hasActions, $hasTitle }) => getMobilePadding(theme, $hasActions, $hasCloseButton, $hasTitle)};
156
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 9, 8)};
157
+
158
+ .${alertClassnames.contentWrapper} {
159
+ grid-template-columns: 24px 1fr 40px;
160
+ }
161
+
162
+ /* hasCloseButton only */
163
+ &.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasActions}) {
164
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 9, 8)};
165
+ }
166
+
167
+ /* hasActions only */
168
+ &.${alertClassnames.hasActions}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasCloseButton}) {
169
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 10, 8)};
170
+ }
171
+
172
+ /* hasActions and hasCloseButton */
173
+ &.${alertClassnames.hasCloseButton}.${alertClassnames.hasActions}:not(.${alertClassnames.hasTitle}) {
174
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 10, 8)};
175
+ }
176
+
177
+ /* hasTitle only */
178
+ &.${alertClassnames.hasTitle}:not(.${alertClassnames.hasActions}):not(.${alertClassnames.hasCloseButton}) {
179
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 8, 8)};
180
+ }
181
+
182
+ /* hasTitle and hasCloseButton */
183
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasActions}) {
184
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 8, 8)};
185
+ }
186
+
187
+ /* hasTitle and hasActions */
188
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasActions}:not(.${alertClassnames.hasCloseButton}) {
189
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 10, 8)};
190
+ }
191
+
192
+ /* нет модификаторов */
193
+ &:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasActions}):not(.${alertClassnames.hasCloseButton}) {
194
+ .${alertClassnames.content} {
195
+ padding-top: ${({ theme }) => theme.microSpacing(1)};
196
+ }
197
+ }
198
+
199
+ /* all three */
200
+ &.${alertClassnames.hasTitle}.${alertClassnames.hasActions}.${alertClassnames.hasCloseButton} {
201
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 10, 8)};
202
+ }
203
+
204
+ /* for close button without title */
205
+ &.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}) {
206
+ .${alertClassnames.iconWrapper} {
207
+ padding-top: ${({ theme }) => theme.spacing(2)};
208
+ }
209
+ }
210
+
211
+ /* close button only case */
212
+ &.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasActions}) {
213
+ .${alertClassnames.content} {
214
+ padding-top: ${({ theme }) => theme.microSpacing(5)};
215
+ padding-bottom: 0;
216
+ }
217
+ }
218
+
219
+ /* actions only case */
220
+ &.${alertClassnames.hasActions}:not(.${alertClassnames.hasTitle}):not(.${alertClassnames.hasCloseButton}) {
221
+ .${alertClassnames.content} {
222
+ padding-top: ${({ theme }) => theme.microSpacing(1)};
223
+ padding-bottom: 0;
224
+ }
225
+ }
226
+
227
+ /* actions + close button case */
228
+ &.${alertClassnames.hasActions}.${alertClassnames.hasCloseButton}:not(.${alertClassnames.hasTitle}) {
229
+ .${alertClassnames.content} {
230
+ padding-top: ${({ theme }) => theme.microSpacing(5)};
231
+ padding-bottom: 0;
232
+ }
233
+ }
117
234
  }
118
235
  `;
119
236
  export const IconWrapper = styled.div `
120
237
  height: 20px;
121
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => $hasTitle || !$hasCloseButton ? '0' : theme.microSpacing(3)};
122
-
123
- color: ${({ theme, $severity }) => getIconColor(theme, $severity)};
124
238
 
125
- ${({ theme }) => theme.breakpoints.down('sm')} {
126
- height: 24px;
127
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => getMobileIconPadding(theme, $hasTitle, $hasCloseButton)};
128
- }
239
+ color: inherit;
129
240
 
130
241
  & .${svgIconClassnames.root} {
131
242
  font-size: 20px;
@@ -134,34 +245,30 @@ export const IconWrapper = styled.div `
134
245
  font-size: 24px;
135
246
  }
136
247
  }
248
+
249
+ ${({ theme }) => theme.breakpoints.down('sm')} {
250
+ height: 24px;
251
+ }
137
252
  `;
138
253
  export const Content = styled.div `
139
254
  display: grid;
140
255
  grid-column: 1 / -1;
141
256
  grid-gap: ${({ theme }) => theme.microSpacing(1, 4)};
142
257
  grid-template-columns: 20px 1fr 32px;
143
- grid-template-rows: ${({ $hasTitle, $hasCloseButton }) => getContentGridRows($hasTitle, $hasCloseButton)};
144
- align-items: ${({ $hasTitle }) => ($hasTitle ? 'center' : 'unset')};
258
+ grid-template-rows: minmax(20px, auto);
259
+ align-items: unset;
145
260
 
146
- ${({ theme }) => theme.breakpoints.down('sm')} {
147
- grid-template-columns: 24px 1fr 40px;
148
- }
149
261
  `;
150
- export const StyledTypography = styled(Typography, {
151
- shouldForwardProp: (prop) => !['$hasTitle', '$hasCloseButton', '$hasActions'].includes(prop),
152
- }) `
153
- grid-column: ${({ $hasTitle, $hasCloseButton }) => $hasTitle || !$hasCloseButton ? '2 / -1' : '2'};
154
- grid-row: ${({ $hasTitle }) => ($hasTitle ? '2' : '1')};
262
+ export const StyledTypography = styled(Typography) `
263
+ grid-column: 2 / -1;
264
+ grid-row: 1;
155
265
 
156
- padding: ${({ $hasTitle, theme, $hasCloseButton, $hasActions }) => getContentPadding(theme, $hasTitle, $hasCloseButton, $hasActions)};
266
+ padding: 0;
157
267
 
158
- ${({ theme }) => theme.breakpoints.down('sm')} {
159
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => getMobileContentPadding(theme, $hasTitle, $hasCloseButton)};
160
- padding-bottom: 0;
268
+ .${alertClassnames.hasTitle} & {
269
+ grid-row: 2;
161
270
  }
162
271
  `;
163
- export const Title = styled(Typography, {
164
- shouldForwardProp: (prop) => !['$hasTitle', '$hasCloseButton'].includes(prop),
165
- }) `
166
- grid-column: ${({ $hasCloseButton }) => ($hasCloseButton ? '2' : '2 / -1')};
272
+ export const Title = styled(Typography) `
273
+ grid-column: 2 / -1;
167
274
  `;
@@ -20,7 +20,6 @@ export const Wrapper = styled.article `
20
20
  grid-gap: ${({ theme }) => theme.spacing(2)};
21
21
 
22
22
  background-color: inherit;
23
-
24
23
  border-radius: ${({ theme }) => theme.shape.medium};
25
24
 
26
25
  &.${complianceStatusClassnames.contained} {
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Typography } from '../Typography';
3
+ import { classNames } from '../utils/classNames';
4
+ import { dashboardAlertClassnames } from './constants';
3
5
  import { StyledAlert, StyledButton } from './styles';
4
6
  /**
5
7
  * Компонент отображения уведомления на всех страницах приложения
6
8
  */
7
9
  export const DashboardAlert = (props) => {
8
- const { linkButtonProps, children, isShow, ...restProps } = props;
10
+ const { linkButtonProps, children, isShow, className, ...restProps } = props;
9
11
  const { name, color: linkButtonColor, ...restButtonProps } = linkButtonProps || {};
10
- return (_jsx(StyledAlert, { display: isShow, ...restProps, children: _jsxs(Typography, { variant: "body1", children: [children, "\u00A0", linkButtonProps && (_jsx(StyledButton, { variant: "link", ...restButtonProps, children: name }))] }) }));
12
+ return (_jsx(StyledAlert, { className: classNames(dashboardAlertClassnames.root, className), display: isShow, ...restProps, children: _jsxs(Typography, { variant: "body1", children: [children, "\u00A0", linkButtonProps && (_jsx(StyledButton, { variant: "link", ...restButtonProps, children: name }))] }) }));
11
13
  };
@@ -0,0 +1,3 @@
1
+ export declare const dashboardAlertClassnames: {
2
+ root: string;
3
+ };
@@ -0,0 +1,4 @@
1
+ import { createUIKitClassname } from '../utils/createUIKitClassname';
2
+ export const dashboardAlertClassnames = {
3
+ root: createUIKitClassname('dashboard-alert'),
4
+ };
@@ -2,39 +2,41 @@ import { Alert, alertClassnames } from '../Alert';
2
2
  import { Button } from '../Button';
3
3
  import { svgIconClassnames } from '../SvgIcon';
4
4
  import { styled } from '../styled';
5
+ import { dashboardAlertClassnames } from './constants';
5
6
  export const StyledAlert = styled(Alert) `
6
- &.${alertClassnames.root} {
7
+ &.${alertClassnames.root}.${dashboardAlertClassnames.root}.${dashboardAlertClassnames.root} {
7
8
  grid-template-columns: 24px 1fr 32px;
8
9
 
9
10
  margin-bottom: ${({ theme }) => theme.spacing(4)};
10
11
  padding: ${({ theme }) => theme.spacing(3, 4)};
11
- }
12
12
 
13
- .${alertClassnames.contentWrapper} {
14
- grid-template-columns: 24px 1fr 32px;
15
- grid-template-rows: minmax(32px, auto);
16
- align-items: center;
17
13
 
18
- ${({ theme }) => theme.breakpoints.down('sm')} {
19
- align-items: flex-start;
14
+ .${alertClassnames.contentWrapper} {
15
+ grid-template-columns: 24px 1fr 32px;
16
+ grid-template-rows: minmax(32px, auto);
17
+ align-items: center;
18
+
19
+ ${({ theme }) => theme.breakpoints.down('sm')} {
20
+ align-items: flex-start;
21
+ }
20
22
  }
21
- }
22
23
 
23
- .${alertClassnames.iconWrapper} {
24
- height: 24px;
25
- padding: 0;
24
+ .${alertClassnames.iconWrapper} {
25
+ height: 24px;
26
+ padding: 0;
26
27
 
27
- & .${svgIconClassnames.root} {
28
- font-size: 24px;
28
+ & .${svgIconClassnames.root} {
29
+ font-size: 24px;
30
+ }
29
31
  }
30
- }
31
32
 
32
- .${alertClassnames.content} {
33
- padding: 0;
34
- }
33
+ .${alertClassnames.content} {
34
+ padding: 0;
35
+ }
35
36
 
36
- ${({ theme }) => theme.breakpoints.down('sm')} {
37
- margin: ${({ theme }) => theme.spacing(3, 4, 1)};
37
+ ${({ theme }) => theme.breakpoints.down('sm')} {
38
+ margin: ${({ theme }) => theme.spacing(3, 4, 1)};
39
+ }
38
40
  }
39
41
  `;
40
42
  export const StyledButton = styled(Button) `
@@ -4,7 +4,7 @@ import { DashboardContext } from '../../DashboardContext';
4
4
  import { cva } from '../../utils/cva';
5
5
  import { containerClassnames } from './constants';
6
6
  import { Root } from './styles';
7
- const containerCva = cva(containerClassnames.root, {
7
+ const rootCva = cva(containerClassnames.root, {
8
8
  variants: {
9
9
  desktopViewMode: {
10
10
  compact: containerClassnames.compact,
@@ -17,7 +17,7 @@ const containerCva = cva(containerClassnames.root, {
17
17
  });
18
18
  export const Container = ({ children }) => {
19
19
  const { isFocusedMode, desktopViewMode } = useContext(DashboardContext);
20
- return (_jsx(Root, { className: containerCva({
20
+ return (_jsx(Root, { className: rootCva({
21
21
  desktopViewMode,
22
22
  isFocusedMode,
23
23
  }), children: children }));
@@ -1,7 +1,7 @@
1
1
  import { createUIKitClassname } from '../../utils/createUIKitClassname';
2
2
  export const containerClassnames = {
3
3
  root: createUIKitClassname('dashboard-layout__container'),
4
- compact: createUIKitClassname('dashboard-layout__container_compact'),
5
- wide: createUIKitClassname('dashboard-layout__container_wide'),
4
+ compact: createUIKitClassname('dashboard-layout__container_view-mode_compact'),
5
+ wide: createUIKitClassname('dashboard-layout__container_view-mode_wide'),
6
6
  focusedMode: createUIKitClassname('dashboard-layout__container_focused-mode'),
7
7
  };
@@ -10,9 +10,29 @@ const SuccessFillMd_1 = require("../../icons/SuccessFillMd");
10
10
  const WarningFillMd_1 = require("../../icons/WarningFillMd");
11
11
  const Collapse_1 = require("../Collapse");
12
12
  const classNames_1 = require("../utils/classNames");
13
+ const cva_1 = require("../utils/cva");
13
14
  const constants_1 = require("./constants");
14
15
  const styles_1 = require("./styles");
15
16
  const useLogic_1 = require("./useLogic");
17
+ const alertCva = (0, cva_1.cva)(constants_1.alertClassnames.root, {
18
+ variants: {
19
+ hasTitle: {
20
+ true: constants_1.alertClassnames.hasTitle,
21
+ },
22
+ hasCloseButton: {
23
+ true: constants_1.alertClassnames.hasCloseButton,
24
+ },
25
+ hasActions: {
26
+ true: constants_1.alertClassnames.hasActions,
27
+ },
28
+ severity: {
29
+ info: constants_1.alertClassnames.severityInfo,
30
+ error: constants_1.alertClassnames.severityError,
31
+ success: constants_1.alertClassnames.severitySuccess,
32
+ warning: constants_1.alertClassnames.severityWarning,
33
+ },
34
+ },
35
+ });
16
36
  exports.Alert = (0, react_1.forwardRef)(({ children, title, closeText = 'Скрыть', display = true, actions, onClose, severity = 'info', style, className, icon, unmountOnExit, }, ref) => {
17
37
  const { shouldRenderParagraph } = (0, useLogic_1.useLogic)({ children });
18
38
  const renderCloseButton = () => {
@@ -25,7 +45,12 @@ exports.Alert = (0, react_1.forwardRef)(({ children, title, closeText = 'Скр
25
45
  success: (0, jsx_runtime_1.jsx)(SuccessFillMd_1.SuccessFillMd, {}),
26
46
  warning: (0, jsx_runtime_1.jsx)(WarningFillMd_1.WarningFillMd, {}),
27
47
  };
28
- return ((0, jsx_runtime_1.jsx)(styles_1.IconWrapper, { "$hasTitle": Boolean(title), "$severity": severity, "$hasCloseButton": Boolean(onClose), className: constants_1.alertClassnames.iconWrapper, children: icon ?? iconMapping[severity] }));
48
+ return ((0, jsx_runtime_1.jsx)(styles_1.IconWrapper, { className: constants_1.alertClassnames.iconWrapper, children: icon ?? iconMapping[severity] }));
29
49
  };
30
- return ((0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: display, unmountOnExit: unmountOnExit, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { style: style, className: (0, classNames_1.classNames)(className, constants_1.alertClassnames.root), role: "alert", ref: ref, "$severity": severity, "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), "$hasActions": Boolean(actions), children: [(0, jsx_runtime_1.jsxs)(styles_1.Content, { "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), className: constants_1.alertClassnames.contentWrapper, children: [renderIcon(), title && ((0, jsx_runtime_1.jsx)(styles_1.Title, { variant: "h5", "$hasCloseButton": Boolean(onClose), className: constants_1.alertClassnames.title, children: title })), onClose && renderCloseButton(), (0, jsx_runtime_1.jsx)(styles_1.StyledTypography, { component: shouldRenderParagraph ? 'p' : 'div', "$hasTitle": Boolean(title), "$hasCloseButton": Boolean(onClose), "$hasActions": Boolean(actions), className: constants_1.alertClassnames.content, children: children })] }), actions && ((0, jsx_runtime_1.jsx)(styles_1.StyledGrid, { container: true, spacing: 4, children: actions }))] }) }));
50
+ return ((0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: display, unmountOnExit: unmountOnExit, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { style: style, className: (0, classNames_1.classNames)(alertCva({
51
+ hasTitle: Boolean(title),
52
+ hasCloseButton: Boolean(onClose),
53
+ hasActions: Boolean(actions),
54
+ severity,
55
+ }), className), role: "alert", ref: ref, children: [(0, jsx_runtime_1.jsxs)(styles_1.Content, { className: constants_1.alertClassnames.contentWrapper, children: [renderIcon(), title && ((0, jsx_runtime_1.jsx)(styles_1.Title, { variant: "h5", className: constants_1.alertClassnames.title, children: title })), onClose && renderCloseButton(), (0, jsx_runtime_1.jsx)(styles_1.StyledTypography, { component: shouldRenderParagraph ? 'p' : 'div', className: constants_1.alertClassnames.content, children: children })] }), actions && ((0, jsx_runtime_1.jsx)(styles_1.StyledGrid, { container: true, spacing: 4, children: actions }))] }) }));
31
56
  });
@@ -5,4 +5,11 @@ export declare const alertClassnames: {
5
5
  closeButton: string;
6
6
  contentWrapper: string;
7
7
  content: string;
8
+ hasTitle: string;
9
+ hasCloseButton: string;
10
+ hasActions: string;
11
+ severityInfo: string;
12
+ severityError: string;
13
+ severitySuccess: string;
14
+ severityWarning: string;
8
15
  };
@@ -9,4 +9,11 @@ exports.alertClassnames = {
9
9
  closeButton: (0, createUIKitClassname_1.createUIKitClassname)('alert__close-button'),
10
10
  contentWrapper: (0, createUIKitClassname_1.createUIKitClassname)('alert__content-wrapper'),
11
11
  content: (0, createUIKitClassname_1.createUIKitClassname)('alert__content'),
12
+ hasTitle: (0, createUIKitClassname_1.createUIKitClassname)('alert_has-title'),
13
+ hasCloseButton: (0, createUIKitClassname_1.createUIKitClassname)('alert_has-close-button'),
14
+ hasActions: (0, createUIKitClassname_1.createUIKitClassname)('alert_has-actions'),
15
+ severityInfo: (0, createUIKitClassname_1.createUIKitClassname)('alert_severity_info'),
16
+ severityError: (0, createUIKitClassname_1.createUIKitClassname)('alert_severity_error'),
17
+ severitySuccess: (0, createUIKitClassname_1.createUIKitClassname)('alert_severity_success'),
18
+ severityWarning: (0, createUIKitClassname_1.createUIKitClassname)('alert_severity_warning'),
12
19
  };
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { AlertSeverity } from './types';
3
2
  export declare const StyledGrid: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../Grid/GridComponent").GridComponentProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
4
3
  theme?: import("@emotion/react").Theme | undefined;
5
4
  } & import("../Grid/styles").StyledGridProps, {}, {}>;
@@ -15,26 +14,14 @@ export declare const StyledIconButton: import("@emotion/styled/dist/declarations
15
14
  export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
16
15
  theme?: import("@emotion/react").Theme | undefined;
17
16
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
18
- } & {
19
- $hasTitle?: boolean | undefined;
20
- $severity: AlertSeverity;
21
- $hasCloseButton?: boolean | undefined;
22
- $hasActions?: boolean | undefined;
23
17
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
24
18
  export declare const IconWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
25
19
  theme?: import("@emotion/react").Theme | undefined;
26
20
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
27
- } & {
28
- $severity: AlertSeverity;
29
- $hasTitle?: boolean | undefined;
30
- $hasCloseButton?: boolean | undefined;
31
21
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
32
22
  export declare const Content: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
33
23
  theme?: import("@emotion/react").Theme | undefined;
34
24
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
35
- } & {
36
- $hasTitle: boolean;
37
- $hasCloseButton?: boolean | undefined;
38
25
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
39
26
  export declare const StyledTypography: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("../Typography/types").TypographyPropsBase & {
40
27
  color?: import("../Typography").TypographyColor | undefined;
@@ -45,10 +32,6 @@ export declare const StyledTypography: import("@emotion/styled/dist/declarations
45
32
  withoutCalt?: boolean | undefined;
46
33
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
47
34
  theme?: import("@emotion/react").Theme | undefined;
48
- } & {
49
- $hasTitle?: boolean | undefined;
50
- $hasCloseButton?: boolean | undefined;
51
- $hasActions?: boolean | undefined;
52
35
  }, {}, {}>;
53
36
  export declare const Title: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("../Typography/types").TypographyPropsBase & {
54
37
  color?: import("../Typography").TypographyColor | undefined;
@@ -59,6 +42,4 @@ export declare const Title: import("@emotion/styled/dist/declarations/src/types"
59
42
  withoutCalt?: boolean | undefined;
60
43
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
61
44
  theme?: import("@emotion/react").Theme | undefined;
62
- } & {
63
- $hasCloseButton?: boolean | undefined;
64
45
  }, {}, {}>;
@@ -6,87 +6,7 @@ const IconButton_1 = require("../IconButton");
6
6
  const SvgIcon_1 = require("../SvgIcon");
7
7
  const styled_1 = require("../styled");
8
8
  const Typography_1 = require("../Typography");
9
- const getBgColor = (theme, severity) => {
10
- const bgColors = {
11
- info: theme.palette.primary[100],
12
- success: theme.palette.success[100],
13
- error: theme.palette.error[100],
14
- warning: theme.palette.warning[100],
15
- };
16
- return bgColors[severity];
17
- };
18
- const getBorderColor = (theme, severity) => {
19
- const borderColors = {
20
- info: theme.palette.primary[300],
21
- success: theme.palette.success[300],
22
- error: theme.palette.error[300],
23
- warning: theme.palette.warning[300],
24
- };
25
- return borderColors[severity];
26
- };
27
- const getIconColor = (theme, severity) => {
28
- const iconColor = {
29
- info: theme.palette.primary[800],
30
- success: theme.palette.success[800],
31
- error: theme.palette.error[800],
32
- warning: theme.palette.warning[800],
33
- };
34
- return iconColor[severity];
35
- };
36
- const getPadding = (theme, hasActions = false, hasCloseButton = false, hasTitle = false) => {
37
- const paddingMap = {
38
- '111': [6, 6, 8, 8],
39
- '110': [6, 8, 8, 8],
40
- '101': [6, 6, 6, 8],
41
- '100': [6, 8, 6, 8],
42
- '011': [6, 6, 8, 8],
43
- '010': [9, 8, 8, 8],
44
- '001': [6, 6, 6, 8],
45
- '000': [9, 8, 9, 8],
46
- };
47
- const key = `${hasTitle ? 1 : 0}${hasActions ? 1 : 0}${hasCloseButton ? 1 : 0}`;
48
- const [top, right, bottom, left] = paddingMap[key];
49
- return theme.microSpacing(top, right, bottom, left);
50
- };
51
- const getMobilePadding = (theme, hasActions = false, hasCloseButton = false, hasTitle = false) => {
52
- const mobilePaddingMap = {
53
- '111': [4, 4, 10, 8],
54
- '110': [8, 8, 10, 8],
55
- '101': [4, 4, 8, 8],
56
- '100': [8, 8, 8, 8],
57
- '011': [4, 4, 10, 8],
58
- '010': [8, 8, 10, 8],
59
- '001': [4, 4, 9, 8],
60
- '000': [8, 8, 9, 8],
61
- };
62
- const key = `${hasTitle ? 1 : 0}${hasActions ? 1 : 0}${hasCloseButton ? 1 : 0}`;
63
- const [top, right, bottom, left] = mobilePaddingMap[key];
64
- return theme.microSpacing(top, right, bottom, left);
65
- };
66
- const getMobileContentPadding = (theme, hasTitle, hasCloseButton) => {
67
- if (hasTitle) {
68
- return '0';
69
- }
70
- return hasCloseButton ? theme.microSpacing(5) : theme.microSpacing(1);
71
- };
72
- const getContentPadding = (theme, hasTitle, hasCloseButton, hasActions) => {
73
- if (hasTitle || !hasCloseButton) {
74
- return '0';
75
- }
76
- return hasActions ? theme.microSpacing(3, 0, 0) : theme.microSpacing(3, 0);
77
- };
78
- const getMobileIconPadding = (theme, hasTitle, hasCloseButton) => {
79
- if (hasTitle || !hasCloseButton) {
80
- return '0';
81
- }
82
- return theme.spacing(2);
83
- };
84
- const getContentGridRows = (hasTitle, hasCloseButton) => {
85
- if (hasCloseButton) {
86
- return hasTitle ? 'minmax(32px, auto) auto' : 'minmax(32px, auto)';
87
- }
88
- return hasTitle ? 'minmax(32px, auto) auto' : 'minmax(20px, auto)';
89
- };
9
+ const constants_1 = require("./constants");
90
10
  exports.StyledGrid = (0, styled_1.styled)(Grid_1.Grid) `
91
11
  grid-auto-flow: column;
92
12
  grid-column: 2 / -1;
@@ -103,32 +23,223 @@ exports.StyledIconButton = (0, styled_1.styled)(IconButton_1.IconButton) `
103
23
  exports.Wrapper = styled_1.styled.div `
104
24
  display: grid;
105
25
  grid-template-columns: 20px 1fr 32px;
106
- gap: ${({ theme, $hasTitle }) => $hasTitle ? theme.spacing(3, 2) : theme.microSpacing(7, 4)};
26
+ gap: ${({ theme }) => theme.microSpacing(7, 4)};
107
27
 
108
- padding: ${({ theme, $hasCloseButton, $hasActions, $hasTitle }) => getPadding(theme, $hasActions, $hasCloseButton, $hasTitle)};
28
+ padding: ${({ theme }) => theme.microSpacing(9, 8, 9, 8)};
109
29
 
110
- background-color: ${({ theme, $severity }) => getBgColor(theme, $severity)};
111
- border: 1px solid
112
- ${({ theme, $severity }) => getBorderColor(theme, $severity)};
30
+ border: 1px solid transparent;
113
31
  border-radius: ${({ theme }) => theme.shape.medium};
114
32
 
33
+ &.${constants_1.alertClassnames.severityInfo} {
34
+ background-color: ${({ theme }) => theme.palette.primary[100]};
35
+ border-color: ${({ theme }) => theme.palette.primary[300]};
36
+
37
+ .${constants_1.alertClassnames.iconWrapper} {
38
+ color: ${({ theme }) => theme.palette.primary[800]};
39
+ }
40
+ }
41
+
42
+ &.${constants_1.alertClassnames.severitySuccess} {
43
+ background-color: ${({ theme }) => theme.palette.success[100]};
44
+ border-color: ${({ theme }) => theme.palette.success[300]};
45
+
46
+ .${constants_1.alertClassnames.iconWrapper} {
47
+ color: ${({ theme }) => theme.palette.success[800]};
48
+ }
49
+ }
50
+
51
+ &.${constants_1.alertClassnames.severityError} {
52
+ background-color: ${({ theme }) => theme.palette.error[100]};
53
+ border-color: ${({ theme }) => theme.palette.error[300]};
54
+
55
+ .${constants_1.alertClassnames.iconWrapper} {
56
+ color: ${({ theme }) => theme.palette.error[800]};
57
+ }
58
+ }
59
+
60
+ &.${constants_1.alertClassnames.severityWarning} {
61
+ background-color: ${({ theme }) => theme.palette.warning[100]};
62
+ border-color: ${({ theme }) => theme.palette.warning[300]};
63
+
64
+ .${constants_1.alertClassnames.iconWrapper} {
65
+ color: ${({ theme }) => theme.palette.warning[800]};
66
+ }
67
+ }
68
+
69
+ /* hasCloseButton only */
70
+ &.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasActions}) {
71
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 6, 8)};
72
+ }
73
+
74
+ /* hasActions only */
75
+ &.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasCloseButton}) {
76
+ padding: ${({ theme }) => theme.microSpacing(9, 8, 8, 8)};
77
+ }
78
+
79
+ /* hasActions and hasCloseButton */
80
+ &.${constants_1.alertClassnames.hasActions}.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}) {
81
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 8, 8)};
82
+ }
83
+
84
+ /* hasTitle only */
85
+ &.${constants_1.alertClassnames.hasTitle}:not(.${constants_1.alertClassnames.hasActions}):not(.${constants_1.alertClassnames.hasCloseButton}) {
86
+ padding: ${({ theme }) => theme.microSpacing(6, 8, 6, 8)};
87
+ }
88
+
89
+ /* hasTitle and hasCloseButton */
90
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasActions}) {
91
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 6, 8)};
92
+ }
93
+
94
+ /* hasTitle and hasActions */
95
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasCloseButton}) {
96
+ padding: ${({ theme }) => theme.microSpacing(6, 8, 8, 8)};
97
+ }
98
+
99
+ /* all three */
100
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasActions}.${constants_1.alertClassnames.hasCloseButton} {
101
+ padding: ${({ theme }) => theme.microSpacing(6, 6, 8, 8)};
102
+ }
103
+
104
+ &.${constants_1.alertClassnames.hasTitle} {
105
+ gap: ${({ theme }) => theme.spacing(3, 2)};
106
+
107
+ .${constants_1.alertClassnames.contentWrapper} {
108
+ grid-template-rows: minmax(32px, auto) auto;
109
+ align-items: center;
110
+ }
111
+
112
+ .${constants_1.alertClassnames.content} {
113
+ grid-row: 2;
114
+ }
115
+ }
116
+
117
+ &:not(.${constants_1.alertClassnames.hasTitle}) {
118
+ .${constants_1.alertClassnames.contentWrapper} {
119
+ align-items: flex-start;
120
+ }
121
+ }
122
+
123
+ &.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}) {
124
+ .${constants_1.alertClassnames.iconWrapper} {
125
+ padding-top: ${({ theme }) => theme.microSpacing(3)};
126
+ }
127
+ }
128
+
129
+ &.${constants_1.alertClassnames.hasCloseButton} {
130
+ .${constants_1.alertClassnames.title} {
131
+ grid-column: 2;
132
+ }
133
+
134
+ &:not(.${constants_1.alertClassnames.hasTitle}) {
135
+ .${constants_1.alertClassnames.content} {
136
+ grid-column: 2;
137
+ }
138
+
139
+ .${constants_1.alertClassnames.contentWrapper} {
140
+ grid-template-rows: minmax(32px, auto);
141
+ }
142
+
143
+ .${constants_1.alertClassnames.content} {
144
+ padding: ${({ theme }) => theme.microSpacing(3, 0)};
145
+ }
146
+ }
147
+
148
+ &.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasTitle}) {
149
+ .${constants_1.alertClassnames.content} {
150
+ padding: ${({ theme }) => theme.microSpacing(3, 0, 0)};
151
+ }
152
+ }
153
+ }
154
+
115
155
  ${({ theme }) => theme.breakpoints.down('sm')} {
116
156
  grid-row-gap: ${({ theme }) => theme.spacing(4)};
117
157
  grid-template-columns: 24px 1fr 40px;
118
158
 
119
- padding: ${({ theme, $hasCloseButton, $hasActions, $hasTitle }) => getMobilePadding(theme, $hasActions, $hasCloseButton, $hasTitle)};
159
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 9, 8)};
160
+
161
+ .${constants_1.alertClassnames.contentWrapper} {
162
+ grid-template-columns: 24px 1fr 40px;
163
+ }
164
+
165
+ /* hasCloseButton only */
166
+ &.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasActions}) {
167
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 9, 8)};
168
+ }
169
+
170
+ /* hasActions only */
171
+ &.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasCloseButton}) {
172
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 10, 8)};
173
+ }
174
+
175
+ /* hasActions and hasCloseButton */
176
+ &.${constants_1.alertClassnames.hasCloseButton}.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasTitle}) {
177
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 10, 8)};
178
+ }
179
+
180
+ /* hasTitle only */
181
+ &.${constants_1.alertClassnames.hasTitle}:not(.${constants_1.alertClassnames.hasActions}):not(.${constants_1.alertClassnames.hasCloseButton}) {
182
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 8, 8)};
183
+ }
184
+
185
+ /* hasTitle and hasCloseButton */
186
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasActions}) {
187
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 8, 8)};
188
+ }
189
+
190
+ /* hasTitle and hasActions */
191
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasCloseButton}) {
192
+ padding: ${({ theme }) => theme.microSpacing(8, 8, 10, 8)};
193
+ }
194
+
195
+ /* нет модификаторов */
196
+ &:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasActions}):not(.${constants_1.alertClassnames.hasCloseButton}) {
197
+ .${constants_1.alertClassnames.content} {
198
+ padding-top: ${({ theme }) => theme.microSpacing(1)};
199
+ }
200
+ }
201
+
202
+ /* all three */
203
+ &.${constants_1.alertClassnames.hasTitle}.${constants_1.alertClassnames.hasActions}.${constants_1.alertClassnames.hasCloseButton} {
204
+ padding: ${({ theme }) => theme.microSpacing(4, 4, 10, 8)};
205
+ }
206
+
207
+ /* for close button without title */
208
+ &.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}) {
209
+ .${constants_1.alertClassnames.iconWrapper} {
210
+ padding-top: ${({ theme }) => theme.spacing(2)};
211
+ }
212
+ }
213
+
214
+ /* close button only case */
215
+ &.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasActions}) {
216
+ .${constants_1.alertClassnames.content} {
217
+ padding-top: ${({ theme }) => theme.microSpacing(5)};
218
+ padding-bottom: 0;
219
+ }
220
+ }
221
+
222
+ /* actions only case */
223
+ &.${constants_1.alertClassnames.hasActions}:not(.${constants_1.alertClassnames.hasTitle}):not(.${constants_1.alertClassnames.hasCloseButton}) {
224
+ .${constants_1.alertClassnames.content} {
225
+ padding-top: ${({ theme }) => theme.microSpacing(1)};
226
+ padding-bottom: 0;
227
+ }
228
+ }
229
+
230
+ /* actions + close button case */
231
+ &.${constants_1.alertClassnames.hasActions}.${constants_1.alertClassnames.hasCloseButton}:not(.${constants_1.alertClassnames.hasTitle}) {
232
+ .${constants_1.alertClassnames.content} {
233
+ padding-top: ${({ theme }) => theme.microSpacing(5)};
234
+ padding-bottom: 0;
235
+ }
236
+ }
120
237
  }
121
238
  `;
122
239
  exports.IconWrapper = styled_1.styled.div `
123
240
  height: 20px;
124
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => $hasTitle || !$hasCloseButton ? '0' : theme.microSpacing(3)};
125
-
126
- color: ${({ theme, $severity }) => getIconColor(theme, $severity)};
127
241
 
128
- ${({ theme }) => theme.breakpoints.down('sm')} {
129
- height: 24px;
130
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => getMobileIconPadding(theme, $hasTitle, $hasCloseButton)};
131
- }
242
+ color: inherit;
132
243
 
133
244
  & .${SvgIcon_1.svgIconClassnames.root} {
134
245
  font-size: 20px;
@@ -137,34 +248,30 @@ exports.IconWrapper = styled_1.styled.div `
137
248
  font-size: 24px;
138
249
  }
139
250
  }
251
+
252
+ ${({ theme }) => theme.breakpoints.down('sm')} {
253
+ height: 24px;
254
+ }
140
255
  `;
141
256
  exports.Content = styled_1.styled.div `
142
257
  display: grid;
143
258
  grid-column: 1 / -1;
144
259
  grid-gap: ${({ theme }) => theme.microSpacing(1, 4)};
145
260
  grid-template-columns: 20px 1fr 32px;
146
- grid-template-rows: ${({ $hasTitle, $hasCloseButton }) => getContentGridRows($hasTitle, $hasCloseButton)};
147
- align-items: ${({ $hasTitle }) => ($hasTitle ? 'center' : 'unset')};
261
+ grid-template-rows: minmax(20px, auto);
262
+ align-items: unset;
148
263
 
149
- ${({ theme }) => theme.breakpoints.down('sm')} {
150
- grid-template-columns: 24px 1fr 40px;
151
- }
152
264
  `;
153
- exports.StyledTypography = (0, styled_1.styled)(Typography_1.Typography, {
154
- shouldForwardProp: (prop) => !['$hasTitle', '$hasCloseButton', '$hasActions'].includes(prop),
155
- }) `
156
- grid-column: ${({ $hasTitle, $hasCloseButton }) => $hasTitle || !$hasCloseButton ? '2 / -1' : '2'};
157
- grid-row: ${({ $hasTitle }) => ($hasTitle ? '2' : '1')};
265
+ exports.StyledTypography = (0, styled_1.styled)(Typography_1.Typography) `
266
+ grid-column: 2 / -1;
267
+ grid-row: 1;
158
268
 
159
- padding: ${({ $hasTitle, theme, $hasCloseButton, $hasActions }) => getContentPadding(theme, $hasTitle, $hasCloseButton, $hasActions)};
269
+ padding: 0;
160
270
 
161
- ${({ theme }) => theme.breakpoints.down('sm')} {
162
- padding-top: ${({ $hasTitle, theme, $hasCloseButton }) => getMobileContentPadding(theme, $hasTitle, $hasCloseButton)};
163
- padding-bottom: 0;
271
+ .${constants_1.alertClassnames.hasTitle} & {
272
+ grid-row: 2;
164
273
  }
165
274
  `;
166
- exports.Title = (0, styled_1.styled)(Typography_1.Typography, {
167
- shouldForwardProp: (prop) => !['$hasTitle', '$hasCloseButton'].includes(prop),
168
- }) `
169
- grid-column: ${({ $hasCloseButton }) => ($hasCloseButton ? '2' : '2 / -1')};
275
+ exports.Title = (0, styled_1.styled)(Typography_1.Typography) `
276
+ grid-column: 2 / -1;
170
277
  `;
@@ -23,7 +23,6 @@ exports.Wrapper = styled_1.styled.article `
23
23
  grid-gap: ${({ theme }) => theme.spacing(2)};
24
24
 
25
25
  background-color: inherit;
26
-
27
26
  border-radius: ${({ theme }) => theme.shape.medium};
28
27
 
29
28
  &.${constants_1.complianceStatusClassnames.contained} {
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DashboardAlert = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const Typography_1 = require("../Typography");
6
+ const classNames_1 = require("../utils/classNames");
7
+ const constants_1 = require("./constants");
6
8
  const styles_1 = require("./styles");
7
9
  /**
8
10
  * Компонент отображения уведомления на всех страницах приложения
9
11
  */
10
12
  const DashboardAlert = (props) => {
11
- const { linkButtonProps, children, isShow, ...restProps } = props;
13
+ const { linkButtonProps, children, isShow, className, ...restProps } = props;
12
14
  const { name, color: linkButtonColor, ...restButtonProps } = linkButtonProps || {};
13
- return ((0, jsx_runtime_1.jsx)(styles_1.StyledAlert, { display: isShow, ...restProps, children: (0, jsx_runtime_1.jsxs)(Typography_1.Typography, { variant: "body1", children: [children, "\u00A0", linkButtonProps && ((0, jsx_runtime_1.jsx)(styles_1.StyledButton, { variant: "link", ...restButtonProps, children: name }))] }) }));
15
+ return ((0, jsx_runtime_1.jsx)(styles_1.StyledAlert, { className: (0, classNames_1.classNames)(constants_1.dashboardAlertClassnames.root, className), display: isShow, ...restProps, children: (0, jsx_runtime_1.jsxs)(Typography_1.Typography, { variant: "body1", children: [children, "\u00A0", linkButtonProps && ((0, jsx_runtime_1.jsx)(styles_1.StyledButton, { variant: "link", ...restButtonProps, children: name }))] }) }));
14
16
  };
15
17
  exports.DashboardAlert = DashboardAlert;
@@ -0,0 +1,3 @@
1
+ export declare const dashboardAlertClassnames: {
2
+ root: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dashboardAlertClassnames = void 0;
4
+ const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
+ exports.dashboardAlertClassnames = {
6
+ root: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-alert'),
7
+ };
@@ -5,39 +5,41 @@ const Alert_1 = require("../Alert");
5
5
  const Button_1 = require("../Button");
6
6
  const SvgIcon_1 = require("../SvgIcon");
7
7
  const styled_1 = require("../styled");
8
+ const constants_1 = require("./constants");
8
9
  exports.StyledAlert = (0, styled_1.styled)(Alert_1.Alert) `
9
- &.${Alert_1.alertClassnames.root} {
10
+ &.${Alert_1.alertClassnames.root}.${constants_1.dashboardAlertClassnames.root}.${constants_1.dashboardAlertClassnames.root} {
10
11
  grid-template-columns: 24px 1fr 32px;
11
12
 
12
13
  margin-bottom: ${({ theme }) => theme.spacing(4)};
13
14
  padding: ${({ theme }) => theme.spacing(3, 4)};
14
- }
15
15
 
16
- .${Alert_1.alertClassnames.contentWrapper} {
17
- grid-template-columns: 24px 1fr 32px;
18
- grid-template-rows: minmax(32px, auto);
19
- align-items: center;
20
16
 
21
- ${({ theme }) => theme.breakpoints.down('sm')} {
22
- align-items: flex-start;
17
+ .${Alert_1.alertClassnames.contentWrapper} {
18
+ grid-template-columns: 24px 1fr 32px;
19
+ grid-template-rows: minmax(32px, auto);
20
+ align-items: center;
21
+
22
+ ${({ theme }) => theme.breakpoints.down('sm')} {
23
+ align-items: flex-start;
24
+ }
23
25
  }
24
- }
25
26
 
26
- .${Alert_1.alertClassnames.iconWrapper} {
27
- height: 24px;
28
- padding: 0;
27
+ .${Alert_1.alertClassnames.iconWrapper} {
28
+ height: 24px;
29
+ padding: 0;
29
30
 
30
- & .${SvgIcon_1.svgIconClassnames.root} {
31
- font-size: 24px;
31
+ & .${SvgIcon_1.svgIconClassnames.root} {
32
+ font-size: 24px;
33
+ }
32
34
  }
33
- }
34
35
 
35
- .${Alert_1.alertClassnames.content} {
36
- padding: 0;
37
- }
36
+ .${Alert_1.alertClassnames.content} {
37
+ padding: 0;
38
+ }
38
39
 
39
- ${({ theme }) => theme.breakpoints.down('sm')} {
40
- margin: ${({ theme }) => theme.spacing(3, 4, 1)};
40
+ ${({ theme }) => theme.breakpoints.down('sm')} {
41
+ margin: ${({ theme }) => theme.spacing(3, 4, 1)};
42
+ }
41
43
  }
42
44
  `;
43
45
  exports.StyledButton = (0, styled_1.styled)(Button_1.Button) `
@@ -7,7 +7,7 @@ const DashboardContext_1 = require("../../DashboardContext");
7
7
  const cva_1 = require("../../utils/cva");
8
8
  const constants_1 = require("./constants");
9
9
  const styles_1 = require("./styles");
10
- const containerCva = (0, cva_1.cva)(constants_1.containerClassnames.root, {
10
+ const rootCva = (0, cva_1.cva)(constants_1.containerClassnames.root, {
11
11
  variants: {
12
12
  desktopViewMode: {
13
13
  compact: constants_1.containerClassnames.compact,
@@ -20,7 +20,7 @@ const containerCva = (0, cva_1.cva)(constants_1.containerClassnames.root, {
20
20
  });
21
21
  const Container = ({ children }) => {
22
22
  const { isFocusedMode, desktopViewMode } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
23
- return ((0, jsx_runtime_1.jsx)(styles_1.Root, { className: containerCva({
23
+ return ((0, jsx_runtime_1.jsx)(styles_1.Root, { className: rootCva({
24
24
  desktopViewMode,
25
25
  isFocusedMode,
26
26
  }), children: children }));
@@ -4,7 +4,7 @@ exports.containerClassnames = void 0;
4
4
  const createUIKitClassname_1 = require("../../utils/createUIKitClassname");
5
5
  exports.containerClassnames = {
6
6
  root: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container'),
7
- compact: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container_compact'),
8
- wide: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container_wide'),
7
+ compact: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container_view-mode_compact'),
8
+ wide: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container_view-mode_wide'),
9
9
  focusedMode: (0, createUIKitClassname_1.createUIKitClassname)('dashboard-layout__container_focused-mode'),
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.53.0",
3
+ "version": "4.53.2",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {