@skbkontur/side-menu 5.0.0-beta.0 → 5.0.0-beta.1

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 (35) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/SideMenu/SideMenu.js +13 -16
  4. package/src/SideMenu/SideMenu.styles.d.ts +4 -4
  5. package/src/SideMenu/SideMenu.styles.js +25 -29
  6. package/src/SideMenuBody/SideMenuBody.js +4 -28
  7. package/src/SideMenuBody/SideMenuBody.styles.js +1 -2
  8. package/src/SideMenuContext.d.ts +1 -8
  9. package/src/SideMenuDropdown/SideMenuDropdown.js +7 -7
  10. package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +0 -1
  11. package/src/SideMenuDropdown/SideMenuDropdown.styles.js +4 -8
  12. package/src/SideMenuFooter/SideMenuFooter.js +6 -30
  13. package/src/SideMenuFooter/SideMenuFooter.styles.js +2 -3
  14. package/src/SideMenuHeader/SideMenuHeader.js +4 -1
  15. package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +2 -0
  16. package/src/SideMenuHeader/SideMenuHeader.styles.js +12 -5
  17. package/src/internal/ClickableElement.d.ts +3 -1
  18. package/src/internal/ClickableElement.js +26 -31
  19. package/src/internal/InnerSubMenu.js +4 -0
  20. package/src/internal/ItemContent/Caption.styles.js +1 -1
  21. package/src/internal/ItemContent/Icon.js +1 -0
  22. package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
  23. package/src/internal/ItemContent/Icon.styles.js +14 -12
  24. package/src/internal/ItemContent/ItemContent.js +26 -7
  25. package/src/internal/ItemContent/ItemContent.styles.d.ts +0 -1
  26. package/src/internal/ItemContent/ItemContent.styles.js +2 -6
  27. package/src/internal/ItemContent/Marker.js +1 -1
  28. package/src/internal/NarrowAccordionDropdown.d.ts +1 -2
  29. package/src/internal/NarrowAccordionDropdown.js +9 -14
  30. package/src/internal/SideMenuLogotype.js +5 -0
  31. package/src/internal/SideMenuLogotype.styles.d.ts +2 -0
  32. package/src/internal/SideMenuLogotype.styles.js +12 -5
  33. package/src/internal/subMenuItems.d.ts +3 -0
  34. package/src/internal/subMenuItems.js +43 -0
  35. package/src/state/reducer.js +46 -26
@@ -16,6 +16,7 @@ import { getStyles } from './ClickableElement.styles.js';
16
16
  import { ItemContent } from './ItemContent/ItemContent.js';
17
17
  import { NarrowAccordionDropdown } from './NarrowAccordionDropdown.js';
18
18
  import { SubMenu } from './SubMenu.js';
19
+ import { hasSubMenuItem, withSubMenuItemIds } from './subMenuItems.js';
19
20
  var ClickableElementWithHint = function (_a) {
20
21
  var hint = _a.hint, isOpened = _a.isOpened, isHidden = _a.isHidden, children = _a.children;
21
22
  var _b = __read(useState(false), 2), hovered = _b[0], setHovered = _b[1];
@@ -93,29 +94,24 @@ var ClickableElementWithHint = function (_a) {
93
94
  var ClickableElement = forwardRef(function (_a, ref) {
94
95
  var _b, _c, _d;
95
96
  var _e;
96
- var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isDropdownOpen = _a._isDropdownOpen, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, noWrap = _a.noWrap, hint = _a.hint, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isDropdownOpen", "_isBackButton", "_isAvatar", "isButton", "href", "disabled", "noWrap", "hint"]);
97
+ var onClick = _a.onClick, icon = _a.icon, marker = _a.marker, caption = _a.caption, subCaption = _a.subCaption, id = _a.id, _isSubMenu = _a._isSubMenu, children = _a.children, Tag = _a.element, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, className = _a.className, _isDropdown = _a._isDropdown, _isDropdownOpen = _a._isDropdownOpen, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, _generatedId = _a._generatedId, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, noWrap = _a.noWrap, hint = _a.hint, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isDropdownOpen", "_isBackButton", "_isAvatar", "_generatedId", "isButton", "href", "disabled", "noWrap", "hint"]);
97
98
  var context = useContext(SideMenuContext);
98
99
  var theme = getSideMenuTheme(useContext(ThemeContext));
99
100
  var styles = useStyles(getStyles);
100
101
  var cx = useEmotion().cx;
101
102
  var keyListener = useKeyListener();
102
103
  var _f = __read(useState(false), 2), isFocusedByTab = _f[0], setIsFocusedByTab = _f[1];
103
- var counter = context.childIdCounterRef;
104
- var autoIndex = !id && !href && counter ? counter.current++ : undefined;
105
- var _g = __read(useState(function () {
106
- if (id) {
107
- return id;
108
- }
109
- if (href) {
110
- return href;
111
- }
112
- if (autoIndex !== undefined) {
113
- return "".concat(context.parentItemId, "__").concat(autoIndex);
104
+ var _g = __read(useState(function () { return id || href; }), 1), explicitId = _g[0];
105
+ var _h = __read(useState(''), 2), instanceId = _h[0], setInstanceId = _h[1];
106
+ useEffect(function () {
107
+ if (_generatedId === undefined) {
108
+ setInstanceId(generateId());
114
109
  }
115
- return generateId();
116
- }), 1), currentId = _g[0];
110
+ }, [_generatedId]);
111
+ var generatedId = _generatedId !== null && _generatedId !== void 0 ? _generatedId : instanceId;
112
+ var currentId = explicitId || generatedId;
113
+ var subMenuChildren = useMemo(function () { return withSubMenuItemIds(children, generatedId); }, [children, generatedId]);
117
114
  var focusRafRef = useRef(null);
118
- var childIdCounterRef = useRef(0);
119
115
  useEffect(function () {
120
116
  return function () {
121
117
  if (focusRafRef.current !== null) {
@@ -124,8 +120,11 @@ var ClickableElement = forwardRef(function (_a, ref) {
124
120
  }
125
121
  };
126
122
  }, []);
127
- var _h = useNodeState(currentId), isActive = _h.isActive, isExpanded = _h.isExpanded, isNestedSubMenu = _h.isNestedSubMenu, hasSeparatedSubMenu = _h.hasSeparatedSubMenu;
123
+ var _j = useNodeState(currentId), isActive = _j.isActive, isExpanded = _j.isExpanded, isNestedSubMenu = _j.isNestedSubMenu, hasSeparatedSubMenu = _j.hasSeparatedSubMenu;
128
124
  useEffect(function () {
125
+ if (!currentId || !context.parentItemId) {
126
+ return;
127
+ }
129
128
  context.dispatch({
130
129
  type: 'REGISTER',
131
130
  id: currentId,
@@ -138,11 +137,14 @@ var ClickableElement = forwardRef(function (_a, ref) {
138
137
  }, [currentId, context.parentItemId, _isSubMenu, context.dispatch]);
139
138
  var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
140
139
  var isDesktopCollapsedMode = (context.isDesktop || context.isNarrowDesktop) && !context.isOpened;
141
- var isActiveSection = context.state.activeFirstLevelParentId === currentId;
142
- var isHighlighted = isActive || (isActiveSection && (context.isSeparatedMenu || isDesktopCollapsedMode));
143
140
  var isCollapsedTopLevelSection = isDesktopCollapsedMode && !_isSubMenu && !_isDropdown && !_isBackButton && !_isAvatar;
144
141
  var isCollapsedAccordionSection = isCollapsedTopLevelSection && !!children && !context.isSeparatedMenu;
145
- var _j = __read(useState(false), 2), isAccordionOpen = _j[0], setIsAccordionOpen = _j[1];
142
+ var _k = context.state, activeFirstLevelParentId = _k.activeFirstLevelParentId, pendingActiveItemId = _k.pendingActiveItemId;
143
+ var isActiveSection = isCollapsedAccordionSection && pendingActiveItemId
144
+ ? hasSubMenuItem(children, pendingActiveItemId)
145
+ : activeFirstLevelParentId === currentId;
146
+ var isHighlighted = isActive || (isActiveSection && (context.isSeparatedMenu || isDesktopCollapsedMode));
147
+ var _l = __read(useState(false), 2), isAccordionOpen = _l[0], setIsAccordionOpen = _l[1];
146
148
  useEffect(function () {
147
149
  if (!isCollapsedAccordionSection) {
148
150
  setIsAccordionOpen(false);
@@ -162,9 +164,6 @@ var ClickableElement = forwardRef(function (_a, ref) {
162
164
  return;
163
165
  }
164
166
  onClick === null || onClick === void 0 ? void 0 : onClick(e);
165
- if (e.defaultPrevented) {
166
- return;
167
- }
168
167
  if (_isBackButton || _isDropdown) {
169
168
  return;
170
169
  }
@@ -256,22 +255,18 @@ var ClickableElement = forwardRef(function (_a, ref) {
256
255
  // The proper fix is to either sync the dropdown's opened state into this element, or
257
256
  // to omit `aria-expanded` here in accordion mode and make the outer caption wrapper
258
257
  // the accessible control (focusable + correct `aria-expanded`).
259
- var clickableElement = (React.createElement(Tag, __assign({ state: isActive ? 'active' : undefined, style: nestingLevelPadding }, newProps, { ref: ref, disabled: !isNativeAnchor ? disabled : undefined, "aria-disabled": isNativeAnchor && disabled ? 'true' : undefined, tabIndex: isNativeAnchor && disabled ? -1 : undefined }, (children ? { 'aria-expanded': isExpanded, 'aria-controls': currentId } : {}))));
258
+ var clickableElement = (React.createElement(Tag, __assign({ state: isActive ? 'active' : undefined, style: nestingLevelPadding }, newProps, { ref: ref, disabled: !isNativeAnchor ? disabled : undefined, "aria-disabled": isNativeAnchor && disabled ? 'true' : undefined, tabIndex: isNativeAnchor && disabled ? -1 : undefined }, (children ? { 'aria-expanded': isExpanded, 'aria-controls': currentId || undefined } : {}))));
260
259
  var clickableElementWithHint = (React.createElement(ClickableElementWithHint, { hint: hint === null ? null : (hint !== null && hint !== void 0 ? hint : caption), isOpened: context.isOpened || (_isSubMenu && (context.isSeparatedMenu || isDesktopCollapsedMode)) }, clickableElement));
261
- // Reset the child id counter on every render so children at this nesting level get stable,
262
- // position-based generated ids across unmount → re-mount transitions (e.g. narrow
263
- // accordion dropdown closing → inline submenu opening).
264
- childIdCounterRef.current = 0;
265
- var subMenuContextValue = useMemo(function () { return (__assign(__assign({ hasSeparatedSubMenu: hasSeparatedSubMenu }, context), { parentItemId: currentId, currentItemNestingLevel: currentItemNestingLevel + 1, childIdCounterRef: childIdCounterRef })); }, [hasSeparatedSubMenu, context, currentId, currentItemNestingLevel]);
260
+ var subMenuContextValue = useMemo(function () { return (__assign(__assign({ hasSeparatedSubMenu: hasSeparatedSubMenu }, context), { parentItemId: currentId, currentItemNestingLevel: currentItemNestingLevel + 1 })); }, [hasSeparatedSubMenu, context, currentId, currentItemNestingLevel]);
266
261
  // При клике на айтем без детей закрывать дропдаун
267
262
  // айтем должен оставаться активным и при разворачивании меню корректно показываться в списке подменю
268
263
  // При клике на активный элемент с детьми, он должен закрыться
269
- return (React.createElement(Component, (_d = { "data-tid": SideMenuDataTids.clickableElement }, _d[navigationAttribute] = currentId, _d),
270
- isCollapsedAccordionSection && (React.createElement(NarrowAccordionDropdown, { caption: clickableElementWithHint, htmlId: currentId, childIdCounterRef: childIdCounterRef, disabled: disabled, onOpenChange: setIsAccordionOpen }, children)),
264
+ return (React.createElement(Component, (_d = { "data-tid": SideMenuDataTids.clickableElement }, _d[navigationAttribute] = currentId || undefined, _d),
265
+ isCollapsedAccordionSection && (React.createElement(NarrowAccordionDropdown, { caption: clickableElementWithHint, htmlId: currentId, disabled: disabled, onOpenChange: setIsAccordionOpen }, subMenuChildren)),
271
266
  !isCollapsedAccordionSection && (React.createElement(React.Fragment, null,
272
267
  clickableElementWithHint,
273
268
  React.createElement(SubMenu, { caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, htmlId: currentId, isOpened: isExpanded },
274
- React.createElement(SideMenuContext.Provider, { value: subMenuContextValue }, children))))));
269
+ React.createElement(SideMenuContext.Provider, { value: subMenuContextValue }, subMenuChildren))))));
275
270
  });
276
271
  ClickableElement.displayName = 'ClickableElement';
277
272
  var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
@@ -1,5 +1,7 @@
1
1
  import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
2
+ import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
2
3
  import React, { forwardRef, useContext } from 'react';
4
+ import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
3
5
  import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
4
6
  import { SideMenuContext } from '../SideMenuContext.js';
5
7
  /**
@@ -11,10 +13,12 @@ var InnerSubMenu = forwardRef(function (_a, ref) {
11
13
  var _b;
12
14
  var children = _a.children, htmlId = _a.htmlId, isOpened = _a.isOpened;
13
15
  var context = useContext(SideMenuContext);
16
+ var theme = getSideMenuTheme(useContext(ThemeContext));
14
17
  var sideMenuStyles = useStyles(getSideMenuStyles);
15
18
  var cx = useEmotion().cx;
16
19
  return (React.createElement("ul", { ref: ref, id: htmlId, className: cx(sideMenuStyles.list(), (_b = {},
17
20
  _b[sideMenuStyles.hidden()] = !isOpened || !context.isOpened,
21
+ _b[sideMenuStyles.hideUntilExpanded(theme)] = isOpened && context.isOpened,
18
22
  _b)) }, children));
19
23
  });
20
24
  InnerSubMenu.displayName = 'InnerSubMenu';
@@ -8,7 +8,7 @@ export var getStyles = memoizeGetStyles(function (_a) {
8
8
  var css = _a.css;
9
9
  return ({
10
10
  root: function () {
11
- 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 "])));
11
+ return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n "], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n min-width: 0;\n "])));
12
12
  },
13
13
  rootMultiline: function (t) {
14
14
  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 "])), t.sideMenuCaptionMultilinePaddingTop);
@@ -44,5 +44,6 @@ export var Icon = function (_a) {
44
44
  _b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
45
45
  _b[styles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
46
46
  _b[styles.rootBackButton(theme)] = _isBackButton,
47
+ _b[styles.rootTopLevelDesktop()] = !_isSubMenu && (context.isDesktop || context.isNarrowDesktop),
47
48
  _b)) }, renderIcon()));
48
49
  };
@@ -2,6 +2,7 @@ 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
4
  rootCollapsed(t: SideMenuTheme): string;
5
+ rootTopLevelDesktop(): string;
5
6
  rootCollapsedLarge(t: SideMenuTheme): string;
6
7
  rootMultiline(): string;
7
8
  rootLarge(t: SideMenuTheme): string;
@@ -1,42 +1,44 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../../lib/theming/ThemeHelpers.js';
3
- import { transitionDuration, transitionEasing } from '../../SideMenu/SideMenu.js';
4
3
  export var getStyles = memoizeGetStyles(function (_a) {
5
4
  var css = _a.css;
6
5
  return ({
7
6
  root: function (t) {
8
- return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight, transitionDuration, transitionEasing, transitionDuration, transitionEasing);
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);
9
8
  },
10
9
  rootCollapsed: function (t) {
11
10
  return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
12
11
  },
12
+ rootTopLevelDesktop: function () {
13
+ return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n "], ["\n align-self: flex-start;\n "])));
14
+ },
13
15
  rootCollapsedLarge: function (t) {
14
- 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);
16
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-left: ", ";\n margin-right: ", ";\n "], ["\n margin-left: ", ";\n margin-right: ", ";\n "])), t.sideMenuIconMarginXCollapsedLarge, t.sideMenuIconMarginXCollapsedLarge);
15
17
  },
16
18
  rootMultiline: function () {
17
- 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 "])));
19
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: -2px;\n "], ["\n align-self: flex-start;\n margin-top: -2px;\n "])));
18
20
  },
19
21
  rootLarge: function (t) {
20
- 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);
22
+ return css(templateObject_6 || (templateObject_6 = __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);
21
23
  },
22
24
  rootSubItemLarge: function (t) {
23
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
25
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
24
26
  },
25
27
  rootSubItem: function (t) {
26
- 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);
28
+ return css(templateObject_8 || (templateObject_8 = __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);
27
29
  },
28
30
  rootSubItemWithoutItemIcons: function (t) {
29
- return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconSubItemPaddingLeftWithoutIcons);
31
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconSubItemPaddingLeftWithoutIcons);
30
32
  },
31
33
  rootSubItemDropdown: function () {
32
- return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
34
+ return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
33
35
  },
34
36
  rootSubItemSeparatedMenu: function (t) {
35
- return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
37
+ return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
36
38
  },
37
39
  rootBackButton: function (t) {
38
- return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
40
+ return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
39
41
  },
40
42
  });
41
43
  });
42
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
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;
@@ -1,8 +1,10 @@
1
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, useLayoutEffect, useRef, useState } from 'react';
4
+ import React, { forwardRef, useContext, useLayoutEffect, useRef, useState } from 'react';
5
+ import { flushSync } from 'react-dom';
5
6
  import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
7
+ import { getStyles as getSideMenuStyles } from '../../SideMenu/SideMenu.styles.js';
6
8
  import { SideMenuContext } from '../../SideMenuContext.js';
7
9
  import { Caption } from './Caption.js';
8
10
  import { Icon } from './Icon.js';
@@ -66,9 +68,9 @@ var ItemContent = forwardRef(function (_a, ref) {
66
68
  useLayoutEffect(function () { return (countsAsItemIcon ? registerItemIcon === null || registerItemIcon === void 0 ? void 0 : registerItemIcon() : undefined); }, [countsAsItemIcon, registerItemIcon]);
67
69
  var theme = getSideMenuTheme(useContext(ThemeContext));
68
70
  var styles = useStyles(getStyles);
71
+ var sideMenuStyles = useStyles(getSideMenuStyles);
69
72
  var cx = useEmotion().cx;
70
- useEffect(function () {
71
- var _a, _b;
73
+ useLayoutEffect(function () {
72
74
  if (noWrap) {
73
75
  setIsMultiline(false);
74
76
  return;
@@ -77,12 +79,29 @@ var ItemContent = forwardRef(function (_a, ref) {
77
79
  setIsMultiline(true);
78
80
  return;
79
81
  }
80
- if (!textRef.current || _isBackButton || _isDropdown) {
82
+ var text = textRef.current;
83
+ if (!text || _isBackButton || _isDropdown) {
81
84
  return;
82
85
  }
83
86
  var captionLineHeight = getCaptionLineHeight(theme, isTouchScreen, _isSubMenu, size);
84
- var captionHeight = (_b = (_a = textRef.current.firstElementChild) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : textRef.current.offsetHeight;
85
- setIsMultiline(parseInt(captionLineHeight, 10) < captionHeight);
87
+ var captionElement = text.firstElementChild;
88
+ var measuredElement = captionElement !== null && captionElement !== void 0 ? captionElement : text;
89
+ var isCaptionMultiline = function () { return parseInt(captionLineHeight, 10) < measuredElement.offsetHeight; };
90
+ var multiline = isCaptionMultiline();
91
+ setIsMultiline(multiline);
92
+ if (typeof ResizeObserver === 'undefined') {
93
+ return;
94
+ }
95
+ var observer = new ResizeObserver(function () {
96
+ var measured = isCaptionMultiline();
97
+ if (measured !== multiline) {
98
+ multiline = measured;
99
+ // Apply the icon alignment before painting the newly visible caption.
100
+ flushSync(function () { return setIsMultiline(measured); });
101
+ }
102
+ });
103
+ observer.observe(measuredElement);
104
+ return function () { return observer.disconnect(); };
86
105
  }, [
87
106
  caption,
88
107
  context.isBeingTransitioned,
@@ -112,8 +131,8 @@ var ItemContent = forwardRef(function (_a, ref) {
112
131
  React.createElement("div", { className: cx(styles.textAndMarkerWrapper(), (_c = {},
113
132
  _c[styles.textAndMarkerWrapperTopLevel(theme)] = !_isSubMenu,
114
133
  _c[styles.textAndMarkerWrapperTopLevelLarge(theme)] = !_isSubMenu && isLarge,
115
- _c[styles.textAndMarkerWrapperDropdown()] = _isDropdown,
116
134
  _c[styles.textAndMarkerWrapperCollapsed()] = !context.isOpened && !_isSubMenu,
135
+ _c[sideMenuStyles.hideUntilExpanded(theme)] = context.isOpened && !_isSubMenu,
117
136
  _c)) },
118
137
  React.createElement(Caption, { _isSubMenu: _isSubMenu, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, hasIcon: !!icon, hasMarker: !!marker, isMultiline: isMultiline, noWrap: noWrap, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, ref: textRef })),
119
138
  marker && !disabled && (React.createElement(Marker, { _isSubMenu: _isSubMenu, marker: marker, isMultiline: isMultiline, isCollapsed: !context.isOpened }))));
@@ -13,6 +13,5 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
13
13
  textAndMarkerWrapper(): string;
14
14
  textAndMarkerWrapperTopLevel(t: SideMenuTheme): string;
15
15
  textAndMarkerWrapperTopLevelLarge(t: SideMenuTheme): string;
16
- textAndMarkerWrapperDropdown(): string;
17
16
  textAndMarkerWrapperCollapsed(): string;
18
17
  }>;
@@ -1,6 +1,5 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../../lib/theming/ThemeHelpers.js';
3
- import { transitionDuration } from '../../SideMenu/SideMenu.js';
4
3
  export var getStyles = memoizeGetStyles(function (_a) {
5
4
  var css = _a.css;
6
5
  return ({
@@ -43,12 +42,9 @@ export var getStyles = memoizeGetStyles(function (_a) {
43
42
  textAndMarkerWrapperTopLevelLarge: function (t) {
44
43
  return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconMinHeightLarge);
45
44
  },
46
- textAndMarkerWrapperDropdown: function () {
47
- return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
48
- },
49
45
  textAndMarkerWrapperCollapsed: function () {
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);
46
+ return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
51
47
  },
52
48
  });
53
49
  });
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;
50
+ 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;
@@ -23,5 +23,5 @@ export var Marker = function (_a) {
23
23
  _b[styles.rootCollapsedLarge()] = isCollapsedItem && isLarge,
24
24
  _b[styles.rootEmptyCollapsed()] = isCollapsedItem && isEmpty,
25
25
  _b[styles.rootEmptyCollapsedLarge()] = isCollapsedItem && isEmpty && isLarge,
26
- _b)) }, marker));
26
+ _b)) }, typeof marker === 'number' && marker > 99 ? '99+' : marker));
27
27
  };
@@ -4,12 +4,11 @@ interface NarrowAccordionDropdownProps {
4
4
  children?: React.ReactNode;
5
5
  htmlId: string;
6
6
  'aria-label'?: string;
7
- childIdCounterRef?: React.MutableRefObject<number>;
8
7
  disabled?: boolean;
9
8
  onOpenChange?: (isOpen: boolean) => void;
10
9
  }
11
10
  export declare const NarrowAccordionDropdown: {
12
- ({ caption, children, htmlId, "aria-label": ariaLabel, childIdCounterRef, disabled, onOpenChange, }: NarrowAccordionDropdownProps): JSX.Element;
11
+ ({ caption, children, htmlId, "aria-label": ariaLabel, disabled, onOpenChange, }: NarrowAccordionDropdownProps): JSX.Element;
13
12
  displayName: string;
14
13
  };
15
14
  export {};
@@ -9,9 +9,9 @@ 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, _c;
13
- var _d;
14
- var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], childIdCounterRef = _a.childIdCounterRef, disabled = _a.disabled, onOpenChange = _a.onOpenChange;
12
+ var _b;
13
+ var _c;
14
+ var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], disabled = _a.disabled, onOpenChange = _a.onOpenChange;
15
15
  var context = useContext(SideMenuContext);
16
16
  var theme = getSideMenuTheme(useContext(ThemeContext));
17
17
  var sideMenuStyles = useStyles(getSideMenuStyles);
@@ -19,17 +19,12 @@ 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(), (_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
- if (childIdCounterRef) {
28
- childIdCounterRef.current = 0;
29
- }
30
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
31
- }, onClose: function () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false); } },
22
+ return (React.createElement("div", { className: 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 () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true); }, onClose: function () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false); } },
32
27
  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)))));
28
+ 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(); } }) }, children)))));
34
29
  };
35
30
  NarrowAccordionDropdown.displayName = 'NarrowAccordionDropdown';
@@ -5,6 +5,7 @@ import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment
5
5
  import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
6
6
  import React, { forwardRef, useContext, useLayoutEffect, useRef, useState } from 'react';
7
7
  import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
8
+ import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
8
9
  import { SideMenuContext } from '../SideMenuContext.js';
9
10
  import { Burger } from './Burger.js';
10
11
  import { getStyles, sideMenuLogotypeIconSize } from './SideMenuLogotype.styles.js';
@@ -55,6 +56,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
55
56
  var context = useContext(SideMenuContext);
56
57
  var theme = getSideMenuTheme(useContext(ThemeContext));
57
58
  var styles = useStyles(getStyles);
59
+ var sideMenuStyles = useStyles(getSideMenuStyles);
58
60
  var cx = useEmotion().cx;
59
61
  var productName = getProductName(productLogo);
60
62
  var _f = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _f[0], setProductIconUrl = _f[1];
@@ -85,10 +87,13 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
85
87
  _b)), ref: mergeRefs(rootRef, ref) },
86
88
  !isTabletOrMobile && (React.createElement("img", { className: cx(styles.iconHidden(theme), (_c = {},
87
89
  _c[styles.icon()] = !context.isOpened && !isTabletOrMobile,
90
+ _c[styles.defaultIconSize()] = !context.isOpened && !iconUrl,
91
+ _c[styles.iconUntilExpanded(theme)] = context.isOpened,
88
92
  _c)), src: iconUrl || productIconUrl, alt: productName, onError: handleError })),
89
93
  React.createElement("div", { className: cx(styles.logoWrapper(theme), (_d = {},
90
94
  _d[styles.logoWrapperTabletAndMobile()] = isTabletOrMobile,
91
95
  _d[styles.logoWrapperHidden()] = !context.isOpened && !isTabletOrMobile,
96
+ _d[sideMenuStyles.hideUntilExpanded(theme)] = context.isOpened && !isTabletOrMobile,
92
97
  _d)) },
93
98
  isTabletOrMobile && React.createElement(Burger, null),
94
99
  React.createElement(Logotype, __assign({ size: 28, productLogo: shownProductLogo && typeof ((_e = shownProductLogo.props) === null || _e === void 0 ? void 0 : _e.logo) === 'string' && !rest.size ? (React.createElement(CdnLogoWithOwnSize, { logo: shownProductLogo })) : (shownProductLogo), konturLogo: konturLogo, withWidget: getWidget(withWidget, isDesktopCollapsedMode) }, rest)))));
@@ -5,6 +5,8 @@ export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").Styl
5
5
  root(): string;
6
6
  rootTabletAndMobile(): string;
7
7
  icon(): string;
8
+ defaultIconSize(): string;
9
+ iconUntilExpanded(t: SideMenuTheme): string;
8
10
  iconHidden(t: SideMenuTheme): string;
9
11
  logoWrapper(t: SideMenuTheme): string;
10
12
  logoWrapperTabletAndMobile(): string;
@@ -1,6 +1,7 @@
1
1
  import { __makeTemplateObject } from "tslib";
2
2
  import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
3
3
  import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
4
+ import { compactDesktopMenu } from '../SideMenu/SideMenu.styles.js';
4
5
  export var sideMenuLogotypeIconSize = '32px';
5
6
  export var sideMenuLogotypeGapBetweenIconAndLogo = '50px';
6
7
  export var getStyles = memoizeGetStyles(function (_a) {
@@ -15,18 +16,24 @@ export var getStyles = memoizeGetStyles(function (_a) {
15
16
  icon: function () {
16
17
  return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "], ["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "])));
17
18
  },
19
+ defaultIconSize: function () {
20
+ return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n "], ["\n width: ", ";\n height: ", ";\n "])), sideMenuLogotypeIconSize, sideMenuLogotypeIconSize);
21
+ },
22
+ iconUntilExpanded: function (t) {
23
+ return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), compactDesktopMenu(t, "width: ".concat(sideMenuLogotypeIconSize, "; height: ").concat(sideMenuLogotypeIconSize, "; opacity: 1;")));
24
+ },
18
25
  iconHidden: function (t) {
19
- return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "], ["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration, transitionEasing);
26
+ return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition:\n opacity ", "ms ", ",\n padding-left ", "ms ", ";\n "], ["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition:\n opacity ", "ms ", ",\n padding-left ", "ms ", ";\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration, transitionEasing, transitionDuration, transitionEasing);
20
27
  },
21
28
  logoWrapper: function (t) {
22
- return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "], ["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft);
29
+ return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown {\n align-items: flex-end;\n }\n\n [data-logotype-widget] {\n align-content: end;\n align-items: end;\n }\n "], ["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown {\n align-items: flex-end;\n }\n\n [data-logotype-widget] {\n align-content: end;\n align-items: end;\n }\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft);
23
30
  },
24
31
  logoWrapperTabletAndMobile: function () {
25
- return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "], ["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "])));
32
+ return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown {\n align-items: center;\n }\n\n [data-logotype-widget] {\n align-content: center;\n align-items: center;\n }\n\n #spwClicker {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n padding: 0;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n }\n "], ["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown {\n align-items: center;\n }\n\n [data-logotype-widget] {\n align-content: center;\n align-items: center;\n }\n\n #spwClicker {\n box-sizing: border-box;\n width: 44px;\n height: 44px;\n padding: 0;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n }\n "])));
26
33
  },
27
34
  logoWrapperHidden: function () {
28
- return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "], ["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "])));
35
+ return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
29
36
  },
30
37
  });
31
38
  });
32
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
39
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
@@ -0,0 +1,3 @@
1
+ import { type ReactNode } from 'react';
2
+ export declare function withSubMenuItemIds(children: ReactNode, parentId: string): ReactNode;
3
+ export declare function hasSubMenuItem(children: ReactNode, id: string): boolean;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ var itemTypes = new Set(['SideMenuItem', 'SideMenuLink', 'SideMenuSubItem', 'SideMenuSubLink']);
3
+ function isMenuItem(child) {
4
+ var type = child.type;
5
+ return type.__KONTUR_REACT_UI__ !== undefined && itemTypes.has(type.__KONTUR_REACT_UI__);
6
+ }
7
+ // The popup and inline submenu mount separate React trees. Seed both from the same
8
+ // child keys within the parent item so switching views preserves the selected item.
9
+ export function withSubMenuItemIds(children, parentId) {
10
+ if (Array.isArray(children)) {
11
+ return children.map(function (child, index) { return withItemId(child, parentId, index); });
12
+ }
13
+ return withItemId(children, parentId, 0);
14
+ }
15
+ function withItemId(child, parentId, index) {
16
+ var key = React.isValidElement(child) ? child.key : null;
17
+ var segment = key === null ? index : encodeURIComponent(JSON.stringify(key));
18
+ var path = parentId ? "".concat(parentId, "/").concat(segment) : '';
19
+ if (Array.isArray(child)) {
20
+ return withSubMenuItemIds(child, path);
21
+ }
22
+ if (!React.isValidElement(child)) {
23
+ return child;
24
+ }
25
+ if (isMenuItem(child)) {
26
+ return React.cloneElement(child, { _generatedId: path });
27
+ }
28
+ var children = child.props.children;
29
+ if (Array.isArray(children) || React.isValidElement(children)) {
30
+ return React.cloneElement(child, { children: withSubMenuItemIds(children, path) });
31
+ }
32
+ return child;
33
+ }
34
+ // A collapsed accordion mounts its popup children on demand. Their declared IDs
35
+ // still identify the active section while the reducer is waiting for registration.
36
+ export function hasSubMenuItem(children, id) {
37
+ return React.Children.toArray(children).some(function (child) {
38
+ if (!React.isValidElement(child)) {
39
+ return false;
40
+ }
41
+ return ((isMenuItem(child) && (child.props.id || child.props.href) === id) || hasSubMenuItem(child.props.children, id));
42
+ });
43
+ }