@skbkontur/side-menu 5.0.0-alpha.1 → 5.0.0-alpha.3

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 (49) hide show
  1. package/internal/themes/SideMenuDarkTheme.js +4 -2
  2. package/internal/themes/SideMenuTheme.d.ts +29 -3
  3. package/internal/themes/SideMenuTheme.js +45 -13
  4. package/package.json +2 -2
  5. package/src/SideMenu/SideMenu.d.ts +3 -0
  6. package/src/SideMenu/SideMenu.js +101 -55
  7. package/src/SideMenu/SideMenu.styles.d.ts +4 -0
  8. package/src/SideMenu/SideMenu.styles.js +28 -11
  9. package/src/SideMenuAvatar/SideMenuAvatar.js +15 -3
  10. package/src/SideMenuBody/SideMenuBody.js +2 -0
  11. package/src/SideMenuBody/SideMenuBody.styles.js +1 -1
  12. package/src/SideMenuContext.d.ts +2 -0
  13. package/src/SideMenuDivider/SideMenuDivider.js +4 -1
  14. package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -0
  15. package/src/SideMenuDivider/SideMenuDivider.styles.js +5 -2
  16. package/src/SideMenuDropdown/SideMenuDropdown.js +9 -7
  17. package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +2 -0
  18. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +11 -4
  19. package/src/SideMenuFooter/SideMenuFooter.js +41 -5
  20. package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +7 -0
  21. package/src/SideMenuFooter/SideMenuFooter.styles.js +30 -8
  22. package/src/SideMenuHeader/SideMenuHeader.js +1 -0
  23. package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +1 -0
  24. package/src/SideMenuHeader/SideMenuHeader.styles.js +9 -6
  25. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -1
  26. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -1
  27. package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +2 -2
  28. package/src/internal/ClickableElement.d.ts +1 -1
  29. package/src/internal/ClickableElement.js +4 -3
  30. package/src/internal/ClickableElement.styles.d.ts +1 -0
  31. package/src/internal/ClickableElement.styles.js +16 -11
  32. package/src/internal/CollapseToggle.js +6 -2
  33. package/src/internal/CollapseToggle.styles.d.ts +2 -0
  34. package/src/internal/CollapseToggle.styles.js +8 -3
  35. package/src/internal/ItemContent/Caption.js +4 -2
  36. package/src/internal/ItemContent/Caption.styles.d.ts +2 -0
  37. package/src/internal/ItemContent/Caption.styles.js +19 -13
  38. package/src/internal/ItemContent/Icon.js +3 -1
  39. package/src/internal/ItemContent/Icon.styles.d.ts +2 -0
  40. package/src/internal/ItemContent/Icon.styles.js +14 -8
  41. package/src/internal/ItemContent/ItemContent.js +40 -3
  42. package/src/internal/ItemContent/ItemContent.styles.d.ts +3 -0
  43. package/src/internal/ItemContent/ItemContent.styles.js +14 -4
  44. package/src/internal/ItemContent/Marker.js +8 -2
  45. package/src/internal/ItemContent/Marker.styles.d.ts +3 -0
  46. package/src/internal/ItemContent/Marker.styles.js +17 -6
  47. package/src/internal/NarrowAccordionDropdown.js +9 -9
  48. package/src/internal/SideMenuLogotype.js +9 -20
  49. package/src/internal/SideMenuLogotype.styles.js +4 -4
@@ -7,36 +7,41 @@ export var getStyles = memoizeGetStyles(function (_a) {
7
7
  root: function (t) {
8
8
  return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n user-select: text;\n ", ";\n color: ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n box-sizing: border-box;\n scroll-margin-top: var(--side-menu-scroll-margin-top, 0);\n scroll-margin-bottom: var(--side-menu-scroll-margin-bottom, 0);\n transition: background ", " ease-out;\n\n &:hover {\n background: ", ";\n }\n "], ["\n user-select: text;\n ", ";\n color: ", ";\n width: 100%;\n border-radius: ", ";\n cursor: pointer;\n box-sizing: border-box;\n scroll-margin-top: var(--side-menu-scroll-margin-top, 0);\n scroll-margin-bottom: var(--side-menu-scroll-margin-bottom, 0);\n transition: background ", " ease-out;\n\n &:hover {\n background: ", ";\n }\n "])), resetButton(), t.sideMenuItemColor, t.sideMenuItemBorderRadius, t.transitionDuration, t.sideMenuItemBgHover);
9
9
  },
10
+ rootLarge: function (t) {
11
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: ", ";\n "], ["\n border-radius: ", ";\n "])), t.sideMenuItemBorderRadiusLarge);
12
+ },
10
13
  rootButton: function (t) {
11
- return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemBgPressed);
14
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemBgPressed);
12
15
  },
13
16
  rootSubItemInSeparatedSubMenu: function (t) {
14
- return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgHover);
17
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgHover);
15
18
  },
16
19
  rootSubItemInSeparatedSubMenuButton: function (t) {
17
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgPressed);
20
+ // :hover:active — чтобы нажатие не перебивалось :hover из rootSubItemInSeparatedSubMenu,
21
+ // который в итоговом классе идёт позже (одинаковое правило :active из rootButton emotion не дублирует)
22
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n &:hover:active,\n &:active {\n background: ", ";\n }\n "], ["\n &:hover:active,\n &:active {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgPressed);
18
23
  },
19
24
  rootFocus: function (t) {
20
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuItemBoxShadowFocus);
25
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n box-shadow: ", ";\n "], ["\n box-shadow: ", ";\n "])), t.sideMenuItemBoxShadowFocus);
21
26
  },
22
27
  rootDisabled: function (t) {
23
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n color: ", ";\n pointer-events: none;\n "], ["\n color: ", ";\n pointer-events: none;\n "])), t.sideMenuItemColorDisabled);
28
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n color: ", ";\n pointer-events: none;\n "], ["\n color: ", ";\n pointer-events: none;\n "])), t.sideMenuItemColorDisabled);
24
29
  },
25
30
  rootActive: function (t) {
26
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgActive);
31
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgActive);
27
32
  },
28
33
  rootDropdownOpen: function (t) {
29
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgHover);
34
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgHover);
30
35
  },
31
36
  rootSubItemInDropdownActive: function (t) {
32
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgHover);
37
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgHover);
33
38
  },
34
39
  rootSubItemInDropdownButton: function (t) {
35
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemBgPressed);
40
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemBgPressed);
36
41
  },
37
42
  rootSubItemInSeparatedSubMenuActive: function (t) {
38
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgActive);
43
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background: ", " !important;\n\n &:hover {\n background: ", " !important;\n }\n\n &:active {\n background: ", " !important;\n }\n "], ["\n background: ", " !important;\n\n &:hover {\n background: ", " !important;\n }\n\n &:active {\n background: ", " !important;\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgActive, t.sideMenuSubItemWithSeparatedSubMenuBgActiveHover, t.sideMenuSubItemWithSeparatedSubMenuBgActivePressed);
39
44
  },
40
45
  });
41
46
  });
42
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
47
+ 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;
@@ -13,12 +13,13 @@ var SideMenuCollapseIcon = function () {
13
13
  React.createElement("path", { stroke: "currentColor", strokeWidth: 1.5, d: "M8.5 19V5M6 19h12a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3Z" })));
14
14
  };
15
15
  export var CollapseToggle = function () {
16
+ var _a;
16
17
  var context = useContext(SideMenuContext);
17
18
  var theme = getSideMenuTheme(useContext(ThemeContext));
18
19
  var styles = useStyles(getStyles);
19
20
  var cx = useEmotion().cx;
20
21
  var slotRef = context.collapseToggleRef;
21
- var _a = __read(useState(false), 2), mounted = _a[0], setMounted = _a[1];
22
+ var _b = __read(useState(false), 2), mounted = _b[0], setMounted = _b[1];
22
23
  // The slot lives in the Footer, which mounts in the same commit. Refs are assigned
23
24
  // before layout effects run, so after this effect the portal target is ready.
24
25
  useLayoutEffect(function () {
@@ -31,7 +32,10 @@ export var CollapseToggle = function () {
31
32
  (_a = context.setMenuOpened) === null || _a === void 0 ? void 0 : _a.call(context, !isOpened);
32
33
  };
33
34
  var button = (React.createElement(ClickableElementWithHint, { hint: hintText, isOpened: false },
34
- React.createElement("button", { type: 'button', className: cx(styles.root(theme)), "aria-label": hintText, "aria-expanded": isOpened, "data-tid": SideMenuDataTids.collapseToggle, onClick: handleClick },
35
+ React.createElement("button", { type: 'button', className: cx(styles.root(theme), (_a = {},
36
+ _a[styles.rootOpened(theme)] = isOpened,
37
+ _a[styles.rootLarge(theme)] = context.size === 'large',
38
+ _a)), "aria-label": hintText, "aria-expanded": isOpened, "data-tid": SideMenuDataTids.collapseToggle, onClick: handleClick },
35
39
  React.createElement(SideMenuCollapseIcon, null))));
36
40
  if (!mounted || !(slotRef === null || slotRef === void 0 ? void 0 : slotRef.current)) {
37
41
  return null;
@@ -1,4 +1,6 @@
1
1
  import type { SideMenuTheme } from '../../lib/theming/ThemeTypes.js';
2
2
  export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").StylesGetter<{
3
3
  root(t: SideMenuTheme): string;
4
+ rootOpened(t: SideMenuTheme): string;
5
+ rootLarge(t: SideMenuTheme): string;
4
6
  }>;
@@ -1,13 +1,18 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
3
3
  import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
4
- import { transitionDuration } from '../SideMenu/SideMenu.js';
5
4
  export var getStyles = memoizeGetStyles(function (_a) {
6
5
  var css = _a.css;
7
6
  return ({
8
7
  root: function (t) {
9
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: background ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n\n svg {\n transition: opacity ", ";\n }\n "], ["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: background ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n\n svg {\n transition: opacity ", ";\n }\n "])), resetButton(), t.sideMenuCollapseToggleSize, t.sideMenuCollapseToggleSize, t.sideMenuItemBorderRadius, t.sideMenuRightBorderIconColor, t.transitionDuration, t.sideMenuRightBorderIconColorHover, t.sideMenuItemBoxShadowFocus, transitionDuration);
8
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: color ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n "], ["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: color ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n "])), resetButton(), t.sideMenuCollapseToggleSize, t.sideMenuCollapseToggleSize, t.sideMenuItemBorderRadius, t.sideMenuRightBorderIconColor, t.transitionDuration, t.sideMenuRightBorderIconColorHover, t.sideMenuItemBoxShadowFocus);
9
+ },
10
+ rootOpened: function (t) {
11
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-sizing: content-box;\n padding-right: ", ";\n "], ["\n box-sizing: content-box;\n padding-right: ", ";\n "])), t.sideMenuCollapseToggleOffsetRight);
12
+ },
13
+ rootLarge: function (t) {
14
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n border-radius: ", ";\n "], ["\n width: ", ";\n height: ", ";\n border-radius: ", ";\n "])), t.sideMenuCollapseToggleSizeLarge, t.sideMenuCollapseToggleSizeLarge, t.sideMenuItemBorderRadiusLarge);
10
15
  },
11
16
  });
12
17
  });
13
- var templateObject_1;
18
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -19,7 +19,7 @@ export var Caption = forwardRef(function (_a, ref) {
19
19
  var _b, _c;
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;
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;
23
23
  var isLarge = size === 'large';
24
24
  var isCaptionPlainText = typeof caption === 'string';
25
25
  var captionRef = useRef(null);
@@ -58,10 +58,12 @@ export var Caption = forwardRef(function (_a, ref) {
58
58
  React.createElement(Component, { className: cx(styles.caption(theme), (_c = {},
59
59
  _c[styles.captionDropdown()] = _isDropdown,
60
60
  _c[styles.captionTruncated()] = isCaptionPlainText && _isDropdown,
61
+ _c[styles.captionWithoutMarker(theme)] = !hasMarker && !_isSubMenu,
61
62
  _c[styles.captionSubItem(theme)] = _isSubMenu,
62
63
  _c[styles.captionSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !isNestedSubMenu && _isSubMenu && !hasIcon,
63
64
  _c[styles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
64
- _c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu && isOpened,
65
+ _c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu && isOpened && (hasItemIcons || _isSubMenu),
66
+ _c[styles.captionWithoutAnyIcons(theme)] = !hasIcon && !isSeparatedMenu && isOpened && !hasItemIcons && !_isSubMenu,
65
67
  _c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSeparatedSubMenu,
66
68
  _c[styles.captionLarge(theme)] = isLarge,
67
69
  _c[styles.captionTouchScreen(theme)] = isTouchScreen,
@@ -8,11 +8,13 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
8
8
  rootMultiline(t: SideMenuTheme): string;
9
9
  caption(t: SideMenuTheme): string;
10
10
  captionTouchScreen(t: SideMenuTheme): string;
11
+ captionWithoutMarker(t: SideMenuTheme): string;
11
12
  captionSubItem(t: SideMenuTheme): string;
12
13
  captionSubItemTouchScreen(t: SideMenuTheme): string;
13
14
  captionSubItemSeparatedMenuTopLevel(): string;
14
15
  captionNestedItemSeparatedMenu(): string;
15
16
  captionWithoutItemIcon(): string;
17
+ captionWithoutAnyIcons(t: SideMenuTheme): string;
16
18
  captionSubItemWithoutColumnIcons(): string;
17
19
  captionLarge(t: SideMenuTheme): string;
18
20
  captionInBackButton(t: SideMenuTheme): string;
@@ -19,42 +19,48 @@ export var getStyles = memoizeGetStyles(function (_a) {
19
19
  captionTouchScreen: function (t) {
20
20
  return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeTouchScreen, t.sideMenuCaptionLineHeightTouchScreen);
21
21
  },
22
+ captionWithoutMarker: function (t) {
23
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-right: ", ";\n "], ["\n margin-right: ", ";\n "])), t.sideMenuItemPaddingRight);
24
+ },
22
25
  captionSubItem: function (t) {
23
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
26
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
24
27
  },
25
28
  captionSubItemTouchScreen: function (t) {
26
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeTouchScreen, t.sideMenuCaptionSubItemLineHeightTouchScreen);
29
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeTouchScreen, t.sideMenuCaptionSubItemLineHeightTouchScreen);
27
30
  },
28
31
  captionSubItemSeparatedMenuTopLevel: function () {
29
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0 8px;\n "], ["\n margin: 0 8px;\n "])));
32
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin: 0 8px 0 12px;\n "], ["\n margin: 0 8px 0 12px;\n "])));
30
33
  },
31
34
  captionNestedItemSeparatedMenu: function () {
32
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin-left: 25px;\n "], ["\n margin-left: 25px;\n "])));
35
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 28px;\n "], ["\n margin-left: 28px;\n "])));
33
36
  },
34
37
  captionWithoutItemIcon: function () {
35
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 40px;\n "], ["\n margin-left: 40px;\n "])));
38
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 48px;\n "], ["\n margin-left: 48px;\n "])));
39
+ },
40
+ captionWithoutAnyIcons: function (t) {
41
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeft);
36
42
  },
37
43
  captionSubItemWithoutColumnIcons: function () {
38
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 8px;\n "], ["\n margin-left: 8px;\n "])));
44
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n margin-left: 12px;\n "], ["\n margin-left: 12px;\n "])));
39
45
  },
40
46
  captionLarge: function (t) {
41
- 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.sideMenuCaptionFontSizeLarge, t.sideMenuCaptionLineHeightLarge);
47
+ return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionFontSizeLarge, t.sideMenuCaptionLineHeightLarge);
42
48
  },
43
49
  captionInBackButton: function (t) {
44
- 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);
50
+ return css(templateObject_14 || (templateObject_14 = __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);
45
51
  },
46
52
  captionDropdown: function () {
47
- return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
53
+ return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
48
54
  },
49
55
  captionTruncated: function () {
50
- 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 "])));
56
+ return css(templateObject_16 || (templateObject_16 = __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 "])));
51
57
  },
52
58
  captionNoWrap: function () {
53
- return css(templateObject_15 || (templateObject_15 = __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 "])));
59
+ return css(templateObject_17 || (templateObject_17 = __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 "])));
54
60
  },
55
61
  captionNoWrapWithMarker: function (t) {
56
- return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
62
+ return css(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
57
63
  },
58
64
  });
59
65
  });
60
- 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;
66
+ 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;
@@ -24,7 +24,7 @@ export var Icon = function (_a) {
24
24
  var cx = useEmotion().cx;
25
25
  var renderIcon = function () {
26
26
  var iconColor = _isSubMenu && !disabled ? theme.sideMenuIconSubItemColor : undefined;
27
- if (isKonturIcon(icon)) {
27
+ if (icon && isKonturIcon(icon)) {
28
28
  return React.cloneElement(icon, {
29
29
  size: getIconSize(theme, _isSubMenu, _isBackButton),
30
30
  color: iconColor,
@@ -36,6 +36,8 @@ export var Icon = function (_a) {
36
36
  return (React.createElement("span", { className: cx(styles.root(theme), (_b = {},
37
37
  _b[styles.rootMultiline()] = isMultiline && (isOpened || _isSubMenu),
38
38
  _b[styles.rootLarge(theme)] = isLarge,
39
+ _b[styles.rootCollapsed(theme)] = !isOpened && !_isSubMenu,
40
+ _b[styles.rootCollapsedLarge(theme)] = !isOpened && !_isSubMenu && isLarge,
39
41
  _b[styles.rootSubItem(theme)] = _isSubMenu,
40
42
  _b[styles.rootSubItemDropdown()] = _isSubMenu && !isOpened && !isSeparatedMenu,
41
43
  _b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
@@ -1,6 +1,8 @@
1
1
  import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes.js';
2
2
  export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").StylesGetter<{
3
3
  root(t: SideMenuTheme): string;
4
+ rootCollapsed(t: SideMenuTheme): string;
5
+ rootCollapsedLarge(t: SideMenuTheme): string;
4
6
  rootMultiline(): string;
5
7
  rootLarge(t: SideMenuTheme): string;
6
8
  rootSubItemLarge(t: SideMenuTheme): string;
@@ -6,27 +6,33 @@ export var getStyles = memoizeGetStyles(function (_a) {
6
6
  root: function (t) {
7
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
8
  },
9
+ rootCollapsed: function (t) {
10
+ return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
11
+ },
12
+ rootCollapsedLarge: function (t) {
13
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-left: ", ";\n margin-right: ", ";\n "], ["\n margin-left: ", ";\n margin-right: ", ";\n "])), t.sideMenuIconMarginXCollapsedLarge, t.sideMenuIconMarginXCollapsedLarge);
14
+ },
9
15
  rootMultiline: function () {
10
- 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 "])));
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: -2px;\n "], ["\n align-self: flex-start;\n margin-top: -2px;\n "])));
11
17
  },
12
18
  rootLarge: function (t) {
13
- 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.sideMenuIconMinHeightLarge, t.sideMenuIconLineHeightLarge);
19
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "], ["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "])), t.sideMenuIconMinHeightLarge, t.sideMenuIconLineHeightLarge);
14
20
  },
15
21
  rootSubItemLarge: function (t) {
16
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
22
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
17
23
  },
18
24
  rootSubItem: function (t) {
19
- 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);
25
+ return css(templateObject_7 || (templateObject_7 = __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);
20
26
  },
21
27
  rootSubItemDropdown: function () {
22
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
28
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
23
29
  },
24
30
  rootSubItemSeparatedMenu: function (t) {
25
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
31
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
26
32
  },
27
33
  rootBackButton: function (t) {
28
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
34
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
29
35
  },
30
36
  });
31
37
  });
32
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
38
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -1,7 +1,7 @@
1
- import { __read } from "tslib";
1
+ import { __read, __values } from "tslib";
2
2
  import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
3
3
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
4
- import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
4
+ import React, { forwardRef, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
5
5
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
6
6
  import { SideMenuContext } from '../../SideMenuContext.js';
7
7
  import { Caption } from './Caption.js';
@@ -20,6 +20,35 @@ var getCaptionLineHeight = function (theme, isTouchScreen, _isSubMenu, size) {
20
20
  }
21
21
  return theme.sideMenuCaptionLineHeight;
22
22
  };
23
+ var getFirstLetter = function (node) {
24
+ var e_1, _a;
25
+ if (typeof node === 'string' || typeof node === 'number') {
26
+ return String(node).trim().charAt(0).toUpperCase();
27
+ }
28
+ if (Array.isArray(node)) {
29
+ try {
30
+ for (var node_1 = __values(node), node_1_1 = node_1.next(); !node_1_1.done; node_1_1 = node_1.next()) {
31
+ var child = node_1_1.value;
32
+ var letter = getFirstLetter(child);
33
+ if (letter) {
34
+ return letter;
35
+ }
36
+ }
37
+ }
38
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
39
+ finally {
40
+ try {
41
+ if (node_1_1 && !node_1_1.done && (_a = node_1.return)) _a.call(node_1);
42
+ }
43
+ finally { if (e_1) throw e_1.error; }
44
+ }
45
+ return '';
46
+ }
47
+ if (React.isValidElement(node)) {
48
+ return getFirstLetter(node.props.children);
49
+ }
50
+ return '';
51
+ };
23
52
  /**
24
53
  * Контент для SideMenuItem или SideMenuLink
25
54
  */
@@ -31,6 +60,10 @@ var ItemContent = forwardRef(function (_a, ref) {
31
60
  var textRef = useRef(null);
32
61
  var isLarge = size === 'large';
33
62
  var _d = __read(useState(false), 2), isMultiline = _d[0], setIsMultiline = _d[1];
63
+ var isTopLevelItem = !_isSubMenu && !_isAvatar && !_isBackButton;
64
+ var registerItemIcon = context.registerItemIcon;
65
+ var countsAsItemIcon = isTopLevelItem && !!icon;
66
+ useLayoutEffect(function () { return (countsAsItemIcon ? registerItemIcon === null || registerItemIcon === void 0 ? void 0 : registerItemIcon() : undefined); }, [countsAsItemIcon, registerItemIcon]);
34
67
  var theme = getSideMenuTheme(useContext(ThemeContext));
35
68
  var styles = useStyles(getStyles);
36
69
  var cx = useEmotion().cx;
@@ -61,6 +94,8 @@ var ItemContent = forwardRef(function (_a, ref) {
61
94
  _isSubMenu,
62
95
  size,
63
96
  ]);
97
+ var letterIcon = !icon && isTopLevelItem && !context.isOpened && getFirstLetter(caption) ? (React.createElement("span", { className: styles.letterIcon(theme), "aria-hidden": true }, getFirstLetter(caption))) : null;
98
+ var itemIcon = icon || letterIcon;
64
99
  return (React.createElement("div", { className: cx(styles.root(theme), (_b = {},
65
100
  _b[styles.rootLarge(theme)] = isLarge,
66
101
  _b[styles.rootSubItem(theme)] = _isSubMenu,
@@ -71,8 +106,10 @@ var ItemContent = forwardRef(function (_a, ref) {
71
106
  _b[styles.rootSubItemTouchScreen(theme)] = isTouchScreen && _isSubMenu,
72
107
  _b[styles.rootInDropdown(theme)] = !context.isSeparatedMenu && !context.isOpened && _isSubMenu,
73
108
  _b)), ref: ref },
74
- icon && (React.createElement(Icon, { _isSubMenu: _isSubMenu, icon: icon, isMultiline: isMultiline, disabled: disabled, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
109
+ itemIcon && (React.createElement(Icon, { _isSubMenu: _isSubMenu, icon: itemIcon, isMultiline: isMultiline, disabled: disabled, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
75
110
  React.createElement("div", { className: cx(styles.textAndMarkerWrapper(), (_c = {},
111
+ _c[styles.textAndMarkerWrapperTopLevel(theme)] = !_isSubMenu,
112
+ _c[styles.textAndMarkerWrapperTopLevelLarge(theme)] = !_isSubMenu && isLarge,
76
113
  _c[styles.textAndMarkerWrapperDropdown()] = _isDropdown,
77
114
  _c[styles.textAndMarkerWrapperCollapsed()] = !context.isOpened && !_isSubMenu,
78
115
  _c)) },
@@ -9,7 +9,10 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
9
9
  rootTouchScreen(t: SideMenuTheme): string;
10
10
  rootSubItemTouchScreen(t: SideMenuTheme): string;
11
11
  rootInDropdown(t: SideMenuTheme): string;
12
+ letterIcon(t: SideMenuTheme): string;
12
13
  textAndMarkerWrapper(): string;
14
+ textAndMarkerWrapperTopLevel(t: SideMenuTheme): string;
15
+ textAndMarkerWrapperTopLevelLarge(t: SideMenuTheme): string;
13
16
  textAndMarkerWrapperDropdown(): string;
14
17
  textAndMarkerWrapperCollapsed(): string;
15
18
  }>;
@@ -1,5 +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
4
  export var getStyles = memoizeGetStyles(function (_a) {
4
5
  var css = _a.css;
5
6
  return ({
@@ -30,15 +31,24 @@ export var getStyles = memoizeGetStyles(function (_a) {
30
31
  rootInDropdown: function (t) {
31
32
  return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding: ", " ", ";\n "], ["\n padding: ", " ", ";\n "])), t.sideMenuSubItemContentPaddingYDropdown, t.sideMenuSubItemContentPaddingXDropdown);
32
33
  },
34
+ letterIcon: function (t) {
35
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: block;\n width: ", "px;\n font-size: 16px;\n font-weight: 600;\n line-height: ", "px;\n text-align: center;\n "], ["\n display: block;\n width: ", "px;\n font-size: 16px;\n font-weight: 600;\n line-height: ", "px;\n text-align: center;\n "])), t.sideMenuIconSize, t.sideMenuIconSize);
36
+ },
33
37
  textAndMarkerWrapper: function () {
34
- return css(templateObject_10 || (templateObject_10 = __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 "])));
38
+ return css(templateObject_11 || (templateObject_11 = __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 "])));
39
+ },
40
+ textAndMarkerWrapperTopLevel: function (t) {
41
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconMinHeight);
42
+ },
43
+ textAndMarkerWrapperTopLevelLarge: function (t) {
44
+ return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconMinHeightLarge);
35
45
  },
36
46
  textAndMarkerWrapperDropdown: function () {
37
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
47
+ return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
38
48
  },
39
49
  textAndMarkerWrapperCollapsed: function () {
40
- return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
50
+ return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n position: absolute;\n white-space: nowrap;\n visibility: hidden;\n transition: visibility 0s linear ", "ms;\n "], ["\n position: absolute;\n white-space: nowrap;\n visibility: hidden;\n transition: visibility 0s linear ", "ms;\n "])), transitionDuration);
41
51
  },
42
52
  });
43
53
  });
44
- 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;
54
+ 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;
@@ -2,6 +2,7 @@ import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment
2
2
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
3
3
  import React, { useContext } from 'react';
4
4
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
5
+ import { SideMenuContext } from '../../SideMenuContext.js';
5
6
  import { getStyles } from './Marker.styles.js';
6
7
  export var Marker = function (_a) {
7
8
  var _b;
@@ -10,12 +11,17 @@ export var Marker = function (_a) {
10
11
  var styles = useStyles(getStyles);
11
12
  var cx = useEmotion().cx;
12
13
  var isEmpty = marker === true || marker === '';
14
+ var isLarge = useContext(SideMenuContext).size === 'large';
15
+ var isCollapsedItem = !_isSubMenu && isCollapsed;
13
16
  return (React.createElement("span", { className: cx(styles.root(theme), (_b = {},
14
17
  _b[styles.rootEmpty(theme)] = isEmpty,
15
18
  _b[styles.rootMultiline(theme)] = isMultiline,
16
19
  _b[styles.rootSubMenu(theme)] = _isSubMenu,
17
20
  _b[styles.rootSubMenuEmpty(theme)] = _isSubMenu && isEmpty,
18
- _b[styles.rootCollapsed()] = !_isSubMenu && isCollapsed,
19
- _b[styles.rootEmptyCollapsed()] = !_isSubMenu && isEmpty && isCollapsed,
21
+ _b[styles.rootSubMenuLarge(theme)] = _isSubMenu && !isEmpty && isLarge,
22
+ _b[styles.rootCollapsed()] = isCollapsedItem,
23
+ _b[styles.rootCollapsedLarge()] = isCollapsedItem && isLarge,
24
+ _b[styles.rootEmptyCollapsed()] = isCollapsedItem && isEmpty,
25
+ _b[styles.rootEmptyCollapsedLarge()] = isCollapsedItem && isEmpty && isLarge,
20
26
  _b)) }, marker));
21
27
  };
@@ -5,6 +5,9 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
5
5
  rootMultiline(t: SideMenuTheme): string;
6
6
  rootSubMenu(t: SideMenuTheme): string;
7
7
  rootSubMenuEmpty(t: SideMenuTheme): string;
8
+ rootSubMenuLarge(t: SideMenuTheme): string;
8
9
  rootCollapsed(): string;
10
+ rootCollapsedLarge(): string;
9
11
  rootEmptyCollapsed(): string;
12
+ rootEmptyCollapsedLarge(): string;
10
13
  }>;
@@ -4,7 +4,7 @@ export var getStyles = memoizeGetStyles(function (_a) {
4
4
  var css = _a.css;
5
5
  return ({
6
6
  root: function (t) {
7
- 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);
7
+ 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 font-variant-numeric: tabular-nums;\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 font-variant-numeric: tabular-nums;\n flex-shrink: 0;\n "])), t.sideMenuMarkerPaddingY, t.sideMenuMarkerPaddingX, t.sideMenuMarkerBg, t.sideMenuMarkerMarginRight, t.sideMenuMarkerColor, t.sideMenuMarkerFontSize, t.sideMenuMarkerLineHeight, t.sideMenuMarkerFontWeight);
8
8
  },
9
9
  rootEmpty: function (t) {
10
10
  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);
@@ -13,17 +13,28 @@ export var getStyles = memoizeGetStyles(function (_a) {
13
13
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: ", ";\n "], ["\n align-self: flex-start;\n margin-top: ", ";\n "])), t.sideMenuMarkerMultilineMarginTop);
14
14
  },
15
15
  rootSubMenu: function (t) {
16
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemMarginRight, t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
17
17
  },
18
18
  rootSubMenuEmpty: function (t) {
19
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuMarkerBg);
19
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-right: ", ";\n background: ", ";\n "], ["\n margin-right: ", ";\n background: ", ";\n "])), t.sideMenuMarkerSubItemEmptyMarginRight, t.sideMenuMarkerBg);
20
20
  },
21
+ rootSubMenuLarge: function (t) {
22
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuMarkerSubItemFontSizeLarge, t.sideMenuMarkerSubItemLineHeightLarge);
23
+ },
24
+ // В свёрнутом меню бейдж позиционируется относительно центра пункта (т.е. иконки),
25
+ // чтобы не отрываться от неё при любом размере пункта.
21
26
  rootCollapsed: function () {
22
- return css(templateObject_6 || (templateObject_6 = __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 "])));
27
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "], ["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "])));
28
+ },
29
+ rootCollapsedLarge: function () {
30
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n top: 3px;\n "], ["\n top: 3px;\n "])));
23
31
  },
24
32
  rootEmptyCollapsed: function () {
25
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n right: 4px;\n top: 4px;\n "], ["\n right: 4px;\n top: 4px;\n "])));
33
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n left: calc(50% + 12px);\n top: 4px;\n "], ["\n left: calc(50% + 12px);\n top: 4px;\n "])));
34
+ },
35
+ rootEmptyCollapsedLarge: function () {
36
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n top: 8px;\n "], ["\n top: 8px;\n "])));
26
37
  },
27
38
  });
28
39
  });
29
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
40
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -9,8 +9,8 @@ import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
9
9
  import { SideMenuContext } from '../SideMenuContext.js';
10
10
  import { getStyles as getDropdownStyles } from '../SideMenuDropdown/SideMenuDropdown.styles.js';
11
11
  export var NarrowAccordionDropdown = function (_a) {
12
- var _b;
13
- var _c;
12
+ var _b, _c;
13
+ var _d;
14
14
  var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], childIdCounterRef = _a.childIdCounterRef, disabled = _a.disabled, onOpenChange = _a.onOpenChange;
15
15
  var context = useContext(SideMenuContext);
16
16
  var theme = getSideMenuTheme(useContext(ThemeContext));
@@ -19,17 +19,17 @@ export var NarrowAccordionDropdown = function (_a) {
19
19
  var dropdownStyles = useStyles(getDropdownStyles);
20
20
  var dropdownMenuRef = useRef(null);
21
21
  var isMenuCollapsed = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
22
- return (React.createElement("div", { className: cx(dropdownStyles.wrapper()) },
23
- React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (_b = {},
24
- _b[dropdownStyles.labelTouchScreen(theme)] = context.isTouchScreen,
25
- _b[dropdownStyles.labelCollapsed()] = isMenuCollapsed,
26
- _b)), onClick: disabled ? function (e) { return e.stopPropagation(); } : undefined }, caption), positions: ['right top', 'right middle', 'right bottom'], disableAnimations: true, popupMenuId: htmlId, "aria-label": ariaLabel, onOpen: function () {
22
+ return (React.createElement("div", { className: cx(dropdownStyles.wrapper(), (_b = {}, _b[dropdownStyles.wrapperCollapsed()] = isMenuCollapsed, _b)) },
23
+ React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (_c = {},
24
+ _c[dropdownStyles.labelTouchScreen(theme)] = context.isTouchScreen,
25
+ _c[dropdownStyles.labelCollapsed()] = isMenuCollapsed,
26
+ _c)), onClick: disabled ? function (e) { return e.stopPropagation(); } : undefined }, caption), positions: ['right top', 'right middle', 'right bottom'], disableAnimations: true, popupMenuId: htmlId, "aria-label": ariaLabel, onOpen: function () {
27
27
  if (childIdCounterRef) {
28
28
  childIdCounterRef.current = 0;
29
29
  }
30
30
  onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
31
31
  }, onClose: function () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false); } },
32
- React.createElement("ul", { className: cx(sideMenuStyles.list()), "data-tid": SideMenuDataTids.narrowAccordionDropdown },
33
- React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((_c = context.currentItemNestingLevel) !== null && _c !== void 0 ? _c : 0) + 1, closeParentDropdown: function () { var _a; return (_a = dropdownMenuRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, childIdCounterRef: childIdCounterRef !== null && childIdCounterRef !== void 0 ? childIdCounterRef : context.childIdCounterRef }) }, children)))));
32
+ React.createElement("ul", { className: cx(sideMenuStyles.list(), dropdownStyles.collapsedDropdownList(theme)), "data-tid": SideMenuDataTids.narrowAccordionDropdown },
33
+ React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((_d = context.currentItemNestingLevel) !== null && _d !== void 0 ? _d : 0) + 1, closeParentDropdown: function () { var _a; return (_a = dropdownMenuRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, childIdCounterRef: childIdCounterRef !== null && childIdCounterRef !== void 0 ? childIdCounterRef : context.childIdCounterRef }) }, children)))));
34
34
  };
35
35
  NarrowAccordionDropdown.displayName = 'NarrowAccordionDropdown';