@skbkontur/side-menu 4.0.10-ddcb0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +13 -40
- package/SideMenuDataTids.d.ts +1 -2
- package/SideMenuDataTids.js +1 -2
- package/hooks/useMemoIcon.d.ts +2 -1
- package/hooks/useMemoIcon.js +9 -0
- package/internal/themes/SideMenuDarkTheme.js +3 -3
- package/internal/themes/SideMenuTheme.d.ts +7 -4
- package/internal/themes/SideMenuTheme.js +26 -9
- package/lib/theming/ThemeHelpers.js +4 -0
- package/lib/utils/scripts.d.ts +0 -1
- package/lib/utils/scripts.js +0 -9
- package/package.json +4 -5
- package/src/Navigation.d.ts +53 -0
- package/src/Navigation.js +194 -0
- package/src/SideMenu/SideMenu.d.ts +4 -7
- package/src/SideMenu/SideMenu.js +178 -148
- package/src/SideMenu/SideMenu.styles.js +2 -2
- package/src/SideMenuAvatar/SideMenuAvatar.js +2 -11
- package/src/SideMenuContext.d.ts +9 -16
- package/src/SideMenuContext.js +1 -6
- package/src/SideMenuDropdown/SideMenuDropdown.js +18 -11
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +3 -3
- package/src/SideMenuFooter/SideMenuFooter.js +3 -15
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +0 -4
- package/src/SideMenuFooter/SideMenuFooter.styles.js +4 -16
- package/src/SideMenuHeader/SideMenuHeader.js +3 -4
- package/src/SideMenuNotifications/BellWidget.js +13 -6
- package/src/SideMenuNotifications/BellWidgetError.js +6 -3
- package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +7 -4
- package/src/SideMenuNotifications/BellWidgetView.styles.js +20 -9
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +11 -0
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +10 -0
- package/src/SideMenuSubItem/SideMenuSubItem.d.ts +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +0 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +0 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +2 -5
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
- package/src/Tree.d.ts +17 -0
- package/src/Tree.js +135 -0
- package/src/internal/BackButton.d.ts +3 -1
- package/src/internal/BackButton.js +3 -4
- package/src/internal/ClickableElement.d.ts +1 -8
- package/src/internal/ClickableElement.js +67 -125
- package/src/internal/ClickableElement.styles.d.ts +0 -1
- package/src/internal/ClickableElement.styles.js +3 -6
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +26 -9
- package/src/internal/ItemContent/Icon.js +2 -3
- package/src/internal/ItemContent/Icon.styles.d.ts +0 -1
- package/src/internal/ItemContent/Icon.styles.js +3 -6
- package/src/internal/ItemContent/ItemContent.js +5 -17
- package/src/internal/ItemContent/ItemContent.styles.d.ts +0 -1
- package/src/internal/ItemContent/ItemContent.styles.js +4 -7
- package/src/internal/RightBorder.d.ts +9 -0
- package/src/internal/RightBorder.js +37 -0
- package/src/internal/{CollapseToggle.styles.d.ts → RightBorder.styles.d.ts} +1 -0
- package/src/internal/RightBorder.styles.js +14 -0
- package/src/internal/SeparatedSubMenu.js +9 -7
- package/src/internal/SeparatedSubMenu.styles.d.ts +3 -0
- package/src/internal/SeparatedSubMenu.styles.js +15 -6
- package/src/internal/SideMenuLogotype.js +8 -10
- package/src/internal/SubMenu.js +2 -3
- package/hooks/useNodeState.d.ts +0 -7
- package/hooks/useNodeState.js +0 -12
- package/hooks/useSideMenuReducer.d.ts +0 -13
- package/hooks/useSideMenuReducer.js +0 -23
- package/src/internal/CollapseToggle.d.ts +0 -1
- package/src/internal/CollapseToggle.js +0 -27
- package/src/internal/CollapseToggle.styles.js +0 -12
- package/src/internal/NarrowAccordionDropdown.d.ts +0 -13
- package/src/internal/NarrowAccordionDropdown.js +0 -34
- package/src/navigationAttributes.d.ts +0 -3
- package/src/navigationAttributes.js +0 -3
- package/src/state/reducer.d.ts +0 -2
- package/src/state/reducer.js +0 -258
- package/src/state/selectors.d.ts +0 -16
- package/src/state/selectors.js +0 -71
- package/src/state/types.d.ts +0 -59
- package/src/state/types.js +0 -17
- package/unstable.d.ts +0 -1
- package/unstable.js +0 -1
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
|
-
import { Hint } from '@skbkontur/react-ui/components/Hint/Hint';
|
|
3
2
|
import { useKeyListener } from '@skbkontur/react-ui/lib/events/keyListener';
|
|
4
3
|
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
5
4
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
6
|
-
import React, { forwardRef, useContext, useEffect,
|
|
5
|
+
import React, { forwardRef, useContext, useEffect, useState } from 'react';
|
|
7
6
|
import { useMemoIcon } from '../../hooks/useMemoIcon.js';
|
|
8
|
-
import { useNodeState } from '../../hooks/useNodeState.js';
|
|
9
7
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
10
8
|
import { generateId } from '../../lib/utils/scripts.js';
|
|
11
9
|
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
12
|
-
import { navigationAttribute } from '../
|
|
10
|
+
import { navigationAttribute } from '../Navigation.js';
|
|
13
11
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
14
|
-
import { hasChildren } from '../state/selectors.js';
|
|
15
12
|
import { getStyles } from './ClickableElement.styles.js';
|
|
16
13
|
import { ItemContent } from './ItemContent/ItemContent.js';
|
|
17
|
-
import { NarrowAccordionDropdown } from './NarrowAccordionDropdown.js';
|
|
18
14
|
import { SubMenu } from './SubMenu.js';
|
|
19
|
-
var ClickableElementWithHint = function (_a) {
|
|
20
|
-
var hint = _a.hint, isOpened = _a.isOpened, children = _a.children;
|
|
21
|
-
if (hint === null || hint === undefined) {
|
|
22
|
-
return children;
|
|
23
|
-
}
|
|
24
|
-
if (isOpened) {
|
|
25
|
-
return (React.createElement(Hint, { text: hint, pos: 'right', manual: true, opened: false }, children));
|
|
26
|
-
}
|
|
27
|
-
return (React.createElement(Hint, { text: hint, pos: 'right' }, children));
|
|
28
|
-
};
|
|
29
15
|
/**
|
|
30
16
|
* Элемент списка (пункт меню либо ссылка)
|
|
31
17
|
*
|
|
@@ -34,106 +20,90 @@ var ClickableElementWithHint = function (_a) {
|
|
|
34
20
|
var ClickableElement = forwardRef(function (_a, ref) {
|
|
35
21
|
var _b, _c, _d;
|
|
36
22
|
var _e;
|
|
37
|
-
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, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, noWrap = _a.noWrap,
|
|
23
|
+
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, _isBackButton = _a._isBackButton, _isAvatar = _a._isAvatar, isButton = _a.isButton, href = _a.href, disabled = _a.disabled, noWrap = _a.noWrap, rest = __rest(_a, ["onClick", "icon", "marker", "caption", "subCaption", "id", "_isSubMenu", "children", "element", "onKeyDown", "onFocus", "onBlur", "className", "_isDropdown", "_isBackButton", "_isAvatar", "isButton", "href", "disabled", "noWrap"]);
|
|
38
24
|
var context = useContext(SideMenuContext);
|
|
39
25
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
40
26
|
var styles = useStyles(getStyles);
|
|
41
27
|
var cx = useEmotion().cx;
|
|
42
28
|
var keyListener = useKeyListener();
|
|
43
|
-
var _f = __read(useState(false), 2),
|
|
44
|
-
var _g = __read(useState(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
var counter = context.childIdCounterRef;
|
|
52
|
-
if (counter) {
|
|
53
|
-
var index = counter.current;
|
|
54
|
-
counter.current += 1;
|
|
55
|
-
return "".concat(context.parentItemId, "__").concat(index);
|
|
56
|
-
}
|
|
57
|
-
return generateId();
|
|
58
|
-
}), 1), currentId = _g[0];
|
|
59
|
-
var focusRafRef = useRef(null);
|
|
60
|
-
var childIdCounterRef = useRef(0);
|
|
61
|
-
useEffect(function () {
|
|
62
|
-
return function () {
|
|
63
|
-
if (focusRafRef.current !== null) {
|
|
64
|
-
cancelAnimationFrame(focusRafRef.current);
|
|
65
|
-
focusRafRef.current = null;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
var _h = useNodeState(currentId), isActive = _h.isActive, isExpanded = _h.isExpanded, isNestedSubMenu = _h.isNestedSubMenu, hasSeparatedSubMenu = _h.hasSeparatedSubMenu;
|
|
29
|
+
var _f = __read(useState(false), 2), isActive = _f[0], setIsActive = _f[1];
|
|
30
|
+
var _g = __read(useState(false), 2), isFirstLevelParentOfActiveMenuItem = _g[0], setIsFirstLevelParentOfActiveMenuItem = _g[1];
|
|
31
|
+
var _h = __read(useState(false), 2), isOpened = _h[0], setIsOpened = _h[1];
|
|
32
|
+
var _j = __read(useState(false), 2), isNestedSubMenu = _j[0], setIsNestedSubMenu = _j[1];
|
|
33
|
+
var _k = __read(useState(false), 2), hasSubIcons = _k[0], setHasSubIcons = _k[1];
|
|
34
|
+
var _l = __read(useState(false), 2), isFocusedByTab = _l[0], setIsFocusedByTab = _l[1];
|
|
35
|
+
var _m = __read(useState(id || href || ''), 2), currentId = _m[0], setCurrentId = _m[1];
|
|
70
36
|
useEffect(function () {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
37
|
+
var _a;
|
|
38
|
+
if (!currentId) {
|
|
39
|
+
var generatedId = generateId();
|
|
40
|
+
setCurrentId(generatedId);
|
|
41
|
+
}
|
|
42
|
+
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.addValue(currentId, {
|
|
43
|
+
setIsActive: setIsActive,
|
|
44
|
+
setIsOpened: setIsOpened,
|
|
45
|
+
isSubMenu: _isSubMenu,
|
|
46
|
+
setIsNestedSubMenu: setIsNestedSubMenu,
|
|
47
|
+
setHasSubIcons: setHasSubIcons,
|
|
48
|
+
setIsFirstLevelParentOfActiveMenuItem: setIsFirstLevelParentOfActiveMenuItem,
|
|
76
49
|
});
|
|
77
50
|
return function () {
|
|
78
|
-
|
|
51
|
+
var _a;
|
|
52
|
+
(_a = context.navigation) === null || _a === void 0 ? void 0 : _a.updateNavigationTree();
|
|
79
53
|
};
|
|
80
|
-
}
|
|
81
|
-
var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
|
|
82
|
-
var isDesktopCollapsedMode = (context.isDesktop || context.isNarrowDesktop) && !context.isOpened;
|
|
83
|
-
var isActiveSection = context.state.activeFirstLevelParentId === currentId;
|
|
84
|
-
var isHighlighted = isActive || (isActiveSection && (context.isSeparatedMenu || isDesktopCollapsedMode));
|
|
85
|
-
var isCollapsedTopLevelSection = isDesktopCollapsedMode && !_isSubMenu && !_isDropdown && !_isBackButton && !_isAvatar;
|
|
86
|
-
var isCollapsedAccordionSection = isCollapsedTopLevelSection && !!children && !context.isSeparatedMenu;
|
|
54
|
+
});
|
|
87
55
|
var toggleIsShown = function (lastElementInTheHierarchy) {
|
|
88
56
|
var _a;
|
|
89
57
|
if ((context.isMobile || context.isTablet) && lastElementInTheHierarchy) {
|
|
90
58
|
(_a = context.toggleIsOpened) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
91
59
|
}
|
|
92
60
|
};
|
|
93
|
-
var
|
|
94
|
-
|
|
61
|
+
var setIsCollapsed = function (lastElementInTheHierarchy) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
if (context.isMobile || context.isTablet || (context.isDesktop && !context.isCollapsable)) {
|
|
95
64
|
return;
|
|
96
65
|
}
|
|
97
|
-
|
|
98
|
-
|
|
66
|
+
var topLevelItemInSeparatedSideMenu = context.isSeparatedMenu && !_isSubMenu && children;
|
|
67
|
+
if (context.isCollapsable && (lastElementInTheHierarchy || topLevelItemInSeparatedSideMenu)) {
|
|
68
|
+
(_a = context.setIsCollapsed) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
99
69
|
}
|
|
100
|
-
|
|
101
|
-
|
|
70
|
+
if (!_isSubMenu) {
|
|
71
|
+
(_b = context.setIsCollapsed) === null || _b === void 0 ? void 0 : _b.call(context, false);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var setMouseIsOutside = function (lastElementInTheHierarchy) {
|
|
75
|
+
var _a;
|
|
76
|
+
if (lastElementInTheHierarchy) {
|
|
77
|
+
(_a = context.setIsMouseOutside) === null || _a === void 0 ? void 0 : _a.call(context, true);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var handleClick = function (e) {
|
|
81
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
82
|
+
if (disabled) {
|
|
102
83
|
return;
|
|
103
84
|
}
|
|
85
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
104
86
|
if (_isBackButton || _isDropdown) {
|
|
105
87
|
return;
|
|
106
88
|
}
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
if (!hasKids && context.closeParentDropdown) {
|
|
110
|
-
context.closeParentDropdown();
|
|
111
|
-
}
|
|
112
|
-
if (isButton && !hasKids) {
|
|
89
|
+
var item = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId);
|
|
90
|
+
if (isButton && !(item === null || item === void 0 ? void 0 : item.hasChildren)) {
|
|
113
91
|
return;
|
|
114
92
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// (collapsing it would hide the whole column), and
|
|
118
|
-
// - touch (mobile/tablet) has its own BackButton toggle driven by SELECT.
|
|
119
|
-
var isTouchViewport = !!(context.isMobile || context.isTablet);
|
|
120
|
-
var isProtectedSeparatedTopLevel = context.isSeparatedMenu && !_isSubMenu && hasKids && !isTouchViewport;
|
|
121
|
-
if (isExpanded && !isProtectedSeparatedTopLevel && !(context.isSeparatedMenu && isTouchViewport)) {
|
|
122
|
-
context.dispatch({ type: 'CLOSE_NODE', id: currentId });
|
|
93
|
+
if (isOpened && !((_c = item === null || item === void 0 ? void 0 : item.value) === null || _c === void 0 ? void 0 : _c.isSubMenu) && !context.isSeparatedMenu) {
|
|
94
|
+
(_d = item === null || item === void 0 ? void 0 : item.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
123
95
|
}
|
|
124
96
|
else {
|
|
125
|
-
context.
|
|
126
|
-
var lastElementInTheHierarchy = !_isDropdown && !_isBackButton && !
|
|
97
|
+
(_e = context.navigation) === null || _e === void 0 ? void 0 : _e.switchActiveMenuItem(currentId, isButton);
|
|
98
|
+
var lastElementInTheHierarchy = !_isDropdown && !_isBackButton && !((_g = (_f = context.navigation) === null || _f === void 0 ? void 0 : _f.activeMenuItemTreeNode) === null || _g === void 0 ? void 0 : _g.hasChildren);
|
|
127
99
|
toggleIsShown(lastElementInTheHierarchy);
|
|
100
|
+
setIsCollapsed(lastElementInTheHierarchy);
|
|
101
|
+
setMouseIsOutside(lastElementInTheHierarchy);
|
|
128
102
|
}
|
|
129
103
|
};
|
|
130
104
|
var handleFocus = function (e) {
|
|
131
105
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
132
|
-
|
|
133
|
-
cancelAnimationFrame(focusRafRef.current);
|
|
134
|
-
}
|
|
135
|
-
focusRafRef.current = requestAnimationFrame(function () {
|
|
136
|
-
focusRafRef.current = null;
|
|
106
|
+
requestAnimationFrame(function () {
|
|
137
107
|
if (keyListener.isTabPressed) {
|
|
138
108
|
setIsFocusedByTab(true);
|
|
139
109
|
}
|
|
@@ -143,20 +113,17 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
143
113
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
144
114
|
setIsFocusedByTab(false);
|
|
145
115
|
};
|
|
116
|
+
var Component = _isSubMenu || _isDropdown ? 'div' : 'li';
|
|
117
|
+
var isHighlighted = isActive ||
|
|
118
|
+
(isFirstLevelParentOfActiveMenuItem && !context.isOpened && context.isCollapsable) ||
|
|
119
|
+
(isFirstLevelParentOfActiveMenuItem && context.isSeparatedMenu);
|
|
146
120
|
var handleCollapse = function (e) {
|
|
121
|
+
var _a, _b, _c, _d;
|
|
147
122
|
if (disabled) {
|
|
148
123
|
return;
|
|
149
124
|
}
|
|
150
125
|
e.stopPropagation();
|
|
151
|
-
context.
|
|
152
|
-
};
|
|
153
|
-
var subMenuIcon = useMemoIcon(children, { isOpened: isExpanded, onClick: handleCollapse });
|
|
154
|
-
var isNativeAnchor = Tag === 'a';
|
|
155
|
-
var handleKeyDown = function (e) {
|
|
156
|
-
if (isNativeAnchor && disabled && e.key === 'Enter') {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
}
|
|
159
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
126
|
+
(_d = (_c = (_b = (_a = context.navigation) === null || _a === void 0 ? void 0 : _a.navigationTree) === null || _b === void 0 ? void 0 : _b.find(currentId)) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.setIsOpened(false);
|
|
160
127
|
};
|
|
161
128
|
var newProps = __assign({ className: cx(styles.root(theme), (_b = {},
|
|
162
129
|
_b[styles.rootButton(theme)] = isButton,
|
|
@@ -166,44 +133,19 @@ var ClickableElement = forwardRef(function (_a, ref) {
|
|
|
166
133
|
_b), (_c = {},
|
|
167
134
|
_c[styles.rootSubItemInSeparatedSubMenu(theme)] = context.isSeparatedMenu && _isSubMenu,
|
|
168
135
|
_c[styles.rootSubItemInSeparatedSubMenuActive(theme)] = isActive && context.isSeparatedMenu && _isSubMenu,
|
|
169
|
-
_c
|
|
170
|
-
_c), className), onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
136
|
+
_c), className), onClick: handleClick, onFocus: handleFocus, onBlur: handleBlur, children: (React.createElement(ItemContent, { _isSubMenu: _isSubMenu,
|
|
171
137
|
// @ts-expect-error: SideMenuItem should have icon
|
|
172
|
-
icon: _isSubMenu && !_isBackButton ?
|
|
138
|
+
icon: _isSubMenu && !_isBackButton ? useMemoIcon(children, { isOpened: isOpened, onClick: handleCollapse }) : icon, isNestedSubMenu: isNestedSubMenu, caption: caption, subCaption: subCaption, marker: marker, _isBackButton: _isBackButton, _isDropdown: _isDropdown, _isAvatar: _isAvatar, disabled: disabled, noWrap: noWrap })), ref: ref, href: href, 'aria-current': isActive ? 'page' : undefined }, rest);
|
|
173
139
|
// Подсчет смещения вправо для текущего уровня вложенности
|
|
174
|
-
// NOTE: Probably it can be calculated using Navigation Tree
|
|
175
140
|
var currentItemNestingLevel = (_e = context.currentItemNestingLevel) !== null && _e !== void 0 ? _e : 0;
|
|
176
141
|
var nestingLevelPadding = {
|
|
177
|
-
paddingLeft:
|
|
142
|
+
paddingLeft: (currentItemNestingLevel - 1) * parseInt(theme.sideMenuItemNestedPaddingLeft),
|
|
178
143
|
};
|
|
179
|
-
// NOTE: In the collapsed-accordion path (`isCollapsedAccordionSection`) this element is
|
|
180
|
-
// wrapped by `NarrowAccordionDropdown` → `DropdownMenu` → `PopupMenu`. `PopupMenu` adds
|
|
181
|
-
// its own correct `aria-expanded`/`aria-controls` to the outer caption wrapper, but
|
|
182
|
-
// this inner focusable element still keeps the `aria-expanded` set below. Because
|
|
183
|
-
// `handleClick` bails out early in accordion mode, the reducer never marks the section
|
|
184
|
-
// as opened, so the inner element always reports `aria-expanded="false"` while the
|
|
185
|
-
// popup is actually open. Screen readers announce the focused element's state, so
|
|
186
|
-
// the user can hear "collapsed" for an open section.
|
|
187
|
-
//
|
|
188
|
-
// The proper fix is to either sync the dropdown's opened state into this element, or
|
|
189
|
-
// to omit `aria-expanded` here in accordion mode and make the outer caption wrapper
|
|
190
|
-
// the accessible control (focusable + correct `aria-expanded`).
|
|
191
|
-
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 } : {}))));
|
|
192
|
-
var clickableElementWithHint = (React.createElement(ClickableElementWithHint, { hint: hint, isOpened: context.isOpened }, clickableElement));
|
|
193
|
-
// Reset the child id counter on every render so children at this nesting level get stable,
|
|
194
|
-
// position-based generated ids across unmount → re-mount transitions (e.g. narrow
|
|
195
|
-
// accordion dropdown closing → inline submenu opening).
|
|
196
|
-
childIdCounterRef.current = 0;
|
|
197
|
-
var subMenuContextValue = useMemo(function () { return (__assign(__assign({ hasSeparatedSubMenu: hasSeparatedSubMenu }, context), { parentItemId: currentId, currentItemNestingLevel: currentItemNestingLevel + 1, childIdCounterRef: childIdCounterRef })); }, [hasSeparatedSubMenu, context, currentId, currentItemNestingLevel]);
|
|
198
|
-
// При клике на айтем без детей закрывать дропдаун
|
|
199
|
-
// айтем должен оставаться активным и при разворачивании меню корректно показываться в списке подменю
|
|
200
|
-
// При клике на активный элемент с детьми, он должен закрыться
|
|
201
144
|
return (React.createElement(Component, (_d = { "data-tid": SideMenuDataTids.clickableElement }, _d[navigationAttribute] = currentId, _d),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
React.createElement(
|
|
206
|
-
React.createElement(SideMenuContext.Provider, { value: subMenuContextValue }, children))))));
|
|
145
|
+
React.cloneElement(React.createElement(Tag, { state: isActive ? 'active' : undefined, style: nestingLevelPadding }), children
|
|
146
|
+
? __assign(__assign({}, newProps), { 'aria-expanded': children ? isOpened : undefined, 'aria-controls': children ? currentId : undefined }) : __assign({}, newProps)),
|
|
147
|
+
React.createElement(SubMenu, { caption: caption, isSubMenu: _isSubMenu, isSeparatedMenu: context.isSeparatedMenu, htmlId: currentId, isOpened: isOpened },
|
|
148
|
+
React.createElement(SideMenuContext.Provider, { value: __assign(__assign({ hasSubIcons: hasSubIcons }, context), { currentItemNestingLevel: currentItemNestingLevel + 1 }) }, children))));
|
|
207
149
|
});
|
|
208
150
|
ClickableElement.displayName = 'ClickableElement';
|
|
209
151
|
var ClickableElementWithStaticFields = Object.assign(ClickableElement, {
|
|
@@ -6,6 +6,5 @@ export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").Styl
|
|
|
6
6
|
rootFocus(t: SideMenuTheme): string;
|
|
7
7
|
rootDisabled(t: SideMenuTheme): string;
|
|
8
8
|
rootActive(t: SideMenuTheme): string;
|
|
9
|
-
rootSubItemInDropdownActive(t: SideMenuTheme): string;
|
|
10
9
|
rootSubItemInSeparatedSubMenuActive(t: SideMenuTheme): string;
|
|
11
10
|
}>;
|
|
@@ -8,7 +8,7 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
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\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\n &:hover {\n background: ", ";\n }\n "])), resetButton(), t.sideMenuItemColor, t.sideMenuItemBorderRadius, t.sideMenuItemBgHover);
|
|
9
9
|
},
|
|
10
10
|
rootButton: function (t) {
|
|
11
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.
|
|
11
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:active {\n background: ", ";\n }\n "], ["\n &:active {\n background: ", ";\n }\n "])), t.sideMenuItemBgActive);
|
|
12
12
|
},
|
|
13
13
|
rootSubItemInSeparatedSubMenu: function (t) {
|
|
14
14
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n &:hover {\n background: ", ";\n }\n "], ["\n &:hover {\n background: ", ";\n }\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgHover);
|
|
@@ -22,12 +22,9 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
22
22
|
rootActive: function (t) {
|
|
23
23
|
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgActive);
|
|
24
24
|
},
|
|
25
|
-
rootSubItemInDropdownActive: function (t) {
|
|
26
|
-
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuItemBgHover);
|
|
27
|
-
},
|
|
28
25
|
rootSubItemInSeparatedSubMenuActive: function (t) {
|
|
29
|
-
return css(
|
|
26
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: ", " !important;\n "], ["\n background: ", " !important;\n "])), t.sideMenuSubItemWithSeparatedSubMenuBgActive);
|
|
30
27
|
},
|
|
31
28
|
});
|
|
32
29
|
});
|
|
33
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7
|
|
30
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -7,5 +7,5 @@ interface CaptionProps extends Pick<SideMenuItemProps, '_isSubMenu' | 'caption'
|
|
|
7
7
|
isNestedSubMenu?: boolean;
|
|
8
8
|
noWrap?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const Caption: React.ForwardRefExoticComponent<CaptionProps & React.RefAttributes<
|
|
10
|
+
export declare const Caption: React.ForwardRefExoticComponent<CaptionProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
11
11
|
export {};
|
|
@@ -5,7 +5,13 @@ import React, { forwardRef, useContext, useEffect, useRef, useState } from 'reac
|
|
|
5
5
|
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
|
|
6
6
|
import { SideMenuContext } from '../../SideMenuContext.js';
|
|
7
7
|
import { getStyles } from './Caption.styles.js';
|
|
8
|
-
|
|
8
|
+
var getTruncatedUserName = function (caption, captionWidth, maxCaptionWidth) {
|
|
9
|
+
var _a = __read(caption.split(' '), 2), firstName = _a[0], lastName = _a[1];
|
|
10
|
+
if (captionWidth > maxCaptionWidth && lastName) {
|
|
11
|
+
return "".concat(firstName, " ").concat(lastName[0], ".");
|
|
12
|
+
}
|
|
13
|
+
return caption;
|
|
14
|
+
};
|
|
9
15
|
var getCaptionTail = function (caption, captionWidth, maxCaptionWidth) {
|
|
10
16
|
if (captionWidth > maxCaptionWidth) {
|
|
11
17
|
var symbolsCount = caption.length;
|
|
@@ -19,7 +25,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
19
25
|
var _b, _c;
|
|
20
26
|
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
27
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
22
|
-
var _d = useContext(SideMenuContext), isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen,
|
|
28
|
+
var _d = useContext(SideMenuContext), isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSubIcons = _d.hasSubIcons, isBeingTransitioned = _d.isBeingTransitioned, sideMenuRef = _d.sideMenuRef;
|
|
23
29
|
var isLarge = size === 'large';
|
|
24
30
|
var isCaptionPlainText = typeof caption === 'string';
|
|
25
31
|
var captionRef = useRef(null);
|
|
@@ -30,9 +36,13 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
30
36
|
if (!caption || !isCaptionPlainText || !captionRef.current || !_isDropdown) {
|
|
31
37
|
return;
|
|
32
38
|
}
|
|
39
|
+
captionRef.current.innerText = caption;
|
|
33
40
|
var captionWidth = captionRef.current.scrollWidth;
|
|
34
41
|
var maxCaptionWidth = captionRef.current.offsetWidth;
|
|
35
|
-
if (
|
|
42
|
+
if (_isAvatar) {
|
|
43
|
+
captionRef.current.innerText = getTruncatedUserName(caption, captionWidth, maxCaptionWidth);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
36
46
|
setTail(getCaptionTail(caption, captionWidth, maxCaptionWidth));
|
|
37
47
|
}
|
|
38
48
|
};
|
|
@@ -40,29 +50,36 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
40
50
|
truncateSpecialCaption();
|
|
41
51
|
}, [caption]);
|
|
42
52
|
useEffect(function () {
|
|
53
|
+
var _a;
|
|
43
54
|
var handleTransition = function (e) {
|
|
44
55
|
if (e.propertyName === 'width') {
|
|
45
56
|
truncateSpecialCaption();
|
|
46
57
|
}
|
|
47
58
|
};
|
|
48
|
-
|
|
49
|
-
sideMenuNode === null || sideMenuNode === void 0 ? void 0 : sideMenuNode.addEventListener('transitionend', handleTransition);
|
|
59
|
+
(_a = sideMenuRef === null || sideMenuRef === void 0 ? void 0 : sideMenuRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('transitionend', handleTransition);
|
|
50
60
|
return function () {
|
|
51
|
-
|
|
61
|
+
removeEventListener('transitionend', handleTransition);
|
|
52
62
|
};
|
|
53
63
|
}, [isBeingTransitioned]);
|
|
64
|
+
var isAvatarCaptionSingleWord = function (userName, _isAvatar) {
|
|
65
|
+
if (userName === void 0) { userName = ''; }
|
|
66
|
+
if (_isAvatar === void 0) { _isAvatar = false; }
|
|
67
|
+
return _isAvatar && userName.split(' ').length === 1;
|
|
68
|
+
};
|
|
54
69
|
var Component = isCaptionPlainText ? 'p' : 'div';
|
|
55
70
|
return (React.createElement("div", { className: cx(styles.root(), (_b = {},
|
|
56
71
|
_b[styles.rootMultiline(theme)] = isMultiline && !noWrap && !_isSubMenu,
|
|
57
72
|
_b)), ref: ref },
|
|
58
73
|
React.createElement(Component, { className: cx(styles.caption(theme), (_c = {},
|
|
59
74
|
_c[styles.captionDropdown()] = _isDropdown,
|
|
60
|
-
_c[styles.captionTruncated()] = isCaptionPlainText &&
|
|
75
|
+
_c[styles.captionTruncated()] = isCaptionPlainText &&
|
|
76
|
+
_isDropdown &&
|
|
77
|
+
(!_isAvatar || isAvatarCaptionSingleWord(caption, _isAvatar)),
|
|
61
78
|
_c[styles.captionSubItem(theme)] = _isSubMenu,
|
|
62
79
|
_c[styles.captionSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !isNestedSubMenu && _isSubMenu && !hasIcon,
|
|
63
80
|
_c[styles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
|
|
64
|
-
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu
|
|
65
|
-
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !
|
|
81
|
+
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu,
|
|
82
|
+
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSubIcons,
|
|
66
83
|
_c[styles.captionLarge(theme)] = isLarge,
|
|
67
84
|
_c[styles.captionTouchScreen(theme)] = isTouchScreen,
|
|
68
85
|
_c[styles.captionSubItemTouchScreen(theme)] = isTouchScreen && _isSubMenu,
|
|
@@ -17,7 +17,7 @@ export var Icon = function (_a) {
|
|
|
17
17
|
var _b;
|
|
18
18
|
var _isSubMenu = _a._isSubMenu, icon = _a.icon, isMultiline = _a.isMultiline, disabled = _a.disabled, _c = _a._isBackButton, _isBackButton = _c === void 0 ? false : _c;
|
|
19
19
|
var context = useContext(SideMenuContext);
|
|
20
|
-
var isSeparatedMenu = context.isSeparatedMenu, size = context.size
|
|
20
|
+
var isSeparatedMenu = context.isSeparatedMenu, size = context.size;
|
|
21
21
|
var isLarge = size === 'large';
|
|
22
22
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
23
23
|
var styles = useStyles(getStyles);
|
|
@@ -34,10 +34,9 @@ export var Icon = function (_a) {
|
|
|
34
34
|
return icon;
|
|
35
35
|
};
|
|
36
36
|
return (React.createElement("span", { className: cx(styles.root(theme), (_b = {},
|
|
37
|
-
_b[styles.rootMultiline()] = isMultiline && (isOpened || _isSubMenu),
|
|
37
|
+
_b[styles.rootMultiline()] = isMultiline && (context.isOpened || _isSubMenu),
|
|
38
38
|
_b[styles.rootLarge(theme)] = isLarge,
|
|
39
39
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
40
|
-
_b[styles.rootSubItemDropdown()] = _isSubMenu && !isOpened && !isSeparatedMenu,
|
|
41
40
|
_b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
42
41
|
_b[styles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
|
|
43
42
|
_b[styles.rootBackButton(theme)] = _isBackButton,
|
|
@@ -5,7 +5,6 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
5
5
|
rootLarge(t: SideMenuTheme): string;
|
|
6
6
|
rootSubItemLarge(t: SideMenuTheme): string;
|
|
7
7
|
rootSubItem(t: SideMenuTheme): string;
|
|
8
|
-
rootSubItemDropdown(): string;
|
|
9
8
|
rootSubItemSeparatedMenu(t: SideMenuTheme): string;
|
|
10
9
|
rootBackButton(t: SideMenuTheme): string;
|
|
11
10
|
}>;
|
|
@@ -18,15 +18,12 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
18
18
|
rootSubItem: function (t) {
|
|
19
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);
|
|
20
20
|
},
|
|
21
|
-
rootSubItemDropdown: function () {
|
|
22
|
-
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
|
|
23
|
-
},
|
|
24
21
|
rootSubItemSeparatedMenu: function (t) {
|
|
25
|
-
return css(
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
|
|
26
23
|
},
|
|
27
24
|
rootBackButton: function (t) {
|
|
28
|
-
return css(
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
|
|
29
26
|
},
|
|
30
27
|
});
|
|
31
28
|
});
|
|
32
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7
|
|
29
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -25,12 +25,13 @@ var getCaptionLineHeight = function (theme, isTouchScreen, _isSubMenu, size) {
|
|
|
25
25
|
*/
|
|
26
26
|
var ItemContent = forwardRef(function (_a, ref) {
|
|
27
27
|
var _b, _c;
|
|
28
|
+
var _d;
|
|
28
29
|
var _isSubMenu = _a._isSubMenu, icon = _a.icon, isNestedSubMenu = _a.isNestedSubMenu, caption = _a.caption, subCaption = _a.subCaption, marker = _a.marker, _isBackButton = _a._isBackButton, _isDropdown = _a._isDropdown, _isAvatar = _a._isAvatar, disabled = _a.disabled, noWrap = _a.noWrap;
|
|
29
30
|
var context = useContext(SideMenuContext);
|
|
30
31
|
var size = context.size, isTouchScreen = context.isTouchScreen;
|
|
31
32
|
var textRef = useRef(null);
|
|
32
33
|
var isLarge = size === 'large';
|
|
33
|
-
var
|
|
34
|
+
var _e = __read(useState(false), 2), isMultiline = _e[0], setIsMultiline = _e[1];
|
|
34
35
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
35
36
|
var styles = useStyles(getStyles);
|
|
36
37
|
var cx = useEmotion().cx;
|
|
@@ -46,21 +47,9 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
46
47
|
if (!textRef.current || _isBackButton || _isDropdown) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
|
-
var captionLineHeight = getCaptionLineHeight(theme, isTouchScreen, _isSubMenu, size);
|
|
50
|
-
setIsMultiline(parseInt(captionLineHeight
|
|
51
|
-
}, [
|
|
52
|
-
caption,
|
|
53
|
-
context.isBeingTransitioned,
|
|
54
|
-
context.state.activeItemId,
|
|
55
|
-
noWrap,
|
|
56
|
-
subCaption,
|
|
57
|
-
_isBackButton,
|
|
58
|
-
_isDropdown,
|
|
59
|
-
theme,
|
|
60
|
-
isTouchScreen,
|
|
61
|
-
_isSubMenu,
|
|
62
|
-
size,
|
|
63
|
-
]);
|
|
50
|
+
var captionLineHeight = getCaptionLineHeight(theme, context.isTouchScreen, _isSubMenu, size);
|
|
51
|
+
setIsMultiline(parseInt(captionLineHeight) < textRef.current.offsetHeight);
|
|
52
|
+
}, [caption, context.isBeingTransitioned, (_d = context.navigation) === null || _d === void 0 ? void 0 : _d.activeMenuItem]);
|
|
64
53
|
return (React.createElement("div", { className: cx(styles.root(theme), (_b = {},
|
|
65
54
|
_b[styles.rootLarge(theme)] = isLarge,
|
|
66
55
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
@@ -69,7 +58,6 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
69
58
|
_b[styles.rootMultilineLarge(theme)] = isMultiline && !noWrap && isLarge,
|
|
70
59
|
_b[styles.rootTouchScreen(theme)] = isTouchScreen,
|
|
71
60
|
_b[styles.rootSubItemTouchScreen(theme)] = isTouchScreen && _isSubMenu,
|
|
72
|
-
_b[styles.rootInDropdown(theme)] = !context.isSeparatedMenu && !context.isOpened && _isSubMenu,
|
|
73
61
|
_b)), ref: ref },
|
|
74
62
|
icon && (React.createElement(Icon, { _isSubMenu: _isSubMenu, icon: icon, isMultiline: isMultiline, disabled: disabled, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
|
|
75
63
|
React.createElement("div", { className: cx(styles.textAndMarkerWrapper(), (_c = {},
|
|
@@ -8,7 +8,6 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
8
8
|
rootMultilineLarge(t: SideMenuTheme): string;
|
|
9
9
|
rootTouchScreen(t: SideMenuTheme): string;
|
|
10
10
|
rootSubItemTouchScreen(t: SideMenuTheme): string;
|
|
11
|
-
rootInDropdown(t: SideMenuTheme): string;
|
|
12
11
|
textAndMarkerWrapper(): string;
|
|
13
12
|
textAndMarkerWrapperDropdown(): string;
|
|
14
13
|
textAndMarkerWrapperCollapsed(): string;
|
|
@@ -27,18 +27,15 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
27
27
|
rootSubItemTouchScreen: function (t) {
|
|
28
28
|
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuSubItemContentPaddingYTouchScreen, t.sideMenuSubItemContentPaddingYTouchScreen);
|
|
29
29
|
},
|
|
30
|
-
rootInDropdown: function (t) {
|
|
31
|
-
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding: ", " ", ";\n "], ["\n padding: ", " ", ";\n "])), t.sideMenuSubItemContentPaddingYDropdown, t.sideMenuSubItemContentPaddingXDropdown);
|
|
32
|
-
},
|
|
33
30
|
textAndMarkerWrapper: function () {
|
|
34
|
-
return css(
|
|
31
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "])));
|
|
35
32
|
},
|
|
36
33
|
textAndMarkerWrapperDropdown: function () {
|
|
37
|
-
return css(
|
|
34
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
38
35
|
},
|
|
39
36
|
textAndMarkerWrapperCollapsed: function () {
|
|
40
|
-
return css(
|
|
37
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
|
|
41
38
|
},
|
|
42
39
|
});
|
|
43
40
|
});
|
|
44
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11
|
|
41
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RightBorderProps {
|
|
3
|
+
onClick: () => void;
|
|
4
|
+
showButton: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const RightBorderWithStaticFields: React.ForwardRefExoticComponent<RightBorderProps & React.RefAttributes<HTMLDivElement>> & {
|
|
7
|
+
__KONTUR_REACT_UI__: string;
|
|
8
|
+
};
|
|
9
|
+
export { RightBorderWithStaticFields as RightBorder };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Hint } from '@skbkontur/react-ui/components/Hint/Hint';
|
|
2
|
+
import { ZIndex } from '@skbkontur/react-ui/internal/ZIndex';
|
|
3
|
+
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
4
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
5
|
+
import React, { forwardRef, useContext } from 'react';
|
|
6
|
+
import { useMemoBorderIcon } from '../../hooks/useMemoIcon.js';
|
|
7
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
8
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
9
|
+
import { SideMenuContext } from '../SideMenuContext.js';
|
|
10
|
+
import { getStyles } from './RightBorder.styles.js';
|
|
11
|
+
/**
|
|
12
|
+
* Элемент интерактивной правой границы
|
|
13
|
+
*
|
|
14
|
+
* @visibleName RightBorder
|
|
15
|
+
*/
|
|
16
|
+
var RightBorder = forwardRef(function (_a, ref) {
|
|
17
|
+
var _b;
|
|
18
|
+
var onClick = _a.onClick, showButton = _a.showButton;
|
|
19
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
20
|
+
var context = useContext(SideMenuContext);
|
|
21
|
+
var styles = useStyles(getStyles);
|
|
22
|
+
var cx = useEmotion().cx;
|
|
23
|
+
var icon = useMemoBorderIcon(context.isCollapsable);
|
|
24
|
+
var hintText = context.isCollapsable ? 'Закрепить меню' : 'Свернуть меню';
|
|
25
|
+
return (React.createElement(Hint, { text: hintText, pos: 'right' },
|
|
26
|
+
React.createElement("div", { className: cx(styles.root(theme), (_b = {},
|
|
27
|
+
_b[styles.rootWithButton()] = showButton,
|
|
28
|
+
_b)), ref: ref, onClick: onClick, onKeyDown: function (e) {
|
|
29
|
+
if (e.key === 'Enter' || e.key === 'Space') {
|
|
30
|
+
onClick();
|
|
31
|
+
}
|
|
32
|
+
}, role: "button", tabIndex: 0, "data-tid": SideMenuDataTids.rightBorder },
|
|
33
|
+
React.createElement(ZIndex, { priority: 1 }, icon))));
|
|
34
|
+
});
|
|
35
|
+
RightBorder.displayName = 'RightBorder';
|
|
36
|
+
var RightBorderWithStaticFields = Object.assign(RightBorder, { __KONTUR_REACT_UI__: 'RightBorder' });
|
|
37
|
+
export { RightBorderWithStaticFields as RightBorder };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
3
|
+
export var getStyles = memoizeGetStyles(function (_a) {
|
|
4
|
+
var css = _a.css;
|
|
5
|
+
return ({
|
|
6
|
+
root: function (t) {
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n align-items: center;\n color: ", ";\n transition:\n opacity,\n color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "], ["\n opacity: 0;\n position: absolute;\n width: ", ";\n height: 100%;\n right: 0;\n background: transparent;\n display: flex;\n align-items: center;\n color: ", ";\n transition:\n opacity,\n color 150ms cubic-bezier(0.5, 1, 0.89, 1);\n &:hover {\n color: ", ";\n }\n "])), t.sideMenuRightBorderWidth, t.sideMenuRightBorderIconColor, t.sideMenuRightBorderIconColorHover);
|
|
8
|
+
},
|
|
9
|
+
rootWithButton: function () {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n "], ["\n opacity: 1;\n "])));
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
var templateObject_1, templateObject_2;
|