@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,51 +1,99 @@
1
- import { __makeTemplateObject } from "tslib";
2
- import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
3
- import { memoizeStyle } from '../../../lib/theming/ThemeHelpers';
4
- export var sideMenuMultilineCaptionPaddingTop = '4px';
5
- export var sideMenuCaptionMarginRight = '8px';
6
- var styles = {
7
- root: function () {
8
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n "])));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsStyles = exports.sideMenuCaptionMarginRight = exports.sideMenuMultilineCaptionPaddingTop = void 0;
4
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
5
+ const ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
6
+ exports.sideMenuMultilineCaptionPaddingTop = '4px';
7
+ exports.sideMenuCaptionMarginRight = '8px';
8
+ const styles = {
9
+ root() {
10
+ return (0, Emotion_1.css) `
11
+ display: flex;
12
+ flex-direction: column;
13
+ flex: 1;
14
+ overflow: hidden;
15
+ `;
9
16
  },
10
- rootMultiline: function () {
11
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", ";\n align-self: flex-start;\n "], ["\n padding-top: ", ";\n align-self: flex-start;\n "])), sideMenuMultilineCaptionPaddingTop);
17
+ rootMultiline() {
18
+ return (0, Emotion_1.css) `
19
+ padding-top: ${exports.sideMenuMultilineCaptionPaddingTop};
20
+ align-self: flex-start;
21
+ `;
12
22
  },
13
- caption: function (t) {
14
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "], ["\n font-size: ", ";\n line-height: ", ";\n margin: 0 ", " 0 0;\n overflow-wrap: anywhere;\n "])), t.sideMenuCaptionFontSize, t.sideMenuCaptionLineHeight, sideMenuCaptionMarginRight);
23
+ caption(t) {
24
+ return (0, Emotion_1.css) `
25
+ font-size: ${t.sideMenuCaptionFontSize};
26
+ line-height: ${t.sideMenuCaptionLineHeight};
27
+ margin: 0 ${exports.sideMenuCaptionMarginRight} 0 0;
28
+ overflow-wrap: anywhere;
29
+ `;
15
30
  },
16
- captionForTouchScreens: function (t) {
17
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeForTouchScreens, t.sideMenuCaptionLineHeightForTouchScreens);
31
+ captionForTouchScreens(t) {
32
+ return (0, Emotion_1.css) `
33
+ font-size: ${t.sideMenuCaptionFontSizeForTouchScreens};
34
+ line-height: ${t.sideMenuCaptionLineHeightForTouchScreens};
35
+ `;
18
36
  },
19
- captionSubItem: function (t) {
20
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
37
+ captionSubItem(t) {
38
+ return (0, Emotion_1.css) `
39
+ margin-left: ${t.sideMenuCaptionSubItemMarginLeft};
40
+ `;
21
41
  },
22
- captionSubItemForTouchScreens: function (t) {
23
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeForTouchScreens, t.sideMenuCaptionSubItemLineHeightForTouchScreens);
42
+ captionSubItemForTouchScreens(t) {
43
+ return (0, Emotion_1.css) `
44
+ font-size: ${t.sideMenuCaptionSubItemFontSizeForTouchScreens};
45
+ line-height: ${t.sideMenuCaptionSubItemLineHeightForTouchScreens};
46
+ `;
24
47
  },
25
- captionSubItemSeparatedMenuTopLevel: function () {
26
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
48
+ captionSubItemSeparatedMenuTopLevel() {
49
+ return (0, Emotion_1.css) `
50
+ margin: 0 8px;
51
+ `;
27
52
  },
28
- captionNestedItemSeparatedMenu: function () {
29
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
53
+ captionNestedItemSeparatedMenu() {
54
+ return (0, Emotion_1.css) `
55
+ margin-left: 25px;
56
+ `;
30
57
  },
31
- captionWithoutItemIcon: function () {
32
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
58
+ captionWithoutItemIcon() {
59
+ return (0, Emotion_1.css) `
60
+ margin-left: 40px;
61
+ `;
33
62
  },
34
- captionSubItemWithoutColumnIcons: function () {
35
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
63
+ captionSubItemWithoutColumnIcons() {
64
+ return (0, Emotion_1.css) `
65
+ margin-left: 8px;
66
+ `;
36
67
  },
37
- captionLarge: function (t) {
38
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionLargeFontSize, t.sideMenuCaptionLargeLineHeight);
68
+ captionLarge(t) {
69
+ return (0, Emotion_1.css) `
70
+ font-size: ${t.sideMenuCaptionLargeFontSize} !important;
71
+ line-height: ${t.sideMenuCaptionLargeLineHeight} !important;
72
+ `;
39
73
  },
40
- captionInBackButton: function (t) {
41
- return css(templateObject_12 || (templateObject_12 = __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);
74
+ captionInBackButton(t) {
75
+ return (0, Emotion_1.css) `
76
+ font-weight: ${t.sideMenuBackButtonCaptionFontWeight};
77
+ font-size: ${t.sideMenuBackButtonCaptionFontSize};
78
+ line-height: ${t.sideMenuBackButtonCaptionLineHeight};
79
+ padding-top: ${t.sideMenuBackButtonCaptionPaddingY};
80
+ padding-bottom: ${t.sideMenuBackButtonCaptionPaddingY};
81
+ `;
42
82
  },
43
- captionDropdown: function () {
44
- return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
83
+ captionDropdown() {
84
+ return (0, Emotion_1.css) `
85
+ white-space: nowrap;
86
+ overflow: hidden;
87
+ `;
45
88
  },
46
- captionTruncated: function () {
47
- return css(templateObject_14 || (templateObject_14 = __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 "])));
89
+ captionTruncated() {
90
+ return (0, Emotion_1.css) `
91
+ text-overflow: ellipsis;
92
+ &::before {
93
+ float: right;
94
+ content: attr(data-tail);
95
+ }
96
+ `;
48
97
  },
49
98
  };
50
- export var jsStyles = memoizeStyle(styles);
51
- 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;
99
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,11 +1,15 @@
1
- import React, { 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 { SideMenuContext } from '../../SideMenuContext';
5
- import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
6
- import { isKonturIcon } from '../../../lib/utils/scripts';
7
- import { jsStyles } from './Icon.styles';
8
- var getIconSize = function (theme, _isSubMenu, _isBackButton) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Icon = 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 SideMenuContext_1 = require("../../SideMenuContext");
9
+ const ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
10
+ const scripts_1 = require("../../../lib/utils/scripts");
11
+ const Icon_styles_1 = require("./Icon.styles");
12
+ const getIconSize = (theme, _isSubMenu, _isBackButton) => {
9
13
  if (!_isSubMenu) {
10
14
  return parseInt(theme.sideMenuIconSize);
11
15
  }
@@ -13,16 +17,14 @@ var getIconSize = function (theme, _isSubMenu, _isBackButton) {
13
17
  return parseInt(theme.sideMenuIconSubItemSize);
14
18
  }
15
19
  };
16
- export var Icon = function (_a) {
17
- var _b;
18
- var icon = _a.icon, _isSubMenu = _a._isSubMenu, isMultiline = _a.isMultiline, _c = _a._isBackButton, _isBackButton = _c === void 0 ? false : _c, disabled = _a.disabled;
19
- var context = useContext(SideMenuContext);
20
- var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
21
- var theme = getSideMenuTheme(useContext(ThemeContext));
22
- var renderIcon = function () {
23
- var iconColor = _isSubMenu && !disabled ? theme.sideMenuIconSubItemColor : undefined;
24
- if (isKonturIcon(icon)) {
25
- return React.cloneElement(icon, {
20
+ const Icon = ({ icon, _isSubMenu, isMultiline, _isBackButton = false, disabled }) => {
21
+ const context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
22
+ const { isSeparatedMenu, size } = context;
23
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
24
+ const renderIcon = () => {
25
+ const iconColor = _isSubMenu && !disabled ? theme.sideMenuIconSubItemColor : undefined;
26
+ if ((0, scripts_1.isKonturIcon)(icon)) {
27
+ return react_1.default.cloneElement(icon, {
26
28
  size: getIconSize(theme, _isSubMenu, _isBackButton),
27
29
  color: iconColor,
28
30
  align: _isBackButton ? 'baseline' : 'none',
@@ -30,13 +32,14 @@ export var Icon = function (_a) {
30
32
  }
31
33
  return icon;
32
34
  };
33
- return (React.createElement("span", { className: cx((_b = {},
34
- _b[jsStyles.root(theme)] = true,
35
- _b[jsStyles.rootMultiline()] = isMultiline && (context.isOpened || _isSubMenu),
36
- _b[jsStyles.rootLarge(theme)] = size === 'large',
37
- _b[jsStyles.rootSubItem(theme)] = _isSubMenu,
38
- _b[jsStyles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
39
- _b[jsStyles.rootSubItemLarge(theme)] = _isSubMenu && size === 'large',
40
- _b[jsStyles.rootBackButton(theme)] = _isBackButton,
41
- _b)) }, renderIcon()));
35
+ return (react_1.default.createElement("span", { className: (0, Emotion_1.cx)({
36
+ [Icon_styles_1.jsStyles.root(theme)]: true,
37
+ [Icon_styles_1.jsStyles.rootMultiline()]: isMultiline && (context.isOpened || _isSubMenu),
38
+ [Icon_styles_1.jsStyles.rootLarge(theme)]: size === 'large',
39
+ [Icon_styles_1.jsStyles.rootSubItem(theme)]: _isSubMenu,
40
+ [Icon_styles_1.jsStyles.rootSubItemSeparatedMenu(theme)]: isSeparatedMenu && _isSubMenu,
41
+ [Icon_styles_1.jsStyles.rootSubItemLarge(theme)]: _isSubMenu && size === 'large',
42
+ [Icon_styles_1.jsStyles.rootBackButton(theme)]: _isBackButton,
43
+ }) }, renderIcon()));
42
44
  };
45
+ exports.Icon = Icon;
@@ -1,28 +1,57 @@
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 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);
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
+ display: flex;
10
+ align-items: center;
11
+ margin: ${t.sideMenuIconMarginY} ${t.sideMenuIconMarginRight} ${t.sideMenuIconMarginY} ${t.sideMenuIconMarginLeft};
12
+ min-height: ${t.sideMenuIconMinHeight};
13
+ line-height: ${t.sideMenuIconLineHeight};
14
+ flex-shrink: 0;
15
+ box-sizing: content-box;
16
+ `;
7
17
  },
8
- rootMultiline: function () {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: -2px;\n "], ["\n align-self: flex-start;\n margin-top: -2px;\n "])));
18
+ rootMultiline() {
19
+ return (0, Emotion_1.css) `
20
+ align-self: flex-start;
21
+ margin-top: -2px;
22
+ `;
10
23
  },
11
- rootLarge: function (t) {
12
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "], ["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "])), t.sideMenuIconLargeMinHeight, t.sideMenuIconLargeLineHeight);
24
+ rootLarge(t) {
25
+ return (0, Emotion_1.css) `
26
+ min-height: ${t.sideMenuIconLargeMinHeight};
27
+ line-height: ${t.sideMenuIconLargeLineHeight};
28
+ margin-top: 0;
29
+ `;
13
30
  },
14
- rootSubItemLarge: function (t) {
15
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconLargeSubItemMinHeight);
31
+ rootSubItemLarge(t) {
32
+ return (0, Emotion_1.css) `
33
+ min-height: ${t.sideMenuIconLargeSubItemMinHeight};
34
+ `;
16
35
  },
17
- rootSubItem: function (t) {
18
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "], ["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "])), t.sideMenuIconSubItemPaddingLeft, t.sideMenuIconSubItemPaddingRight, t.sideMenuIconSubItemMinHeight, t.sideMenuIconSubItemLineHeight);
36
+ rootSubItem(t) {
37
+ return (0, Emotion_1.css) `
38
+ margin: 0;
39
+ padding-left: ${t.sideMenuIconSubItemPaddingLeft};
40
+ padding-right: ${t.sideMenuIconSubItemPaddingRight};
41
+ min-height: ${t.sideMenuIconSubItemMinHeight};
42
+ line-height: ${t.sideMenuIconSubItemLineHeight};
43
+ `;
19
44
  },
20
- rootSubItemSeparatedMenu: function (t) {
21
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
45
+ rootSubItemSeparatedMenu(t) {
46
+ return (0, Emotion_1.css) `
47
+ padding-left: ${t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft};
48
+ `;
22
49
  },
23
- rootBackButton: function (t) {
24
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
50
+ rootBackButton(t) {
51
+ return (0, Emotion_1.css) `
52
+ padding-left: ${t.sideMenuBackButtonIconPaddingLeft};
53
+ padding-right: ${t.sideMenuBackButtonIconPaddingRight};
54
+ `;
25
55
  },
26
56
  };
27
- export var jsStyles = memoizeStyle(styles);
28
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
57
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,14 +1,17 @@
1
- import { __read } from "tslib";
2
- import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
3
- import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
4
- import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
5
- import { SideMenuContext } from '../../SideMenuContext';
6
- import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
7
- import { jsStyles } from './ItemContent.styles';
8
- import { Icon } from './Icon';
9
- import { Caption } from './Caption';
10
- import { Marker } from './Marker';
11
- var getCaptionLineHeight = function (theme, isTouchScreen, _isSubMenu, size) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ItemContent = 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 SideMenuContext_1 = require("../../SideMenuContext");
9
+ const ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
10
+ const ItemContent_styles_1 = require("./ItemContent.styles");
11
+ const Icon_1 = require("./Icon");
12
+ const Caption_1 = require("./Caption");
13
+ const Marker_1 = require("./Marker");
14
+ const getCaptionLineHeight = (theme, isTouchScreen, _isSubMenu, size) => {
12
15
  if (isTouchScreen) {
13
16
  if (_isSubMenu) {
14
17
  return theme.sideMenuCaptionSubItemLineHeightForTouchScreens;
@@ -23,16 +26,13 @@ var getCaptionLineHeight = function (theme, isTouchScreen, _isSubMenu, size) {
23
26
  /**
24
27
  * Контент для SideMenuItem или SideMenuLink
25
28
  */
26
- var ItemContent = forwardRef(function (_a, ref) {
27
- var _b, _c;
28
- var _d;
29
- var _isSubMenu = _a._isSubMenu, icon = _a.icon, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, marker = _a.marker, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar, disabled = _a.disabled;
30
- var context = useContext(SideMenuContext);
31
- var size = context.size, isTouchScreen = context.isTouchScreen;
32
- var textRef = useRef(null);
33
- var _e = __read(useState(false), 2), isMultiline = _e[0], setIsMultiline = _e[1];
34
- var theme = getSideMenuTheme(useContext(ThemeContext));
35
- useEffect(function () {
29
+ const ItemContent = (0, react_1.forwardRef)(({ _isSubMenu, icon, isNestedSubMenu, caption, subCaption, marker, _isBackButton, _isDropdown, _isAvatar, disabled }, ref) => {
30
+ const context = (0, react_1.useContext)(SideMenuContext_1.SideMenuContext);
31
+ const { size, isTouchScreen } = context;
32
+ const textRef = (0, react_1.useRef)(null);
33
+ const [isMultiline, setIsMultiline] = (0, react_1.useState)(false);
34
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
35
+ (0, react_1.useEffect)(() => {
36
36
  if (subCaption) {
37
37
  setIsMultiline(true);
38
38
  return;
@@ -40,31 +40,31 @@ var ItemContent = forwardRef(function (_a, ref) {
40
40
  if (!textRef.current || _isBackButton || _isDropdown) {
41
41
  return;
42
42
  }
43
- var captionLineHeight = getCaptionLineHeight(theme, context.isTouchScreen, _isSubMenu, size);
44
- var isMultiline = parseInt(captionLineHeight) < textRef.current.offsetHeight;
43
+ const captionLineHeight = getCaptionLineHeight(theme, context.isTouchScreen, _isSubMenu, size);
44
+ const isMultiline = parseInt(captionLineHeight) < textRef.current.offsetHeight;
45
45
  if (isMultiline) {
46
46
  setIsMultiline(true);
47
47
  }
48
- }, [caption, context.isBeingTransitioned, (_d = context.navigation) === null || _d === void 0 ? void 0 : _d.activeMenuItem]);
49
- return (React.createElement("div", { className: cx((_b = {},
50
- _b[jsStyles.root(theme)] = true,
51
- _b[jsStyles.subItemRoot(theme)] = _isSubMenu,
52
- _b[jsStyles.largeRoot(theme)] = size === 'large' && !_isSubMenu,
53
- _b[jsStyles.subItemLargeRoot(theme)] = size === 'large' && _isSubMenu,
54
- _b[jsStyles.multilineRoot(theme)] = isMultiline && !_isSubMenu && context.isOpened,
55
- _b[jsStyles.largeMultilineRoot(theme)] = isMultiline && size === 'large',
56
- _b[jsStyles.rootForTouchScreens(theme)] = isTouchScreen,
57
- _b[jsStyles.subItemRootForTouchScreens(theme)] = isTouchScreen && _isSubMenu,
58
- _b)), ref: ref },
59
- icon && (React.createElement(Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton, _isAvatar: _isAvatar, disabled: disabled })),
60
- React.createElement("div", { className: cx((_c = {},
61
- _c[jsStyles.textAndMarkerWrapper()] = true,
62
- _c[jsStyles.textAndMarkerWrapperDropdown()] = _isDropdown,
63
- _c[jsStyles.textAndMarkerWrapperMinimized()] = !context.isOpened && !_isSubMenu,
64
- _c)) },
65
- React.createElement(Caption, { _isSubMenu: _isSubMenu, isNestedSubMenu: isNestedSubMenu, hasIcon: !!icon, isMultiline: isMultiline, caption: caption, subCaption: subCaption, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef })),
66
- marker !== undefined && (React.createElement(Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu, isMinimized: !context.isOpened, disabled: disabled }))));
48
+ }, [caption, context.isBeingTransitioned, context.navigation?.activeMenuItem]);
49
+ return (react_1.default.createElement("div", { className: (0, Emotion_1.cx)({
50
+ [ItemContent_styles_1.jsStyles.root(theme)]: true,
51
+ [ItemContent_styles_1.jsStyles.subItemRoot(theme)]: _isSubMenu,
52
+ [ItemContent_styles_1.jsStyles.largeRoot(theme)]: size === 'large' && !_isSubMenu,
53
+ [ItemContent_styles_1.jsStyles.subItemLargeRoot(theme)]: size === 'large' && _isSubMenu,
54
+ [ItemContent_styles_1.jsStyles.multilineRoot(theme)]: isMultiline && !_isSubMenu && context.isOpened,
55
+ [ItemContent_styles_1.jsStyles.largeMultilineRoot(theme)]: isMultiline && size === 'large',
56
+ [ItemContent_styles_1.jsStyles.rootForTouchScreens(theme)]: isTouchScreen,
57
+ [ItemContent_styles_1.jsStyles.subItemRootForTouchScreens(theme)]: isTouchScreen && _isSubMenu,
58
+ }), ref: ref },
59
+ icon && (react_1.default.createElement(Icon_1.Icon, { icon: icon, _isSubMenu: _isSubMenu, isMultiline: isMultiline, _isBackButton: _isBackButton, _isAvatar: _isAvatar, disabled: disabled })),
60
+ react_1.default.createElement("div", { className: (0, Emotion_1.cx)({
61
+ [ItemContent_styles_1.jsStyles.textAndMarkerWrapper()]: true,
62
+ [ItemContent_styles_1.jsStyles.textAndMarkerWrapperDropdown()]: _isDropdown,
63
+ [ItemContent_styles_1.jsStyles.textAndMarkerWrapperMinimized()]: !context.isOpened && !_isSubMenu,
64
+ }) },
65
+ react_1.default.createElement(Caption_1.Caption, { _isSubMenu: _isSubMenu, isNestedSubMenu: isNestedSubMenu, hasIcon: !!icon, isMultiline: isMultiline, caption: caption, subCaption: subCaption, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef })),
66
+ marker !== undefined && (react_1.default.createElement(Marker_1.Marker, { isMultiline: isMultiline, marker: marker, _isSubMenu: _isSubMenu, isMinimized: !context.isOpened, disabled: disabled }))));
67
67
  });
68
68
  ItemContent.displayName = 'ItemContent';
69
- var ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
70
- export { ItemContentWithStaticFields as ItemContent };
69
+ const ItemContentWithStaticFields = Object.assign(ItemContent, { __KONTUR_REACT_UI__: 'ItemContent' });
70
+ exports.ItemContent = ItemContentWithStaticFields;
@@ -1,40 +1,77 @@
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 display: flex;\n align-items: center;\n padding-top: ", ";\n padding-bottom: ", ";\n position: relative;\n "], ["\n display: flex;\n align-items: center;\n padding-top: ", ";\n padding-bottom: ", ";\n position: relative;\n "])), t.sideMenuItemContentPaddingY, t.sideMenuItemContentPaddingY);
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
+ display: flex;
10
+ align-items: center;
11
+ padding-top: ${t.sideMenuItemContentPaddingY};
12
+ padding-bottom: ${t.sideMenuItemContentPaddingY};
13
+ position: relative;
14
+ `;
7
15
  },
8
- largeRoot: function (t) {
9
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentLargePaddingY, t.sideMenuItemContentLargePaddingY);
16
+ largeRoot(t) {
17
+ return (0, Emotion_1.css) `
18
+ padding-top: ${t.sideMenuItemContentLargePaddingY} !important;
19
+ padding-bottom: ${t.sideMenuItemContentLargePaddingY} !important;
20
+ `;
10
21
  },
11
- subItemLargeRoot: function (t) {
12
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuSubItemContentLargePaddingY, t.sideMenuSubItemContentLargePaddingY);
22
+ subItemLargeRoot(t) {
23
+ return (0, Emotion_1.css) `
24
+ padding-top: ${t.sideMenuSubItemContentLargePaddingY} !important;
25
+ padding-bottom: ${t.sideMenuSubItemContentLargePaddingY} !important;
26
+ `;
13
27
  },
14
- multilineRoot: function (t) {
15
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentMultilinePaddingTop, t.sideMenuItemContentMultilinePaddingBottom);
28
+ multilineRoot(t) {
29
+ return (0, Emotion_1.css) `
30
+ padding-top: ${t.sideMenuItemContentMultilinePaddingTop} !important;
31
+ padding-bottom: ${t.sideMenuItemContentMultilinePaddingBottom} !important;
32
+ `;
16
33
  },
17
- largeMultilineRoot: function (t) {
18
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "], ["\n padding-top: ", " !important;\n padding-bottom: ", " !important;\n "])), t.sideMenuItemContentLargeMultilinePaddingTop, t.sideMenuItemContentLargeMultilinePaddingBottom);
34
+ largeMultilineRoot(t) {
35
+ return (0, Emotion_1.css) `
36
+ padding-top: ${t.sideMenuItemContentLargeMultilinePaddingTop} !important;
37
+ padding-bottom: ${t.sideMenuItemContentLargeMultilinePaddingBottom} !important;
38
+ `;
19
39
  },
20
- rootForTouchScreens: function (t) {
21
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuItemContentPaddingYForTouchScreens, t.sideMenuItemContentPaddingYForTouchScreens);
40
+ rootForTouchScreens(t) {
41
+ return (0, Emotion_1.css) `
42
+ padding-top: ${t.sideMenuItemContentPaddingYForTouchScreens};
43
+ padding-bottom: ${t.sideMenuItemContentPaddingYForTouchScreens};
44
+ `;
22
45
  },
23
- subItemRootForTouchScreens: function (t) {
24
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingYForTouchScreens, t.sideMenuSubItemContentPaddingYForTouchScreens);
46
+ subItemRootForTouchScreens(t) {
47
+ return (0, Emotion_1.css) `
48
+ padding-top: ${t.sideMenuSubItemContentPaddingYForTouchScreens};
49
+ padding-bottom: ${t.sideMenuSubItemContentPaddingYForTouchScreens};
50
+ `;
25
51
  },
26
- subItemRoot: function (t) {
27
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingY, t.sideMenuSubItemContentPaddingY);
52
+ subItemRoot(t) {
53
+ return (0, Emotion_1.css) `
54
+ padding-top: ${t.sideMenuSubItemContentPaddingY};
55
+ padding-bottom: ${t.sideMenuSubItemContentPaddingY};
56
+ `;
28
57
  },
29
- textAndMarkerWrapper: function () {
30
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "])));
58
+ textAndMarkerWrapper() {
59
+ return (0, Emotion_1.css) `
60
+ display: flex;
61
+ flex-grow: 1;
62
+ align-items: center;
63
+ min-width: 0;
64
+ `;
31
65
  },
32
- textAndMarkerWrapperDropdown: function () {
33
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
66
+ textAndMarkerWrapperDropdown() {
67
+ return (0, Emotion_1.css) `
68
+ overflow: hidden;
69
+ `;
34
70
  },
35
- textAndMarkerWrapperMinimized: function () {
36
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
71
+ textAndMarkerWrapperMinimized() {
72
+ return (0, Emotion_1.css) `
73
+ display: none;
74
+ `;
37
75
  },
38
76
  };
39
- export var jsStyles = memoizeStyle(styles);
40
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
77
+ exports.jsStyles = (0, ThemeHelpers_1.memoizeStyle)(styles);
@@ -1,21 +1,24 @@
1
- import { cx } from '@skbkontur/react-ui/lib/theming/Emotion';
2
- import React, { useContext } from 'react';
3
- import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
4
- import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers';
5
- import { jsStyles } from './Marker.styles';
6
- export var Marker = function (_a) {
7
- var _b;
8
- var isMultiline = _a.isMultiline, marker = _a.marker, _isSubMenu = _a._isSubMenu, disabled = _a.disabled, isMinimized = _a.isMinimized;
9
- var theme = getSideMenuTheme(useContext(ThemeContext));
10
- var emptyMarker = marker === true || marker === '';
11
- return (React.createElement("span", { className: cx((_b = {},
12
- _b[jsStyles.root(theme)] = true,
13
- _b[jsStyles.rootDisabled(theme)] = disabled,
14
- _b[jsStyles.rootEmpty(theme)] = emptyMarker,
15
- _b[jsStyles.rootMultiline(theme)] = isMultiline,
16
- _b[jsStyles.rootSubMenu(theme)] = _isSubMenu,
17
- _b[jsStyles.rootSubMenuEmpty(theme)] = _isSubMenu && emptyMarker,
18
- _b[jsStyles.rootMinimized()] = isMinimized && !_isSubMenu,
19
- _b[jsStyles.rootEmptyMinimized()] = emptyMarker && isMinimized && !_isSubMenu,
20
- _b)) }, marker));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Marker = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Emotion_1 = require("@skbkontur/react-ui/lib/theming/Emotion");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const ThemeContext_1 = require("@skbkontur/react-ui/lib/theming/ThemeContext");
8
+ const ThemeHelpers_1 = require("../../../lib/theming/ThemeHelpers");
9
+ const Marker_styles_1 = require("./Marker.styles");
10
+ const Marker = ({ isMultiline, marker, _isSubMenu, disabled, isMinimized }) => {
11
+ const theme = (0, ThemeHelpers_1.getSideMenuTheme)((0, react_1.useContext)(ThemeContext_1.ThemeContext));
12
+ const emptyMarker = marker === true || marker === '';
13
+ return (react_1.default.createElement("span", { className: (0, Emotion_1.cx)({
14
+ [Marker_styles_1.jsStyles.root(theme)]: true,
15
+ [Marker_styles_1.jsStyles.rootDisabled(theme)]: disabled,
16
+ [Marker_styles_1.jsStyles.rootEmpty(theme)]: emptyMarker,
17
+ [Marker_styles_1.jsStyles.rootMultiline(theme)]: isMultiline,
18
+ [Marker_styles_1.jsStyles.rootSubMenu(theme)]: _isSubMenu,
19
+ [Marker_styles_1.jsStyles.rootSubMenuEmpty(theme)]: _isSubMenu && emptyMarker,
20
+ [Marker_styles_1.jsStyles.rootMinimized()]: isMinimized && !_isSubMenu,
21
+ [Marker_styles_1.jsStyles.rootEmptyMinimized()]: emptyMarker && isMinimized && !_isSubMenu,
22
+ }) }, marker));
21
23
  };
24
+ exports.Marker = Marker;