@skbkontur/side-menu 4.0.8 → 4.0.10-beta.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 +11 -0
- package/README.md +38 -11
- package/SideMenuDataTids.d.ts +2 -1
- package/SideMenuDataTids.js +2 -1
- package/hooks/useMemoIcon.d.ts +1 -2
- package/hooks/useMemoIcon.js +0 -9
- package/hooks/useNodeState.d.ts +7 -0
- package/hooks/useNodeState.js +12 -0
- package/hooks/useSideMenuReducer.d.ts +13 -0
- package/hooks/useSideMenuReducer.js +23 -0
- package/internal/themes/SideMenuTheme.d.ts +4 -0
- package/internal/themes/SideMenuTheme.js +4 -0
- package/lib/utils/scripts.d.ts +1 -0
- package/lib/utils/scripts.js +9 -0
- package/package.json +1 -1
- package/src/SideMenu/SideMenu.d.ts +7 -4
- package/src/SideMenu/SideMenu.js +148 -178
- package/src/SideMenu/SideMenu.styles.js +2 -2
- package/src/SideMenuAvatar/SideMenuAvatar.js +11 -2
- package/src/SideMenuContext.d.ts +16 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDropdown/SideMenuDropdown.js +11 -18
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +3 -3
- package/src/SideMenuFooter/SideMenuFooter.js +15 -3
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +4 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +16 -4
- package/src/SideMenuHeader/SideMenuHeader.js +4 -3
- package/src/SideMenuNotifications/BellWidget.d.ts +1 -1
- package/src/SideMenuNotifications/BellWidgetError.d.ts +1 -3
- package/src/SideMenuNotifications/SideMenuNotifications.d.ts +1 -1
- package/src/SideMenuSubItem/SideMenuSubItem.d.ts +1 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +1 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +5 -2
- package/src/SideMenuSubLink/SideMenuSubLink.d.ts +1 -1
- package/src/internal/BackButton.d.ts +1 -3
- package/src/internal/BackButton.js +4 -3
- package/src/internal/ClickableElement.d.ts +8 -1
- package/src/internal/ClickableElement.js +125 -67
- package/src/internal/ClickableElement.styles.d.ts +1 -0
- package/src/internal/ClickableElement.styles.js +6 -3
- package/src/internal/CollapseToggle.d.ts +1 -0
- package/src/internal/CollapseToggle.js +27 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +0 -1
- package/src/internal/CollapseToggle.styles.js +12 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +9 -26
- package/src/internal/ItemContent/Icon.js +3 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +6 -3
- package/src/internal/ItemContent/ItemContent.js +17 -5
- package/src/internal/ItemContent/ItemContent.styles.d.ts +1 -0
- package/src/internal/ItemContent/ItemContent.styles.js +7 -4
- package/src/internal/NarrowAccordionDropdown.d.ts +13 -0
- package/src/internal/NarrowAccordionDropdown.js +34 -0
- package/src/internal/SeparatedSubMenu.js +7 -9
- package/src/internal/SeparatedSubMenu.styles.d.ts +0 -3
- package/src/internal/SeparatedSubMenu.styles.js +6 -15
- package/src/internal/SideMenuLogotype.js +10 -8
- package/src/internal/SubMenu.js +3 -2
- package/src/navigationAttributes.d.ts +3 -0
- package/src/navigationAttributes.js +3 -0
- package/src/state/reducer.d.ts +2 -0
- package/src/state/reducer.js +258 -0
- package/src/state/selectors.d.ts +16 -0
- package/src/state/selectors.js +71 -0
- package/src/state/types.d.ts +59 -0
- package/src/state/types.js +17 -0
- package/src/Navigation.d.ts +0 -53
- package/src/Navigation.js +0 -194
- package/src/Tree.d.ts +0 -17
- package/src/Tree.js +0 -135
- package/src/internal/RightBorder.d.ts +0 -9
- package/src/internal/RightBorder.js +0 -37
- package/src/internal/RightBorder.styles.js +0 -14
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
3
|
+
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
4
|
+
export var getStyles = memoizeGetStyles(function (_a) {
|
|
5
|
+
var css = _a.css;
|
|
6
|
+
return ({
|
|
7
|
+
root: function (t) {
|
|
8
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n "], ["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n "])), resetButton(), t.sideMenuCollapseToggleSize, t.sideMenuCollapseToggleSize, t.sideMenuItemBorderRadius, t.sideMenuRightBorderIconColor, t.sideMenuRightBorderIconColorHover, t.sideMenuItemBoxShadowFocus);
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
var templateObject_1;
|
|
@@ -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<HTMLDivElement>>;
|
|
11
11
|
export {};
|
|
@@ -5,13 +5,7 @@ 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
|
-
|
|
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
|
-
};
|
|
8
|
+
// NOTE: assumes an approximately monospaced character width; proportional fonts give only approximate tail length.
|
|
15
9
|
var getCaptionTail = function (caption, captionWidth, maxCaptionWidth) {
|
|
16
10
|
if (captionWidth > maxCaptionWidth) {
|
|
17
11
|
var symbolsCount = caption.length;
|
|
@@ -25,7 +19,7 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
25
19
|
var _b, _c;
|
|
26
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;
|
|
27
21
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
28
|
-
var _d = useContext(SideMenuContext), isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen,
|
|
22
|
+
var _d = useContext(SideMenuContext), isSeparatedMenu = _d.isSeparatedMenu, size = _d.size, isTouchScreen = _d.isTouchScreen, hasSeparatedSubMenu = _d.hasSeparatedSubMenu, isBeingTransitioned = _d.isBeingTransitioned, sideMenuRef = _d.sideMenuRef, isOpened = _d.isOpened;
|
|
29
23
|
var isLarge = size === 'large';
|
|
30
24
|
var isCaptionPlainText = typeof caption === 'string';
|
|
31
25
|
var captionRef = useRef(null);
|
|
@@ -36,13 +30,9 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
36
30
|
if (!caption || !isCaptionPlainText || !captionRef.current || !_isDropdown) {
|
|
37
31
|
return;
|
|
38
32
|
}
|
|
39
|
-
captionRef.current.innerText = caption;
|
|
40
33
|
var captionWidth = captionRef.current.scrollWidth;
|
|
41
34
|
var maxCaptionWidth = captionRef.current.offsetWidth;
|
|
42
|
-
if (_isAvatar) {
|
|
43
|
-
captionRef.current.innerText = getTruncatedUserName(caption, captionWidth, maxCaptionWidth);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
35
|
+
if (!_isAvatar) {
|
|
46
36
|
setTail(getCaptionTail(caption, captionWidth, maxCaptionWidth));
|
|
47
37
|
}
|
|
48
38
|
};
|
|
@@ -50,36 +40,29 @@ export var Caption = forwardRef(function (_a, ref) {
|
|
|
50
40
|
truncateSpecialCaption();
|
|
51
41
|
}, [caption]);
|
|
52
42
|
useEffect(function () {
|
|
53
|
-
var _a;
|
|
54
43
|
var handleTransition = function (e) {
|
|
55
44
|
if (e.propertyName === 'width') {
|
|
56
45
|
truncateSpecialCaption();
|
|
57
46
|
}
|
|
58
47
|
};
|
|
59
|
-
|
|
48
|
+
var sideMenuNode = sideMenuRef === null || sideMenuRef === void 0 ? void 0 : sideMenuRef.current;
|
|
49
|
+
sideMenuNode === null || sideMenuNode === void 0 ? void 0 : sideMenuNode.addEventListener('transitionend', handleTransition);
|
|
60
50
|
return function () {
|
|
61
|
-
removeEventListener('transitionend', handleTransition);
|
|
51
|
+
sideMenuNode === null || sideMenuNode === void 0 ? void 0 : sideMenuNode.removeEventListener('transitionend', handleTransition);
|
|
62
52
|
};
|
|
63
53
|
}, [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
|
-
};
|
|
69
54
|
var Component = isCaptionPlainText ? 'p' : 'div';
|
|
70
55
|
return (React.createElement("div", { className: cx(styles.root(), (_b = {},
|
|
71
56
|
_b[styles.rootMultiline(theme)] = isMultiline && !noWrap && !_isSubMenu,
|
|
72
57
|
_b)), ref: ref },
|
|
73
58
|
React.createElement(Component, { className: cx(styles.caption(theme), (_c = {},
|
|
74
59
|
_c[styles.captionDropdown()] = _isDropdown,
|
|
75
|
-
_c[styles.captionTruncated()] = isCaptionPlainText &&
|
|
76
|
-
_isDropdown &&
|
|
77
|
-
(!_isAvatar || isAvatarCaptionSingleWord(caption, _isAvatar)),
|
|
60
|
+
_c[styles.captionTruncated()] = isCaptionPlainText && _isDropdown,
|
|
78
61
|
_c[styles.captionSubItem(theme)] = _isSubMenu,
|
|
79
62
|
_c[styles.captionSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !isNestedSubMenu && _isSubMenu && !hasIcon,
|
|
80
63
|
_c[styles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
|
|
81
|
-
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu,
|
|
82
|
-
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !
|
|
64
|
+
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu && isOpened,
|
|
65
|
+
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSeparatedSubMenu,
|
|
83
66
|
_c[styles.captionLarge(theme)] = isLarge,
|
|
84
67
|
_c[styles.captionTouchScreen(theme)] = isTouchScreen,
|
|
85
68
|
_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, isOpened = context.isOpened;
|
|
21
21
|
var isLarge = size === 'large';
|
|
22
22
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
23
23
|
var styles = useStyles(getStyles);
|
|
@@ -34,9 +34,10 @@ 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 && (
|
|
37
|
+
_b[styles.rootMultiline()] = isMultiline && (isOpened || _isSubMenu),
|
|
38
38
|
_b[styles.rootLarge(theme)] = isLarge,
|
|
39
39
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
40
|
+
_b[styles.rootSubItemDropdown()] = _isSubMenu && !isOpened && !isSeparatedMenu,
|
|
40
41
|
_b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
41
42
|
_b[styles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
|
|
42
43
|
_b[styles.rootBackButton(theme)] = _isBackButton,
|
|
@@ -5,6 +5,7 @@ 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;
|
|
8
9
|
rootSubItemSeparatedMenu(t: SideMenuTheme): string;
|
|
9
10
|
rootBackButton(t: SideMenuTheme): string;
|
|
10
11
|
}>;
|
|
@@ -18,12 +18,15 @@ 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
|
+
},
|
|
21
24
|
rootSubItemSeparatedMenu: function (t) {
|
|
22
|
-
return css(
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
|
|
23
26
|
},
|
|
24
27
|
rootBackButton: function (t) {
|
|
25
|
-
return css(
|
|
28
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
|
|
26
29
|
},
|
|
27
30
|
});
|
|
28
31
|
});
|
|
29
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
32
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -25,13 +25,12 @@ 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;
|
|
29
28
|
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;
|
|
30
29
|
var context = useContext(SideMenuContext);
|
|
31
30
|
var size = context.size, isTouchScreen = context.isTouchScreen;
|
|
32
31
|
var textRef = useRef(null);
|
|
33
32
|
var isLarge = size === 'large';
|
|
34
|
-
var
|
|
33
|
+
var _d = __read(useState(false), 2), isMultiline = _d[0], setIsMultiline = _d[1];
|
|
35
34
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
36
35
|
var styles = useStyles(getStyles);
|
|
37
36
|
var cx = useEmotion().cx;
|
|
@@ -47,9 +46,21 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
47
46
|
if (!textRef.current || _isBackButton || _isDropdown) {
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
var captionLineHeight = getCaptionLineHeight(theme,
|
|
51
|
-
setIsMultiline(parseInt(captionLineHeight) < textRef.current.offsetHeight);
|
|
52
|
-
}, [
|
|
49
|
+
var captionLineHeight = getCaptionLineHeight(theme, isTouchScreen, _isSubMenu, size);
|
|
50
|
+
setIsMultiline(parseInt(captionLineHeight, 10) < textRef.current.offsetHeight);
|
|
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
|
+
]);
|
|
53
64
|
return (React.createElement("div", { className: cx(styles.root(theme), (_b = {},
|
|
54
65
|
_b[styles.rootLarge(theme)] = isLarge,
|
|
55
66
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
@@ -58,6 +69,7 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
58
69
|
_b[styles.rootMultilineLarge(theme)] = isMultiline && !noWrap && isLarge,
|
|
59
70
|
_b[styles.rootTouchScreen(theme)] = isTouchScreen,
|
|
60
71
|
_b[styles.rootSubItemTouchScreen(theme)] = isTouchScreen && _isSubMenu,
|
|
72
|
+
_b[styles.rootInDropdown(theme)] = !context.isSeparatedMenu && !context.isOpened && _isSubMenu,
|
|
61
73
|
_b)), ref: ref },
|
|
62
74
|
icon && (React.createElement(Icon, { _isSubMenu: _isSubMenu, icon: icon, isMultiline: isMultiline, disabled: disabled, _isBackButton: _isBackButton, _isAvatar: _isAvatar })),
|
|
63
75
|
React.createElement("div", { className: cx(styles.textAndMarkerWrapper(), (_c = {},
|
|
@@ -8,6 +8,7 @@ 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;
|
|
11
12
|
textAndMarkerWrapper(): string;
|
|
12
13
|
textAndMarkerWrapperDropdown(): string;
|
|
13
14
|
textAndMarkerWrapperCollapsed(): string;
|
|
@@ -27,15 +27,18 @@ 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
|
+
},
|
|
30
33
|
textAndMarkerWrapper: function () {
|
|
31
|
-
return css(
|
|
34
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "], ["\n display: flex;\n flex-grow: 1;\n align-items: center;\n min-width: 0;\n "])));
|
|
32
35
|
},
|
|
33
36
|
textAndMarkerWrapperDropdown: function () {
|
|
34
|
-
return css(
|
|
37
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n overflow: hidden;\n "], ["\n overflow: hidden;\n "])));
|
|
35
38
|
},
|
|
36
39
|
textAndMarkerWrapperCollapsed: function () {
|
|
37
|
-
return css(
|
|
40
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: none;\n "], ["\n display: none;\n "])));
|
|
38
41
|
},
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
|
-
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface NarrowAccordionDropdownProps {
|
|
3
|
+
caption: React.ReactNode;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
htmlId: string;
|
|
6
|
+
'aria-label'?: string;
|
|
7
|
+
childIdCounterRef?: React.MutableRefObject<number>;
|
|
8
|
+
}
|
|
9
|
+
export declare const NarrowAccordionDropdown: {
|
|
10
|
+
({ caption, children, htmlId, "aria-label": ariaLabel, childIdCounterRef, }: NarrowAccordionDropdownProps): JSX.Element;
|
|
11
|
+
displayName: string;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { DropdownMenu } from '@skbkontur/react-ui/components/DropdownMenu';
|
|
3
|
+
import { useStyles, useEmotion } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
4
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
5
|
+
import React, { useContext, useRef } from 'react';
|
|
6
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
7
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
8
|
+
import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
|
|
9
|
+
import { SideMenuContext } from '../SideMenuContext.js';
|
|
10
|
+
import { getStyles as getDropdownStyles } from '../SideMenuDropdown/SideMenuDropdown.styles.js';
|
|
11
|
+
export var NarrowAccordionDropdown = function (_a) {
|
|
12
|
+
var _b;
|
|
13
|
+
var _c;
|
|
14
|
+
var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], childIdCounterRef = _a.childIdCounterRef;
|
|
15
|
+
var context = useContext(SideMenuContext);
|
|
16
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
17
|
+
var sideMenuStyles = useStyles(getSideMenuStyles);
|
|
18
|
+
var cx = useEmotion().cx;
|
|
19
|
+
var dropdownStyles = useStyles(getDropdownStyles);
|
|
20
|
+
var dropdownMenuRef = useRef(null);
|
|
21
|
+
var isMenuCollapsed = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
|
|
22
|
+
return (React.createElement("div", { className: cx(dropdownStyles.wrapper()) },
|
|
23
|
+
React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (_b = {},
|
|
24
|
+
_b[dropdownStyles.labelTouchScreen(theme)] = context.isTouchScreen,
|
|
25
|
+
_b[dropdownStyles.labelCollapsed()] = isMenuCollapsed,
|
|
26
|
+
_b)) }, 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
|
+
} },
|
|
31
|
+
React.createElement("ul", { className: cx(sideMenuStyles.list()), "data-tid": SideMenuDataTids.narrowAccordionDropdown },
|
|
32
|
+
React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((_c = context.currentItemNestingLevel) !== null && _c !== void 0 ? _c : 0) + 1, closeParentDropdown: function () { var _a; return (_a = dropdownMenuRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, childIdCounterRef: childIdCounterRef !== null && childIdCounterRef !== void 0 ? childIdCounterRef : context.childIdCounterRef }) }, children)))));
|
|
33
|
+
};
|
|
34
|
+
NarrowAccordionDropdown.displayName = 'NarrowAccordionDropdown';
|
|
@@ -5,7 +5,7 @@ import React, { forwardRef, useContext, useEffect, useRef } from 'react';
|
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
6
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
7
7
|
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
8
|
-
import { navigationAttributeForSeparatedMenu } from '../
|
|
8
|
+
import { navigationAttributeForSeparatedMenu } from '../navigationAttributes.js';
|
|
9
9
|
import { getStyles as getSideMenuStyles } from '../SideMenu/SideMenu.styles.js';
|
|
10
10
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
11
11
|
import { BackButton } from './BackButton.js';
|
|
@@ -17,7 +17,7 @@ import { getCustomStyles, getStyles } from './SeparatedSubMenu.styles.js';
|
|
|
17
17
|
*/
|
|
18
18
|
var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
19
19
|
var _b, _c, _d;
|
|
20
|
-
var _e, _f
|
|
20
|
+
var _e, _f;
|
|
21
21
|
var children = _a.children, caption = _a.caption, htmlId = _a.htmlId, isOpened = _a.isOpened;
|
|
22
22
|
var context = useContext(SideMenuContext);
|
|
23
23
|
var scrollContainerRef = useRef(null);
|
|
@@ -30,22 +30,20 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
30
30
|
if (!context.isMobile) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
setTimeout(function () {
|
|
33
|
+
var timeoutId = setTimeout(function () {
|
|
34
34
|
var _a, _b;
|
|
35
35
|
if (isOpened) {
|
|
36
36
|
(_a = context.setHasScrollBar) === null || _a === void 0 ? void 0 : _a.call(context, !!((_b = scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.hasScrollBar('y')));
|
|
37
37
|
}
|
|
38
38
|
}, 50);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return function () { return clearTimeout(timeoutId); };
|
|
40
|
+
}, [context.isMobile, context.setHasScrollBar, isOpened, context.state.activeItemId]);
|
|
41
|
+
if (!((_e = context.sideMenuRef) === null || _e === void 0 ? void 0 : _e.current)) {
|
|
41
42
|
return null;
|
|
42
43
|
}
|
|
43
44
|
return ReactDOM.createPortal(React.createElement("div", (_b = { className: cx(sideMenuStyles.container(theme), styles.root(theme), (_c = {},
|
|
44
45
|
_c[sideMenuStyles.containerTouchScreen(theme)] = context.isTouchScreen,
|
|
45
46
|
_c[customStyles.rootMobile(context.headerHeight)] = context.isMobile,
|
|
46
|
-
_c[styles.rootDesktop()] = context.isDesktop,
|
|
47
|
-
_c[styles.rootTouchScreen(theme)] = context.isTouchScreen && context.isOpened && context.isCollapsable,
|
|
48
|
-
_c[styles.rootNarrowDesktop(theme)] = context.isCollapsable,
|
|
49
47
|
_c[styles.rootTablet(theme)] = context.isTablet,
|
|
50
48
|
_c[sideMenuStyles.hidden()] = !isOpened || (!context.isOpened && (context.isTablet || context.isMobile)),
|
|
51
49
|
_c)), ref: ref, "data-tid": SideMenuDataTids.separatedSubMenu }, _b[navigationAttributeForSeparatedMenu] = htmlId, _b),
|
|
@@ -59,7 +57,7 @@ var SeparatedSubMenu = forwardRef(function (_a, ref) {
|
|
|
59
57
|
_d[styles.contentWrapperMobile()] = context.isMobile,
|
|
60
58
|
_d)) },
|
|
61
59
|
context.isMobile && React.createElement(BackButton, { caption: caption, id: htmlId }),
|
|
62
|
-
children))), (
|
|
60
|
+
children))), (_f = context.sideMenuRef) === null || _f === void 0 ? void 0 : _f.current);
|
|
63
61
|
});
|
|
64
62
|
SeparatedSubMenu.displayName = 'SeparatedSubMenu';
|
|
65
63
|
var SeparatedSubMenuWithStaticFields = Object.assign(SeparatedSubMenu, { __KONTUR_REACT_UI__: 'SeparatedSubMenu' });
|
|
@@ -2,9 +2,6 @@ import { type Emotion } from '../../lib/theming/ThemeHelpers.js';
|
|
|
2
2
|
import type { SideMenuTheme } from '../../lib/theming/ThemeTypes.js';
|
|
3
3
|
export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").StylesGetter<{
|
|
4
4
|
root(t: SideMenuTheme): string;
|
|
5
|
-
rootTouchScreen(t: SideMenuTheme): string;
|
|
6
|
-
rootNarrowDesktop(t: SideMenuTheme): string;
|
|
7
|
-
rootDesktop(): string;
|
|
8
5
|
rootTablet(t: SideMenuTheme): string;
|
|
9
6
|
contentWrapper(t: SideMenuTheme): string;
|
|
10
7
|
contentWrapperMobile(): string;
|
|
@@ -4,25 +4,16 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
4
4
|
var css = _a.css;
|
|
5
5
|
return ({
|
|
6
6
|
root: function (t) {
|
|
7
|
-
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n
|
|
8
|
-
},
|
|
9
|
-
rootTouchScreen: function (t) {
|
|
10
|
-
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n left: ", ";\n z-index: -1;\n "], ["\n left: ", ";\n z-index: -1;\n "])), t.sideMenuWidthTouchScreen);
|
|
11
|
-
},
|
|
12
|
-
rootNarrowDesktop: function (t) {
|
|
13
|
-
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n left: ", ";\n z-index: -1;\n "], ["\n left: ", ";\n z-index: -1;\n "])), t.sideMenuWidthCollapsed);
|
|
14
|
-
},
|
|
15
|
-
rootDesktop: function () {
|
|
16
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n z-index: -1;\n "], ["\n z-index: -1;\n "])));
|
|
7
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background: ", ";\n border-right: 1px solid ", ";\n z-index: 8000;\n "], ["\n background: ", ";\n border-right: 1px solid ", ";\n z-index: 8000;\n "])), t.sideMenuSeparatedSubMenuBg, t.sideMenuSeparatedSubMenuBorderRightColor);
|
|
17
8
|
},
|
|
18
9
|
rootTablet: function (t) {
|
|
19
|
-
return css(
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-right: none;\n "], ["\n border-right: none;\n "])));
|
|
20
11
|
},
|
|
21
12
|
contentWrapper: function (t) {
|
|
22
|
-
return css(
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: ", " ", ";\n "], ["\n padding: ", " ", ";\n "])), t.sideMenuSeparatedSubMenuPaddingY, t.sideMenuSeparatedSubMenuPaddingX);
|
|
23
14
|
},
|
|
24
15
|
contentWrapperMobile: function () {
|
|
25
|
-
return css(
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding-top: 0;\n "], ["\n padding-top: 0;\n "])));
|
|
26
17
|
},
|
|
27
18
|
});
|
|
28
19
|
});
|
|
@@ -30,8 +21,8 @@ export var getCustomStyles = function (_a) {
|
|
|
30
21
|
var css = _a.css;
|
|
31
22
|
return ({
|
|
32
23
|
rootMobile: function (headerHeight) {
|
|
33
|
-
return css(
|
|
24
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n position: absolute;\n height: calc(100vh - ", "px);\n left: 0;\n top: ", "px;\n "], ["\n position: absolute;\n height: calc(100vh - ", "px);\n left: 0;\n top: ", "px;\n "])), headerHeight, headerHeight);
|
|
34
25
|
},
|
|
35
26
|
});
|
|
36
27
|
};
|
|
37
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5
|
|
28
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -27,7 +27,7 @@ var getProductName = function (productLogo) {
|
|
|
27
27
|
: 'kontur';
|
|
28
28
|
};
|
|
29
29
|
var getStaticIconPath = function (productName) {
|
|
30
|
-
return "https://s.kontur.ru/common-v2/icons-products/".concat(productName, "/").concat(productName, "-").concat(parseInt(sideMenuLogotypeIconSize), ".svg");
|
|
30
|
+
return "https://s.kontur.ru/common-v2/icons-products/".concat(productName, "/").concat(productName, "-").concat(parseInt(sideMenuLogotypeIconSize, 10), ".svg");
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Логотип
|
|
@@ -47,20 +47,22 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
47
47
|
var _f = __read(useState(false), 2), isSizeCalculated = _f[0], setIsSizeCalculated = _f[1];
|
|
48
48
|
var _g = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _g[0], setProductIconUrl = _g[1];
|
|
49
49
|
var isTabletOrMobile = context.isTablet || context.isMobile;
|
|
50
|
+
var isDesktopCollapsedMode = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
|
|
51
|
+
var sideMenuWidth = theme.sideMenuWidth, sideMenuMarginX = theme.sideMenuMarginX, sideMenuLogotypePaddingLeft = theme.sideMenuLogotypePaddingLeft;
|
|
50
52
|
useEffect(function () {
|
|
51
53
|
var _a, _b;
|
|
52
54
|
var logotypeWidth = (_b = (_a = refLogotype.current) === null || _a === void 0 ? void 0 : _a.logotypeRef) === null || _b === void 0 ? void 0 : _b.clientWidth;
|
|
53
|
-
var maxWidth = parseInt(
|
|
54
|
-
2 * parseInt(
|
|
55
|
-
parseInt(
|
|
55
|
+
var maxWidth = parseInt(sideMenuWidth, 10) -
|
|
56
|
+
2 * parseInt(sideMenuMarginX, 10) -
|
|
57
|
+
parseInt(sideMenuLogotypePaddingLeft, 10) +
|
|
56
58
|
(withWidget ? -28 : 0);
|
|
57
59
|
if (logotypeWidth && logotypeWidth > maxWidth && !rest.size) {
|
|
58
60
|
setSize(24);
|
|
59
61
|
}
|
|
60
62
|
setIsSizeCalculated(true);
|
|
61
|
-
}, []);
|
|
62
|
-
var getWidget = function (withWidget,
|
|
63
|
-
if (
|
|
63
|
+
}, [sideMenuWidth, sideMenuMarginX, sideMenuLogotypePaddingLeft, withWidget, rest.size]);
|
|
64
|
+
var getWidget = function (withWidget, isCollapsedOnDesktop) {
|
|
65
|
+
if (isCollapsedOnDesktop) {
|
|
64
66
|
return false;
|
|
65
67
|
}
|
|
66
68
|
return withWidget;
|
|
@@ -79,7 +81,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
79
81
|
_d[styles.logoWrapperHidden()] = isSizeCalculated && !context.isOpened && !isTabletOrMobile,
|
|
80
82
|
_d)) },
|
|
81
83
|
isTabletOrMobile && React.createElement(Burger, null),
|
|
82
|
-
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget,
|
|
84
|
+
React.createElement(Logotype, __assign({ ref: refLogotype, size: size, productLogo: productLogo, konturLogo: konturLogo, withWidget: getWidget(withWidget, isDesktopCollapsedMode) }, rest)))));
|
|
83
85
|
});
|
|
84
86
|
SideMenuLogotype.displayName = 'SideMenuLogotype';
|
|
85
87
|
var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
|
package/src/internal/SubMenu.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, useContext } from 'react';
|
|
2
2
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
3
|
+
import { separatedShown } from '../state/selectors.js';
|
|
3
4
|
import { InnerSubMenu } from './InnerSubMenu.js';
|
|
4
5
|
import { NestedMenu } from './NestedMenu.js';
|
|
5
6
|
import { SeparatedSubMenu } from './SeparatedSubMenu.js';
|
|
@@ -9,14 +10,14 @@ import { SeparatedSubMenu } from './SeparatedSubMenu.js';
|
|
|
9
10
|
* @visibleName InnerSubMenu
|
|
10
11
|
*/
|
|
11
12
|
var SubMenu = forwardRef(function (_a, ref) {
|
|
12
|
-
var _b;
|
|
13
13
|
var children = _a.children, isOpened = _a.isOpened, isSubMenu = _a.isSubMenu, isSeparatedMenu = _a.isSeparatedMenu, caption = _a.caption, htmlId = _a.htmlId;
|
|
14
14
|
var context = useContext(SideMenuContext);
|
|
15
|
+
var isSeparatedMenuShown = separatedShown(context.state);
|
|
15
16
|
if (isSubMenu) {
|
|
16
17
|
return (React.createElement(NestedMenu, { ref: ref, htmlId: htmlId, isOpened: isOpened }, children));
|
|
17
18
|
}
|
|
18
19
|
if (isSeparatedMenu) {
|
|
19
|
-
return (React.createElement(SeparatedSubMenu, { ref: ref, caption: caption, htmlId: htmlId, isOpened: isOpened &&
|
|
20
|
+
return (React.createElement(SeparatedSubMenu, { ref: ref, caption: caption, htmlId: htmlId, isOpened: isOpened && isSeparatedMenuShown }, children));
|
|
20
21
|
}
|
|
21
22
|
return (React.createElement(InnerSubMenu, { ref: ref, htmlId: htmlId, isOpened: isOpened }, children));
|
|
22
23
|
});
|