@astral/ui 4.122.1 → 4.123.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/components/Banner/Banner.d.ts +1 -1
  2. package/components/Banner/Banner.js +4 -1
  3. package/components/Banner/BannerContainer/styles.js +25 -10
  4. package/components/Banner/BannerTemplate/BannerTemplate.d.ts +5 -1
  5. package/components/Banner/BannerTemplate/BannerTemplate.js +6 -2
  6. package/components/Banner/BannerTemplate/styles.js +7 -1
  7. package/components/Banner/constants.d.ts +2 -0
  8. package/components/Banner/constants.js +2 -0
  9. package/components/Banner/types.d.ts +11 -1
  10. package/components/Dialog/useLogic/useLogic.js +3 -3
  11. package/components/Notification/NotificationContainer/styles.js +10 -4
  12. package/components/Notification/NotificationStackContainer/styles.js +9 -2
  13. package/components/utils/formatCssSize/formatCssSize.d.ts +7 -0
  14. package/components/utils/formatCssSize/formatCssSize.js +7 -0
  15. package/components/utils/formatCssSize/index.d.ts +1 -0
  16. package/components/utils/formatCssSize/index.js +1 -0
  17. package/node/components/Banner/Banner.d.ts +1 -1
  18. package/node/components/Banner/Banner.js +4 -1
  19. package/node/components/Banner/BannerContainer/styles.js +24 -9
  20. package/node/components/Banner/BannerTemplate/BannerTemplate.d.ts +5 -1
  21. package/node/components/Banner/BannerTemplate/BannerTemplate.js +6 -2
  22. package/node/components/Banner/BannerTemplate/styles.js +7 -1
  23. package/node/components/Banner/constants.d.ts +2 -0
  24. package/node/components/Banner/constants.js +3 -1
  25. package/node/components/Banner/types.d.ts +11 -1
  26. package/node/components/Dialog/useLogic/useLogic.js +3 -3
  27. package/node/components/Notification/NotificationContainer/styles.js +10 -4
  28. package/node/components/Notification/NotificationStackContainer/styles.js +9 -2
  29. package/node/components/utils/formatCssSize/formatCssSize.d.ts +7 -0
  30. package/node/components/utils/formatCssSize/formatCssSize.js +11 -0
  31. package/node/components/utils/formatCssSize/index.d.ts +1 -0
  32. package/node/components/utils/formatCssSize/index.js +17 -0
  33. package/package.json +1 -1
  34. package/components/utils/getCssSize/getCssSize.d.ts +0 -4
  35. package/components/utils/getCssSize/getCssSize.js +0 -4
  36. package/components/utils/getCssSize/index.d.ts +0 -1
  37. package/components/utils/getCssSize/index.js +0 -1
  38. package/node/components/utils/getCssSize/getCssSize.d.ts +0 -4
  39. package/node/components/utils/getCssSize/getCssSize.js +0 -8
  40. package/node/components/utils/getCssSize/index.d.ts +0 -1
  41. package/node/components/utils/getCssSize/index.js +0 -5
@@ -1,5 +1,5 @@
1
1
  import { type Dispatch, type SetStateAction } from 'react';
2
- import type { BannerProps } from './types';
2
+ import { type BannerProps } from './types';
3
3
  /**
4
4
  * Сервис для отображения рекламного баннера или опроса
5
5
  * Для работы, необходим react >= 18
@@ -1,5 +1,6 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { BANNER_CONTAINER_ID, notify } from '../Notification';
3
+ import { formatCssSize } from '../utils/formatCssSize';
3
4
  import { BannerTemplate } from './BannerTemplate';
4
5
  import { bannerClassnames } from './constants';
5
6
  /**
@@ -59,14 +60,16 @@ class Banner {
59
60
  this.setIsOpenModal(true);
60
61
  return;
61
62
  }
63
+ const { width, ...templateOptions } = options;
62
64
  bannerId = notify.custom(({ toastProps }) => {
63
65
  const { key, ...restToastProps } = toastProps;
64
- return (_createElement(BannerTemplate, { ...options, ...restToastProps, onClose: options?.onClose, key: key }));
66
+ return (_createElement(BannerTemplate, { ...templateOptions, ...restToastProps, onClose: options?.onClose, key: key }));
65
67
  }, {
66
68
  containerId: options.containerId || BANNER_CONTAINER_ID,
67
69
  hideProgressBar: true,
68
70
  autoClose: false,
69
71
  className: bannerClassnames.root,
72
+ style: { '--banner-width': formatCssSize(width) },
70
73
  });
71
74
  },
72
75
  /**
@@ -1,23 +1,38 @@
1
1
  import { ToastContainer } from 'react-toastify-next';
2
2
  import { styled } from '../../styled';
3
- import { bannerClassnames } from '../constants';
3
+ import { BANNER_DEFAULT_WIDTH, bannerClassnames } from '../constants';
4
4
  export const Inner = styled(ToastContainer) `
5
- position: relative;
6
- right: 0;
7
- bottom: 0;
5
+ --banner-width: ${BANNER_DEFAULT_WIDTH};
8
6
 
9
- width: 100%;
10
- min-width: 400px;
11
- max-width: 432px;
12
- padding-bottom: 0;
13
- padding-left: ${({ theme }) => theme.spacing(3)};
7
+ /* Базовые стили Toastify могут подключиться после стилей контейнера. */
8
+ && {
9
+ position: relative;
10
+ right: 0;
11
+ bottom: 0;
14
12
 
13
+ /* Баннер может быть шире контейнера уведомлений, поэтому выравниваем его по правому краю, а лишнее уходит влево */
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: flex-end;
17
+
18
+ width: 100%;
19
+ padding-right: ${({ theme }) => theme.spacing(5)};
20
+ padding-bottom: 0;
21
+ padding-left: ${({ theme }) => theme.spacing(3)};
22
+ }
15
23
 
16
24
  .${bannerClassnames.root} {
17
- width: 400px;
25
+ flex-shrink: 0;
26
+
27
+ width: var(--banner-width);
28
+ max-width: calc(100vw - ${({ theme }) => theme.spacing(10)});
18
29
  height: auto;
19
30
  padding: 0;
20
31
 
21
32
  border-radius: ${({ theme }) => theme.shape.medium};
33
+
34
+ &:last-child {
35
+ margin-bottom: 0;
36
+ }
22
37
  }
23
38
  `;
@@ -1,4 +1,4 @@
1
- import { type Dispatch, type ReactNode, type SetStateAction } from 'react';
1
+ import { type CSSProperties, type Dispatch, type ReactNode, type SetStateAction } from 'react';
2
2
  import { type ToastProps } from 'react-toastify-next/dist/types';
3
3
  import { type ActionParams } from '../types';
4
4
  type BannerTemplateProps = {
@@ -10,6 +10,10 @@ type BannerTemplateProps = {
10
10
  * Обработчик, для выполнения дополнительных действий при закрытии(например, снятие метрик)
11
11
  */
12
12
  onClose?: () => void;
13
+ /**
14
+ * Высота изображения. Число задаётся в пикселях. На mobile не применяется
15
+ */
16
+ imageHeight?: CSSProperties['height'];
13
17
  setIsOpenDialog?: Dispatch<SetStateAction<boolean>>;
14
18
  } & Partial<ToastProps>;
15
19
  export declare const BannerTemplate: (props: BannerTemplateProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,10 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button } from '../../Button';
3
3
  import { Typography } from '../../Typography';
4
4
  import { useViewportType } from '../../useViewportType';
5
+ import { formatCssSize } from '../../utils/formatCssSize';
5
6
  import { Container, Footer, Image, Wrapper, WrapperTextContent, } from './styles';
6
7
  export const BannerTemplate = (props) => {
7
- const { closeToast, imageSrc, title, description, onClose, action, setIsOpenDialog, } = props;
8
+ const { closeToast, imageSrc, title, description, onClose, action, setIsOpenDialog, imageHeight, } = props;
8
9
  const { isMobile } = useViewportType();
10
+ const containerStyle = {
11
+ '--banner-image-height': formatCssSize(imageHeight),
12
+ };
9
13
  const handleClose = () => {
10
14
  closeToast?.();
11
15
  onClose?.();
@@ -14,5 +18,5 @@ export const BannerTemplate = (props) => {
14
18
  closeToast?.();
15
19
  setIsOpenDialog?.(false);
16
20
  };
17
- return (_jsxs(Container, { children: [imageSrc && _jsx(Image, { src: imageSrc }), _jsxs(Wrapper, { container: true, children: [_jsxs(WrapperTextContent, { container: true, children: [title && _jsx(Typography, { variant: "h4", children: title }), description && (_jsx(Typography, { variant: "body1", children: description }))] }), _jsxs(Footer, { children: [!isMobile && (_jsx(Button, { onClick: handleClose, variant: "text", size: "large", children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C" })), action?.({ closeBanner: handleCloseForAction })] })] })] }));
21
+ return (_jsxs(Container, { style: containerStyle, children: [imageSrc && _jsx(Image, { src: imageSrc }), _jsxs(Wrapper, { container: true, children: [_jsxs(WrapperTextContent, { container: true, children: [title && _jsx(Typography, { variant: "h4", children: title }), description && (_jsx(Typography, { variant: "body1", children: description }))] }), _jsxs(Footer, { children: [!isMobile && (_jsx(Button, { onClick: handleClose, variant: "text", size: "large", children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C" })), action?.({ closeBanner: handleCloseForAction })] })] })] }));
18
22
  };
@@ -1,6 +1,9 @@
1
1
  import { Grid } from '../../Grid';
2
2
  import { styled } from '../../styled';
3
+ import { BANNER_DEFAULT_IMAGE_HEIGHT } from '../constants';
3
4
  export const Container = styled.article `
5
+ --banner-image-height: ${BANNER_DEFAULT_IMAGE_HEIGHT};
6
+
4
7
  width: 100%;
5
8
  height: 100%;
6
9
 
@@ -11,12 +14,15 @@ export const Image = styled.img `
11
14
 
12
15
  width: 100%;
13
16
  max-width: 100%;
14
- height: 160px;
17
+ height: var(--banner-image-height);
15
18
  max-height: 100%;
16
19
 
17
20
  object-fit: contain;
18
21
 
19
22
  ${({ theme }) => theme.breakpoints.down('mobile')} {
23
+ /* На mobile высота изображения фиксированная, imageHeight не применяется */
24
+ height: ${BANNER_DEFAULT_IMAGE_HEIGHT};
25
+
20
26
  object-fit: cover;
21
27
  }
22
28
  `;
@@ -1,3 +1,5 @@
1
+ export declare const BANNER_DEFAULT_WIDTH = "400px";
2
+ export declare const BANNER_DEFAULT_IMAGE_HEIGHT = "160px";
1
3
  export declare const bannerClassnames: {
2
4
  root: string;
3
5
  };
@@ -1,4 +1,6 @@
1
1
  import { createUIKitClassname } from '../utils/createUIKitClassname';
2
+ export const BANNER_DEFAULT_WIDTH = '400px';
3
+ export const BANNER_DEFAULT_IMAGE_HEIGHT = '160px';
2
4
  export const bannerClassnames = {
3
5
  root: createUIKitClassname('banner'),
4
6
  };
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  import { type ToastProps } from 'react-toastify-next/dist/types';
3
3
  export type ActionParams = {
4
4
  closeBanner: () => void;
@@ -35,4 +35,14 @@ export type BannerProps = {
35
35
  * Обработчик, для выполнения дополнительных действий при закрытии(например, снятие метрик)
36
36
  */
37
37
  onClose?: () => void;
38
+ /**
39
+ * Ширина баннера. Число задаётся в пикселях. На mobile не применяется
40
+ * @default 400px
41
+ */
42
+ width?: CSSProperties['width'];
43
+ /**
44
+ * Высота изображения. Число задаётся в пикселях. На mobile не применяется
45
+ * @default 160px
46
+ */
47
+ imageHeight?: CSSProperties['height'];
38
48
  } & Pick<ToastProps, 'containerId'>;
@@ -1,6 +1,6 @@
1
1
  import { useViewportType } from '../../useViewportType';
2
2
  import { cn } from '../../utils/cn';
3
- import { getCssSize } from '../../utils/getCssSize';
3
+ import { formatCssSize } from '../../utils/formatCssSize';
4
4
  import { dialogClassnames } from '../constants';
5
5
  export const useLogic = ({ onClose, disableBackdropClick, classes, disableMobileDrawer, height, width, }) => {
6
6
  const { isMobile } = useViewportType();
@@ -17,8 +17,8 @@ export const useLogic = ({ onClose, disableBackdropClick, classes, disableMobile
17
17
  ...restClasses,
18
18
  };
19
19
  const dialogCssVars = {
20
- '--dialog-width': getCssSize(width),
21
- '--dialog-height': getCssSize(height),
20
+ '--dialog-width': formatCssSize(width),
21
+ '--dialog-height': formatCssSize(height),
22
22
  };
23
23
  return {
24
24
  dialogCssVars,
@@ -41,7 +41,7 @@ export const Wrapper = styled('div', {
41
41
  position: fixed;
42
42
  z-index: ${theme.zIndex.snackbar};
43
43
  right: 0;
44
- bottom: 0;
44
+ bottom: calc(var(--toastify-toast-bottom, 16px) + ${theme.spacing(1)});
45
45
  width: 432px;
46
46
  `}
47
47
  }
@@ -88,6 +88,10 @@ export const Wrapper = styled('div', {
88
88
  }
89
89
  ${({ theme }) => theme.breakpoints.up('mobile')} {
90
90
  min-height: ${NOTIFY_HEIGHT};
91
+
92
+ &:last-child {
93
+ margin-bottom: 0;
94
+ }
91
95
  }
92
96
  ${({ theme }) => theme.breakpoints.down('mobile')} {
93
97
  min-height: ${NOTIFY_HEIGHT_MOBILE};
@@ -143,10 +147,12 @@ export const Inner = styled(ToastContainer, {
143
147
  position: relative !important;
144
148
  right: 0 !important;
145
149
  bottom: 0 !important;
146
- width: 100%;
147
- max-width: 432px;
150
+ width: 400px;
151
+ max-width: 400px;
152
+ margin-right: var(--toastify-toast-right, 16px);
153
+ margin-left: auto;
148
154
  padding-bottom: 0 !important;
149
- padding-left: ${theme.spacing(3)} !important;
155
+ padding-left: ${theme.spacing(1)} !important;
150
156
  `}
151
157
  }
152
158
 
@@ -405,8 +405,10 @@ export const Inner = styled(ToastContainer) `
405
405
  .${notifyClassnames.root} {
406
406
  border-radius: ${({ theme }) => theme.shape.medium};
407
407
 
408
- &:last-of-type{
409
- margin-bottom: ${({ theme }) => theme.spacing(1)} ;
408
+ ${({ theme }) => theme.breakpoints.up('mobile')} {
409
+ &:last-of-type {
410
+ margin-bottom: 0;
411
+ }
410
412
  }
411
413
  }
412
414
 
@@ -427,6 +429,10 @@ export const Inner = styled(ToastContainer) `
427
429
  margin-bottom: ${({ theme }) => theme.spacing(1)} !important;
428
430
 
429
431
  opacity: 1 !important;
432
+
433
+ &:last-of-type {
434
+ margin-bottom: 0 !important;
435
+ }
430
436
  }
431
437
 
432
438
  .${notifyClassnames.root}__content {
@@ -480,6 +486,7 @@ export const CloseButton = styled(Button) `
480
486
  right: ${({ theme }) => theme.spacing(3)};
481
487
 
482
488
  width: 400px;
489
+ margin-top: ${({ theme }) => theme.spacing(1)};
483
490
  margin-left: ${({ theme }) => theme.spacing(6)};
484
491
 
485
492
  box-shadow: ${({ theme }) => theme.elevation[300]};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Приводит размер к строке для CSS: число считается в пикселях, строка возвращается как есть.
3
+ * Нужна для CSS-переменных, к которым React не добавляет px автоматически
4
+ * @example formatCssSize(320) // '320px'
5
+ * @example formatCssSize('50%') // '50%'
6
+ */
7
+ export declare const formatCssSize: (value?: number | string) => string | undefined;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Приводит размер к строке для CSS: число считается в пикселях, строка возвращается как есть.
3
+ * Нужна для CSS-переменных, к которым React не добавляет px автоматически
4
+ * @example formatCssSize(320) // '320px'
5
+ * @example formatCssSize('50%') // '50%'
6
+ */
7
+ export const formatCssSize = (value) => typeof value === 'number' ? `${value}px` : value;
@@ -0,0 +1 @@
1
+ export * from './formatCssSize';
@@ -0,0 +1 @@
1
+ export * from './formatCssSize';
@@ -1,5 +1,5 @@
1
1
  import { type Dispatch, type SetStateAction } from 'react';
2
- import type { BannerProps } from './types';
2
+ import { type BannerProps } from './types';
3
3
  /**
4
4
  * Сервис для отображения рекламного баннера или опроса
5
5
  * Для работы, необходим react >= 18
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.banner = void 0;
4
4
  const react_1 = require("react");
5
5
  const Notification_1 = require("../Notification");
6
+ const formatCssSize_1 = require("../utils/formatCssSize");
6
7
  const BannerTemplate_1 = require("./BannerTemplate");
7
8
  const constants_1 = require("./constants");
8
9
  /**
@@ -62,14 +63,16 @@ class Banner {
62
63
  this.setIsOpenModal(true);
63
64
  return;
64
65
  }
66
+ const { width, ...templateOptions } = options;
65
67
  bannerId = Notification_1.notify.custom(({ toastProps }) => {
66
68
  const { key, ...restToastProps } = toastProps;
67
- return ((0, react_1.createElement)(BannerTemplate_1.BannerTemplate, { ...options, ...restToastProps, onClose: options?.onClose, key: key }));
69
+ return ((0, react_1.createElement)(BannerTemplate_1.BannerTemplate, { ...templateOptions, ...restToastProps, onClose: options?.onClose, key: key }));
68
70
  }, {
69
71
  containerId: options.containerId || Notification_1.BANNER_CONTAINER_ID,
70
72
  hideProgressBar: true,
71
73
  autoClose: false,
72
74
  className: constants_1.bannerClassnames.root,
75
+ style: { '--banner-width': (0, formatCssSize_1.formatCssSize)(width) },
73
76
  });
74
77
  },
75
78
  /**
@@ -5,22 +5,37 @@ const react_toastify_next_1 = require("react-toastify-next");
5
5
  const styled_1 = require("../../styled");
6
6
  const constants_1 = require("../constants");
7
7
  exports.Inner = (0, styled_1.styled)(react_toastify_next_1.ToastContainer) `
8
- position: relative;
9
- right: 0;
10
- bottom: 0;
8
+ --banner-width: ${constants_1.BANNER_DEFAULT_WIDTH};
11
9
 
12
- width: 100%;
13
- min-width: 400px;
14
- max-width: 432px;
15
- padding-bottom: 0;
16
- padding-left: ${({ theme }) => theme.spacing(3)};
10
+ /* Базовые стили Toastify могут подключиться после стилей контейнера. */
11
+ && {
12
+ position: relative;
13
+ right: 0;
14
+ bottom: 0;
17
15
 
16
+ /* Баннер может быть шире контейнера уведомлений, поэтому выравниваем его по правому краю, а лишнее уходит влево */
17
+ display: flex;
18
+ flex-direction: column;
19
+ align-items: flex-end;
20
+
21
+ width: 100%;
22
+ padding-right: ${({ theme }) => theme.spacing(5)};
23
+ padding-bottom: 0;
24
+ padding-left: ${({ theme }) => theme.spacing(3)};
25
+ }
18
26
 
19
27
  .${constants_1.bannerClassnames.root} {
20
- width: 400px;
28
+ flex-shrink: 0;
29
+
30
+ width: var(--banner-width);
31
+ max-width: calc(100vw - ${({ theme }) => theme.spacing(10)});
21
32
  height: auto;
22
33
  padding: 0;
23
34
 
24
35
  border-radius: ${({ theme }) => theme.shape.medium};
36
+
37
+ &:last-child {
38
+ margin-bottom: 0;
39
+ }
25
40
  }
26
41
  `;
@@ -1,4 +1,4 @@
1
- import { type Dispatch, type ReactNode, type SetStateAction } from 'react';
1
+ import { type CSSProperties, type Dispatch, type ReactNode, type SetStateAction } from 'react';
2
2
  import { type ToastProps } from 'react-toastify-next/dist/types';
3
3
  import { type ActionParams } from '../types';
4
4
  type BannerTemplateProps = {
@@ -10,6 +10,10 @@ type BannerTemplateProps = {
10
10
  * Обработчик, для выполнения дополнительных действий при закрытии(например, снятие метрик)
11
11
  */
12
12
  onClose?: () => void;
13
+ /**
14
+ * Высота изображения. Число задаётся в пикселях. На mobile не применяется
15
+ */
16
+ imageHeight?: CSSProperties['height'];
13
17
  setIsOpenDialog?: Dispatch<SetStateAction<boolean>>;
14
18
  } & Partial<ToastProps>;
15
19
  export declare const BannerTemplate: (props: BannerTemplateProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,10 +5,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const Button_1 = require("../../Button");
6
6
  const Typography_1 = require("../../Typography");
7
7
  const useViewportType_1 = require("../../useViewportType");
8
+ const formatCssSize_1 = require("../../utils/formatCssSize");
8
9
  const styles_1 = require("./styles");
9
10
  const BannerTemplate = (props) => {
10
- const { closeToast, imageSrc, title, description, onClose, action, setIsOpenDialog, } = props;
11
+ const { closeToast, imageSrc, title, description, onClose, action, setIsOpenDialog, imageHeight, } = props;
11
12
  const { isMobile } = (0, useViewportType_1.useViewportType)();
13
+ const containerStyle = {
14
+ '--banner-image-height': (0, formatCssSize_1.formatCssSize)(imageHeight),
15
+ };
12
16
  const handleClose = () => {
13
17
  closeToast?.();
14
18
  onClose?.();
@@ -17,6 +21,6 @@ const BannerTemplate = (props) => {
17
21
  closeToast?.();
18
22
  setIsOpenDialog?.(false);
19
23
  };
20
- return ((0, jsx_runtime_1.jsxs)(styles_1.Container, { children: [imageSrc && (0, jsx_runtime_1.jsx)(styles_1.Image, { src: imageSrc }), (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { container: true, children: [(0, jsx_runtime_1.jsxs)(styles_1.WrapperTextContent, { container: true, children: [title && (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "h4", children: title }), description && ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", children: description }))] }), (0, jsx_runtime_1.jsxs)(styles_1.Footer, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: handleClose, variant: "text", size: "large", children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C" })), action?.({ closeBanner: handleCloseForAction })] })] })] }));
24
+ return ((0, jsx_runtime_1.jsxs)(styles_1.Container, { style: containerStyle, children: [imageSrc && (0, jsx_runtime_1.jsx)(styles_1.Image, { src: imageSrc }), (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { container: true, children: [(0, jsx_runtime_1.jsxs)(styles_1.WrapperTextContent, { container: true, children: [title && (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "h4", children: title }), description && ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", children: description }))] }), (0, jsx_runtime_1.jsxs)(styles_1.Footer, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: handleClose, variant: "text", size: "large", children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C" })), action?.({ closeBanner: handleCloseForAction })] })] })] }));
21
25
  };
22
26
  exports.BannerTemplate = BannerTemplate;
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Footer = exports.WrapperTextContent = exports.Wrapper = exports.Image = exports.Container = void 0;
4
4
  const Grid_1 = require("../../Grid");
5
5
  const styled_1 = require("../../styled");
6
+ const constants_1 = require("../constants");
6
7
  exports.Container = styled_1.styled.article `
8
+ --banner-image-height: ${constants_1.BANNER_DEFAULT_IMAGE_HEIGHT};
9
+
7
10
  width: 100%;
8
11
  height: 100%;
9
12
 
@@ -14,12 +17,15 @@ exports.Image = styled_1.styled.img `
14
17
 
15
18
  width: 100%;
16
19
  max-width: 100%;
17
- height: 160px;
20
+ height: var(--banner-image-height);
18
21
  max-height: 100%;
19
22
 
20
23
  object-fit: contain;
21
24
 
22
25
  ${({ theme }) => theme.breakpoints.down('mobile')} {
26
+ /* На mobile высота изображения фиксированная, imageHeight не применяется */
27
+ height: ${constants_1.BANNER_DEFAULT_IMAGE_HEIGHT};
28
+
23
29
  object-fit: cover;
24
30
  }
25
31
  `;
@@ -1,3 +1,5 @@
1
+ export declare const BANNER_DEFAULT_WIDTH = "400px";
2
+ export declare const BANNER_DEFAULT_IMAGE_HEIGHT = "160px";
1
3
  export declare const bannerClassnames: {
2
4
  root: string;
3
5
  };
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bannerClassnames = void 0;
3
+ exports.bannerClassnames = exports.BANNER_DEFAULT_IMAGE_HEIGHT = exports.BANNER_DEFAULT_WIDTH = void 0;
4
4
  const createUIKitClassname_1 = require("../utils/createUIKitClassname");
5
+ exports.BANNER_DEFAULT_WIDTH = '400px';
6
+ exports.BANNER_DEFAULT_IMAGE_HEIGHT = '160px';
5
7
  exports.bannerClassnames = {
6
8
  root: (0, createUIKitClassname_1.createUIKitClassname)('banner'),
7
9
  };
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  import { type ToastProps } from 'react-toastify-next/dist/types';
3
3
  export type ActionParams = {
4
4
  closeBanner: () => void;
@@ -35,4 +35,14 @@ export type BannerProps = {
35
35
  * Обработчик, для выполнения дополнительных действий при закрытии(например, снятие метрик)
36
36
  */
37
37
  onClose?: () => void;
38
+ /**
39
+ * Ширина баннера. Число задаётся в пикселях. На mobile не применяется
40
+ * @default 400px
41
+ */
42
+ width?: CSSProperties['width'];
43
+ /**
44
+ * Высота изображения. Число задаётся в пикселях. На mobile не применяется
45
+ * @default 160px
46
+ */
47
+ imageHeight?: CSSProperties['height'];
38
48
  } & Pick<ToastProps, 'containerId'>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const useViewportType_1 = require("../../useViewportType");
5
5
  const cn_1 = require("../../utils/cn");
6
- const getCssSize_1 = require("../../utils/getCssSize");
6
+ const formatCssSize_1 = require("../../utils/formatCssSize");
7
7
  const constants_1 = require("../constants");
8
8
  const useLogic = ({ onClose, disableBackdropClick, classes, disableMobileDrawer, height, width, }) => {
9
9
  const { isMobile } = (0, useViewportType_1.useViewportType)();
@@ -20,8 +20,8 @@ const useLogic = ({ onClose, disableBackdropClick, classes, disableMobileDrawer,
20
20
  ...restClasses,
21
21
  };
22
22
  const dialogCssVars = {
23
- '--dialog-width': (0, getCssSize_1.getCssSize)(width),
24
- '--dialog-height': (0, getCssSize_1.getCssSize)(height),
23
+ '--dialog-width': (0, formatCssSize_1.formatCssSize)(width),
24
+ '--dialog-height': (0, formatCssSize_1.formatCssSize)(height),
25
25
  };
26
26
  return {
27
27
  dialogCssVars,
@@ -44,7 +44,7 @@ exports.Wrapper = (0, styled_1.styled)('div', {
44
44
  position: fixed;
45
45
  z-index: ${theme.zIndex.snackbar};
46
46
  right: 0;
47
- bottom: 0;
47
+ bottom: calc(var(--toastify-toast-bottom, 16px) + ${theme.spacing(1)});
48
48
  width: 432px;
49
49
  `}
50
50
  }
@@ -91,6 +91,10 @@ exports.Wrapper = (0, styled_1.styled)('div', {
91
91
  }
92
92
  ${({ theme }) => theme.breakpoints.up('mobile')} {
93
93
  min-height: ${constants_1.NOTIFY_HEIGHT};
94
+
95
+ &:last-child {
96
+ margin-bottom: 0;
97
+ }
94
98
  }
95
99
  ${({ theme }) => theme.breakpoints.down('mobile')} {
96
100
  min-height: ${constants_1.NOTIFY_HEIGHT_MOBILE};
@@ -146,10 +150,12 @@ exports.Inner = (0, styled_1.styled)(react_toastify_next_1.ToastContainer, {
146
150
  position: relative !important;
147
151
  right: 0 !important;
148
152
  bottom: 0 !important;
149
- width: 100%;
150
- max-width: 432px;
153
+ width: 400px;
154
+ max-width: 400px;
155
+ margin-right: var(--toastify-toast-right, 16px);
156
+ margin-left: auto;
151
157
  padding-bottom: 0 !important;
152
- padding-left: ${theme.spacing(3)} !important;
158
+ padding-left: ${theme.spacing(1)} !important;
153
159
  `}
154
160
  }
155
161
 
@@ -408,8 +408,10 @@ exports.Inner = (0, styled_1.styled)(react_toastify_next_1.ToastContainer) `
408
408
  .${constants_2.notifyClassnames.root} {
409
409
  border-radius: ${({ theme }) => theme.shape.medium};
410
410
 
411
- &:last-of-type{
412
- margin-bottom: ${({ theme }) => theme.spacing(1)} ;
411
+ ${({ theme }) => theme.breakpoints.up('mobile')} {
412
+ &:last-of-type {
413
+ margin-bottom: 0;
414
+ }
413
415
  }
414
416
  }
415
417
 
@@ -430,6 +432,10 @@ exports.Inner = (0, styled_1.styled)(react_toastify_next_1.ToastContainer) `
430
432
  margin-bottom: ${({ theme }) => theme.spacing(1)} !important;
431
433
 
432
434
  opacity: 1 !important;
435
+
436
+ &:last-of-type {
437
+ margin-bottom: 0 !important;
438
+ }
433
439
  }
434
440
 
435
441
  .${constants_2.notifyClassnames.root}__content {
@@ -483,6 +489,7 @@ exports.CloseButton = (0, styled_1.styled)(Button_1.Button) `
483
489
  right: ${({ theme }) => theme.spacing(3)};
484
490
 
485
491
  width: 400px;
492
+ margin-top: ${({ theme }) => theme.spacing(1)};
486
493
  margin-left: ${({ theme }) => theme.spacing(6)};
487
494
 
488
495
  box-shadow: ${({ theme }) => theme.elevation[300]};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Приводит размер к строке для CSS: число считается в пикселях, строка возвращается как есть.
3
+ * Нужна для CSS-переменных, к которым React не добавляет px автоматически
4
+ * @example formatCssSize(320) // '320px'
5
+ * @example formatCssSize('50%') // '50%'
6
+ */
7
+ export declare const formatCssSize: (value?: number | string) => string | undefined;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatCssSize = void 0;
4
+ /**
5
+ * Приводит размер к строке для CSS: число считается в пикселях, строка возвращается как есть.
6
+ * Нужна для CSS-переменных, к которым React не добавляет px автоматически
7
+ * @example formatCssSize(320) // '320px'
8
+ * @example formatCssSize('50%') // '50%'
9
+ */
10
+ const formatCssSize = (value) => typeof value === 'number' ? `${value}px` : value;
11
+ exports.formatCssSize = formatCssSize;
@@ -0,0 +1 @@
1
+ export * from './formatCssSize';
@@ -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("./formatCssSize"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.122.1",
3
+ "version": "4.123.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {
@@ -1,4 +0,0 @@
1
- /**
2
- * Добавляет px к числу, сохраняет строки с CSS-размерами и undefined.
3
- */
4
- export declare const getCssSize: (value?: string | number) => string | undefined;
@@ -1,4 +0,0 @@
1
- /**
2
- * Добавляет px к числу, сохраняет строки с CSS-размерами и undefined.
3
- */
4
- export const getCssSize = (value) => typeof value === 'number' ? `${value}px` : value;
@@ -1 +0,0 @@
1
- export { getCssSize } from './getCssSize';
@@ -1 +0,0 @@
1
- export { getCssSize } from './getCssSize';
@@ -1,4 +0,0 @@
1
- /**
2
- * Добавляет px к числу, сохраняет строки с CSS-размерами и undefined.
3
- */
4
- export declare const getCssSize: (value?: string | number) => string | undefined;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCssSize = void 0;
4
- /**
5
- * Добавляет px к числу, сохраняет строки с CSS-размерами и undefined.
6
- */
7
- const getCssSize = (value) => typeof value === 'number' ? `${value}px` : value;
8
- exports.getCssSize = getCssSize;
@@ -1 +0,0 @@
1
- export { getCssSize } from './getCssSize';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCssSize = void 0;
4
- var getCssSize_1 = require("./getCssSize");
5
- Object.defineProperty(exports, "getCssSize", { enumerable: true, get: function () { return getCssSize_1.getCssSize; } });