@skbkontur/side-menu 5.0.0-alpha.3 → 5.0.0-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 +26 -0
- package/README.md +2 -2
- package/internal/themes/SideMenuDarkTheme.js +7 -6
- package/internal/themes/SideMenuTheme.d.ts +21 -0
- package/internal/themes/SideMenuTheme.js +49 -8
- package/lib/theming/ThemeHelpers.js +4 -0
- package/package.json +7 -7
- package/src/SideMenu/SideMenu.d.ts +1 -0
- package/src/SideMenu/SideMenu.js +17 -20
- package/src/SideMenu/SideMenu.styles.d.ts +1 -2
- package/src/SideMenu/SideMenu.styles.js +12 -18
- package/src/SideMenuBody/SideMenuBody.js +27 -2
- package/src/SideMenuBody/SideMenuBody.styles.js +2 -1
- package/src/SideMenuDivider/SideMenuDivider.js +12 -2
- package/src/SideMenuDivider/SideMenuDivider.styles.d.ts +5 -0
- package/src/SideMenuDivider/SideMenuDivider.styles.js +18 -3
- package/src/SideMenuDropdown/SideMenuDropdown.styles.js +2 -2
- package/src/SideMenuFooter/SideMenuFooter.js +6 -4
- package/src/SideMenuFooter/SideMenuFooter.styles.js +3 -2
- package/src/SideMenuHeader/SideMenuHeader.styles.js +1 -1
- 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/SideMenuSubItemHeader/SideMenuSubItemHeader.js +2 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.d.ts +2 -0
- package/src/SideMenuSubItemHeader/SideMenuSubItemHeader.styles.js +9 -3
- package/src/internal/ClickableElement.d.ts +2 -1
- package/src/internal/ClickableElement.js +14 -10
- package/src/internal/CollapseToggle.js +1 -2
- package/src/internal/CollapseToggle.styles.d.ts +0 -1
- package/src/internal/CollapseToggle.styles.js +2 -5
- package/src/internal/ItemContent/Caption.js +7 -6
- package/src/internal/ItemContent/Caption.styles.d.ts +3 -0
- package/src/internal/ItemContent/Caption.styles.js +18 -9
- package/src/internal/ItemContent/Icon.js +2 -1
- package/src/internal/ItemContent/Icon.styles.d.ts +1 -0
- package/src/internal/ItemContent/Icon.styles.js +9 -5
- package/src/internal/ItemContent/ItemContent.js +3 -1
- package/src/internal/SideMenuLogotype.js +24 -3
- package/src/internal/SideMenuLogotype.styles.js +3 -3
|
@@ -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, isOpened = context.isOpened;
|
|
20
|
+
var isSeparatedMenu = context.isSeparatedMenu, size = context.size, isOpened = context.isOpened, hasItemIcons = context.hasItemIcons;
|
|
21
21
|
var isLarge = size === 'large';
|
|
22
22
|
var theme = getSideMenuTheme(useContext(ThemeContext));
|
|
23
23
|
var styles = useStyles(getStyles);
|
|
@@ -39,6 +39,7 @@ export var Icon = function (_a) {
|
|
|
39
39
|
_b[styles.rootCollapsed(theme)] = !isOpened && !_isSubMenu,
|
|
40
40
|
_b[styles.rootCollapsedLarge(theme)] = !isOpened && !_isSubMenu && isLarge,
|
|
41
41
|
_b[styles.rootSubItem(theme)] = _isSubMenu,
|
|
42
|
+
_b[styles.rootSubItemWithoutItemIcons(theme)] = _isSubMenu && !hasItemIcons && !isSeparatedMenu,
|
|
42
43
|
_b[styles.rootSubItemDropdown()] = _isSubMenu && !isOpened && !isSeparatedMenu,
|
|
43
44
|
_b[styles.rootSubItemSeparatedMenu(theme)] = isSeparatedMenu && _isSubMenu,
|
|
44
45
|
_b[styles.rootSubItemLarge(theme)] = _isSubMenu && isLarge,
|
|
@@ -7,6 +7,7 @@ export declare const getStyles: import("../../../lib/theming/ThemeHelpers.js").S
|
|
|
7
7
|
rootLarge(t: SideMenuTheme): string;
|
|
8
8
|
rootSubItemLarge(t: SideMenuTheme): string;
|
|
9
9
|
rootSubItem(t: SideMenuTheme): string;
|
|
10
|
+
rootSubItemWithoutItemIcons(t: SideMenuTheme): string;
|
|
10
11
|
rootSubItemDropdown(): string;
|
|
11
12
|
rootSubItemSeparatedMenu(t: SideMenuTheme): string;
|
|
12
13
|
rootBackButton(t: SideMenuTheme): string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { memoizeGetStyles } from '../../../lib/theming/ThemeHelpers.js';
|
|
3
|
+
import { transitionDuration, transitionEasing } from '../../SideMenu/SideMenu.js';
|
|
3
4
|
export var getStyles = memoizeGetStyles(function (_a) {
|
|
4
5
|
var css = _a.css;
|
|
5
6
|
return ({
|
|
6
7
|
root: function (t) {
|
|
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
|
+
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "], ["\n display: flex;\n align-items: center;\n margin: ", " ", " ", " ", ";\n min-height: ", ";\n line-height: ", ";\n flex-shrink: 0;\n box-sizing: content-box;\n transition:\n margin-left ", "ms ", ",\n margin-right ", "ms ", ";\n "])), t.sideMenuIconMarginY, t.sideMenuIconMarginRight, t.sideMenuIconMarginY, t.sideMenuIconMarginLeft, t.sideMenuIconMinHeight, t.sideMenuIconLineHeight, transitionDuration, transitionEasing, transitionDuration, transitionEasing);
|
|
8
9
|
},
|
|
9
10
|
rootCollapsed: function (t) {
|
|
10
11
|
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-left: ", ";\n "], ["\n margin-left: ", ";\n "])), t.sideMenuIconMarginLeftCollapsed);
|
|
@@ -24,15 +25,18 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
24
25
|
rootSubItem: function (t) {
|
|
25
26
|
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "], ["\n margin: 0;\n padding-left: ", ";\n padding-right: ", ";\n min-height: ", ";\n line-height: ", ";\n "])), t.sideMenuIconSubItemPaddingLeft, t.sideMenuIconSubItemPaddingRight, t.sideMenuIconSubItemMinHeight, t.sideMenuIconSubItemLineHeight);
|
|
26
27
|
},
|
|
28
|
+
rootSubItemWithoutItemIcons: function (t) {
|
|
29
|
+
return css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconSubItemPaddingLeftWithoutIcons);
|
|
30
|
+
},
|
|
27
31
|
rootSubItemDropdown: function () {
|
|
28
|
-
return css(
|
|
32
|
+
return css(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n padding-left: 0;\n "], ["\n padding-left: 0;\n "])));
|
|
29
33
|
},
|
|
30
34
|
rootSubItemSeparatedMenu: function (t) {
|
|
31
|
-
return css(
|
|
35
|
+
return css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n padding-left: ", ";\n "], ["\n padding-left: ", ";\n "])), t.sideMenuIconWithSeparatedSubMenuSubItemPaddingLeft);
|
|
32
36
|
},
|
|
33
37
|
rootBackButton: function (t) {
|
|
34
|
-
return css(
|
|
38
|
+
return css(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n "], ["\n padding-left: ", ";\n padding-right: ", ";\n "])), t.sideMenuBackButtonIconPaddingLeft, t.sideMenuBackButtonIconPaddingRight);
|
|
35
39
|
},
|
|
36
40
|
});
|
|
37
41
|
});
|
|
38
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
42
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
|
|
@@ -68,6 +68,7 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
68
68
|
var styles = useStyles(getStyles);
|
|
69
69
|
var cx = useEmotion().cx;
|
|
70
70
|
useEffect(function () {
|
|
71
|
+
var _a, _b;
|
|
71
72
|
if (noWrap) {
|
|
72
73
|
setIsMultiline(false);
|
|
73
74
|
return;
|
|
@@ -80,7 +81,8 @@ var ItemContent = forwardRef(function (_a, ref) {
|
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
var captionLineHeight = getCaptionLineHeight(theme, isTouchScreen, _isSubMenu, size);
|
|
83
|
-
|
|
84
|
+
var captionHeight = (_b = (_a = textRef.current.firstElementChild) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : textRef.current.offsetHeight;
|
|
85
|
+
setIsMultiline(parseInt(captionLineHeight, 10) < captionHeight);
|
|
84
86
|
}, [
|
|
85
87
|
caption,
|
|
86
88
|
context.isBeingTransitioned,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { Logotype } from '@skbkontur/react-ui-addons/components/Logotype/Logotype';
|
|
3
|
+
import { mergeRefs } from '@skbkontur/react-ui/lib/mergeRefs';
|
|
3
4
|
import { useEmotion, useStyles } from '@skbkontur/react-ui/lib/renderEnvironment';
|
|
4
5
|
import { ThemeContext } from '@skbkontur/react-ui/lib/theming/ThemeContext';
|
|
5
|
-
import React, { forwardRef, useContext, useState } from 'react';
|
|
6
|
+
import React, { forwardRef, useContext, useLayoutEffect, useRef, useState } from 'react';
|
|
6
7
|
import { getSideMenuTheme } from '../../lib/theming/ThemeHelpers.js';
|
|
7
8
|
import { SideMenuContext } from '../SideMenuContext.js';
|
|
8
9
|
import { Burger } from './Burger.js';
|
|
@@ -30,6 +31,15 @@ var CdnLogoWithOwnSize = function (_a) {
|
|
|
30
31
|
var logo = _a.logo, _size = _a.size, rest = __rest(_a, ["logo", "size"]);
|
|
31
32
|
return React.cloneElement(logo, rest);
|
|
32
33
|
};
|
|
34
|
+
var VERTICAL_LOGO_SUFFIX = '-vertical';
|
|
35
|
+
var getOneLineLogo = function (logo) {
|
|
36
|
+
var _a;
|
|
37
|
+
var name = (_a = logo === null || logo === void 0 ? void 0 : logo.props) === null || _a === void 0 ? void 0 : _a.logo;
|
|
38
|
+
if (!logo || typeof name !== 'string' || !name.includes(VERTICAL_LOGO_SUFFIX)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return React.cloneElement(logo, { logo: name.replace(VERTICAL_LOGO_SUFFIX, '') });
|
|
42
|
+
};
|
|
33
43
|
var getStaticIconPath = function (productName) {
|
|
34
44
|
return "https://s.kontur.ru/common-v2/icons-products/".concat(productName, "/").concat(productName, "-").concat(parseInt(sideMenuLogotypeIconSize, 10), ".svg");
|
|
35
45
|
};
|
|
@@ -50,6 +60,17 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
50
60
|
var _f = __read(useState(getStaticIconPath(productName)), 2), productIconUrl = _f[0], setProductIconUrl = _f[1];
|
|
51
61
|
var isTabletOrMobile = context.isTablet || context.isMobile;
|
|
52
62
|
var isDesktopCollapsedMode = !context.isOpened && (context.isDesktop || context.isNarrowDesktop);
|
|
63
|
+
var rootRef = useRef(null);
|
|
64
|
+
var _g = __read(useState(true), 2), oneLineLogoFits = _g[0], setOneLineLogoFits = _g[1];
|
|
65
|
+
var oneLineLogo = isTabletOrMobile ? getOneLineLogo(productLogo) : null;
|
|
66
|
+
var isOneLine = !!oneLineLogo && (!context.isOpened || oneLineLogoFits);
|
|
67
|
+
var shownProductLogo = isOneLine ? oneLineLogo : productLogo;
|
|
68
|
+
useLayoutEffect(function () {
|
|
69
|
+
var root = rootRef.current;
|
|
70
|
+
if (root && isOneLine && context.isOpened && root.scrollWidth > root.clientWidth) {
|
|
71
|
+
setOneLineLogoFits(false);
|
|
72
|
+
}
|
|
73
|
+
}, [isOneLine, context.isOpened]);
|
|
53
74
|
var getWidget = function (withWidget, isCollapsedOnDesktop) {
|
|
54
75
|
if (isCollapsedOnDesktop) {
|
|
55
76
|
return false;
|
|
@@ -61,7 +82,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
61
82
|
};
|
|
62
83
|
return (React.createElement("div", { className: cx(styles.root(), (_b = {},
|
|
63
84
|
_b[styles.rootTabletAndMobile()] = isTabletOrMobile,
|
|
64
|
-
_b)), ref: ref },
|
|
85
|
+
_b)), ref: mergeRefs(rootRef, ref) },
|
|
65
86
|
!isTabletOrMobile && (React.createElement("img", { className: cx(styles.iconHidden(theme), (_c = {},
|
|
66
87
|
_c[styles.icon()] = !context.isOpened && !isTabletOrMobile,
|
|
67
88
|
_c)), src: iconUrl || productIconUrl, alt: productName, onError: handleError })),
|
|
@@ -70,7 +91,7 @@ var SideMenuLogotype = forwardRef(function (_a, ref) {
|
|
|
70
91
|
_d[styles.logoWrapperHidden()] = !context.isOpened && !isTabletOrMobile,
|
|
71
92
|
_d)) },
|
|
72
93
|
isTabletOrMobile && React.createElement(Burger, null),
|
|
73
|
-
React.createElement(Logotype, __assign({ size: 28, productLogo:
|
|
94
|
+
React.createElement(Logotype, __assign({ size: 28, productLogo: shownProductLogo && typeof ((_e = shownProductLogo.props) === null || _e === void 0 ? void 0 : _e.logo) === 'string' && !rest.size ? (React.createElement(CdnLogoWithOwnSize, { logo: shownProductLogo })) : (shownProductLogo), konturLogo: konturLogo, withWidget: getWidget(withWidget, isDesktopCollapsedMode) }, rest)))));
|
|
74
95
|
});
|
|
75
96
|
SideMenuLogotype.displayName = 'SideMenuLogotype';
|
|
76
97
|
var SideMenuLogotypeWithStaticFields = Object.assign(SideMenuLogotype, { __KONTUR_REACT_UI__: 'SideMenuLogotype' });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __makeTemplateObject } from "tslib";
|
|
2
2
|
import { memoizeGetStyles } from '../../lib/theming/ThemeHelpers.js';
|
|
3
|
-
import { transitionDuration } from '../SideMenu/SideMenu.js';
|
|
3
|
+
import { transitionDuration, transitionEasing } from '../SideMenu/SideMenu.js';
|
|
4
4
|
export var sideMenuLogotypeIconSize = '32px';
|
|
5
5
|
export var sideMenuLogotypeGapBetweenIconAndLogo = '50px';
|
|
6
6
|
export var getStyles = memoizeGetStyles(function (_a) {
|
|
@@ -16,13 +16,13 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
16
16
|
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "], ["\n align-self: flex-start;\n opacity: 1;\n width: auto;\n "])));
|
|
17
17
|
},
|
|
18
18
|
iconHidden: function (t) {
|
|
19
|
-
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms
|
|
19
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "], ["\n display: block;\n align-self: flex-start;\n width: 0;\n padding-left: ", ";\n opacity: 0;\n transition: all ", "ms ", ";\n "])), t.sideMenuLogotypeHiddenIconPaddingLeft, transitionDuration, transitionEasing);
|
|
20
20
|
},
|
|
21
21
|
logoWrapper: function (t) {
|
|
22
22
|
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "], ["\n display: flex;\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n\n [data-logotype-component] {\n height: auto !important;\n }\n #spwDropdown,\n #spwDropdown > span {\n align-items: flex-end;\n }\n "])), t.sideMenuLogotypePaddingTop, t.sideMenuLogotypePaddingBottom, t.sideMenuLogotypePaddingLeft);
|
|
23
23
|
},
|
|
24
24
|
logoWrapperTabletAndMobile: function () {
|
|
25
|
-
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n "], ["\n padding: 0;\n gap: 2px;\n "])));
|
|
25
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "], ["\n padding: 0;\n gap: 2px;\n align-items: center;\n\n #spwDropdown,\n #spwDropdown > span {\n align-items: center;\n }\n "])));
|
|
26
26
|
},
|
|
27
27
|
logoWrapperHidden: function () {
|
|
28
28
|
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "], ["\n width: 0;\n height: 0;\n opacity: 0;\n overflow: hidden;\n "])));
|