@skbkontur/side-menu 5.0.0-beta.0 → 5.0.0-beta.2
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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.js +43 -22
- package/src/SideMenu/SideMenu.styles.d.ts +1 -4
- package/src/SideMenu/SideMenu.styles.js +18 -30
- package/src/SideMenuBody/SideMenuBody.js +4 -28
- package/src/SideMenuBody/SideMenuBody.styles.js +1 -2
- package/src/SideMenuContext.d.ts +2 -8
- package/src/SideMenuDropdown/SideMenuDropdown.js +7 -7
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +0 -1
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +3 -8
- package/src/SideMenuFooter/SideMenuFooter.js +6 -30
- package/src/SideMenuFooter/SideMenuFooter.styles.js +2 -3
- package/src/SideMenuHeader/SideMenuHeader.js +5 -3
- package/src/SideMenuHeader/SideMenuHeader.styles.d.ts +1 -0
- package/src/SideMenuHeader/SideMenuHeader.styles.js +4 -1
- package/src/internal/ClickableElement.d.ts +3 -1
- package/src/internal/ClickableElement.js +26 -31
- package/src/internal/InnerSubMenu.js +4 -1
- package/src/internal/ItemContent/Caption.js +5 -3
- package/src/internal/ItemContent/Caption.styles.js +1 -1
- package/src/internal/ItemContent/Icon.js +1 -0
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +14 -12
- package/src/internal/ItemContent/ItemContent.js +27 -8
- package/src/internal/ItemContent/ItemContent.styles.d.ts +0 -2
- package/src/internal/ItemContent/ItemContent.styles.js +1 -8
- package/src/internal/ItemContent/Marker.js +1 -1
- package/src/internal/NarrowAccordionDropdown.d.ts +1 -2
- package/src/internal/NarrowAccordionDropdown.js +9 -14
- package/src/internal/SideMenuLogotype.js +4 -2
- package/src/internal/SideMenuLogotype.styles.d.ts +1 -0
- package/src/internal/SideMenuLogotype.styles.js +8 -5
- package/src/internal/subMenuItems.d.ts +3 -0
- package/src/internal/subMenuItems.js +43 -0
- package/src/state/reducer.js +46 -26
|
@@ -5,7 +5,7 @@ export interface CommonClickableElementProps extends CommonProps {
|
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
/** Иконка. */
|
|
7
7
|
icon?: React.ReactElement;
|
|
8
|
-
/** Визуальный маркер. */
|
|
8
|
+
/** Визуальный маркер. Числа больше 99 отображаются как «99+». Строки отображаются как переданы. */
|
|
9
9
|
marker?: ReactNode;
|
|
10
10
|
/** Заголовок элемента. */
|
|
11
11
|
caption?: ReactNode;
|
|
@@ -37,6 +37,8 @@ export interface CommonClickableElementProps extends CommonProps {
|
|
|
37
37
|
_isAvatar?: boolean;
|
|
38
38
|
/** @ignore */
|
|
39
39
|
_isBackButton?: boolean;
|
|
40
|
+
/** @ignore */
|
|
41
|
+
_generatedId?: string;
|
|
40
42
|
}
|
|
41
43
|
export interface ClickableElementProps extends CommonClickableElementProps {
|
|
42
44
|
element: 'a' | 'button' | React.ComponentType<any>;
|
|
@@ -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
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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,
|
|
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 },
|
|
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,11 @@ 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
|
-
_b[sideMenuStyles.hidden()] = !isOpened || !context.isOpened,
|
|
20
|
+
_b[sideMenuStyles.hidden()] = !isOpened || !context.isOpened || context.isDesktopOpening,
|
|
18
21
|
_b)) }, children));
|
|
19
22
|
});
|
|
20
23
|
InnerSubMenu.displayName = 'InnerSubMenu';
|
|
@@ -19,7 +19,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
19
19
|
var _b, _c, _d;
|
|
20
20
|
var _isSubMenu = _a._isSubMenu, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, hasIcon = _a.hasIcon, hasMarker = _a.hasMarker, isMultiline = _a.isMultiline, noWrap = _a.noWrap, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar;
|
|
21
21
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
22
|
-
var _e = useContext(SideMenuContext), isSeparatedMenu = _e.isSeparatedMenu, size = _e.size, isTouchScreen = _e.isTouchScreen, hasSeparatedSubMenu = _e.hasSeparatedSubMenu, isBeingTransitioned = _e.isBeingTransitioned, sideMenuRef = _e.sideMenuRef, isOpened = _e.isOpened, hasItemIcons = _e.hasItemIcons;
|
|
22
|
+
var _e = useContext(SideMenuContext), isSeparatedMenu = _e.isSeparatedMenu, size = _e.size, isTouchScreen = _e.isTouchScreen, hasSeparatedSubMenu = _e.hasSeparatedSubMenu, isBeingTransitioned = _e.isBeingTransitioned, isDesktopOpening = _e.isDesktopOpening, sideMenuRef = _e.sideMenuRef, isOpened = _e.isOpened, hasItemIcons = _e.hasItemIcons;
|
|
23
23
|
var isLarge = size === 'large';
|
|
24
24
|
var isCaptionPlainText = typeof caption === 'string';
|
|
25
25
|
var captionRef = useRef(null);
|
|
@@ -37,8 +37,10 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
useEffect(function () {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (!isDesktopOpening) {
|
|
41
|
+
truncateSpecialCaption();
|
|
42
|
+
}
|
|
43
|
+
}, [caption, isDesktopOpening]);
|
|
42
44
|
useEffect(function () {
|
|
43
45
|
var handleTransition = function (e) {
|
|
44
46
|
if (e.propertyName === 'width') {
|
|
@@ -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
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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,
|
|
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
|
-
|
|
71
|
-
var _a, _b;
|
|
73
|
+
useLayoutEffect(function () {
|
|
72
74
|
if (noWrap) {
|
|
73
75
|
setIsMultiline(false);
|
|
74
76
|
return;
|
|
@@ -77,15 +79,33 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
77
79
|
setIsMultiline(true);
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
|
-
|
|
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
|
|
85
|
-
|
|
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,
|
|
108
|
+
context.isDesktopOpening,
|
|
89
109
|
context.state.activeItemId,
|
|
90
110
|
noWrap,
|
|
91
111
|
subCaption,
|
|
@@ -112,8 +132,7 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
112
132
|
React.createElement("div", { className: cx(styles.textAndMarkerWrapper(), (_c = {},
|
|
113
133
|
_c[styles.textAndMarkerWrapperTopLevel(theme)] = !_isSubMenu,
|
|
114
134
|
_c[styles.textAndMarkerWrapperTopLevelLarge(theme)] = !_isSubMenu && isLarge,
|
|
115
|
-
_c[
|
|
116
|
-
_c[styles.textAndMarkerWrapperCollapsed()] = !context.isOpened && !_isSubMenu,
|
|
135
|
+
_c[sideMenuStyles.hidden()] = (!context.isOpened || context.isDesktopOpening) && !_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,4 @@ 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
|
-
textAndMarkerWrapperCollapsed(): string;
|
|
18
16
|
}>;
|
|
@@ -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,6 @@ 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
|
-
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);
|
|
51
|
-
},
|
|
52
45
|
});
|
|
53
46
|
});
|
|
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
|
|
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, templateObject_13;
|
|
@@ -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,
|
|
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
|
|
13
|
-
var
|
|
14
|
-
var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"],
|
|
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:
|
|
23
|
-
React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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, width: "100%", 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: ((
|
|
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';
|
|
@@ -60,6 +60,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
60
60
|
var _f = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _f[0], setProductIconUrl = _f[1];
|
|
61
61
|
var isTabletOrMobile = context.isTablet || context.isMobile;
|
|
62
62
|
var isDesktopCollapsedMode = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
|
|
63
|
+
var showDesktopIcon = !isTabletOrMobile && (!context.isOpened || context.isDesktopOpening);
|
|
63
64
|
var rootRef = useRef(null);
|
|
64
65
|
var _g = __read(useState(true), 2), oneLineLogoFits = _g[0], setOneLineLogoFits = _g[1];
|
|
65
66
|
var oneLineLogo = isTabletOrMobile ? getOneLineLogo(productLogo) : null;
|
|
@@ -84,11 +85,12 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
84
85
|
_b[styles.rootTabletAndMobile()] = isTabletOrMobile,
|
|
85
86
|
_b)), ref: mergeRefs(rootRef, ref) },
|
|
86
87
|
!isTabletOrMobile && (React.createElement("img", { className: cx(styles.iconHidden(theme), (_c = {},
|
|
87
|
-
_c[styles.icon()] =
|
|
88
|
+
_c[styles.icon()] = showDesktopIcon,
|
|
89
|
+
_c[styles.defaultIconSize()] = showDesktopIcon && !iconUrl,
|
|
88
90
|
_c)), src: iconUrl || productIconUrl, alt: productName, onError: handleError })),
|
|
89
91
|
React.createElement("div", { className: cx(styles.logoWrapper(theme), (_d = {},
|
|
90
92
|
_d[styles.logoWrapperTabletAndMobile()] = isTabletOrMobile,
|
|
91
|
-
_d[styles.logoWrapperHidden()] =
|
|
93
|
+
_d[styles.logoWrapperHidden()] = showDesktopIcon,
|
|
92
94
|
_d)) },
|
|
93
95
|
isTabletOrMobile && React.createElement(Burger, null),
|
|
94
96
|
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,7 @@ 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;
|
|
8
9
|
iconHidden(t: SideMenuTheme): string;
|
|
9
10
|
logoWrapper(t: SideMenuTheme): string;
|
|
10
11
|
logoWrapperTabletAndMobile(): string;
|
|
@@ -15,18 +15,21 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
15
15
|
icon: function () {
|
|
16
16
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "], ["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "])));
|
|
17
17
|
},
|
|
18
|
+
defaultIconSize: function () {
|
|
19
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n "], ["\n width: ", ";\n height: ", ";\n "])), sideMenuLogotypeIconSize, sideMenuLogotypeIconSize);
|
|
20
|
+
},
|
|
18
21
|
iconHidden: function (t) {
|
|
19
|
-
return css(
|
|
22
|
+
return css(templateObject_5 || (templateObject_5 = __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
23
|
},
|
|
21
24
|
logoWrapper: function (t) {
|
|
22
|
-
return css(
|
|
25
|
+
return css(templateObject_6 || (templateObject_6 = __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
26
|
},
|
|
24
27
|
logoWrapperTabletAndMobile: function () {
|
|
25
|
-
return css(
|
|
28
|
+
return css(templateObject_7 || (templateObject_7 = __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
29
|
},
|
|
27
30
|
logoWrapperHidden: function () {
|
|
28
|
-
return css(
|
|
31
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
|
|
29
32
|
},
|
|
30
33
|
});
|
|
31
34
|
});
|
|
32
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
35
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -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
|
+
}
|