@skbkontur/side-menu 5.0.0-alpha.4 → 5.0.0-beta.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/CHANGELOG.md +26 -0
  2. package/README.md +2 -2
  3. package/internal/themes/SideMenuDarkTheme.js +7 -6
  4. package/internal/themes/SideMenuTheme.d.ts +16 -0
  5. package/internal/themes/SideMenuTheme.js +38 -8
  6. package/lib/theming/ThemeHelpers.js +4 -0
  7. package/package.json +7 -7
  8. package/src/SideMenu/SideMenu.d.ts +1 -0
  9. package/src/SideMenu/SideMenu.js +17 -19
  10. package/src/SideMenu/SideMenu.styles.d.ts +1 -2
  11. package/src/SideMenu/SideMenu.styles.js +12 -18
  12. package/src/SideMenuBody/SideMenuBody.js +27 -2
  13. package/src/SideMenuBody/SideMenuBody.styles.js +2 -2
  14. package/src/SideMenuDivider/SideMenuDivider.js +4 -2
  15. package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -0
  16. package/src/SideMenuDivider/SideMenuDivider.styles.js +6 -3
  17. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +2 -2
  18. package/src/SideMenuFooter/SideMenuFooter.js +3 -2
  19. package/src/SideMenuFooter/SideMenuFooter.styles.js +3 -3
  20. package/src/SideMenuHeader/SideMenuHeader.styles.js +1 -1
  21. package/src/SideMenuNotifications/BellWidget.js +13 -6
  22. package/src/SideMenuNotifications/BellWidgetError.js +6 -3
  23. package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +7 -4
  24. package/src/SideMenuNotifications/BellWidgetView.styles.js +20 -9
  25. package/src/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +11 -0
  26. package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +10 -0
  27. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -0
  28. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -0
  29. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +5 -2
  30. package/src/internal/ClickableElement.js +13 -9
  31. package/src/internal/ItemContent/Caption.js +4 -4
  32. package/src/internal/ItemContent/Caption.styles.d.ts +2 -0
  33. package/src/internal/ItemContent/Caption.styles.js +13 -7
  34. package/src/internal/ItemContent/Icon.styles.js +2 -1
  35. package/src/internal/ItemContent/ItemContent.js +3 -1
  36. package/src/internal/SideMenuLogotype.js +24 -3
  37. package/src/internal/SideMenuLogotype.styles.js +3 -3
@@ -1,12 +1,12 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
3
- import { transitionDuration } from '../SideMenu/SideMenu.js';
3
+ import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
4
4
  export var getStyles = memoizeGetStyles(function (_a) {
5
5
  var css = _a.css, injectGlobal = _a.injectGlobal;
6
6
  var _unused = injectGlobal(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n [data-tid='MenuItem']:active {\n background: rgba(0, 0, 0, 0.1) !important;\n transition: background 80ms ease-out;\n }\n "], ["\n [data-tid='MenuItem']:active {\n background: rgba(0, 0, 0, 0.1) !important;\n transition: background 80ms ease-out;\n }\n "])));
7
7
  return {
8
8
  label: function (t) {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ease-out;\n "], ["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ease-out;\n "])), t.sideMenuWidth, t.sideMenuItemsMarginX, transitionDuration);
9
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ", ";\n "], ["\n width: calc(\n ", " - 2 * ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n min-width: 0;\n transition: width ", "ms ", ";\n "])), t.sideMenuWidth, t.sideMenuItemsMarginX, transitionDuration, transitionEasing);
10
10
  },
11
11
  labelTouchScreen: function (t) {
12
12
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: calc(\n ", " - 2 *\n ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n "], ["\n width: calc(\n ", " - 2 *\n ", " - var(--side-menu-footer-trailing-reserved-width, 0px)\n );\n "])), t.sideMenuWidthTouchScreen, t.sideMenuItemsMarginX);
@@ -7,7 +7,7 @@ import React, { forwardRef, useContext, useEffect, useLayoutEffect, useRef, useS
7
7
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
8
8
  import { flattenChildren } from '../../lib/utils/scripts.js';
9
9
  import { SideMenuDataTids } from '../../SideMenuDataTids.js';
10
- import { transitionDuration } from '../SideMenu/SideMenu.js';
10
+ import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
11
11
  import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
12
12
  import { SideMenuContext } from '../SideMenuContext.js';
13
13
  import { getStyles } from './SideMenuFooter.styles.js';
@@ -43,7 +43,7 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
43
43
  if (offset && !prefersReducedMotion) {
44
44
  node.animate([{ transform: "translateY(".concat(offset, "px)") }, { transform: 'translateY(0)' }], {
45
45
  duration: transitionDuration,
46
- easing: 'ease-out',
46
+ easing: transitionEasing,
47
47
  });
48
48
  }
49
49
  }, [context.isOpened]);
@@ -64,6 +64,7 @@ var SideMenuFooterInner = forwardRef(function (_a, ref) {
64
64
  if (!isTabletOrMobile || context.isOpened) {
65
65
  return (React.createElement("footer", __assign({ "data-tid": SideMenuDataTids.footer, "data-visual-state-fixed": isFixed, className: cx(styles.root(theme), (_b = {},
66
66
  _b[styles.rootLarge(theme)] = isLarge,
67
+ _b[sideMenuStyles.itemsContainerOpened(theme)] = context.isOpened && !isEmpty,
67
68
  _b[sideMenuStyles.itemsContainerCollapsed(theme)] = !context.isOpened || isEmpty,
68
69
  _b[sideMenuStyles.itemsContainerCollapsedLarge(theme)] = (!context.isOpened || isEmpty) && isLarge,
69
70
  _b[styles.rootFixed(theme)] = isFixed,
@@ -1,11 +1,11 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
3
- import { transitionDuration } from '../SideMenu/SideMenu.js';
3
+ import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
4
4
  export var getStyles = memoizeGetStyles(function (_a) {
5
5
  var css = _a.css;
6
6
  return ({
7
7
  root: function (t) {
8
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n transition: margin ", "ms ease-out;\n "], ["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n transition: margin ", "ms ease-out;\n "])), t.sideMenuFooterPaddingBottom, t.sideMenuFooterPaddingTop, t.sideMenuItemsMarginX, transitionDuration);
8
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n transition: margin ", "ms ", ";\n "], ["\n display: flex;\n flex-direction: column;\n flex-grow: 0;\n position: sticky;\n bottom: 0;\n padding-bottom: ", ";\n padding-top: ", ";\n margin: 0 ", ";\n background-color: inherit;\n transition: margin ", "ms ", ";\n "])), t.sideMenuFooterPaddingBottom, t.sideMenuFooterPaddingTop, t.sideMenuItemsMarginX, transitionDuration, transitionEasing);
9
9
  },
10
10
  rootLarge: function (t) {
11
11
  return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-bottom: ", ";\n "], ["\n padding-bottom: ", ";\n "])), t.sideMenuFooterPaddingBottomLarge);
@@ -36,7 +36,7 @@ export var getStyles = memoizeGetStyles(function (_a) {
36
36
  },
37
37
  // Разделитель выравнивается по разделителю шапки, а не по краям пунктов
38
38
  rootFixed: function (t) {
39
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n height: 1px;\n background: ", ";\n }\n "], ["\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n height: 1px;\n background: ", ";\n }\n "])), t.sideMenuMarginX, t.sideMenuItemsMarginX, t.sideMenuMarginX, t.sideMenuItemsMarginX, t.sideMenuFooterDividerColor);
39
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n border-top: 1px solid ", ";\n }\n "], ["\n &::before {\n content: '';\n position: absolute;\n top: 0;\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n border-top: 1px solid ", ";\n }\n "])), t.sideMenuMarginX, t.sideMenuItemsMarginX, t.sideMenuMarginX, t.sideMenuItemsMarginX, t.sideMenuFooterDividerColor);
40
40
  },
41
41
  rootFixedCollapsed: function (t) {
42
42
  return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n &::before {\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n }\n "], ["\n &::before {\n left: calc(", " - ", ");\n right: calc(", " - ", ");\n }\n "])), t.sideMenuMarginX, t.sideMenuItemsMarginXCollapsed, t.sideMenuMarginX, t.sideMenuItemsMarginXCollapsed);
@@ -19,7 +19,7 @@ export var getStyles = memoizeGetStyles(function (_a) {
19
19
  return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", ";\n z-index: 9000;\n "], ["\n background: ", ";\n z-index: 9000;\n "])), t.sideMenuSeparatedSubMenuBg);
20
20
  },
21
21
  fixedRoot: function (t) {
22
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n box-shadow: 0 1px 0 ", ";\n "], ["\n box-shadow: 0 1px 0 ", ";\n "])), t.sideMenuHeaderDividerColor);
22
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n &::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n bottom: -1px;\n border-top: 1px solid ", ";\n }\n "], ["\n &::after {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n bottom: -1px;\n border-top: 1px solid ", ";\n }\n "])), t.sideMenuHeaderDividerColor);
23
23
  },
24
24
  });
25
25
  });
@@ -2,7 +2,6 @@ import { __awaiter, __generator } from "tslib";
2
2
  import { IconXRegular20 } from '@skbkontur/icons/IconXRegular20';
3
3
  import { createFailure, createSuccess, isFailure } from '@skbkontur/operation-result';
4
4
  import { Button } from '@skbkontur/react-ui/components/Button/Button';
5
- import { Center } from '@skbkontur/react-ui/components/Center/Center';
6
5
  import { Spinner } from '@skbkontur/react-ui/components/Spinner/Spinner';
7
6
  import { useStyles, useEmotion } from '@skbkontur/react-ui/lib/renderEnvironment';
8
7
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
@@ -11,9 +10,11 @@ import React, { useContext } from 'react';
11
10
  import { SideMenuTheme } from '../../internal/themes/SideMenuTheme.js';
12
11
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
13
12
  import { SideMenuDataTids } from '../../SideMenuDataTids.js';
13
+ import { SideMenuContext } from '../SideMenuContext.js';
14
14
  import { BellWidgetError } from './BellWidgetError.js';
15
15
  import { getCustomStyles, getStyles } from './BellWidgetView.styles.js';
16
16
  import { BELL_SIDE_MENU_DATA_ITEM } from './SideMenuNotifications.js';
17
+ import { getWrapperHeightClass } from './utils/getWrapperHeightClass.js';
17
18
  var getBtnTopPosition = function () {
18
19
  var _a;
19
20
  var bellDropDownItem = document.querySelector("[data-item=\"".concat(BELL_SIDE_MENU_DATA_ITEM, "\"]"));
@@ -22,6 +23,8 @@ var getBtnTopPosition = function () {
22
23
  export var BellWidget = function (props) {
23
24
  var widgetApi = props.widgetApi, onClose = props.onClose, renderErrorButton = props.renderErrorButton, renderErrorMessage = props.renderErrorMessage, onError = props.onError, redirect = props.redirect;
24
25
  var theme = getSideMenuTheme(useContext(ThemeContext));
26
+ var context = useContext(SideMenuContext);
27
+ var isMobile = Boolean(context.isMobile);
25
28
  var styles = useStyles(getStyles);
26
29
  var customStyles = useStyles(getCustomStyles);
27
30
  var cx = useEmotion().cx;
@@ -72,16 +75,20 @@ export var BellWidget = function (props) {
72
75
  var buttonCloseTheme = {
73
76
  btnBorderRadiusMedium: '20px',
74
77
  };
75
- var wrapperHeightClass = hasCustomWrapperHeight
76
- ? customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight)
77
- : customStyles.defaultHeight(btnTopPosition);
78
- return (React.createElement("div", { className: cx(styles.root(), wrapperHeightClass) },
78
+ var wrapperHeightClass = getWrapperHeightClass({
79
+ hasCustomWrapperHeight: hasCustomWrapperHeight,
80
+ theme: theme,
81
+ isMobile: isMobile,
82
+ btnTopPosition: btnTopPosition,
83
+ customStyles: customStyles,
84
+ });
85
+ return (React.createElement("div", { className: cx(styles.root(), isMobile ? styles.rootMobile() : styles.rootDesktop(), wrapperHeightClass) },
79
86
  React.createElement("div", { className: styles.header(), "data-tid": SideMenuDataTids.bellHeader },
80
87
  React.createElement("span", { className: styles.headerText() }, "\u0423\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F"),
81
88
  React.createElement(Button, { use: "text", size: "medium", width: 40, icon: React.createElement(IconXRegular20, null), onClick: onClose, theme: buttonCloseTheme, "data-tid": SideMenuDataTids.bellCloseButton, "aria-label": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F" })),
82
89
  React.createElement(WidgetRenderer, { renderWidget: renderWidget, renderFault: function (_a) {
83
90
  var fault = _a.fault, retryRender = _a.retryRender;
84
91
  return (React.createElement(BellWidgetError, { renderErrorButton: renderErrorButton, error: fault, renderErrorMessage: renderErrorMessage, retryRender: retryRender }));
85
- }, loader: React.createElement(Center, null,
92
+ }, loader: React.createElement("div", { className: styles.centeredContent() },
86
93
  React.createElement(Spinner, { caption: "\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u0443\u0432\u0435\u0434\u043E\u043C\u043B\u0435\u043D\u0438\u044F..." })) })));
87
94
  };
@@ -1,19 +1,22 @@
1
+ import * as colors from '@skbkontur/colors/tokens-default/light';
1
2
  import { EmptyState } from '@skbkontur/empty-state';
2
3
  import { IconArrowUiAuthLoginRegular64 } from '@skbkontur/icons/IconArrowUiAuthLoginRegular64';
3
4
  import { IconWarningTriangleSolid64 } from '@skbkontur/icons/IconWarningTriangleSolid64';
4
- import { Center } from '@skbkontur/react-ui/components/Center/Center';
5
+ import { useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
5
6
  import React from 'react';
7
+ import { getStyles } from './BellWidgetView.styles.js';
6
8
  import { getErrorMessages } from './utils/getNotificationsErrorMessages.js';
7
9
  export var BellWidgetError = function (_a) {
8
10
  var renderErrorButton = _a.renderErrorButton, error = _a.error, renderErrorMessage = _a.renderErrorMessage, retryRender = _a.retryRender;
11
+ var styles = useStyles(getStyles);
9
12
  if (renderErrorMessage) {
10
13
  return React.createElement(React.Fragment, null, renderErrorMessage(error, retryRender));
11
14
  }
12
15
  var isNotAuthorizedError = error.type === 'userNotAuthorized';
13
16
  var errorButton = renderErrorButton === null || renderErrorButton === void 0 ? void 0 : renderErrorButton(error, retryRender);
14
17
  var _b = getErrorMessages(isNotAuthorizedError), titleMessage = _b.titleMessage, errorMessage = _b.errorMessage;
15
- var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color: "#FCB73E" })) : (React.createElement(IconWarningTriangleSolid64, { color: "#FCB73E" }));
16
- return (React.createElement(Center, null,
18
+ var icon = isNotAuthorizedError ? (React.createElement(IconArrowUiAuthLoginRegular64, { color: colors.shapeBoldWarning })) : (React.createElement(IconWarningTriangleSolid64, { color: colors.shapeBoldWarning }));
19
+ return (React.createElement("div", { className: styles.centeredContent() },
17
20
  React.createElement(EmptyState, { use: "status" },
18
21
  React.createElement(EmptyState.Header, { icon: icon }, titleMessage),
19
22
  React.createElement(EmptyState.Body, null, errorMessage),
@@ -1,13 +1,16 @@
1
1
  import { type Emotion } from '../../lib/theming/ThemeHelpers.js';
2
2
  export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").StylesGetter<{
3
3
  root(): string;
4
+ rootMobile(): string;
5
+ rootDesktop(): string;
4
6
  widgetWrapper(): string;
7
+ centeredContent(): string;
5
8
  header(): string;
6
9
  headerText(): string;
7
10
  }>;
8
- interface CustomStyles {
9
- defaultHeight: (offsetTop: number) => string;
10
- customHeight: (value: string) => string;
11
+ export interface CustomStyles {
12
+ defaultHeightDesktop: (offsetTop: number) => string;
13
+ defaultHeightMobile: (mobilePopupHeightOffset: string) => string;
14
+ customHeight: (value?: string) => string;
11
15
  }
12
16
  export declare const getCustomStyles: ({ css }: Emotion) => CustomStyles;
13
- export {};
@@ -4,31 +4,42 @@ export var getStyles = memoizeGetStyles(function (_a) {
4
4
  var css = _a.css;
5
5
  return ({
6
6
  root: function () {
7
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n width: 100%;\n max-width: 100vw;\n\n @media (min-width: 768px) {\n width: 448px;\n }\n "], ["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n width: 100%;\n max-width: 100vw;\n\n @media (min-width: 768px) {\n width: 448px;\n }\n "])));
7
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n max-width: 100vw;\n "], ["\n display: flex;\n flex-direction: column;\n min-height: 400px;\n max-height: 784px;\n max-width: 100vw;\n "])));
8
+ },
9
+ rootMobile: function () {
10
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "])));
11
+ },
12
+ rootDesktop: function () {
13
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 448px;\n "], ["\n width: 448px;\n "])));
8
14
  },
9
15
  widgetWrapper: function () {
10
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n min-height: 0;\n flex-grow: 1;\n "], ["\n min-height: 0;\n flex-grow: 1;\n "])));
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 0;\n flex-grow: 1;\n "], ["\n min-height: 0;\n flex-grow: 1;\n "])));
17
+ },
18
+ centeredContent: function () {
19
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n min-height: 0;\n overflow: auto;\n align-items: center;\n justify-content: center;\n "], ["\n display: flex;\n flex: 1;\n min-height: 0;\n overflow: auto;\n align-items: center;\n justify-content: center;\n "])));
11
20
  },
12
21
  header: function () {
13
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "], ["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "])));
22
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "], ["\n display: flex;\n padding: 6px 6px 0 20px;\n align-items: center;\n justify-content: space-between;\n "])));
14
23
  },
15
24
  headerText: function () {
16
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "], ["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "])));
25
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "], ["\n font-size: 18px;\n line-height: 24px;\n font-weight: 700;\n "])));
17
26
  },
18
27
  });
19
28
  });
20
29
  export var getCustomStyles = function (_a) {
21
30
  var css = _a.css;
22
31
  return ({
23
- defaultHeight: function (offsetTop) {
24
- if (offsetTop === void 0) { offsetTop = 0; }
32
+ defaultHeightDesktop: function (offsetTop) {
25
33
  var offsetBottom = '20px';
26
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: calc(100vh - ", "px - ", ");\n "], ["\n height: calc(100vh - ", "px - ", ");\n "])), offsetTop, offsetBottom);
34
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n height: calc(100vh - ", "px - ", ");\n "], ["\n height: calc(100vh - ", "px - ", ");\n "])), offsetTop, offsetBottom);
35
+ },
36
+ defaultHeightMobile: function (mobilePopupHeightOffset) {
37
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n height: calc(100vh - (", "));\n max-height: calc(100vh - (", "));\n\n @supports (height: 100dvh) {\n height: calc(100dvh - (", "));\n max-height: calc(100dvh - (", "));\n }\n "], ["\n height: calc(100vh - (", "));\n max-height: calc(100vh - (", "));\n\n @supports (height: 100dvh) {\n height: calc(100dvh - (", "));\n max-height: calc(100dvh - (", "));\n }\n "])), mobilePopupHeightOffset, mobilePopupHeightOffset, mobilePopupHeightOffset, mobilePopupHeightOffset);
27
38
  },
28
39
  customHeight: function (value) {
29
40
  if (value === void 0) { value = ''; }
30
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), value);
41
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), value);
31
42
  },
32
43
  });
33
44
  };
34
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
45
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -0,0 +1,11 @@
1
+ import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes.js';
2
+ import type { CustomStyles } from '../BellWidgetView.styles.js';
3
+ interface GetWrapperHeightClassParameters {
4
+ hasCustomWrapperHeight: boolean;
5
+ theme: SideMenuTheme;
6
+ isMobile: boolean;
7
+ btnTopPosition: number;
8
+ customStyles: CustomStyles;
9
+ }
10
+ export declare const getWrapperHeightClass: ({ hasCustomWrapperHeight, theme, isMobile, btnTopPosition, customStyles, }: GetWrapperHeightClassParameters) => string;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ export var getWrapperHeightClass = function (_a) {
2
+ var hasCustomWrapperHeight = _a.hasCustomWrapperHeight, theme = _a.theme, isMobile = _a.isMobile, btnTopPosition = _a.btnTopPosition, customStyles = _a.customStyles;
3
+ if (hasCustomWrapperHeight) {
4
+ return customStyles.customHeight(theme.sideMenuNotificationsWrapperHeight);
5
+ }
6
+ if (isMobile) {
7
+ return customStyles.defaultHeightMobile(theme.sideMenuNotificationsMobilePopupHeightOffset);
8
+ }
9
+ return customStyles.defaultHeightDesktop(btnTopPosition);
10
+ };
@@ -16,6 +16,7 @@ var SideMenuSubItemHeaderInner = forwardRef(function (_a, ref) {
16
16
  _b[styles.rootWithoutItemIcons(theme)] = context.isOpened && !context.isSeparatedMenu && !context.hasItemIcons,
17
17
  _b[styles.rootInDropdown()] = !context.isOpened && !context.isSeparatedMenu,
18
18
  _b[styles.rootInSeparatedSubMenu(theme)] = context.isSeparatedMenu,
19
+ _b[styles.rootInSeparatedSubMenuLarge(theme)] = context.isSeparatedMenu && context.size === 'large',
19
20
  _b), className), ref: ref }, rest), children));
20
21
  });
21
22
  SideMenuSubItemHeaderInner.displayName = 'SideMenuSubItemHeader';
@@ -3,5 +3,6 @@ export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").Styl
3
3
  root(t: SideMenuTheme): string;
4
4
  rootWithoutItemIcons(t: SideMenuTheme): string;
5
5
  rootInDropdown(): string;
6
+ rootInSeparatedSubMenuLarge(t: SideMenuTheme): string;
6
7
  rootInSeparatedSubMenu(t: SideMenuTheme): string;
7
8
  }>;
@@ -12,9 +12,12 @@ export var getStyles = memoizeGetStyles(function (_a) {
12
12
  rootInDropdown: function () {
13
13
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 12px 8px 4px 8px;\n "], ["\n padding: 12px 8px 4px 8px;\n "])));
14
14
  },
15
+ rootInSeparatedSubMenuLarge: function (t) {
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuSubItemHeaderFontSizeLargeInSeparatedSubMenu, t.sideMenuSubItemHeaderLineHeightLargeInSeparatedSubMenu);
17
+ },
15
18
  rootInSeparatedSubMenu: function (t) {
16
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding: ", ";\n line-height: 16px;\n color: ", ";\n "], ["\n padding: ", ";\n line-height: 16px;\n color: ", ";\n "])), t.sideMenuSubItemHeaderPaddingInSeparatedSubMenu, t.sideMenuSubItemHeaderColorInSeparatedSubMenu);
19
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding: ", ";\n line-height: 16px;\n color: ", ";\n "], ["\n padding: ", ";\n line-height: 16px;\n color: ", ";\n "])), t.sideMenuSubItemHeaderPaddingInSeparatedSubMenu, t.sideMenuSubItemHeaderColorInSeparatedSubMenu);
17
20
  },
18
21
  });
19
22
  });
20
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
23
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -21,6 +21,7 @@ var ClickableElementWithHint = function (_a) {
21
21
  var _b = __read(useState(false), 2), hovered = _b[0], setHovered = _b[1];
22
22
  var _c = __read(useState(false), 2), focused = _c[0], setFocused = _c[1];
23
23
  var _d = __read(useState(false), 2), tabFocused = _d[0], setTabFocused = _d[1];
24
+ var _e = __read(useState(false), 2), isTruncated = _e[0], setIsTruncated = _e[1];
24
25
  useEffect(function () {
25
26
  var handleKeyDown = function (e) {
26
27
  if (e.key === 'Tab') {
@@ -37,6 +38,10 @@ var ClickableElementWithHint = function (_a) {
37
38
  window.removeEventListener('blur', handleBlur);
38
39
  };
39
40
  }, []);
41
+ var checkTruncated = useCallback(function (element) {
42
+ var caption = element.querySelector('[data-tail]');
43
+ setIsTruncated(!!caption && caption.scrollWidth > caption.clientWidth);
44
+ }, []);
40
45
  var handleMouseEnter = useCallback(function () { return setHovered(true); }, []);
41
46
  var handleMouseLeave = useCallback(function () { return setHovered(false); }, []);
42
47
  var handleFocus = useCallback(function () {
@@ -49,14 +54,13 @@ var ClickableElementWithHint = function (_a) {
49
54
  if (hint === null || hint === undefined) {
50
55
  return children;
51
56
  }
52
- if (isOpened) {
53
- return children;
54
- }
55
- var shouldShow = !isHidden && (hovered || (tabFocused && focused));
57
+ var isRequested = hovered || (tabFocused && focused);
58
+ var shouldShow = !isHidden && isRequested && (!isOpened || isTruncated);
56
59
  var childrenWithHandlers = React.cloneElement(children, {
57
60
  onMouseEnter: function (e) {
58
61
  var _a, _b;
59
62
  (_b = (_a = children.props).onMouseEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
63
+ checkTruncated(e.currentTarget);
60
64
  handleMouseEnter();
61
65
  },
62
66
  onMouseLeave: function (e) {
@@ -67,6 +71,7 @@ var ClickableElementWithHint = function (_a) {
67
71
  onFocus: function (e) {
68
72
  var _a, _b;
69
73
  (_b = (_a = children.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e);
74
+ checkTruncated(e.currentTarget);
70
75
  handleFocus();
71
76
  },
72
77
  onBlur: function (e) {
@@ -95,6 +100,8 @@ var ClickableElement = forwardRef(function (_a, ref) {
95
100
  var cx = useEmotion().cx;
96
101
  var keyListener = useKeyListener();
97
102
  var _f = __read(useState(false), 2), isFocusedByTab = _f[0], setIsFocusedByTab = _f[1];
103
+ var counter = context.childIdCounterRef;
104
+ var autoIndex = !id && !href && counter ? counter.current++ : undefined;
98
105
  var _g = __read(useState(function () {
99
106
  if (id) {
100
107
  return id;
@@ -102,11 +109,8 @@ var ClickableElement = forwardRef(function (_a, ref) {
102
109
  if (href) {
103
110
  return href;
104
111
  }
105
- var counter = context.childIdCounterRef;
106
- if (counter) {
107
- var index = counter.current;
108
- counter.current += 1;
109
- return "".concat(context.parentItemId, "__").concat(index);
112
+ if (autoIndex !== undefined) {
113
+ return "".concat(context.parentItemId, "__").concat(autoIndex);
110
114
  }
111
115
  return generateId();
112
116
  }), 1), currentId = _g[0];
@@ -16,14 +16,14 @@ var getCaptionTail = function (caption, captionWidth, maxCaptionWidth) {
16
16
  return '';
17
17
  };
18
18
  export var Caption = forwardRef(function (_a, ref) {
19
- var _b, _c;
19
+ var _b, _c, _d;
20
20
  var _isSubMenu = _a._isSubMenu, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, hasIcon = _a.hasIcon, hasMarker = _a.hasMarker, isMultiline = _a.isMultiline, noWrap = _a.noWrap, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
21
21
  var theme = getSideMenuTheme(useContext(ThemeContext));
22
- var _d = useContext(SideMenuContext), isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSeparatedSubMenu = _d.hasSeparatedSubMenu, isBeingTransitioned = _d.isBeingTransitioned, sideMenuRef = _d.sideMenuRef, isOpened = _d.isOpened, hasItemIcons = _d.hasItemIcons;
22
+ var _e = useContext(SideMenuContext), isSeparatedMenu = _e.isSeparatedMenu, size = _e.size, isTouchScreen = _e.isTouchScreen, hasSeparatedSubMenu = _e.hasSeparatedSubMenu, isBeingTransitioned = _e.isBeingTransitioned, sideMenuRef = _e.sideMenuRef, isOpened = _e.isOpened, hasItemIcons = _e.hasItemIcons;
23
23
  var isLarge = size === 'large';
24
24
  var isCaptionPlainText = typeof caption === 'string';
25
25
  var captionRef = useRef(null);
26
- var _e = __read(useState(''), 2), tail = _e[0], setTail = _e[1];
26
+ var _f = __read(useState(''), 2), tail = _f[0], setTail = _f[1];
27
27
  var styles = useStyles(getStyles);
28
28
  var cx = useEmotion().cx;
29
29
  var truncateSpecialCaption = function () {
@@ -73,6 +73,6 @@ export var Caption = forwardRef(function (_a, ref) {
73
73
  _c[styles.captionNoWrap()] = noWrap,
74
74
  _c[styles.captionNoWrapWithMarker(theme)] = noWrap && hasMarker,
75
75
  _c)), ref: captionRef, "data-tail": tail }, caption),
76
- subCaption));
76
+ subCaption && (React.createElement("div", { className: cx(styles.subCaption(theme), (_d = {}, _d[styles.subCaptionLarge(theme)] = isLarge, _d)) }, subCaption))));
77
77
  });
78
78
  Caption.displayName = 'Caption';
@@ -17,6 +17,8 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
17
17
  captionWithoutAnyIcons(t: SideMenuTheme): string;
18
18
  captionSubItemWithoutAnyIcons(t: SideMenuTheme): string;
19
19
  captionSubItemWithoutColumnIcons(): string;
20
+ subCaption(t: SideMenuTheme): string;
21
+ subCaptionLarge(t: SideMenuTheme): string;
20
22
  captionLarge(t: SideMenuTheme): string;
21
23
  captionInBackButton(t: SideMenuTheme): string;
22
24
  captionDropdown(): string;
@@ -46,24 +46,30 @@ export var getStyles = memoizeGetStyles(function (_a) {
46
46
  captionSubItemWithoutColumnIcons: function () {
47
47
  return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n margin-left: 12px;\n "], ["\n margin-left: 12px;\n "])));
48
48
  },
49
+ subCaption: function (t) {
50
+ return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n margin-top: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "], ["\n margin-top: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n "])), t.sideMenuSubCaptionMarginTop, t.sideMenuSubCaptionFontSize, t.sideMenuSubCaptionLineHeight, t.sideMenuSubCaptionColor);
51
+ },
52
+ subCaptionLarge: function (t) {
53
+ return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuSubCaptionFontSizeLarge, t.sideMenuSubCaptionLineHeightLarge);
54
+ },
49
55
  captionLarge: function (t) {
50
- return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionFontSizeLarge, t.sideMenuCaptionLineHeightLarge);
56
+ return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionFontSizeLarge, t.sideMenuCaptionLineHeightLarge);
51
57
  },
52
58
  captionInBackButton: function (t) {
53
- return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
59
+ return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
54
60
  },
55
61
  captionDropdown: function () {
56
- return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
62
+ return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
57
63
  },
58
64
  captionTruncated: function () {
59
- return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
65
+ return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
60
66
  },
61
67
  captionNoWrap: function () {
62
- return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "])));
68
+ return css(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "])));
63
69
  },
64
70
  captionNoWrapWithMarker: function (t) {
65
- return css(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
71
+ return css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
66
72
  },
67
73
  });
68
74
  });
69
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19;
75
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21;
@@ -1,10 +1,11 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../../lib/theming/ThemeHelpers.js';
3
+ import { transitionDuration, transitionEasing } from '../../SideMenu/SideMenu.js';
3
4
  export var getStyles = memoizeGetStyles(function (_a) {
4
5
  var css = _a.css;
5
6
  return ({
6
7
  root: function (t) {
7
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight);
8
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight, transitionDuration, transitionEasing, transitionDuration, transitionEasing);
8
9
  },
9
10
  rootCollapsed: function (t) {
10
11
  return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
@@ -68,6 +68,7 @@ var ItemContent = forwardRef(function (_a, ref) {
68
68
  var styles = useStyles(getStyles);
69
69
  var cx = useEmotion().cx;
70
70
  useEffect(function () {
71
+ var _a, _b;
71
72
  if (noWrap) {
72
73
  setIsMultiline(false);
73
74
  return;
@@ -80,7 +81,8 @@ var ItemContent = forwardRef(function (_a, ref) {
80
81
  return;
81
82
  }
82
83
  var captionLineHeight = getCaptionLineHeight(theme, isTouchScreen, _isSubMenu, size);
83
- setIsMultiline(parseInt(captionLineHeight, 10) < textRef.current.offsetHeight);
84
+ var captionHeight = (_b = (_a = textRef.current.firstElementChild) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : textRef.current.offsetHeight;
85
+ setIsMultiline(parseInt(captionLineHeight, 10) < captionHeight);
84
86
  }, [
85
87
  caption,
86
88
  context.isBeingTransitioned,
@@ -1,8 +1,9 @@
1
1
  import { __assign, __read, __rest } from "tslib";
2
2
  import { Logotype } from '@skbkontur/react-ui-addons/components/Logotype/Logotype';
3
+ import { mergeRefs } from '@skbkontur/react-ui/lib/mergeRefs';
3
4
  import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
4
5
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
5
- import React, { forwardRef, useContext, useState } from 'react';
6
+ import React, { forwardRef, useContext, useLayoutEffect, useRef, useState } from 'react';
6
7
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
7
8
  import { SideMenuContext } from '../SideMenuContext.js';
8
9
  import { Burger } from './Burger.js';
@@ -30,6 +31,15 @@ var CdnLogoWithOwnSize = function (_a) {
30
31
  var logo = _a.logo, _size = _a.size, rest = __rest(_a, ["logo", "size"]);
31
32
  return React.cloneElement(logo, rest);
32
33
  };
34
+ var VERTICAL_LOGO_SUFFIX = '-vertical';
35
+ var getOneLineLogo = function (logo) {
36
+ var _a;
37
+ var name = (_a = logo === null || logo === void 0 ? void 0 : logo.props) === null || _a === void 0 ? void 0 : _a.logo;
38
+ if (!logo || typeof name !== 'string' || !name.includes(VERTICAL_LOGO_SUFFIX)) {
39
+ return null;
40
+ }
41
+ return React.cloneElement(logo, { logo: name.replace(VERTICAL_LOGO_SUFFIX, '') });
42
+ };
33
43
  var getStaticIconPath = function (productName) {
34
44
  return "https://s.kontur.ru/common-v2/icons-products/".concat(productName, "/").concat(productName, "-").concat(parseInt(sideMenuLogotypeIconSize, 10), ".svg");
35
45
  };
@@ -50,6 +60,17 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
50
60
  var _f = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _f[0], setProductIconUrl = _f[1];
51
61
  var isTabletOrMobile = context.isTablet || context.isMobile;
52
62
  var isDesktopCollapsedMode = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
63
+ var rootRef = useRef(null);
64
+ var _g = __read(useState(true), 2), oneLineLogoFits = _g[0], setOneLineLogoFits = _g[1];
65
+ var oneLineLogo = isTabletOrMobile ? getOneLineLogo(productLogo) : null;
66
+ var isOneLine = !!oneLineLogo && (!context.isOpened || oneLineLogoFits);
67
+ var shownProductLogo = isOneLine ? oneLineLogo : productLogo;
68
+ useLayoutEffect(function () {
69
+ var root = rootRef.current;
70
+ if (root && isOneLine && context.isOpened && root.scrollWidth > root.clientWidth) {
71
+ setOneLineLogoFits(false);
72
+ }
73
+ }, [isOneLine, context.isOpened]);
53
74
  var getWidget = function (withWidget, isCollapsedOnDesktop) {
54
75
  if (isCollapsedOnDesktop) {
55
76
  return false;
@@ -61,7 +82,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
61
82
  };
62
83
  return (React.createElement("div", { className: cx(styles.root(), (_b = {},
63
84
  _b[styles.rootTabletAndMobile()] = isTabletOrMobile,
64
- _b)), ref: ref },
85
+ _b)), ref: mergeRefs(rootRef, ref) },
65
86
  !isTabletOrMobile && (React.createElement("img", { className: cx(styles.iconHidden(theme), (_c = {},
66
87
  _c[styles.icon()] = !context.isOpened && !isTabletOrMobile,
67
88
  _c)), src: iconUrl || productIconUrl, alt: productName, onError: handleError })),
@@ -70,7 +91,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
70
91
  _d[styles.logoWrapperHidden()] = !context.isOpened && !isTabletOrMobile,
71
92
  _d)) },
72
93
  isTabletOrMobile && React.createElement(Burger, null),
73
- React.createElement(Logotype, __assign({ size: 28, productLogo: productLogo && typeof ((_e = productLogo.props) === null || _e === void 0 ? void 0 : _e.logo) === 'string' && !rest.size ? (React.createElement(CdnLogoWithOwnSize, { logo: productLogo })) : (productLogo), konturLogo: konturLogo, withWidget: getWidget(withWidget, isDesktopCollapsedMode) }, rest)))));
94
+ React.createElement(Logotype, __assign({ size: 28, productLogo: shownProductLogo && typeof ((_e = shownProductLogo.props) === null || _e === void 0 ? void 0 : _e.logo) === 'string' && !rest.size ? (React.createElement(CdnLogoWithOwnSize, { logo: shownProductLogo })) : (shownProductLogo), konturLogo: konturLogo, withWidget: getWidget(withWidget, isDesktopCollapsedMode) }, rest)))));
74
95
  });
75
96
  SideMenuLogotype.displayName = 'SideMenuLogotype';
76
97
  var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
@@ -1,6 +1,6 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
3
- import { transitionDuration } from '../SideMenu/SideMenu.js';
3
+ import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
4
4
  export var sideMenuLogotypeIconSize = '32px';
5
5
  export var sideMenuLogotypeGapBetweenIconAndLogo = '50px';
6
6
  export var getStyles = memoizeGetStyles(function (_a) {
@@ -16,13 +16,13 @@ export var getStyles = memoizeGetStyles(function (_a) {
16
16
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "], ["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "])));
17
17
  },
18
18
  iconHidden: function (t) {
19
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "], ["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ease-out;\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration);
19
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "], ["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration, transitionEasing);
20
20
  },
21
21
  logoWrapper: function (t) {
22
22
  return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "], ["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft);
23
23
  },
24
24
  logoWrapperTabletAndMobile: function () {
25
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n "], ["\n padding: 0;\n gap: 2px;\n "])));
25
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "], ["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "])));
26
26
  },
27
27
  logoWrapperHidden: function () {
28
28
  return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "], ["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "])));