@astral/ui 4.122.2 → 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 (37) 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 +13 -4
  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/utils/formatCssSize/formatCssSize.d.ts +7 -0
  12. package/components/utils/formatCssSize/formatCssSize.js +7 -0
  13. package/components/utils/formatCssSize/index.d.ts +1 -0
  14. package/components/utils/formatCssSize/index.js +1 -0
  15. package/node/components/Banner/Banner.d.ts +1 -1
  16. package/node/components/Banner/Banner.js +4 -1
  17. package/node/components/Banner/BannerContainer/styles.js +12 -3
  18. package/node/components/Banner/BannerTemplate/BannerTemplate.d.ts +5 -1
  19. package/node/components/Banner/BannerTemplate/BannerTemplate.js +6 -2
  20. package/node/components/Banner/BannerTemplate/styles.js +7 -1
  21. package/node/components/Banner/constants.d.ts +2 -0
  22. package/node/components/Banner/constants.js +3 -1
  23. package/node/components/Banner/types.d.ts +11 -1
  24. package/node/components/Dialog/useLogic/useLogic.js +3 -3
  25. package/node/components/utils/formatCssSize/formatCssSize.d.ts +7 -0
  26. package/node/components/utils/formatCssSize/formatCssSize.js +11 -0
  27. package/node/components/utils/formatCssSize/index.d.ts +1 -0
  28. package/node/components/utils/formatCssSize/index.js +17 -0
  29. package/package.json +1 -1
  30. package/components/utils/getCssSize/getCssSize.d.ts +0 -4
  31. package/components/utils/getCssSize/getCssSize.js +0 -4
  32. package/components/utils/getCssSize/index.d.ts +0 -1
  33. package/components/utils/getCssSize/index.js +0 -1
  34. package/node/components/utils/getCssSize/getCssSize.d.ts +0 -4
  35. package/node/components/utils/getCssSize/getCssSize.js +0 -8
  36. package/node/components/utils/getCssSize/index.d.ts +0 -1
  37. 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,22 +1,31 @@
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
+ --banner-width: ${BANNER_DEFAULT_WIDTH};
6
+
5
7
  /* Базовые стили Toastify могут подключиться после стилей контейнера. */
6
8
  && {
7
9
  position: relative;
8
10
  right: 0;
9
11
  bottom: 0;
10
12
 
13
+ /* Баннер может быть шире контейнера уведомлений, поэтому выравниваем его по правому краю, а лишнее уходит влево */
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: flex-end;
17
+
11
18
  width: 100%;
12
- min-width: 400px;
13
- max-width: 432px;
19
+ padding-right: ${({ theme }) => theme.spacing(5)};
14
20
  padding-bottom: 0;
15
21
  padding-left: ${({ theme }) => theme.spacing(3)};
16
22
  }
17
23
 
18
24
  .${bannerClassnames.root} {
19
- width: 400px;
25
+ flex-shrink: 0;
26
+
27
+ width: var(--banner-width);
28
+ max-width: calc(100vw - ${({ theme }) => theme.spacing(10)});
20
29
  height: auto;
21
30
  padding: 0;
22
31
 
@@ -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,
@@ -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,21 +5,30 @@ 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
+ --banner-width: ${constants_1.BANNER_DEFAULT_WIDTH};
9
+
8
10
  /* Базовые стили Toastify могут подключиться после стилей контейнера. */
9
11
  && {
10
12
  position: relative;
11
13
  right: 0;
12
14
  bottom: 0;
13
15
 
16
+ /* Баннер может быть шире контейнера уведомлений, поэтому выравниваем его по правому краю, а лишнее уходит влево */
17
+ display: flex;
18
+ flex-direction: column;
19
+ align-items: flex-end;
20
+
14
21
  width: 100%;
15
- min-width: 400px;
16
- max-width: 432px;
22
+ padding-right: ${({ theme }) => theme.spacing(5)};
17
23
  padding-bottom: 0;
18
24
  padding-left: ${({ theme }) => theme.spacing(3)};
19
25
  }
20
26
 
21
27
  .${constants_1.bannerClassnames.root} {
22
- width: 400px;
28
+ flex-shrink: 0;
29
+
30
+ width: var(--banner-width);
31
+ max-width: calc(100vw - ${({ theme }) => theme.spacing(10)});
23
32
  height: auto;
24
33
  padding: 0;
25
34
 
@@ -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,
@@ -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.2",
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; } });