@skbkontur/side-menu 4.0.10 → 5.0.0-alpha.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 +0 -15
- 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/SideMenuDarkTheme.js +6 -0
- package/internal/themes/SideMenuTheme.d.ts +32 -10
- package/internal/themes/SideMenuTheme.js +44 -30
- package/lib/theming/ThemeHelpers.js +0 -4
- package/lib/utils/scripts.d.ts +1 -0
- package/lib/utils/scripts.js +9 -0
- package/package.json +2 -2
- package/src/SideMenu/SideMenu.d.ts +9 -4
- package/src/SideMenu/SideMenu.js +206 -189
- package/src/SideMenu/SideMenu.styles.d.ts +5 -0
- package/src/SideMenu/SideMenu.styles.js +35 -12
- package/src/SideMenuAvatar/SideMenuAvatar.js +7 -2
- package/src/SideMenuBody/SideMenuBody.js +2 -0
- package/src/SideMenuBody/SideMenuBody.styles.js +1 -1
- package/src/SideMenuContext.d.ts +21 -9
- package/src/SideMenuContext.js +6 -1
- package/src/SideMenuDivider/SideMenuDivider.js +4 -1
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +1 -0
- package/src/SideMenuDivider/SideMenuDivider.styles.js +5 -2
- package/src/SideMenuDropdown/SideMenuDropdown.js +20 -20
- package/src/SideMenuDropdown/SideMenuDropdown.styles.d.ts +1 -0
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +13 -8
- package/src/SideMenuFooter/SideMenuFooter.js +59 -5
- package/src/SideMenuFooter/SideMenuFooter.styles.d.ts +11 -0
- package/src/SideMenuFooter/SideMenuFooter.styles.js +38 -4
- package/src/SideMenuHeader/SideMenuHeader.js +6 -5
- package/src/SideMenuNotifications/BellWidget.js +6 -13
- package/src/SideMenuNotifications/BellWidgetError.js +3 -6
- package/src/SideMenuNotifications/BellWidgetView.styles.d.ts +4 -7
- package/src/SideMenuNotifications/BellWidgetView.styles.js +9 -20
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.js +2 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +2 -1
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +6 -3
- 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 +18 -2
- package/src/internal/ClickableElement.js +191 -69
- package/src/internal/ClickableElement.styles.d.ts +5 -0
- package/src/internal/ClickableElement.styles.js +25 -8
- package/src/internal/CollapseToggle.d.ts +2 -0
- package/src/internal/CollapseToggle.js +44 -0
- package/src/internal/{RightBorder.styles.d.ts → CollapseToggle.styles.d.ts} +2 -1
- package/src/internal/CollapseToggle.styles.js +19 -0
- package/src/internal/ItemContent/Caption.d.ts +1 -1
- package/src/internal/ItemContent/Caption.js +10 -26
- package/src/internal/ItemContent/Caption.styles.d.ts +1 -0
- package/src/internal/ItemContent/Caption.styles.js +16 -13
- package/src/internal/ItemContent/Icon.js +5 -2
- package/src/internal/ItemContent/Icon.styles.d.ts +3 -0
- package/src/internal/ItemContent/Icon.styles.js +16 -7
- 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/ItemContent/Marker.js +8 -2
- package/src/internal/ItemContent/Marker.styles.d.ts +3 -0
- package/src/internal/ItemContent/Marker.styles.js +16 -5
- package/src/internal/NarrowAccordionDropdown.d.ts +15 -0
- package/src/internal/NarrowAccordionDropdown.js +35 -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 +13 -11
- 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/SideMenuNotifications/utils/getWrapperHeightClass.d.ts +0 -11
- package/src/SideMenuNotifications/utils/getWrapperHeightClass.js +0 -10
- 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,44 @@
|
|
|
1
|
+
import { __read } from "tslib";
|
|
2
|
+
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
3
|
+
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
4
|
+
import React, { useContext, useLayoutEffect, useState } from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
7
|
+
import { SideMenuDataTids } from '../../SideMenuDataTids.js';
|
|
8
|
+
import { SideMenuContext } from '../SideMenuContext.js';
|
|
9
|
+
import { ClickableElementWithHint } from './ClickableElement.js';
|
|
10
|
+
import { getStyles } from './CollapseToggle.styles.js';
|
|
11
|
+
var SideMenuCollapseIcon = function () {
|
|
12
|
+
return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "none" },
|
|
13
|
+
React.createElement("path", { stroke: "currentColor", strokeWidth: 1.5, d: "M8.5 19V5M6 19h12a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3Z" })));
|
|
14
|
+
};
|
|
15
|
+
export var CollapseToggle = function () {
|
|
16
|
+
var _a;
|
|
17
|
+
var context = useContext(SideMenuContext);
|
|
18
|
+
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
19
|
+
var styles = useStyles(getStyles);
|
|
20
|
+
var cx = useEmotion().cx;
|
|
21
|
+
var slotRef = context.collapseToggleRef;
|
|
22
|
+
var _b = __read(useState(false), 2), mounted = _b[0], setMounted = _b[1];
|
|
23
|
+
// The slot lives in the Footer, which mounts in the same commit. Refs are assigned
|
|
24
|
+
// before layout effects run, so after this effect the portal target is ready.
|
|
25
|
+
useLayoutEffect(function () {
|
|
26
|
+
setMounted(true);
|
|
27
|
+
}, []);
|
|
28
|
+
var isOpened = !!context.isOpened;
|
|
29
|
+
var hintText = isOpened ? 'Свернуть меню' : 'Развернуть меню';
|
|
30
|
+
var handleClick = function () {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = context.setMenuOpened) === null || _a === void 0 ? void 0 : _a.call(context, !isOpened);
|
|
33
|
+
};
|
|
34
|
+
var button = (React.createElement(ClickableElementWithHint, { hint: hintText, isOpened: false },
|
|
35
|
+
React.createElement("button", { type: 'button', className: cx(styles.root(theme), (_a = {},
|
|
36
|
+
_a[styles.rootOpened(theme)] = isOpened,
|
|
37
|
+
_a[styles.rootLarge(theme)] = context.size === 'large',
|
|
38
|
+
_a)), "aria-label": hintText, "aria-expanded": isOpened, "data-tid": SideMenuDataTids.collapseToggle, onClick: handleClick },
|
|
39
|
+
React.createElement(SideMenuCollapseIcon, null))));
|
|
40
|
+
if (!mounted || !(slotRef === null || slotRef === void 0 ? void 0 : slotRef.current)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return ReactDOM.createPortal(button, slotRef.current);
|
|
44
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SideMenuTheme } from '../../lib/theming/ThemeTypes.js';
|
|
2
2
|
export declare const getStyles: import("../../lib/theming/ThemeHelpers.js").StylesGetter<{
|
|
3
3
|
root(t: SideMenuTheme): string;
|
|
4
|
-
|
|
4
|
+
rootOpened(t: SideMenuTheme): string;
|
|
5
|
+
rootLarge(t: SideMenuTheme): string;
|
|
5
6
|
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __makeTemplateObject } from "tslib";
|
|
2
|
+
import { resetButton } from '@skbkontur/react-ui/lib/styles/Mixins';
|
|
3
|
+
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
4
|
+
import { transitionDuration } from '../SideMenu/SideMenu.js';
|
|
5
|
+
export var getStyles = memoizeGetStyles(function (_a) {
|
|
6
|
+
var css = _a.css;
|
|
7
|
+
return ({
|
|
8
|
+
root: function (t) {
|
|
9
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: background ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n\n svg {\n transition: opacity ", ";\n }\n "], ["\n ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n width: ", ";\n height: ", ";\n flex-shrink: 0;\n border-radius: ", ";\n color: ", ";\n cursor: pointer;\n transition: background ", " ease-out;\n\n &:hover {\n color: ", ";\n }\n\n &:focus-visible {\n box-shadow: ", ";\n }\n\n svg {\n transition: opacity ", ";\n }\n "])), resetButton(), t.sideMenuCollapseToggleSize, t.sideMenuCollapseToggleSize, t.sideMenuItemBorderRadius, t.sideMenuRightBorderIconColor, t.transitionDuration, t.sideMenuRightBorderIconColorHover, t.sideMenuItemBoxShadowFocus, transitionDuration);
|
|
10
|
+
},
|
|
11
|
+
rootOpened: function (t) {
|
|
12
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n box-sizing: content-box;\n padding-right: ", ";\n "], ["\n box-sizing: content-box;\n padding-right: ", ";\n "])), t.sideMenuCollapseToggleOffsetRight);
|
|
13
|
+
},
|
|
14
|
+
rootLarge: function (t) {
|
|
15
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n border-radius: ", ";\n "], ["\n width: ", ";\n height: ", ";\n border-radius: ", ";\n "])), t.sideMenuCollapseToggleSizeLarge, t.sideMenuCollapseToggleSizeLarge, t.sideMenuItemBorderRadiusLarge);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -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,30 @@ 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
|
-
|
|
77
|
-
(!_isAvatar || isAvatarCaptionSingleWord(caption, _isAvatar)),
|
|
60
|
+
_c[styles.captionTruncated()] = isCaptionPlainText && _isDropdown,
|
|
61
|
+
_c[styles.captionWithoutMarker(theme)] = !hasMarker && !_isSubMenu,
|
|
78
62
|
_c[styles.captionSubItem(theme)] = _isSubMenu,
|
|
79
63
|
_c[styles.captionSubItemSeparatedMenuTopLevel()] = isSeparatedMenu && !isNestedSubMenu && _isSubMenu && !hasIcon,
|
|
80
64
|
_c[styles.captionNestedItemSeparatedMenu()] = isSeparatedMenu && isNestedSubMenu && !hasIcon,
|
|
81
|
-
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu,
|
|
82
|
-
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !
|
|
65
|
+
_c[styles.captionWithoutItemIcon()] = !hasIcon && !isSeparatedMenu && isOpened,
|
|
66
|
+
_c[styles.captionSubItemWithoutColumnIcons()] = _isSubMenu && isSeparatedMenu && !hasSeparatedSubMenu,
|
|
83
67
|
_c[styles.captionLarge(theme)] = isLarge,
|
|
84
68
|
_c[styles.captionTouchScreen(theme)] = isTouchScreen,
|
|
85
69
|
_c[styles.captionSubItemTouchScreen(theme)] = isTouchScreen && _isSubMenu,
|
|
@@ -8,6 +8,7 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
8
8
|
rootMultiline(t: SideMenuTheme): string;
|
|
9
9
|
caption(t: SideMenuTheme): string;
|
|
10
10
|
captionTouchScreen(t: SideMenuTheme): string;
|
|
11
|
+
captionWithoutMarker(t: SideMenuTheme): string;
|
|
11
12
|
captionSubItem(t: SideMenuTheme): string;
|
|
12
13
|
captionSubItemTouchScreen(t: SideMenuTheme): string;
|
|
13
14
|
captionSubItemSeparatedMenuTopLevel(): string;
|
|
@@ -19,42 +19,45 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
19
19
|
captionTouchScreen: function (t) {
|
|
20
20
|
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionFontSizeTouchScreen, t.sideMenuCaptionLineHeightTouchScreen);
|
|
21
21
|
},
|
|
22
|
+
captionWithoutMarker: function (t) {
|
|
23
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-right: ", ";\n "], ["\n margin-right: ", ";\n "])), t.sideMenuItemPaddingRight);
|
|
24
|
+
},
|
|
22
25
|
captionSubItem: function (t) {
|
|
23
|
-
return css(
|
|
26
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuCaptionSubItemMarginLeft);
|
|
24
27
|
},
|
|
25
28
|
captionSubItemTouchScreen: function (t) {
|
|
26
|
-
return css(
|
|
29
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuCaptionSubItemFontSizeTouchScreen, t.sideMenuCaptionSubItemLineHeightTouchScreen);
|
|
27
30
|
},
|
|
28
31
|
captionSubItemSeparatedMenuTopLevel: function () {
|
|
29
|
-
return css(
|
|
32
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin: 0 8px 0 12px;\n "], ["\n margin: 0 8px 0 12px;\n "])));
|
|
30
33
|
},
|
|
31
34
|
captionNestedItemSeparatedMenu: function () {
|
|
32
|
-
return css(
|
|
35
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin-left: 28px;\n "], ["\n margin-left: 28px;\n "])));
|
|
33
36
|
},
|
|
34
37
|
captionWithoutItemIcon: function () {
|
|
35
|
-
return css(
|
|
38
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n margin-left: 48px;\n "], ["\n margin-left: 48px;\n "])));
|
|
36
39
|
},
|
|
37
40
|
captionSubItemWithoutColumnIcons: function () {
|
|
38
|
-
return css(
|
|
41
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n margin-left: 12px;\n "], ["\n margin-left: 12px;\n "])));
|
|
39
42
|
},
|
|
40
43
|
captionLarge: function (t) {
|
|
41
|
-
return css(
|
|
44
|
+
return css(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-size: ", " !important;\n line-height: ", " !important;\n "], ["\n font-size: ", " !important;\n line-height: ", " !important;\n "])), t.sideMenuCaptionFontSizeLarge, t.sideMenuCaptionLineHeightLarge);
|
|
42
45
|
},
|
|
43
46
|
captionInBackButton: function (t) {
|
|
44
|
-
return css(
|
|
47
|
+
return css(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n "])), t.sideMenuBackButtonCaptionFontWeight, t.sideMenuBackButtonCaptionFontSize, t.sideMenuBackButtonCaptionLineHeight, t.sideMenuBackButtonCaptionPaddingY, t.sideMenuBackButtonCaptionPaddingY);
|
|
45
48
|
},
|
|
46
49
|
captionDropdown: function () {
|
|
47
|
-
return css(
|
|
50
|
+
return css(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n white-space: nowrap;\n overflow: hidden;\n "], ["\n white-space: nowrap;\n overflow: hidden;\n "])));
|
|
48
51
|
},
|
|
49
52
|
captionTruncated: function () {
|
|
50
|
-
return css(
|
|
53
|
+
return css(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "], ["\n text-overflow: ellipsis;\n &::before {\n float: right;\n content: attr(data-tail);\n }\n "])));
|
|
51
54
|
},
|
|
52
55
|
captionNoWrap: function () {
|
|
53
|
-
return css(
|
|
56
|
+
return css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n "])));
|
|
54
57
|
},
|
|
55
58
|
captionNoWrapWithMarker: function (t) {
|
|
56
|
-
return css(
|
|
59
|
+
return css(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n margin: 0 ", " 0 0;\n "], ["\n margin: 0 ", " 0 0;\n "])), t.sideMenuCaptionNoWrapWithMarkerMarginRight);
|
|
57
60
|
},
|
|
58
61
|
});
|
|
59
62
|
});
|
|
60
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16;
|
|
63
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17;
|
|
@@ -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,12 @@ 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
|
+
_b[styles.rootCollapsed(theme)] = !isOpened && !_isSubMenu,
|
|
40
|
+
_b[styles.rootCollapsedLarge(theme)] = !isOpened && !_isSubMenu && isLarge,
|
|
39
41
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
42
|
+
_b[styles.rootSubItemDropdown()] = _isSubMenu && !isOpened && !isSeparatedMenu,
|
|
40
43
|
_b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
41
44
|
_b[styles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
|
|
42
45
|
_b[styles.rootBackButton(theme)] = _isBackButton,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { SideMenuTheme } from '../../../lib/theming/ThemeTypes.js';
|
|
2
2
|
export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").StylesGetter<{
|
|
3
3
|
root(t: SideMenuTheme): string;
|
|
4
|
+
rootCollapsed(t: SideMenuTheme): string;
|
|
5
|
+
rootCollapsedLarge(t: SideMenuTheme): string;
|
|
4
6
|
rootMultiline(): string;
|
|
5
7
|
rootLarge(t: SideMenuTheme): string;
|
|
6
8
|
rootSubItemLarge(t: SideMenuTheme): string;
|
|
7
9
|
rootSubItem(t: SideMenuTheme): string;
|
|
10
|
+
rootSubItemDropdown(): string;
|
|
8
11
|
rootSubItemSeparatedMenu(t: SideMenuTheme): string;
|
|
9
12
|
rootBackButton(t: SideMenuTheme): string;
|
|
10
13
|
}>;
|
|
@@ -6,24 +6,33 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
6
6
|
root: function (t) {
|
|
7
7
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight);
|
|
8
8
|
},
|
|
9
|
+
rootCollapsed: function (t) {
|
|
10
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
|
|
11
|
+
},
|
|
12
|
+
rootCollapsedLarge: function (t) {
|
|
13
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n margin-left: ", ";\n margin-right: ", ";\n "], ["\n margin-left: ", ";\n margin-right: ", ";\n "])), t.sideMenuIconMarginXCollapsedLarge, t.sideMenuIconMarginXCollapsedLarge);
|
|
14
|
+
},
|
|
9
15
|
rootMultiline: function () {
|
|
10
|
-
return css(
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: -2px;\n "], ["\n align-self: flex-start;\n margin-top: -2px;\n "])));
|
|
11
17
|
},
|
|
12
18
|
rootLarge: function (t) {
|
|
13
|
-
return css(
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "], ["\n min-height: ", ";\n line-height: ", ";\n margin-top: 0;\n "])), t.sideMenuIconMinHeightLarge, t.sideMenuIconLineHeightLarge);
|
|
14
20
|
},
|
|
15
21
|
rootSubItemLarge: function (t) {
|
|
16
|
-
return css(
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), t.sideMenuIconSubItemMinHeightLarge);
|
|
17
23
|
},
|
|
18
24
|
rootSubItem: function (t) {
|
|
19
|
-
return css(
|
|
25
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "], ["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "])), t.sideMenuIconSubItemPaddingLeft, t.sideMenuIconSubItemPaddingRight, t.sideMenuIconSubItemMinHeight, t.sideMenuIconSubItemLineHeight);
|
|
26
|
+
},
|
|
27
|
+
rootSubItemDropdown: function () {
|
|
28
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
|
|
20
29
|
},
|
|
21
30
|
rootSubItemSeparatedMenu: function (t) {
|
|
22
|
-
return css(
|
|
31
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
|
|
23
32
|
},
|
|
24
33
|
rootBackButton: function (t) {
|
|
25
|
-
return css(
|
|
34
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
|
|
26
35
|
},
|
|
27
36
|
});
|
|
28
37
|
});
|
|
29
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
38
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment
|
|
|
2
2
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
4
|
import { getSideMenuTheme } from '../../../lib/theming/ThemeHelpers.js';
|
|
5
|
+
import { SideMenuContext } from '../../SideMenuContext.js';
|
|
5
6
|
import { getStyles } from './Marker.styles.js';
|
|
6
7
|
export var Marker = function (_a) {
|
|
7
8
|
var _b;
|
|
@@ -10,12 +11,17 @@ export var Marker = function (_a) {
|
|
|
10
11
|
var styles = useStyles(getStyles);
|
|
11
12
|
var cx = useEmotion().cx;
|
|
12
13
|
var isEmpty = marker === true || marker === '';
|
|
14
|
+
var isLarge = useContext(SideMenuContext).size === 'large';
|
|
15
|
+
var isCollapsedItem = !_isSubMenu && isCollapsed;
|
|
13
16
|
return (React.createElement("span", { className: cx(styles.root(theme), (_b = {},
|
|
14
17
|
_b[styles.rootEmpty(theme)] = isEmpty,
|
|
15
18
|
_b[styles.rootMultiline(theme)] = isMultiline,
|
|
16
19
|
_b[styles.rootSubMenu(theme)] = _isSubMenu,
|
|
17
20
|
_b[styles.rootSubMenuEmpty(theme)] = _isSubMenu && isEmpty,
|
|
18
|
-
_b[styles.
|
|
19
|
-
_b[styles.
|
|
21
|
+
_b[styles.rootSubMenuLarge(theme)] = _isSubMenu && !isEmpty && isLarge,
|
|
22
|
+
_b[styles.rootCollapsed()] = isCollapsedItem,
|
|
23
|
+
_b[styles.rootCollapsedLarge()] = isCollapsedItem && isLarge,
|
|
24
|
+
_b[styles.rootEmptyCollapsed()] = isCollapsedItem && isEmpty,
|
|
25
|
+
_b[styles.rootEmptyCollapsedLarge()] = isCollapsedItem && isEmpty && isLarge,
|
|
20
26
|
_b)) }, marker));
|
|
21
27
|
};
|
|
@@ -5,6 +5,9 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
5
5
|
rootMultiline(t: SideMenuTheme): string;
|
|
6
6
|
rootSubMenu(t: SideMenuTheme): string;
|
|
7
7
|
rootSubMenuEmpty(t: SideMenuTheme): string;
|
|
8
|
+
rootSubMenuLarge(t: SideMenuTheme): string;
|
|
8
9
|
rootCollapsed(): string;
|
|
10
|
+
rootCollapsedLarge(): string;
|
|
9
11
|
rootEmptyCollapsed(): string;
|
|
12
|
+
rootEmptyCollapsedLarge(): string;
|
|
10
13
|
}>;
|
|
@@ -13,17 +13,28 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
13
13
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n margin-top: ", ";\n "], ["\n align-self: flex-start;\n margin-top: ", ";\n "])), t.sideMenuMarkerMultilineMarginTop);
|
|
14
14
|
},
|
|
15
15
|
rootSubMenu: function (t) {
|
|
16
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
|
|
16
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "], ["\n margin-right: ", ";\n background: transparent;\n color: ", ";\n font-weight: ", ";\n "])), t.sideMenuMarkerSubItemMarginRight, t.sideMenuMarkerSubItemColor, t.sideMenuMarkerSubItemFontWeight);
|
|
17
17
|
},
|
|
18
18
|
rootSubMenuEmpty: function (t) {
|
|
19
|
-
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n background: ", ";\n "], ["\n background: ", ";\n "])), t.sideMenuMarkerBg);
|
|
19
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-right: ", ";\n background: ", ";\n "], ["\n margin-right: ", ";\n background: ", ";\n "])), t.sideMenuMarkerSubItemEmptyMarginRight, t.sideMenuMarkerBg);
|
|
20
20
|
},
|
|
21
|
+
rootSubMenuLarge: function (t) {
|
|
22
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-size: ", ";\n line-height: ", ";\n "])), t.sideMenuMarkerSubItemFontSizeLarge, t.sideMenuMarkerSubItemLineHeightLarge);
|
|
23
|
+
},
|
|
24
|
+
// В свёрнутом меню бейдж позиционируется относительно центра пункта (т.е. иконки),
|
|
25
|
+
// чтобы не отрываться от неё при любом размере пункта.
|
|
21
26
|
rootCollapsed: function () {
|
|
22
|
-
return css(
|
|
27
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "], ["\n position: absolute;\n left: calc(50% + 13px);\n top: 0;\n transform: translateX(-50%);\n margin: 0;\n "])));
|
|
28
|
+
},
|
|
29
|
+
rootCollapsedLarge: function () {
|
|
30
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n top: 3px;\n "], ["\n top: 3px;\n "])));
|
|
23
31
|
},
|
|
24
32
|
rootEmptyCollapsed: function () {
|
|
25
|
-
return css(
|
|
33
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n left: calc(50% + 12px);\n top: 4px;\n "], ["\n left: calc(50% + 12px);\n top: 4px;\n "])));
|
|
34
|
+
},
|
|
35
|
+
rootEmptyCollapsedLarge: function () {
|
|
36
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n top: 8px;\n "], ["\n top: 8px;\n "])));
|
|
26
37
|
},
|
|
27
38
|
});
|
|
28
39
|
});
|
|
29
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
40
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
disabled?: boolean;
|
|
9
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const NarrowAccordionDropdown: {
|
|
12
|
+
({ caption, children, htmlId, "aria-label": ariaLabel, childIdCounterRef, disabled, onOpenChange, }: NarrowAccordionDropdownProps): JSX.Element;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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, _c;
|
|
13
|
+
var _d;
|
|
14
|
+
var caption = _a.caption, children = _a.children, htmlId = _a.htmlId, ariaLabel = _a["aria-label"], childIdCounterRef = _a.childIdCounterRef, disabled = _a.disabled, onOpenChange = _a.onOpenChange;
|
|
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(), (_b = {}, _b[dropdownStyles.wrapperCollapsed()] = isMenuCollapsed, _b)) },
|
|
23
|
+
React.createElement(DropdownMenu, { ref: dropdownMenuRef, caption: React.createElement("div", { className: cx(dropdownStyles.label(theme), (_c = {},
|
|
24
|
+
_c[dropdownStyles.labelTouchScreen(theme)] = context.isTouchScreen,
|
|
25
|
+
_c[dropdownStyles.labelCollapsed()] = isMenuCollapsed,
|
|
26
|
+
_c)), onClick: disabled ? function (e) { return e.stopPropagation(); } : undefined }, caption), positions: ['right top', 'right middle', 'right bottom'], disableAnimations: true, popupMenuId: htmlId, "aria-label": ariaLabel, onOpen: function () {
|
|
27
|
+
if (childIdCounterRef) {
|
|
28
|
+
childIdCounterRef.current = 0;
|
|
29
|
+
}
|
|
30
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
|
|
31
|
+
}, onClose: function () { return onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false); } },
|
|
32
|
+
React.createElement("ul", { className: cx(sideMenuStyles.list()), "data-tid": SideMenuDataTids.narrowAccordionDropdown },
|
|
33
|
+
React.createElement(SideMenuContext.Provider, { value: __assign(__assign({}, context), { hasSeparatedSubMenu: false, parentItemId: htmlId, currentItemNestingLevel: ((_d = context.currentItemNestingLevel) !== null && _d !== void 0 ? _d : 0) + 1, closeParentDropdown: function () { var _a; return (_a = dropdownMenuRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, childIdCounterRef: childIdCounterRef !== null && childIdCounterRef !== void 0 ? childIdCounterRef : context.childIdCounterRef }) }, children)))));
|
|
34
|
+
};
|
|
35
|
+
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;
|