@skbkontur/side-menu 3.3.4 → 3.3.5-19a67.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 (65) hide show
  1. package/SideMenuDataTids.js +4 -1
  2. package/hooks/useAnimateOnMount.js +12 -10
  3. package/hooks/useMemoIcon.js +18 -13
  4. package/index.js +17 -14
  5. package/internal/themes/SideMenuTheme.js +209 -282
  6. package/lib/theming/ThemeHelpers.js +33 -42
  7. package/lib/theming/ThemeTypes.js +2 -1
  8. package/lib/utils/memo.js +7 -3
  9. package/lib/utils/scripts.js +12 -6
  10. package/package.json +1 -1
  11. package/src/Navigation.js +81 -123
  12. package/src/SideMenu/SideMenu.js +202 -207
  13. package/src/SideMenu/SideMenu.styles.js +145 -73
  14. package/src/SideMenuAvatar/SideMenuAvatar.js +13 -11
  15. package/src/SideMenuBody/SideMenuBody.js +21 -20
  16. package/src/SideMenuBody/SideMenuBody.styles.js +17 -10
  17. package/src/SideMenuContext.js +5 -2
  18. package/src/SideMenuDivider/SideMenuDivider.js +13 -12
  19. package/src/SideMenuDivider/SideMenuDivider.styles.js +14 -8
  20. package/src/SideMenuDropdown/SideMenuDropdown.js +34 -36
  21. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +25 -15
  22. package/src/SideMenuFooter/SideMenuFooter.js +24 -23
  23. package/src/SideMenuFooter/SideMenuFooter.styles.js +25 -12
  24. package/src/SideMenuHeader/SideMenuHeader.js +28 -29
  25. package/src/SideMenuHeader/SideMenuHeader.styles.js +34 -16
  26. package/src/SideMenuItem/SideMenuItem.js +9 -7
  27. package/src/SideMenuLink/SideMenuLink.js +11 -10
  28. package/src/SideMenuLink/SideMenuLink.styles.js +11 -7
  29. package/src/SideMenuNotifications/BellWidget.js +61 -78
  30. package/src/SideMenuNotifications/BellWidgetError.js +22 -18
  31. package/src/SideMenuNotifications/BellWidgetView.styles.js +48 -20
  32. package/src/SideMenuNotifications/SideMenuNotifications.js +29 -27
  33. package/src/SideMenuNotifications/utils/getMarker.js +4 -1
  34. package/src/SideMenuNotifications/utils/getNotificationsErrorMessages.js +15 -11
  35. package/src/SideMenuOrganisations/SideMenuOrganisations.js +9 -7
  36. package/src/SideMenuSubItem/SideMenuSubItem.js +10 -8
  37. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +18 -17
  38. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +18 -10
  39. package/src/SideMenuSubLink/SideMenuSubLink.js +10 -7
  40. package/src/Tree.js +39 -112
  41. package/src/internal/BackButton.js +17 -16
  42. package/src/internal/Backdrop.js +18 -12
  43. package/src/internal/Backdrop.styles.js +16 -8
  44. package/src/internal/Burger.js +17 -12
  45. package/src/internal/Burger.styles.js +14 -9
  46. package/src/internal/ClickableElement.js +97 -86
  47. package/src/internal/ClickableElement.styles.js +48 -21
  48. package/src/internal/InnerSubMenu.js +16 -14
  49. package/src/internal/ItemContent/Caption.js +47 -48
  50. package/src/internal/ItemContent/Caption.styles.js +84 -36
  51. package/src/internal/ItemContent/Icon.js +30 -27
  52. package/src/internal/ItemContent/Icon.styles.js +49 -20
  53. package/src/internal/ItemContent/ItemContent.js +44 -44
  54. package/src/internal/ItemContent/ItemContent.styles.js +65 -28
  55. package/src/internal/ItemContent/Marker.js +23 -20
  56. package/src/internal/ItemContent/Marker.styles.js +59 -22
  57. package/src/internal/NestedMenu.js +21 -19
  58. package/src/internal/NestedMenu.styles.js +11 -8
  59. package/src/internal/RightBorder.js +26 -24
  60. package/src/internal/RightBorder.styles.js +26 -10
  61. package/src/internal/SeparatedSubMenu.js +48 -49
  62. package/src/internal/SeparatedSubMenu.styles.js +58 -29
  63. package/src/internal/SideMenuLogotype.js +48 -49
  64. package/src/internal/SideMenuLogotype.styles.js +50 -23
  65. package/src/internal/SubMenu.js +16 -14
@@ -1,31 +1,68 @@
1
- import { __makeTemplateObject } from "tslib";
2
- import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { memoizeStyle } from '../../../lib/theming/ThemeHelpers';
4
- var styles = {
5
- root: function (t) {
6
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", " ", ";\n background: ", ";\n border-radius: 9999px;\n margin-left: auto;\n margin-right: ", ";\n color: ", ";\n font-size: ", ";\n line-height: ", ";\n font-weight: ", ";\n min-width: 8px;\n min-height: 8px;\n text-align: center;\n flex-shrink: 0;\n "], ["\n padding: ", " ", ";\n background: ", ";\n border-radius: 9999px;\n margin-left: auto;\n margin-right: ", ";\n color: ", ";\n font-size: ", ";\n line-height: ", ";\n font-weight: ", ";\n min-width: 8px;\n min-height: 8px;\n text-align: center;\n flex-shrink: 0;\n "])), t.sideMenuMarkerPaddingY, t.sideMenuMarkerPaddingX, t.sideMenuMarkerBg, t.sideMenuMarkerMarginRight, t.sideMenuMarkerColor, t.sideMenuMarkerFontSize, t.sideMenuMarkerLineHeight, t.sideMenuMarkerFontWeight);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsStyles = void 0;
4
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
5
+ const ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
6
+ const styles = {
7
+ root(t) {
8
+ return (0, Emotion_1.css) `
9
+ padding: ${t.sideMenuMarkerPaddingY} ${t.sideMenuMarkerPaddingX};
10
+ background: ${t.sideMenuMarkerBg};
11
+ border-radius: 9999px;
12
+ margin-left: auto;
13
+ margin-right: ${t.sideMenuMarkerMarginRight};
14
+ color: ${t.sideMenuMarkerColor};
15
+ font-size: ${t.sideMenuMarkerFontSize};
16
+ line-height: ${t.sideMenuMarkerLineHeight};
17
+ font-weight: ${t.sideMenuMarkerFontWeight};
18
+ min-width: 8px;
19
+ min-height: 8px;
20
+ text-align: center;
21
+ flex-shrink: 0;
22
+ `;
7
23
  },
8
- rootEmpty: function (t) {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0;\n margin-right: calc(", " + ", ");\n "], ["\n padding: 0;\n margin-right: calc(", " + ", ");\n "])), t.sideMenuMarkerMarginRight, t.sideMenuMarkerPaddingX);
24
+ rootEmpty(t) {
25
+ return (0, Emotion_1.css) `
26
+ padding: 0;
27
+ margin-right: calc(${t.sideMenuMarkerMarginRight} + ${t.sideMenuMarkerPaddingX});
28
+ `;
10
29
  },
11
- rootDisabled: function (t) {
12
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuMarkerBgDisabled);
30
+ rootDisabled(t) {
31
+ return (0, Emotion_1.css) `
32
+ background: ${t.sideMenuMarkerBgDisabled};
33
+ `;
13
34
  },
14
- rootMultiline: function (t) {
15
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: ", ";\n "], ["\n align-self: flex-start;\n margin-top: ", ";\n "])), t.sideMenuMarkerMultilineMarginTop);
35
+ rootMultiline(t) {
36
+ return (0, Emotion_1.css) `
37
+ align-self: flex-start;
38
+ margin-top: ${t.sideMenuMarkerMultilineMarginTop};
39
+ `;
16
40
  },
17
- rootSubMenu: function (t) {
18
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemColor, t.sideMenuSubItemMarkerFontWeight);
41
+ rootSubMenu(t) {
42
+ return (0, Emotion_1.css) `
43
+ background: transparent;
44
+ color: ${t.sideMenuMarkerSubItemColor};
45
+ font-weight: ${t.sideMenuSubItemMarkerFontWeight};
46
+ `;
19
47
  },
20
- rootSubMenuEmpty: function (t) {
21
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuSubItemEmptyMarkerBg);
48
+ rootSubMenuEmpty(t) {
49
+ return (0, Emotion_1.css) `
50
+ background: ${t.sideMenuSubItemEmptyMarkerBg};
51
+ `;
22
52
  },
23
- rootMinimized: function () {
24
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n right: 0;\n top: 0;\n margin: 0;\n "], ["\n position: absolute;\n right: 0;\n top: 0;\n margin: 0;\n "])));
53
+ rootMinimized() {
54
+ return (0, Emotion_1.css) `
55
+ position: absolute;
56
+ right: 0;
57
+ top: 0;
58
+ margin: 0;
59
+ `;
25
60
  },
26
- rootEmptyMinimized: function () {
27
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n right: 4px;\n top: 4px;\n "], ["\n right: 4px;\n top: 4px;\n "])));
61
+ rootEmptyMinimized() {
62
+ return (0, Emotion_1.css) `
63
+ right: 4px;
64
+ top: 4px;
65
+ `;
28
66
  },
29
67
  };
30
- export var jsStyles = memoizeStyle(styles);
31
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
68
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,26 +1,28 @@
1
- import React, { forwardRef, useContext } from 'react';
2
- import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
3
- import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
4
- import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
5
- import { jsStylesForSideMenu } from '../SideMenu/SideMenu.styles';
6
- import { SideMenuContext } from '../SideMenuContext';
7
- import { jsStyles } from './NestedMenu.styles';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NestedMenu = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
+ const ThemeContext_1 = require("@skbkontur/react-ui/lib/theming/ThemeContext");
7
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
8
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
9
+ const SideMenu_styles_1 = require("../SideMenu/SideMenu.styles");
10
+ const SideMenuContext_1 = require("../SideMenuContext");
11
+ const NestedMenu_styles_1 = require("./NestedMenu.styles");
8
12
  /**
9
13
  * Вложенное подменю
10
14
  *
11
15
  * @visibleName NestedMenu
12
16
  */
13
- var NestedMenu = forwardRef(function (_a, ref) {
14
- var _b;
15
- var children = _a.children, htmlId = _a.htmlId, isOpened = _a.isOpened;
16
- var theme = getSideMenuTheme(useContext(ThemeContext));
17
- var context = useContext(SideMenuContext);
18
- return (React.createElement("ul", { ref: ref, className: cx((_b = {},
19
- _b[jsStylesForSideMenu.list()] = true,
20
- _b[jsStylesForSideMenu.hidden()] = !isOpened || (!context.isOpened && (context.isMobile || context.isTablet)),
21
- _b[jsStyles.root(theme)] = true,
22
- _b)), id: htmlId }, children));
17
+ const NestedMenu = (0, react_1.forwardRef)(({ children, htmlId, isOpened }, ref) => {
18
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
19
+ const context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
20
+ return (react_1.default.createElement("ul", { ref: ref, className: (0, Emotion_1.cx)({
21
+ [SideMenu_styles_1.jsStylesForSideMenu.list()]: true,
22
+ [SideMenu_styles_1.jsStylesForSideMenu.hidden()]: !isOpened || (!context.isOpened && (context.isMobile || context.isTablet)),
23
+ [NestedMenu_styles_1.jsStyles.root(theme)]: true,
24
+ }), id: htmlId }, children));
23
25
  });
24
26
  NestedMenu.displayName = 'NestedMenu';
25
- var NestedMenuWithStaticFields = Object.assign(NestedMenu, { __KONTUR_REACT_UI__: 'NestedMenu' });
26
- export { NestedMenuWithStaticFields as NestedMenu };
27
+ const NestedMenuWithStaticFields = Object.assign(NestedMenu, { __KONTUR_REACT_UI__: 'NestedMenu' });
28
+ exports.NestedMenu = NestedMenuWithStaticFields;
@@ -1,10 +1,13 @@
1
- import { __makeTemplateObject } from "tslib";
2
- import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
4
- var styles = {
5
- root: function (t) {
6
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuNestedMenuPaddingLeft);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsStyles = void 0;
4
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
5
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
6
+ const styles = {
7
+ root(t) {
8
+ return (0, Emotion_1.css) `
9
+ padding-left: ${t.sideMenuNestedMenuPaddingLeft};
10
+ `;
7
11
  },
8
12
  };
9
- export var jsStyles = memoizeStyle(styles);
10
- var templateObject_1;
13
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,34 +1,36 @@
1
- import React, { forwardRef, useContext } from 'react';
2
- import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
4
- import { Hint } from '@skbkontur/react-ui/components/Hint/Hint';
5
- import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
6
- import { useMemoBorderIcon } from '../../hooks/useMemoIcon';
7
- import { SideMenuContext } from '../SideMenuContext';
8
- import { SideMenuDataTids } from '../../SideMenuDataTids';
9
- import { jsStyles } from './RightBorder.styles';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RightBorder = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
7
+ const ThemeContext_1 = require("@skbkontur/react-ui/lib/theming/ThemeContext");
8
+ const Hint_1 = require("@skbkontur/react-ui/components/Hint/Hint");
9
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
10
+ const useMemoIcon_1 = require("../../hooks/useMemoIcon");
11
+ const SideMenuContext_1 = require("../SideMenuContext");
12
+ const SideMenuDataTids_1 = require("../../SideMenuDataTids");
13
+ const RightBorder_styles_1 = require("./RightBorder.styles");
10
14
  /**
11
15
  * Элемент интерактивной правой границы
12
16
  *
13
17
  * @visibleName RightBorder
14
18
  */
15
- var RightBorder = forwardRef(function (_a, ref) {
16
- var _b;
17
- var onClick = _a.onClick, showButton = _a.showButton;
18
- var theme = getSideMenuTheme(useContext(ThemeContext));
19
- var context = useContext(SideMenuContext);
20
- var icon = useMemoBorderIcon(context.isCollapsable);
21
- var hintText = context.isCollapsable ? 'Закрепить меню' : 'Свернуть меню';
22
- return (React.createElement(Hint, { text: hintText, pos: 'right' },
23
- React.createElement("div", { className: cx((_b = {},
24
- _b[jsStyles.root(theme)] = true,
25
- _b[jsStyles.rootWithButton()] = showButton,
26
- _b)), ref: ref, onClick: onClick, onKeyDown: function (e) {
19
+ const RightBorder = (0, react_1.forwardRef)(({ onClick, showButton }, ref) => {
20
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
21
+ const context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
22
+ const icon = (0, useMemoIcon_1.useMemoBorderIcon)(context.isCollapsable);
23
+ const hintText = context.isCollapsable ? 'Закрепить меню' : 'Свернуть меню';
24
+ return (react_1.default.createElement(Hint_1.Hint, { text: hintText, pos: 'right' },
25
+ react_1.default.createElement("div", { className: (0, Emotion_1.cx)({
26
+ [RightBorder_styles_1.jsStyles.root(theme)]: true,
27
+ [RightBorder_styles_1.jsStyles.rootWithButton()]: showButton,
28
+ }), ref: ref, onClick: onClick, onKeyDown: (e) => {
27
29
  if (e.key === 'Enter' || e.key === 'Space') {
28
30
  onClick();
29
31
  }
30
- }, role: "button", tabIndex: 0, "data-tid": SideMenuDataTids.rightBorder }, icon)));
32
+ }, role: "button", tabIndex: 0, "data-tid": SideMenuDataTids_1.SideMenuDataTids.rightBorder }, icon)));
31
33
  });
32
34
  RightBorder.displayName = 'RightBorder';
33
- var RightBorderWithStaticFields = Object.assign(RightBorder, { __KONTUR_REACT_UI__: 'RightBorder' });
34
- export { RightBorderWithStaticFields as RightBorder };
35
+ const RightBorderWithStaticFields = Object.assign(RightBorder, { __KONTUR_REACT_UI__: 'RightBorder' });
36
+ exports.RightBorder = RightBorderWithStaticFields;
@@ -1,13 +1,29 @@
1
- import { __makeTemplateObject } from "tslib";
2
- import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
4
- var styles = {
5
- root: function (t) {
6
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n color: ", ";\n transition: opacity, color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "], ["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n color: ", ";\n transition: opacity, color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "])), t.sideMenuRightBorderWidth, t.sideMenuRightBorderIconColor, t.sideMenuRightBorderHoverIconColor);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsStyles = void 0;
4
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
5
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
6
+ const styles = {
7
+ root(t) {
8
+ return (0, Emotion_1.css) `
9
+ opacity: 0;
10
+ position: absolute;
11
+ width: ${t.sideMenuRightBorderWidth};
12
+ height: 100%;
13
+ right: 0;
14
+ background: transparent;
15
+ display: flex;
16
+ color: ${t.sideMenuRightBorderIconColor};
17
+ transition: opacity, color 150ms cubic-bezier(0.5, 1, 0.89, 1);
18
+ &:hover {
19
+ color: ${t.sideMenuRightBorderHoverIconColor};
20
+ }
21
+ `;
7
22
  },
8
- rootWithButton: function () {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n "], ["\n opacity: 1;\n "])));
23
+ rootWithButton() {
24
+ return (0, Emotion_1.css) `
25
+ opacity: 1;
26
+ `;
10
27
  },
11
28
  };
12
- export var jsStyles = memoizeStyle(styles);
13
- var templateObject_1, templateObject_2;
29
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,63 +1,62 @@
1
- import React, { forwardRef, useContext, useEffect, useRef } from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
4
- import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
5
- import { ScrollContainer } from '@skbkontur/react-ui/components/ScrollContainer';
6
- import { isIE11 } from '@skbkontur/react-ui/lib/client';
7
- import { jsStylesForSideMenu } from '../SideMenu/SideMenu.styles';
8
- import { SideMenuContext } from '../SideMenuContext';
9
- import { SideMenuDataTids } from '../../SideMenuDataTids';
10
- import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers';
11
- import { navigationAttributeForSeparatedMenu } from '../Navigation';
12
- import { BackButton } from './BackButton';
13
- import { customStyles, jsStyles } from './SeparatedSubMenu.styles';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeparatedSubMenu = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
+ const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
7
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
8
+ const ThemeContext_1 = require("@skbkontur/react-ui/lib/theming/ThemeContext");
9
+ const ScrollContainer_1 = require("@skbkontur/react-ui/components/ScrollContainer");
10
+ const client_1 = require("@skbkontur/react-ui/lib/client");
11
+ const SideMenu_styles_1 = require("../SideMenu/SideMenu.styles");
12
+ const SideMenuContext_1 = require("../SideMenuContext");
13
+ const SideMenuDataTids_1 = require("../../SideMenuDataTids");
14
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
15
+ const Navigation_1 = require("../Navigation");
16
+ const BackButton_1 = require("./BackButton");
17
+ const SeparatedSubMenu_styles_1 = require("./SeparatedSubMenu.styles");
14
18
  /**
15
19
  * Отдельностоящее подменю
16
20
  *
17
21
  * @visibleName SeparatedSubMenu
18
22
  */
19
- var SeparatedSubMenu = forwardRef(function (_a, ref) {
20
- var _b, _c, _d;
21
- var _e, _f, _g;
22
- var children = _a.children, caption = _a.caption, htmlId = _a.htmlId, isOpened = _a.isOpened;
23
- var context = useContext(SideMenuContext);
24
- var scrollContainerRef = useRef(null);
25
- var theme = getSideMenuTheme(useContext(ThemeContext));
26
- useEffect(function () {
23
+ const SeparatedSubMenu = (0, react_1.forwardRef)(({ children, caption, htmlId, isOpened }, ref) => {
24
+ const context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
25
+ const scrollContainerRef = (0, react_1.useRef)(null);
26
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
27
+ (0, react_1.useEffect)(() => {
27
28
  if (!context.isMobile) {
28
29
  return;
29
30
  }
30
- setTimeout(function () {
31
- var _a, _b;
32
- isOpened && ((_a = context.setHasScrollBar) === null || _a === void 0 ? void 0 : _a.call(context, !!((_b = scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.hasScrollBar('y'))));
31
+ setTimeout(() => {
32
+ isOpened && context.setHasScrollBar?.(!!scrollContainerRef.current?.hasScrollBar('y'));
33
33
  }, 50);
34
- }, [(_e = context.navigation) === null || _e === void 0 ? void 0 : _e.activeMenuItem]);
35
- if (!((_f = context.sideMenuRef) === null || _f === void 0 ? void 0 : _f.current)) {
34
+ }, [context.navigation?.activeMenuItem]);
35
+ if (!context.sideMenuRef?.current) {
36
36
  return null;
37
37
  }
38
- return ReactDOM.createPortal(React.createElement("div", (_b = { className: cx((_c = {},
39
- _c[jsStylesForSideMenu.container(theme)] = true,
40
- _c[jsStylesForSideMenu.containerForTouchScreens(theme)] = context.isTouchScreen,
41
- _c[jsStyles.root(theme)] = true,
42
- _c[customStyles.rootForMobiles(context.headerHeight)] = context.isMobile,
43
- _c[jsStyles.rootForDesktop()] = context.isDesktop,
44
- _c[jsStyles.rootForTouchScreens(theme)] = context.isTouchScreen && context.isOpened && context.isCollapsable,
45
- _c[jsStyles.rootForNarrowDesktop(theme)] = context.isCollapsable,
46
- _c[jsStyles.rootWithShadow(theme)] = context.isTablet && !isIE11,
47
- _c[jsStylesForSideMenu.hidden()] = !isOpened || (!context.isOpened && (context.isTablet || context.isMobile)),
48
- _c)), ref: ref, "data-tid": SideMenuDataTids.separatedSubMenu }, _b[navigationAttributeForSeparatedMenu] = htmlId, _b),
49
- React.createElement(ScrollContainer, { onScrollStateChangeY: function (state) {
50
- var _a;
51
- (_a = context.setScrollState) === null || _a === void 0 ? void 0 : _a.call(context, state);
38
+ return react_dom_1.default.createPortal(react_1.default.createElement("div", { className: (0, Emotion_1.cx)({
39
+ [SideMenu_styles_1.jsStylesForSideMenu.container(theme)]: true,
40
+ [SideMenu_styles_1.jsStylesForSideMenu.containerForTouchScreens(theme)]: context.isTouchScreen,
41
+ [SeparatedSubMenu_styles_1.jsStyles.root(theme)]: true,
42
+ [SeparatedSubMenu_styles_1.customStyles.rootForMobiles(context.headerHeight)]: context.isMobile,
43
+ [SeparatedSubMenu_styles_1.jsStyles.rootForDesktop()]: context.isDesktop,
44
+ [SeparatedSubMenu_styles_1.jsStyles.rootForTouchScreens(theme)]: context.isTouchScreen && context.isOpened && context.isCollapsable,
45
+ [SeparatedSubMenu_styles_1.jsStyles.rootForNarrowDesktop(theme)]: context.isCollapsable,
46
+ [SeparatedSubMenu_styles_1.jsStyles.rootWithShadow(theme)]: context.isTablet && !client_1.isIE11,
47
+ [SideMenu_styles_1.jsStylesForSideMenu.hidden()]: !isOpened || (!context.isOpened && (context.isTablet || context.isMobile)),
48
+ }), ref: ref, "data-tid": SideMenuDataTids_1.SideMenuDataTids.separatedSubMenu, [Navigation_1.navigationAttributeForSeparatedMenu]: htmlId },
49
+ react_1.default.createElement(ScrollContainer_1.ScrollContainer, { onScrollStateChangeY: (state) => {
50
+ context.setScrollState?.(state);
52
51
  }, ref: scrollContainerRef, showScrollBar: context.isTouchScreen ? 'always' : context.showScrollBar },
53
- React.createElement("ul", { className: cx((_d = {},
54
- _d[jsStylesForSideMenu.list()] = true,
55
- _d[jsStyles.contentWrapper(theme)] = true,
56
- _d[jsStyles.contentWrapperForMobiles()] = context.isMobile,
57
- _d)) },
58
- context.isMobile && React.createElement(BackButton, { caption: caption, id: htmlId }),
59
- children))), (_g = context.sideMenuRef) === null || _g === void 0 ? void 0 : _g.current);
52
+ react_1.default.createElement("ul", { className: (0, Emotion_1.cx)({
53
+ [SideMenu_styles_1.jsStylesForSideMenu.list()]: true,
54
+ [SeparatedSubMenu_styles_1.jsStyles.contentWrapper(theme)]: true,
55
+ [SeparatedSubMenu_styles_1.jsStyles.contentWrapperForMobiles()]: context.isMobile,
56
+ }) },
57
+ context.isMobile && react_1.default.createElement(BackButton_1.BackButton, { caption: caption, id: htmlId }),
58
+ children))), context.sideMenuRef?.current);
60
59
  });
61
60
  SeparatedSubMenu.displayName = 'SeparatedSubMenu';
62
- var SeparatedSubMenuWithStaticFields = Object.assign(SeparatedSubMenu, { __KONTUR_REACT_UI__: 'SeparatedSubMenu' });
63
- export { SeparatedSubMenuWithStaticFields as SeparatedSubMenu };
61
+ const SeparatedSubMenuWithStaticFields = Object.assign(SeparatedSubMenu, { __KONTUR_REACT_UI__: 'SeparatedSubMenu' });
62
+ exports.SeparatedSubMenu = SeparatedSubMenuWithStaticFields;
@@ -1,33 +1,62 @@
1
- import { __makeTemplateObject } from "tslib";
2
- import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { memoizeStyle } from '../../lib/theming/ThemeHelpers';
4
- var styles = {
5
- root: function (t) {
6
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n background: ", ";\n left: 100%;\n justify-content: flex-start;\n border-right: 1px solid ", ";\n z-index: 8000;\n "], ["\n position: absolute;\n top: 0;\n background: ", ";\n left: 100%;\n justify-content: flex-start;\n border-right: 1px solid ", ";\n z-index: 8000;\n "])), t.sideMenuSeparatedSubMenuBgColor, t.sideMenuSeparatedSubMenuBorderRightColor);
7
- },
8
- rootForTouchScreens: function (t) {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: ", ";\n z-index: -1;\n "], ["\n left: ", ";\n z-index: -1;\n "])), t.sideMenuWidthForTouchScreens);
10
- },
11
- rootForNarrowDesktop: function (t) {
12
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n left: ", ";\n z-index: -1;\n "], ["\n left: ", ";\n z-index: -1;\n "])), t.sideMenuMinimizedWidth);
13
- },
14
- rootForDesktop: function () {
15
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n z-index: -1;\n "], ["\n z-index: -1;\n "])));
16
- },
17
- rootWithShadow: function (t) {
18
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-shadow: ", ";\n clip-path: inset(0 -", " 0 0);\n border-right: none;\n "], ["\n box-shadow: ", ";\n clip-path: inset(0 -", " 0 0);\n border-right: none;\n "])), t.sideMenuBoxShadow, t.sideMenuBoxShadowBlurRadius);
19
- },
20
- contentWrapper: function (t) {
21
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: ", " ", ";\n "], ["\n padding: ", " ", ";\n "])), t.sideMenuSeparatedSubMenuPaddingY, t.sideMenuSeparatedSubMenuPaddingX);
22
- },
23
- contentWrapperForMobiles: function () {
24
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-top: 0;\n "], ["\n padding-top: 0;\n "])));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsStyles = exports.customStyles = void 0;
4
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
5
+ const ThemeHelpers_1 = require("../../lib/theming/ThemeHelpers");
6
+ const styles = {
7
+ root(t) {
8
+ return (0, Emotion_1.css) `
9
+ position: absolute;
10
+ top: 0;
11
+ background: ${t.sideMenuSeparatedSubMenuBgColor};
12
+ left: 100%;
13
+ justify-content: flex-start;
14
+ border-right: 1px solid ${t.sideMenuSeparatedSubMenuBorderRightColor};
15
+ z-index: 8000;
16
+ `;
17
+ },
18
+ rootForTouchScreens(t) {
19
+ return (0, Emotion_1.css) `
20
+ left: ${t.sideMenuWidthForTouchScreens};
21
+ z-index: -1;
22
+ `;
23
+ },
24
+ rootForNarrowDesktop(t) {
25
+ return (0, Emotion_1.css) `
26
+ left: ${t.sideMenuMinimizedWidth};
27
+ z-index: -1;
28
+ `;
29
+ },
30
+ rootForDesktop() {
31
+ return (0, Emotion_1.css) `
32
+ z-index: -1;
33
+ `;
34
+ },
35
+ rootWithShadow(t) {
36
+ return (0, Emotion_1.css) `
37
+ box-shadow: ${t.sideMenuBoxShadow};
38
+ clip-path: inset(0 -${t.sideMenuBoxShadowBlurRadius} 0 0);
39
+ border-right: none;
40
+ `;
41
+ },
42
+ contentWrapper(t) {
43
+ return (0, Emotion_1.css) `
44
+ padding: ${t.sideMenuSeparatedSubMenuPaddingY} ${t.sideMenuSeparatedSubMenuPaddingX};
45
+ `;
46
+ },
47
+ contentWrapperForMobiles() {
48
+ return (0, Emotion_1.css) `
49
+ padding-top: 0;
50
+ `;
25
51
  },
26
52
  };
27
- export var customStyles = {
28
- rootForMobiles: function (headerHeight) {
29
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n height: calc(100vh - ", "px);\n left: 0;\n top: ", "px;\n "], ["\n height: calc(100vh - ", "px);\n left: 0;\n top: ", "px;\n "])), headerHeight, headerHeight);
53
+ exports.customStyles = {
54
+ rootForMobiles(headerHeight) {
55
+ return (0, Emotion_1.css) `
56
+ height: calc(100vh - ${headerHeight}px);
57
+ left: 0;
58
+ top: ${headerHeight}px;
59
+ `;
30
60
  },
31
61
  };
32
- export var jsStyles = memoizeStyle(styles);
33
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
62
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);